https://github.com/autometrics-dev/diff-metrics
A github action that comments on PR to describe impact on metrics
https://github.com/autometrics-dev/diff-metrics
Last synced: 3 months ago
JSON representation
A github action that comments on PR to describe impact on metrics
- Host: GitHub
- URL: https://github.com/autometrics-dev/diff-metrics
- Owner: autometrics-dev
- Created: 2023-06-06T12:40:12.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-08T21:51:46.000Z (about 1 year ago)
- Last Synced: 2025-04-04T16:28:28.822Z (3 months ago)
- Language: TypeScript
- Size: 3.83 MB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# Autometrics Report
This GitHub action will comment on Pull Requests to tell you how metrics are
going to be affected.The report tells you immediately if your new feature is well instrumented, and
shows a useful summary of the metrics that will be reported without needing to
go through the diff.
## Inputs
- `gh-token`: a github token that gives access to
- the PR
- the repo
- read/write access to comments on issues/PR**The built-in `${{ secrets.GITHUB_TOKEN }}` will work, you do not need to create a new one.**
To make the built-in token work, the job must be given a specific set of permissions. The permissions added in the
["Example Usage" section](#example-usage) show the minimal set of permissions needed.- `rs-roots`: a list of project roots for rust projects, one root per line.
The values are given relative to the root of the repository, and should
point to the directory containing the `Cargo.toml` file.
- `ts-roots`: a list of project roots for typescript projects, one root per line.
The values are given relative to the root of the repository, and should
point to the directory containing the `package.json` file.
- `go-roots`: a list of project roots for golang projects, one root per line.
The values are given relative to the root of the repository, and should
point to the directory containing the `go.mod` file.
- `py-roots`: a list of project roots for python projects, one root per line.
The values are given relative to the root of the repository, and should
point to the directory containing the actual module source code. If you have a monorepo,
you need to specify the root of each submodule.
- `retention-days`: the number of days to keep the list of functions as
[workflow
artifacts](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#about-workflow-artifacts).
By default it will use the same retention settings as the settings in the
repository (by setting `retention-days` to 0)
- `am-version`: a string that allows to choose the version of `am_list` to
download/use. You can skip the patch (e.g. `0.2`) or the minor (e.g. `0`) to
tell the action to download the latest version that falls within the bound.
Defaults to an empty string (`""`), which means "download the latest version,
semver-wise"| Argument | Mandatory |
| :------------: | :-------: |
| gh-token | yes |
| rs-roots | no |
| ts-roots | no |
| go-roots | no |
| py-roots | no |
| retention-days | no |
| am-version | no |## Outputs
The action does 2 things:
- it writes comments to pull request giving the monitoring impact of the Pull Request.
- it saves the data used to compute this report as workflow artifacts. Workflow artifacts
stay private to the repository that created them, but this allows for further processing
if need be.## Example Usage
The job must only contain the checkout step and the diff-metrics step, the steps that follow
within the job would act on an older version of the repository.```yaml
name: Metrics reporton: [pull_request]
jobs:
build:
# The task only runs on linux x64 machines.
runs-on: ubuntu-latest# Permissions are necessary to be able to edit and write comments on the PR
permissions:
issues: write
pull-requests: write
repository-projects: read
contents: readsteps:
- uses: actions/checkout@v3
- uses: autometrics-dev/diff-metrics@v1
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
rs-roots: |
.
```### Mono repo example
In the case of a mono repo that would look like
```
.
├── project-a
│ ├── README.md
│ │ ...
│ └── Cargo.toml
├── project-b
│ ├── README.md
│ │ ...
│ └── Cargo.toml
├── project-c
│ ├── README.md
│ │ ...
│ └── Cargo.toml
├── project-d
│ ├── README.md
│ │ ...
│ └── go.mod
├── project-ts
│ ├── README.md
│ │ ...
│ └── package.json
└── README.md
```The step using diff-metrics would look like this:
```yaml
uses: autometrics-dev/diff-metrics@v1
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
rs-roots: |
project-a
project-b
project-c
go-roots: |
project-d
ts-roots: |
project-ts
```###### Language support
Look at the issues in the repository to see the advancement of language support.
All languages in the table will be eventually supported.| Language | Support |
| :-------------------------------------------------------------: | :------: |
| [Rust](https://github.com/autometrics-dev/autometrics-rs) | ✅ |
| [Typescript](https://github.com/autometrics-dev/autometrics-ts) | ✅ |
| [Go](https://github.com/autometrics-dev/autometrics-go) | ⚠️[^mid] |
| [Python](https://github.com/autometrics-dev/autometrics-py) | ✅ |
| [C#](https://github.com/autometrics-dev/autometrics-cs) | ❌ |[^mid]:
Golang's version detects functions decorated with `//autometrics` directives, but
does not deal with `net/http` middleware wrapper yet.