10 releases
new 0.2.4 | Dec 10, 2024 |
---|---|
0.2.3 | Aug 6, 2024 |
0.2.1 | Jul 20, 2024 |
0.2.0 | Jun 30, 2024 |
0.1.1 | May 28, 2024 |
#63 in Debugging
100 downloads per month
245KB
6K
SLoC
Git Metrics
Right now, if you want to track the evolution of some metrics for your project
over time, you need an external tool to store those metrics. But these metrics
could be stored withing the git repository. Git provides a mechanism of notes
that git-metrics
simplifies.
How to install
From sources
cargo install --git https://github.com/jdrouet/git-metrics
How to use it
Locally
# fetch the remote metrics
$ git metrics pull
# add a new metric
$ git metrics add binary-size \
--tag "platform.os: linux" \
--tag "platform.arch: amd64" \
1024.0
# push the metrics to remote
$ git metrics push
# log all the metrics for the past commits
$ git metrics log --filter-empty
# display the metrics on current commit
$ git metrics show
binary-size{platform.os="linux", platform.arch="amd64"} 1024.0
# display the metrics difference between commits
$ git metrics diff HEAD~2..HEAD
- binary-size{platform.os="linux", platform.arch="amd64"} 512.0
+ binary-size{platform.os="linux", platform.arch="amd64"} 1024.0 (+200.00 %)
# check the metrics against the defined rules
$ git metrics check --show-success-rules --show-skipped-rules HEAD~2..HEAD
[SUCCESS] binary-size{platform.os="linux", platform.arch="amd64"} 3.44 MiB => 3.53 MiB Δ +96.01 kiB (+2.72 %)
increase should be less than 10.00 % ... check
should be lower than 10.00 MiB ... check
[SUCCESS] binary-size{platform.os="linux", platform.arch="aarch64"} 3.14 MiB => 3.14 MiB
increase should be less than 10.00 % ... check
should be lower than 10.00 MiB ... check
With a github action
With git-metrics
, using the GitHub actions, you can even add a check to every pull request that opens on your project.
name: monitoring metrics
on:
pull_request:
branches:
- main
push:
branches:
- main
# this is required to be able to post the result of the check command
# in a comment of the pull request
permissions:
pull-requests: write
jobs:
building:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# this is needed for reporting metrics
fetch-depth: 0
# set the git identity to be able to save and push the metrics
- uses: jdrouet/action-git-identity@main
- uses: jdrouet/action-git-metrics@install
- uses: jdrouet/action-git-metrics@execute
with:
pull: 'true'
# set that to true when not a pull request
push: ${{ github.event_name != 'pull_request' }}
script: |
add binary-size --tag "platform: linux" 1024
# add a comment message to your pull request reporting the evolution
- uses: jdrouet/action-git-metrics@check
if: ${{ github.event_name == 'pull_request' }}
Related projects
- GitHub action to install
git-metrics
: https://github.com/jdrouet/action-git-metrics/tree/install - GitHub action to execute
git-metrics
: https://github.com/jdrouet/action-git-metrics/tree/execute - GitHub action to report
git-metrics
checks: https://github.com/jdrouet/action-git-metrics/tree/check - GitHub action to report
git-metrics
diff: https://github.com/jdrouet/action-git-metrics/tree/diff
Project goals
-
git-metrics show
displays the metrics to the current commit -
git-metrics add
adds a metric to the current commit -
git-metrics remove
removes a metric from the current commit -
git-metrics fetch
fetches the metrics -
git-metrics push
pushes the metrics -
git-metrics log
displays the metrics for the last commits -
git-metrics diff
computes the diff of the metrics between 2 commits -
git-metrics check
compares the metrics against the defined budget -
git-metrics page
generates a web page with charts for every metrics -
git-metrics import
to add metrics based on some apps output- from lcov file
License
Dependencies
~3–16MB
~159K SLoC