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

app git-metrics

一个将指标直接存储在git中的git扩展,使用注释

9个版本

0.2.3 2024年8月6日
0.2.2 2024年8月6日
0.2.1 2024年7月20日
0.2.0 2024年6月30日
0.1.1 2024年5月28日

调试中排名49

Download history 176/week @ 2024-05-19 163/week @ 2024-05-26 160/week @ 2024-06-02 15/week @ 2024-06-09 295/week @ 2024-06-16 9/week @ 2024-06-23 191/week @ 2024-06-30 2/week @ 2024-07-07 72/week @ 2024-07-14 42/week @ 2024-07-21 69/week @ 2024-07-28 234/week @ 2024-08-04 23/week @ 2024-08-11

每月下载440

MIT许可协议

235KB
5K SLoC

Git Metrics

FOSSA Status

目前,如果你想跟踪项目某些指标随时间的变化,你需要一个外部工具来存储这些指标。但这些指标可以存储在git仓库中。Git提供了一个注释机制,git-metrics将其简化。

如何安装

从源码安装

cargo install --git https://github.com/jdrouet/git-metrics

如何使用

本地使用

# 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

使用GitHub Action

使用git-metricsGitHub Action,你甚至可以为你的项目上每个打开的pull request添加检查。

check report

name: monitoring metrics

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

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

项目目标

  • git-metrics show 显示当前提交的指标
  • git-metrics add 将指标添加到当前提交
  • git-metrics remove 从当前提交中删除指标
  • git-metrics fetch 获取指标
  • git-metrics push 推送指标
  • git-metrics log 显示最后提交的指标
  • git-metrics diff 计算两个提交之间的指标差异
  • git-metrics check 将指标与定义的预算进行比较
  • git-metrics page 为每个指标生成带有图表的网页
  • git-metrics import 基于某些应用程序的输出添加指标
    • 从 lcov 文件

许可证

FOSSA Status

依赖项

~3–13MB
~155K SLoC