{"id":15012195,"url":"https://github.com/microsoft/pr-metrics","last_synced_at":"2025-04-06T08:15:49.189Z","repository":{"id":38834629,"uuid":"309438703","full_name":"microsoft/PR-Metrics","owner":"microsoft","description":"A GitHub Action \u0026 Azure Pipelines task for augmenting pull request titles to let reviewers quickly determine PR size and test coverage.","archived":false,"fork":false,"pushed_at":"2025-04-01T18:26:56.000Z","size":13716,"stargazers_count":67,"open_issues_count":0,"forks_count":12,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-06T08:15:38.756Z","etag":null,"topics":["azure-devops","azure-devops-extension","azure-pipelines","github","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/microsoft/Omex","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-02T17:04:42.000Z","updated_at":"2025-04-04T01:58:54.000Z","dependencies_parsed_at":"2023-10-04T13:57:19.990Z","dependency_job_id":"7cb154ed-ad1c-427a-9038-b2eaf5710816","html_url":"https://github.com/microsoft/PR-Metrics","commit_stats":{"total_commits":264,"total_committers":6,"mean_commits":44.0,"dds":0.4734848484848485,"last_synced_commit":"c64c5041b55e61012e65a1b2155be8fded4c1401"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPR-Metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPR-Metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPR-Metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FPR-Metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/PR-Metrics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247451666,"owners_count":20940944,"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":["azure-devops","azure-devops-extension","azure-pipelines","github","typescript"],"created_at":"2024-09-24T19:42:14.451Z","updated_at":"2025-04-06T08:15:49.158Z","avatar_url":"https://github.com/microsoft.png","language":"TypeScript","readme":"# PR Metrics\n\n[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true\u0026repo=309438703)\n\nPR Metrics is a both a GitHub Action and [Azure DevOps Pipelines][azuredevops]\ntask for adding size and test coverage indicators to the start of each Pull\nRequest title.\n\nThe Azure Pipelines task can be downloaded from the\n[Visual Studio Marketplace][vsmarketplace].\n\nFor example, a PR with the title \"Adding code\" could become either:\n\n- XS :heavy_check_mark: :black_small_square: Adding code\n- L :warning: :black_small_square: Adding code\n\nThe former would indicate an extra small PR with sufficient test coverage,\nwhereas the latter would indicate a large PR with insufficient test coverage.\n\nThis task helps ensure engineers keep PRs to an appropriate size with\nappropriate test coverage, while informing reviewers of the expected time\ncommitment for a thorough review of the code.\n\nThe task will also add a comment to the PR with a detailed breakdown of the\nmetrics:\n\n\u003e **Metrics for iteration 1**\n\u003e\n\u003e :heavy_check_mark: Thanks for keeping your pull request small.\n\u003e\n\u003e :heavy_check_mark: Thanks for adding tests.\n\u003e\n\u003e |              |   Lines |\n\u003e | ------------ | ------: |\n\u003e | Product Code |     100 |\n\u003e | Test Code    |      50 |\n\u003e | **Subtotal** | **150** |\n\u003e | Ignored      |       5 |\n\u003e | **Total**    | **155** |\n\nIt will furthermore add a comment to indicate that review of specific excluded\nfiles is unnecessary.\n\n\u003e :exclamation: **This file doesn't require review.**\n\nIf no PR description is provided, the description will be set to:\n\n\u003e :x: **Add a description.**\n\n## Inputs\n\nYou will need to set the environment variable `PR_Metrics_Access_Token` to a\nPersonal Access Token (PAT) with at least Read and Write access to pull\nrequests. If you are using a Classic PAT, it will need at least the 'repos'\nscope. Instructions on creating a new PAT can be found [here][githubpat].\nAlternatively, you can use the in-built `GITHUB_TOKEN`.\n\nIf using `GITHUB_TOKEN`, the following permissions are required:\n\n```YAML\npermissions:\n  pull-requests: write\n  statuses: write\n```\n\n[GitHub token permissions][github-token-pemissions] can be set for an individual\njob, workflow, or for Actions as a whole.\n\nIt is also recommended that you set `continue-on-error: true` as a failure\nwithin the action should not break your pipelines and prevent code development.\n\n### base-size\n\nThe maximum number of new lines in an extra small PR. If left blank, a default\nof `200` will be used.\n\n### growth-rate\n\nThe growth rate applied to the base size for calculating the size of larger PRs.\nIf left blank, a default of `2.0` will be used. With a base size of `200` and a\ngrowth rate of `2.0`, `400` new lines would constitute a medium PR while `800`\nnew lines would constitute a large PR.\n\n### test-factor\n\nThe lines of test code expected for each line of product code. If left blank, a\ndefault of `1.0` will be used. This can be set to `0.0` in order to skip the\nreporting of the test code coverage.\n\n### file-matching-patterns\n\n[Globs][globs] specifying the files and folders to include. Autogenerated files\nshould typically be excluded. Excluded files will contain a comment to inform\nreviewers that they are unlikely to need to review those files. If left blank, a\ndefault of\n\n```Text\n**/*\n!**/package-lock.json\n```\n\n(all files except `package-lock.json`) will be used.\n\n### test-matching-patterns\n\n[Globs][globs] specifying the files and folders to consider tests. If left\nblank, a default of\n\n```Text\n**/*{{t,T}est,TEST}*\n**/*{{t,T}est,TEST}*/**\n**/*.{{s,S}pec,SPEC}.*\n**/*.{{s,S}pec,SPEC}.*/**\n```\n\n(any file or folder with a name containing `test` or `.spec`) will be used.\n\n### code-file-extensions\n\nExtensions for files containing code, so that non-code files can be excluded. If\nleft blank, a default set of file extensions will be used, which are listed\n[here][defaultcodefileextensions].\n\n## Example Usage\n\nThe default input values are expected to be appropriate for most builds.\nTherefore, the following YAML definition is recommended:\n\n```YAML\nuses: microsoft/PR-Metrics@v1.7.2\nname: PR Metrics\nenv:\n  PR_METRICS_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}\ncontinue-on-error: true\n```\n\nIf you wish to modify the inputs, YAML akin the to the following can be used:\n\n```YAML\nuses: microsoft/PR-Metrics@v1.7.2\nname: PR Metrics\nenv:\n  PR_METRICS_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}\nwith:\n  base-size: 200\n  growth-rate: 2.0\n  test-factor: 1.0\n  file-matching-patterns: |\n    **/*\n    !Ignore.cs\n  test-matching-patterns: |\n    **/*test*\n    **/*TEST*\n  code-file-extensions: |\n    cs\n    ps1\ncontinue-on-error: true\n```\n\n**`pull_request` must be used as the pipeline trigger to ensure that sufficient\ninformation, including the Pull Request ID, is available to PR Metrics.\n`pull_request_target` will not work as insufficient information is available\nwhen using this trigger.**\n\nInstructions on using the action within Azure Pipelines can be found\n[here][azurepipelinestask].\n\n## Git History\n\nIf your repository contains _any_ non-linear history, it will be necessary to\nfetch Git history during checkout. This can be done by updating the\n`actions/checkout` step:\n\n```YAML\n- uses: actions/checkout@4.1.7\n  fetch-depth: 0\n```\n\nIn many cases, `fetch-depth` will not be required so it is recommended not to\nset this unless the action explicitly requests it. It may also be possible to\nset this to a value greater than 0 if you only require a partial history, but it\ncan be difficult to determine a value that will work consistently, due to the\nnature of Git history.\n\nTo avoid this, it is recommended to only use commit types that squash the Git\nhistory such as \"squash merge\" or \"rebase and fast-forward\".\n\n## Troubleshooting\n\nA set of steps for troubleshooting any issues encountered can be found\n[here][troubleshooting].\n\n## Contributing\n\nInstructions on contributing can be located in [CONTRIBUTING.md][contributing].\n\nThe code is released under the [MIT license][license].\n\nPR Metrics is created by the OMEX team in Microsoft, which is part of the Office\norganization. Additional source code released by the OMEX team can be located at\n\u003chttps://github.com/microsoft/Omex\u003e.\n\n## Code of Conduct\n\nThis project has adopted the\n[Microsoft Open Source Code of Conduct][codeofconduct]. For more information,\nsee the [Code of Conduct FAQ][codeofconductfaq] or contact\n[opencode@microsoft.com][opencodeemail] with any additional questions or\ncomments.\n\n[azuredevops]: https://azure.microsoft.com/services/devops/\n[vsmarketplace]: https://aka.ms/PRMetrics/AzureDevOps\n[githubpat]: https://docs.github.com/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token\n[globs]: https://en.wikipedia.org/wiki/Glob_(programming)\n[defaultcodefileextensions]: docs/default-code-file-extensions.md\n[azurepipelinestask]: docs/azure-pipelines-task.md\n[github-token-pemissions]: https://docs.github.com/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token\n[contributing]: .github/CONTRIBUTING.md\n[license]: LICENSE\n[codeofconduct]: https://opensource.microsoft.com/codeofconduct/\n[codeofconductfaq]: https://opensource.microsoft.com/codeofconduct/faq/\n[opencodeemail]: mailto:opencode@microsoft.com\n[troubleshooting]: docs/troubleshooting.md\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fpr-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fpr-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fpr-metrics/lists"}