{"id":20445203,"url":"https://github.com/addepar/github-metrics","last_synced_at":"2025-09-24T16:31:35.481Z","repository":{"id":48658692,"uuid":"346433411","full_name":"Addepar/github-metrics","owner":"Addepar","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-13T13:28:28.000Z","size":998,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":53,"default_branch":"master","last_synced_at":"2025-01-13T13:28:41.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Addepar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-10T17:12:49.000Z","updated_at":"2025-01-03T15:20:49.000Z","dependencies_parsed_at":"2025-01-13T13:27:15.743Z","dependency_job_id":"ff54996d-e464-4dc4-95d3-bb02bd89cbb8","html_url":"https://github.com/Addepar/github-metrics","commit_stats":{"total_commits":115,"total_committers":6,"mean_commits":"19.166666666666668","dds":"0.27826086956521734","last_synced_commit":"3ecc842e5cdd8076485cff299bee15f19c7ae177"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Addepar%2Fgithub-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Addepar%2Fgithub-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Addepar%2Fgithub-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Addepar%2Fgithub-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Addepar","download_url":"https://codeload.github.com/Addepar/github-metrics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234098708,"owners_count":18779632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:11:22.973Z","updated_at":"2025-09-24T16:31:34.983Z","avatar_url":"https://github.com/Addepar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Github Metrics\n\nGithub Action that tracks the following metrics on a Github repository:\n\n- Number of Pull Requests Opened\n- Number of Pull Requests Closed\n- Number of Pull Requests Merged\n- Number of hotfixes\n- Aggregated Pull Request Review Depth (number of comments, reviews and reviewers)\n- Time to Merge\n- Average Pull Request Idle Time\n\nIf you would like to know more about the metrics themselves, please see\n[metrics.md](./metrics.md).\n\n## Usage\n\nTo use this github action, specify it in your github workflow file. Here's an example:\n\n```\nname: Report Metrics\n\non:\n  schedule:\n    # At 16:00 UTC every Friday (aka 11am EST, 12pm EDT)\n    - cron: \"0 16 * * 5\"\n\njobs:\n  report:\n    name: Slack\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: Addepar/github-metrics@v1.2.0\n        with:\n          github-owner: bantic\n          github-repo: github-metrics\n          github-token: ${{secrets.GITHUB_TOKEN}}\n          slack-app-token: ${{secrets.SLACK_APP_TOKEN}}\n          slack-channel-id: ${{secrets.SLACK_CHANNEL_ID}}\n          post-to-slack: \"true\"\n          log-debug-messages: \"true\"\n```\n\nBy default, the report will include all metrics. Workflow-related metrics will be run for all active workflows.\nTo change this, specify a config-yml input. See \"Configuration\" below.\n\n### Configuration\n\nThe action can accept a configuration string in yml format in\norder to specify the period to report over, which metrics to run, and for workflow-related metrics which workflows should be included.\n\nHere's an example:\n\n```\nperiod: \"month\" # run a 1-month interval, ending now.\n                # other valid values are \"day\" and \"week\"\nmetrics:        # array of metric specifiers\n  - name: \"workflow/success\"   # 'name' is required\n    # Only workflows that match the paths listed here\n    # will run the WorkflowSuccess metric\n    include:\n      paths:\n        - .github/workflows/my-workflow.yml\n    # Workflows matching these paths will be excluded\n    exclude:\n      paths:\n        - .github/workflows/dont-run-this-one.yml\n    # Extra options for the metric can be passed using \"options\"\n    options:\n      branch: 'master'\n\n  # When no include/exclude are passed,\n  # this WorkflowDuration metric will run for every available\n  # workflow\n  - name: \"workflow/duration\"\n\n  # The non-workflow metrics do not accept additional\n  # configuration properties\n  - name: \"pull-request/time-to-merge\"\n```\n\nNote on the include.paths and exclude.paths:\n\n- exclude paths take precendence: If a path is listed in exclude.paths, that workflow will never be included (even if its path is also in include.paths)\n- If include.paths and/or exclude.paths are passed, only matching workflows are included -- all others are ignored\n- If neither include.paths or exclude.paths are passed, all\n  workflows will be included\n\n## Development\n\n- `yarn build` (build the project)\n- `yarn compile` (package the action in one file: `dist/index.js`)\n- `yarn dev` (build, and rebuild when source is changed)\n- `yarn lint` (run the linter)\n- `yarn test` (run tests)\n\n## Tests using Live Github API\n\nSome of the tests use [PollyJS](https://netflix.github.io/pollyjs/#/README) to record HAR files resulting from the real Github API.\n\nThe repo [bantic/github-metrics-tests](https://github.com/bantic/github-metrics-tests) is used as the source of that live\nGithub API data. Example PRs have been opened (and closed, merged, etc.) to simulate the types of activity that we see on real PRs.\n\nWhen running tests, the recorded HAR files are used unless the env var `RECORD_REQUESTS` is set.\nWhen `RECORD_REQUESTS` is set, the env var `GITHUB_RECORDING_TOKEN` must also be set.\n\nTo \"refresh\" the recorded HAR files:\n\n- ensure you have a valid Github access token that can access bantic/github-metrics-tests (a personal access token with no permissions should do it)\n- set the env var `GITHUB_RECORDING_TOKEN` to the value of that token\n- run `yarn test:record-requests`\n\nThe HAR files, in `tests/fixtures/__recordings__` will all change (because they include the local date and some other information that changes when they are re-run) and should be checked in again after confirming that the diff is acceptable.\n\nTo add a new test that uses live data:\n\n- Add the test that makes the request. Be sure to call `setupPolly` first\n- set the env `RECORD_REQUESTS` and `GITHUB_RECORDING_TOKEN` vars\n  - Note that the repo and owner are currently hardcoded, in `jest.setup.js`, to `bantic/github-metrics-tests`\n- Run your test (e.g. `jest path/to/my/test`)\n- A new recording should be created\n\nAt this point you can unset the `RECORD_REQUESTS` and iterate locally using the recording. Or follow the steps above to regenerate it if needed.\n\n### Debugging\n\nYou can run individual scripts using `ts-node`. In order to use them with breakpoints, run the script like this:\n\n```\nnode --inspect-brk -r ts-node/register src/path/to/ts-file.ts\n```\n\nAnd then open the chrome devtools at: `chrome://inspect`.\n\nThis [article](https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27) has some more details.\n\nYou can run a test with the debugger in a similar manner. For instance, to run the metrics\ntests using the chrome inspector for debugging, run:\n\n```\nnode --inspect-brk node_modules/.bin/jest --runInBand tests/metrics\n```\n\nBoth of the above commands can be run without `--inspect-brk` if you just want to run the script or test in isolation and don't need the debugger.\n\n### Use DEBUG=github-metrics:\\*\n\nThe codebase uses the [debug package](https://github.com/visionmedia/debug#readme) to log debugging info.\nSet the env var `DEBUG` to view logs. To see all of them, use `DEBUG=github-metrics:*`. See debug's docs for more.\n\n### Simulate a run locally\n\nIn order to simulate a run of this action, run the `index.ts` file with some or all of the following environment variables:\n\n- (required) GITHUB_TOKEN\n- (required) GITHUB_OWNER\n- (required) GITHUB_REPO\n- (optional) `export POST_TO_SLACK=false` - to skip posting to a slack channel and display the output on the console only.\n- (optional) CONFIG_YML - to use a specific configuration. If not specified, default config is used. See Configuration section\n\nNote: In order to set a multi-line yml file as an environment variable, a simple way is to write the yml file and then `cat` it into the env var, e.g.:\n\n```\nvim my-config.yml # create/edit file\nexport CONFIG_YML=`cat my-config.yml`\n```\n\nAfter setting the env vars appropriately, run the index.ts script:\n\n```\nnode -r ts-node src/index.ts\n```\n\n## Documentation\n\nTo build a new version of the docs, run `yarn build-with-docs`.\n\n## @vercel/ncc\n\nAccording to [GH docs](https://git.io/Jqnuf), you _need_ to commit\n`node_modules` folder.\n\nThat seems like a nightmare, so we use [@vercel/ncc](https://github.com/vercel/ncc)\nto compile the code and Node Modules into one file.\n\nInstall `vercel/ncc` via `npm install -g @vercel/ncc`\n\n## Deployment \u0026 Release\n\nOnce the changes are made, you should:\n\n- Run `yarn compile`\n- Commit via `git commit -m \"The change\"`\n- Tag via `git tag -a -m \"My first action release\" v1`\n- Push to Github via `git push --follow-tags` or `git push origin **v1**`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faddepar%2Fgithub-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faddepar%2Fgithub-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faddepar%2Fgithub-metrics/lists"}