#git-repository #metrics #git-tool #extension #store #notes #github

app git-metrics

A git extension to store metrics directly in git, using the notes

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

Download history 26/week @ 2024-09-12 12/week @ 2024-09-19 16/week @ 2024-09-26 1/week @ 2024-10-03 2/week @ 2024-10-10 1/week @ 2024-11-07 100/week @ 2024-12-05

100 downloads per month

MIT license

245KB
6K SLoC

Git Metrics

FOSSA Status

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.

check report

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' }}

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

FOSSA Status

Dependencies

~3–16MB
~159K SLoC