{"id":15404760,"url":"https://github.com/k1low/octocov","last_synced_at":"2025-05-16T04:06:58.094Z","repository":{"id":40419081,"uuid":"361720627","full_name":"k1LoW/octocov","owner":"k1LoW","description":"octocov is a toolkit for collecting code metrics (code coverage, code to test ratio, test execution time and your own custom metrics).","archived":false,"fork":false,"pushed_at":"2025-05-15T14:29:58.000Z","size":4609,"stargazers_count":388,"open_issues_count":6,"forks_count":29,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-15T15:27:12.271Z","etag":null,"topics":["badge","code-coverage","code-metrics","code-to-test-ratio","coverage-report","custom-metrics","hacktoberfest","test-execution-time","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","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/k1LoW.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null},"funding":{"github":"k1LoW","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-04-26T11:12:55.000Z","updated_at":"2025-05-15T14:29:47.000Z","dependencies_parsed_at":"2023-12-19T05:16:23.104Z","dependency_job_id":"98950c63-6e1c-4a4a-a4e4-805e674adcf6","html_url":"https://github.com/k1LoW/octocov","commit_stats":{"total_commits":1395,"total_committers":15,"mean_commits":93.0,"dds":0.3763440860215054,"last_synced_commit":"9d6d1f32dd6d4c815cf84a3df829e7b4a6c812b8"},"previous_names":[],"tags_count":147,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Foctocov","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Foctocov/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Foctocov/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Foctocov/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k1LoW","download_url":"https://codeload.github.com/k1LoW/octocov/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464897,"owners_count":22075571,"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":["badge","code-coverage","code-metrics","code-to-test-ratio","coverage-report","custom-metrics","hacktoberfest","test-execution-time","testing"],"created_at":"2024-10-01T16:14:11.136Z","updated_at":"2025-05-16T04:06:53.084Z","avatar_url":"https://github.com/k1LoW.png","language":"Go","readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/k1LoW/octocov/raw/main/docs/logo.png\" width=\"200\" alt=\"octocov\"\u003e\n\u003c/p\u003e\n\n![Coverage](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/octocov/coverage.svg) ![Code to Test Ratio](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/octocov/ratio.svg) ![Test Execution Time](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/octocov/time.svg) [![build](https://github.com/k1LoW/octocov/actions/workflows/ci.yml/badge.svg)](https://github.com/k1LoW/octocov/actions/workflows/ci.yml)\n\n`octocov` is a toolkit for collecting code metrics (code coverage, code to test ratio, test execution time and **[your own custom metrics](#custom-metrics)**).\n\nKey features of `octocov` are:\n\n- **Useful both [as a CI tool](#on-github-actions) and [as a CLI tool](#on-terminal)**\n- **[Support multiple coverage report formats](#supported-coverage-report-formats).**\n- **[Support multiple code metrics](#supported-code-metrics).**\n- **[Support for even generating coverage report badges](#generate-report-badges-self).**\n- **[Have a mechanism to aggregate reports from multiple repositories](#store-report-to-datastores).**\n\n## Getting Started\n\n### On GitHub Actions\n\n**:octocat: GitHub Actions for octocov is [here](https://github.com/k1LoW/octocov-action) !!**\n\nFirst, run test with [coverage report output](#supported-coverage-report-formats).\n\nFor example, in case of Go language, add `-coverprofile=coverage.out` option as follows\n\n``` console\n$ go test ./... -coverprofile=coverage.out\n```\n\nAnd generete `.octocov.yml` to your repository.\n\n``` console\n$ octocov init\n.octocov.yml is generated\n```\n\nAnd set up a workflow file as follows and run octocov on GitHub Actions.\n\n``` yaml\n# .github/workflows/ci.yml\nname: Test\n\non:\n  pull_request:\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      -\n        uses: actions/checkout@v3\n      -\n        uses: actions/setup-go@v4\n        with:\n          go-version-file: go.mod\n      -\n        name: Run tests with coverage report output\n        run: go test ./... -coverprofile=coverage.out\n      -\n        uses: k1LoW/octocov-action@v1\n```\n\nThen, octocov comment the report of the code metrics to the pull request.\n\n![comment](docs/comment_with_diff.png)\n\nIt is also possible to add reports to [GitHub Actions Job Summaries](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/) by editing .octocov.yml.\n\n![summary](docs/summary.png)\n\nIt can also be inserted into the body of a pull request.\n\n![body](docs/body.png)\n\n\u003e **Note** that only pull requests from the same repository can be commented on (Reporting to GitHub Actions Job Summaries is permitted). This is because the workflow token of a forked pull request does not have write permission.\n\n### On Terminal\n\noctocov acts as a code metrics viewer on the terminal.\n\nFor example, in case of Go language, add `-coverprofile=coverage.out` option as follows\n\n``` console\n$ go test ./... -coverprofile=coverage.out\n```\n\nAnd run `octocov ls-files` , `octocov view [FILE...]` and `octocov diff [REPORT_A] [REPORT_B]`\n\n![term](docs/term.svg)\n\n## Usage example\n\n### Comment report to pull request\n\nBy setting `comment:`, [comment the reports to pull request](https://github.com/k1LoW/octocov/pull/30#issuecomment-860188829).\n\n![comment](docs/comment.png)\n\n``` yaml\n# .octocov.yml\ncomment:\n  hideFooterLink: false # hide octocov link\n```\n\noctocov checks for **\"Code Coverage\"** by default. If it is running on GitHub Actions, it will also measure **\"Test Execution Time\"**.\n\nIf you want to measure **\"Code to Test Ratio\"**, set `codeToTestRatio:`.\n\n``` yaml\ncomment:\ncodeToTestRatio:\n  code:\n    - '**/*.go'\n    - '!**/*_test.go'\n  test:\n    - '**/*_test.go'\n```\n\nBy setting `report:` ( `report.path:`  or `report.datastores` ) and `diff:` ( `diff.path:`  or `diff.datastores` ) additionally, it is possible to show differences from previous reports as well.\n\n``` yaml\ncomment:\nreport:\n  datastores:\n    - artifact://${GITHUB_REPOSITORY}\ndiff:\n  datastores:\n    - artifact://${GITHUB_REPOSITORY}\n```\n\n![img](docs/comment_with_diff.png)\n\n### Check for acceptable score\n\nBy setting `coverage.acceptable:`, the condition of acceptable coverage is specified.\n\nIf this condition is not met, the command will exit with exit status `1`.\n\n``` yaml\n# .octocov.yml\ncoverage:\n  acceptable: 60%\n```\n\n``` console\n$ octocov\nError: code coverage is 54.9%. the condition in the `coverage.acceptable:` section is not met (`60%`)\n```\n\nBy setting `codeToTestRatio.acceptable:`, the condition of acceptable \"Code to Test Ratio\" is specified.\n\nIf this condition is not met, the command will exit with exit status `1`.\n\n``` yaml\n# .octocov.yml\ncodeToTestRatio:\n  acceptable: 1:1.2\n  code:\n    - '**/*.go'\n    - '!**/*_test.go'\n  test:\n    - '**/*_test.go'\n```\n\n``` console\n$ octocov\nError: code to test ratio is 1:1.1, the condition in the `codeToTestRatio.acceptable:` section is not met (`1:1.2`)\n```\n\nBy setting `testExecutionTime.acceptable:`, the condition of acceptable \"Test Execution Time\" is specified **(on GitHub Actions only)** .\n\nIf this condition is not met, the command will exit with exit status `1`.\n\n``` yaml\n# .octocov.yml\ntestExecutionTime:\n  acceptable: 1 min\n```\n\n``` console\n$ octocov\nError: test execution time is 1m15s, the condition in the `testExecutionTime.acceptable:` section is not met (`1 min`)\n```\n\n### Generate report badges self.\n\nBy setting `*.badge.path:`, generate badges self.\n\n``` yaml\n# .octocov.yml\ncoverage:\n  badge:\n    path: docs/coverage.svg\n```\n\n``` yaml\n# .octocov.yml\ncodeToTestRatio:\n  badge:\n    path: docs/ratio.svg\n```\n\n``` yaml\n# .octocov.yml\ntestExecutionTime:\n  badge:\n    path: docs/time.svg\n```\n\nYou can display the coverage badge without external communication by setting a link to this badge image in README.md, etc.\n\n``` markdown\n# mytool\n\n![coverage](docs/coverage.svg) ![coverage](docs/ratio.svg) ![coverage](docs/time.svg)\n```\n\n![coverage](docs/coverage.svg) ![coverage](docs/ratio.svg) ![coverage](docs/time.svg)\n\n### Push report badges self.\n\nBy setting `push:`, git push report badges self.\n\n``` yaml\n# .octocov.yml\ncoverage:\n  badge:\n    path: docs/coverage.svg\npush:\n```\n\n### Store report to datastores\n\nBy setting `report:`, store the reports to datastores and local path.\n\n``` yaml\n# .octocov.yml\nreport:\n  datastores:\n    - github://owner/coverages/reports\n    - s3://bucket/reports\n```\n\n``` yaml\n# .octocov.yml\nreport:\n  path: path/to/report.json\n```\n\n#### Supported datastores\n\n- GitHub repository\n- GitHub Actions Artifacts\n- Amazon S3\n- Google Cloud Storage (GCS)\n- BigQuery\n- Local\n\n### Central mode\n\nBy enabling `central:`, `octocov` acts as a central repository for collecting reports ( [example](example/central/README.md) ).\n\n``` yaml\n# .octocov.yml for central mode\ncentral:\n  root: .                                  # root directory or index file path of collected coverage reports pages. default: .\n  reports:\n    datastores:\n      - bq://my-project/my-dataset/reports # datastore paths (URLs) where reports are stored. default: local://reports\n  badges:\n    datastores:\n      - local://badges                     # directory where badges are generated.\n  push:                                    # enable self git push\n```\n\n#### Supported datastores\n\n- GitHub repository\n- GitHub Actions Artifacts\n- Amazon S3\n- Google Cloud Storage (GCS)\n- BigQuery\n- Local\n\n### View code coverage report of file\n\n`octocov ls-files` command can be used to list files logged in code coverage report.\n\n`octocov view` (alias: `octocov cat`) command can be used to view the file coverage report.\n\n![term](docs/term.svg)\n\n## Configuration\n\n### `repository:`\n\nThe name of the repository.\n\nIt should be in the format `owner/repo`.\n\nBy default, the value of the environment variable `GITHUB_REPOSITORY` is set.\n\nIn case of monorepo, code metrics can be reported to datastore separately by specifying `owner/repo/project-a` or `owner/repo@project-a`.\n\n``` yaml\nrepository: k1LoW/octocov\n```\n\n### `timeout:`\n\nTimeout for octocov execution. (default: `30sec`)\n\n``` yaml\ntimeout: 5min\n```\n\n### `coverage:`\n\nConfiguration for code coverage.\n\n### `coverage.path:`\n\n`coverage.path:` has been deprecated. Please use `coverage.paths:` instead.\n\n### `coverage.paths:`\n\nThe path to the coverage report file.\n\nIf no path is specified, the default path for each coverage format will be scanned.\n\n``` yaml\ncoverage:\n  paths:\n    - tests/coverage.xml\n```\n\n### `coverage.exclude:`\n\nExclude files from the coverage report.\n\n``` yaml\ncoverage:\n  exclude:\n    - 'cmd/*.ts'\n    - 'proto/**/*.pb.ts'\n```\n\n### `coverage.acceptable:`\n\nacceptable coverage condition.\n\n``` yaml\ncoverage:\n  acceptable: 60%\n```\n\n``` yaml\ncoverage:\n  acceptable: current \u003e= 60% \u0026\u0026 diff \u003e= 0.5%\n```\n\nThe variables that can be used are as follows.\n\n| value | description |\n| --- | --- |\n| `current` | Current code metrics value |\n| `prev` | Previous value. This value is taken from `diff.datastores:`. |\n| `diff` | The result of `current - prev` |\n\nIt is also possible to omit the expression as follows\n\n| Omitted expression | Expanded expression |\n| --- | --- |\n| `60%` | `current \u003e= 60%` |\n| `\u003e 60%` | `current \u003e 60%` |\n\n### `coverage.badge:`\n\nSet this if want to generate the badge self.\n\n### `coverage.badge.path:`\n\nThe path to the badge.\n\n``` yaml\ncoverage:\n  badge:\n    path: docs/coverage.svg\n```\n\n### `coverage.if:`\n\nConditions for measuring code coverage.\n\n``` yaml\ncoverage:\n  if: is_default_branch\n```\n\n### `codeToTestRatio:`\n\nConfiguration for code to test ratio.\n\n### `codeToTestRatio.code:` `codeToTestRatio.test:`\n\nFiles to count.\n\n``` yaml\ncodeToTestRatio:\n  code:                  # files to count as \"Code\"\n    - '**/*.go'\n    - '!**/*_test.go'\n  test:                  # files to count as \"Test\"\n    - '**/*_test.go'\n```\n\n### `codeToTestRatio.acceptable:`\n\nacceptable ratio condition.\n\n``` yaml\ncodeToTestRatio:\n  acceptable: 1:1.2\n```\n\n``` yaml\ncodeToTestRatio:\n  acceptable: current \u003e= 1.2 \u0026\u0026 diff \u003e= 0.0\n```\n\nThe variables that can be used are as follows.\n\n| value | description |\n| --- | --- |\n| `current` | Current code metrics value |\n| `prev` | Previous value. This value is taken from `diff.datastores:`. |\n| `diff` | The result of `current - prev` |\n\nIt is also possible to omit the expression as follows\n\n| Omitted expression | Expanded expression |\n| --- | --- |\n| `1:1.2` | `current \u003e= 1.2` |\n| `\u003e 1:1.2` | `current \u003e 1.2` |\n\n### `codeToTestRatio.badge:`\n\nSet this if want to generate the badge self.\n\n### `codeToTestRatio.badge.path:`\n\nThe path to the badge.\n\n``` yaml\ncodeToTestRatio:\n  badge:\n    path: docs/ratio.svg\n```\n\n### `codeToTestRatio.if:`\n\nConditions for measuring code to test ratio.\n\n``` yaml\ncodeToTestRatio:\n  if: is_default_branch\n```\n\n### `testExecutionTime:`\n\nConfiguration for test execution time.\n\n### `testExecutionTime.acceptable`\n\nacceptable time condition.\n\n``` yaml\ntestExecutionTime:\n  acceptable: 1min\n```\n\n``` yaml\ntestExecutionTime:\n  acceptable: current \u003c= 1min \u0026\u0026 diff \u003c= 1sec\n```\n\nThe variables that can be used are as follows.\n\n| value | description |\n| --- | --- |\n| `current` | Current code metrics value |\n| `prev` | Previous value. This value is taken from `diff.datastores:`. |\n| `diff` | The result of `current - prev` |\n\nIt is also possible to omit the expression as follows\n\n| Omitted expression | Expanded expression |\n| --- | --- |\n| `1min` | `current \u003c= 1min` |\n| `\u003c 1min` | `current \u003c 1min` |\n\n### `testExecutionTime.steps`\n\nThe name of the step to measure the execution time.\n\n``` yaml\ntestExecutionTime:\n  steps:\n    - Run test\n    - Run slow test\n```\n\nIf not specified, the step where the coverage report file is generated is used as the measurement target.\n\n### `testExecutionTime.badge`\n\nSet this if want to generate the badge self.\n\n### `testExecutionTime.badge.path`\n\nThe path to the badge.\n\n``` yaml\ntestExecutionTime:\n  badge:\n    path: docs/time.svg\n```\n\n### `testExecutionTime.if:`\n\nConditions for measuring test execution time.\n\n``` yaml\ntestExecutionTime:\n  if: is_pull_request\n```\n\n### `push:`\n\nConfiguration for `git push` files self.\n\n### `push.if:`\n\nConditions for pushing files.\n\n``` yaml\n# .octocov.yml\npush:\n  if: is_default_branch\n```\n\nThe variables available in the `if` section are [here](https://github.com/k1LoW/octocov#if).\n\n### `push.message:`\n\nmessage for commit.\n\n``` yaml\n# .octocov.yml\npush:\n  message: Update by octocov [skip ci]\n```\n\n### `comment:`\n\nSet this if want to comment report to pull request\n\n### `comment.hideFooterLink:`\n\nHide footer [octocov](https://github.com/k1LoW/octocov) link.\n\n``` yaml\ncomment:\n  hideFooterLink: true\n```\n\n### `comment.deletePrevious:`\n\nDelete previous code metrics report comments instead of hiding them\n\n``` yaml\ncomment:\n  deletePrevious: true\n```\n\n### `comment.message:`\n\nAdd message to code metrics report comments.\n\n```yaml\ncomment:\n  message: See [coverage html](https://github.com/k1LoW/octocov).\n```\n\n### `comment.if:`\n\nConditions for commenting report.\n\n``` yaml\n# .octocov.yml\ncomment:\n  if: is_pull_request\n```\n\nThe variables available in the `if` section are [here](https://github.com/k1LoW/octocov#if).\n\n### `summary:`\n\nSet this if want to add report to [job summary page](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary).\n\n### `summary.hideFooterLink:`\n\nHide footer [octocov](https://github.com/k1LoW/octocov) link.\n\n``` yaml\nsummary:\n  hideFooterLink: true\n```\n\n### `summary.message:`\n\nAdd message to report.\n\n```yaml\nsummary:\n  message: See [coverage html](https://github.com/k1LoW/octocov).\n```\n\n### `summary.if:`\n\nConditions for adding report to job summary page.\n\n``` yaml\n# .octocov.yml\nsummary:\n  if: true\n```\n\nThe variables available in the `if` section are [here](https://github.com/k1LoW/octocov#if).\n\n### `body:`\n\nSet this if want to insert report to body of pull request.\n\n### `body.hideFooterLink:`\n\nHide footer [octocov](https://github.com/k1LoW/octocov) link.\n\n``` yaml\nbody:\n  hideFooterLink: true\n```\n\n### `body.message:`\n\nAdd message to report.\n\n```yaml\nbody:\n  message: See [coverage html](https://github.com/k1LoW/octocov).\n```\n\n### `body.if:`\n\nConditions for inserting report body of pull request.\n\n``` yaml\n# .octocov.yml\nbody:\n  if: is_pull_request\n```\n\nThe variables available in the `if` section are [here](https://github.com/k1LoW/octocov#if).\n\n### `diff:`\n\nConfiguration for comparing reports.\n\n### `diff.path:`\n\nPath of the report to compare.\n\n``` yaml\ndiff:\n  path: path/to/coverage.yml\n```\n\n``` yaml\ndiff:\n  path: path/to/report.json\n```\n\n### `diff.datastores:`\n\nDatastores where the report to be compared is stored.\n\n``` yaml\ndiff:\n  datastores:\n    - local://.octocov       # Use .octocov/owner/repo/report.json\n    - s3://my-bucket/reports # Use s3://my-bucket/reports/owner/repo/report.json\n```\n\n### `diff.if:`\n\nConditions for comparing reports\n\n``` yaml\n# .octocov.yml\ndiff:\n  if: is_pull_request\n  path: path/to/report.json\n```\n\nThe variables available in the `if` section are [here](https://github.com/k1LoW/octocov#if).\n\n### `report:`\n\nConfiguration for reporting to datastores.\n\n### `report.path:`\n\nPath to save the report.\n\n``` yaml\nreport:\n  path: path/to/report.json\n```\n\n### `report.datastores:`\n\nDatastores where the reports are stored.\n\n``` yaml\nreport:\n  datastores:\n    - github://owner/coverages/reports\n    - s3://bucket/reports\n```\n\n#### GitHub repository\n\nUse `github://` scheme.\n\n```\ngithub://[owner]/[repo]@[branch]/[prefix]\n```\n\n**Required environment variables:**\n\n- `GITHUB_TOKEN` or `OCTOCOV_GITHUB_TOKEN`\n- `GITHUB_REPOSITORY` or `OCTOCOV_GITHUB_REPOSITORY`\n- `GITHUB_API_URL` or `OCTOCOV_GITHUB_API_URL` (optional)\n\n#### GitHub Actions Artifacts\n\nUse `artifact://` or `artifacts://` scheme.\n\n```\nartifact://[owner]/[repo]/[artifactName]\n```\n\n- `artifact://[owner]/[repo]/[artifactName]`\n- `artifact://[owner]/[repo]` ( default artifactName: `octocov-report` )\n\n\n\u003e **Note** that reporting to the artifact can only be sent from the GitHub Actions of the same repository.\n\n**Required environment variables:**\n\n- `GITHUB_TOKEN` or `OCTOCOV_GITHUB_TOKEN`\n- `GITHUB_REPOSITORY` or `OCTOCOV_GITHUB_REPOSITORY`\n- `GITHUB_API_URL` or `OCTOCOV_GITHUB_API_URL` (optional)\n\n#### Amazon S3\n\nUse `s3://` scheme.\n\n```\ns3://[bucket]/[prefix]\n```\n\n**Required permission:**\n\n- `s3:PutObject`\n\n**Required environment variables:**\n\n- `AWS_ACCESS_KEY_ID` or `OCTOCOV_AWS_ACCESS_KEY_ID`\n- `AWS_SECRET_ACCESS_KEY` or `OCTOCOV_AWS_SECRET_ACCESS_KEY`\n- `AWS_SESSION_TOKEN` or `OCTOCOV_AWS_SESSION_TOKEN` (optional)\n\n#### Google Cloud Storage\n\nUse `gs://` scheme.\n\n```\ngs://[bucket]/[prefix]\n```\n\n**Required permission:**\n\n- `storage.objects.create`\n- `storage.objects.delete`\n\n**Required environment variables:**\n\n- `GOOGLE_APPLICATION_CREDENTIALS` or `GOOGLE_APPLICATION_CREDENTIALS_JSON` or `OCTOCOV_GOOGLE_APPLICATION_CREDENTIALS` or `OCTOCOV_GOOGLE_APPLICATION_CREDENTIALS_JSON`\n\n#### BigQuery\n\nUse `bq://` scheme.\n\n```\nbq://[project ID]/[dataset ID]/[table]\n```\n\n**Required permission:**\n\n- `bigquery.datasets.get`\n- `bigquery.tables.get`\n- `bigquery.tables.updateData`\n\n**Required environment variables:**\n\n- `GOOGLE_APPLICATION_CREDENTIALS` or `GOOGLE_APPLICATION_CREDENTIALS_JSON` or `OCTOCOV_GOOGLE_APPLICATION_CREDENTIALS` or `OCTOCOV_GOOGLE_APPLICATION_CREDENTIALS_JSON`\n\n**Datastore schema:**\n\n[Datastore schema](docs/bq/schema/README.md)\n\nIf you want to create a table, execute the following command ( require `bigquery.datasets.create` ).\n\n``` console\n$ octocov migrate-bq-table\n```\n\n#### Mackerel\n\n\u003e **Note**: Only works with `report.datastores` or `central.reReport.datastores`\n\nUse `mackerel://` or `mkr://` scheme.\n\n```\nmackerel://[Service Name]\n```\n\n**Required permission:**\n\n- `read`\n- `write`\n\n**Required environment variables:**\n\n- `MACKEREL_API_KEY` or `OCTOCOV_MACKEREL_API_KEY`\n\n#### Local\n\nUse `local://` or `file://` scheme.\n\n```\nlocal://[path]\n```\n\n**Example:**\n\nIf the absolute path of `.octocov.yml` is `/path/to/.octocov.yml`\n\n- `local://reports` ... `/path/to/reports` directory\n- `local://./reports` ... `/path/to/reports` directory\n- `local://../reports` ... `/path/reports` directory\n- `local:///reports` ... `/reports` directory.\n\n### `report.if:`\n\nConditions for storing a report.\n\n``` yaml\n# .octocov.yml\nreport:\n  if: env.GITHUB_REF == 'refs/heads/main'\n  datastores:\n    - github://owner/coverages/reports\n```\n\nThe variables available in the `if` section are [here](https://github.com/k1LoW/octocov#if).\n\n### `*.if:`\n\n\u003e **Note**: It supports [expr-lang/expr](https://github.com/expr-lang/expr) expressions.\n\nThe variables available in the `if` section are as follows\n\n| Variable name | Type | Description |\n| --- | --- | --- |\n| `year` | `int` | Year of current time (UTC) |\n| `month` | `int` | Month of current time (UTC) |\n| `day` | `int` | Day of current time (UTC) |\n| `hour` | `int` | Hour of current time (UTC) |\n| `weekday` | `int` | Weekday of current time (UTC) (Sunday = 0, ...) |\n| `github.event_name` | `string` | Event name of GitHub Actions ( ex. `issues`, `pull_request` )|\n| `github.event` | `object` | Detailed data for each event of GitHub Actions (ex. `github.event.action`, `github.event.label.name` ) |\n| `env.\u003cenv_name\u003e` | `string` | The value of a specific environment variable |\n| `is_pull_request` | `boolean` | Whether the job is related to an pull request (ex. a job fired by `on.push` will be true if it is related to a pull request) |\n| `is_draft` | `boolean` | Whether the job is related to a draft pull request |\n| `labels` | `array` | Labels that are set for the pull request |\n| `is_default_branch` | `boolean` | Whether the job is related to default branch of repository |\n\n### `central:`\n\n\u003e **Note**: When central mode is enabled, other functions are automatically turned off.\n\n### `central.root:`\n\nThe root directory or index file ( [index file example](example/central/README.md) ) path of collected coverage reports pages. default: `.`\n\n``` yaml\ncentral:\n  root: path/to\n```\n\n### `central.reports:`\n\n### `central.reports.datastores:`\n\nDatastore paths (URLs) where reports are stored. default: `local://reports`\n\n``` yaml\ncentral:\n  reports:\n    datastores:\n      - local://reports\n      - gs://my-gcs-bucket/reports\n```\n\n#### Use GitHub Actions Artifacts as datastore\n\nWhen using [GitHub Actions Artifacts](https://docs.github.com/en/rest/actions/artifacts) as a datastore, perform badge generation via on.schedule.\n\n![github](docs/artifacts.svg)\n\n``` yaml\n# .octocov.yml\nreport:\n  datastores:\n    - artifact://${GITHUB_REPOSITORY}\n```\n\n``` yaml\n# .octocov.yml for central repo\ncentral:\n  reports:\n    datastores:\n      - artifact://owner/repo\n      - artifact://owner/other-repo\n      - artifact://owner/another-repo\n      [...]\n  push:\n```\n\n[Code metrics and badges of my open source projects using octocov central mode is here](https://github.com/k1LoW/octocovs).\n\n[Template repositoty is here](https://github.com/k1LoW/octocovs-template).\n\n#### Use GitHub repository as datastore\n\nWhen using the central repository as a datastore, perform badge generation via on.push.\n\n![github](docs/github.svg)\n\n``` yaml\n# .octocov.yml\nreport:\n  datastores:\n    - github://owner/central-repo/reports\n```\n\n``` yaml\n# .octocov.yml for central repo\ncentral:\n  reports:\n    datastores:\n      - github://owner/central-repo/reports\n  push:\n```\n\nor\n\n``` yaml\n# .octocov.yml for central repo\ncentral:\n  reports:\n    datastores:\n      - local://reports\n  push:\n```\n\n#### Use Amazon S3 bucket as datastore\n\nWhen using the S3 bucket as a datastore, perform badge generation via on.schedule.\n\n![s3](docs/s3.svg)\n\n``` yaml\n# .octocov.yml\nreport:\n  datastores:\n    - s3://my-s3-bucket/reports\n```\n\n``` yaml\n# .octocov.yml for central repo\ncentral:\n  reports:\n    datastores:\n      - s3://my-s3-bucket/reports\n  push:\n```\n\n**Required permission (Central Repo):**\n\n- `s3:GetObject`\n- `s3:ListObject`\n\n**Required environment variables (Central Repo):**\n\n- `AWS_ACCESS_KEY_ID` or `OCTOCOV_AWS_ACCESS_KEY_ID`\n- `AWS_SECRET_ACCESS_KEY` or `OCTOCOV_AWS_SECRET_ACCESS_KEY`\n- `AWS_SESSION_TOKEN` or `OCTOCOV_AWS_SESSION_TOKEN` (optional)\n\n#### Use GCS bucket as datastore\n\n![gcs](docs/gcs.svg)\n\nWhen using the GCS bucket as a datastore, perform badge generation via on.schedule.\n\n``` yaml\n# .octocov.yml\nreport:\n  datastores:\n    - gs://my-gcs-bucket/reports\n```\n\n``` yaml\n# .octocov.yml for central repo\ncentral:\n  reports:\n    datastores:\n      - gs://my-gcs-bucket/reports\n  push:\n```\n\n**Required permission (Central Repo):**\n\n- `storage.objects.get`\n- `storage.objects.list`\n- `storage.buckets.get`\n\n**Required environment variables (Central Repo):**\n\n- `GOOGLE_APPLICATION_CREDENTIALS` or `GOOGLE_APPLICATION_CREDENTIALS_JSON` or `OCTOCOV_GOOGLE_APPLICATION_CREDENTIALS` or `OCTOCOV_GOOGLE_APPLICATION_CREDENTIALS_JSON`\n\n#### Use BigQuery table as datastore\n\n![gcs](docs/bq.svg)\n\nWhen using the BigQuery table as a datastore, perform badge generation via on.schedule.\n\n``` yaml\n# .octocov.yml\nreport:\n  datastores:\n    - bq://my-project/my-dataset/reports\n```\n\n``` yaml\n# .octocov.yml for central repo\ncentral:\n  reports:\n    datastores:\n      - bq://my-project/my-dataset/reports\n  push:\n```\n\n**Required permission (Central Repo):**\n\n- `bigquery.jobs.create`\n- `bigquery.tables.getData`\n\n**Required environment variables (Central Repo):**\n\n- `GOOGLE_APPLICATION_CREDENTIALS` or `GOOGLE_APPLICATION_CREDENTIALS_JSON` or `OCTOCOV_GOOGLE_APPLICATION_CREDENTIALS` or `OCTOCOV_GOOGLE_APPLICATION_CREDENTIALS_JSON`\n\n### `central.badges:`\n\n### `central.badges.datastores:`\n\nDatastore paths (URLs) where badges are generated. default: `local://badges`\n\n``` yaml\ncentral:\n  badges:\n    datastores:\n      - local://badges\n      - s3://my-s3-buckets/badges\n```\n\n### `central.push:`\n\nConfiguration for `git push` index file and badges self.\n\n### `central.if:`\n\nConditions for central mode.\n\n``` yaml\n# .octocov.yml\ncentral:\n  if: env.GITHUB_REF == 'refs/heads/main'\n  reports:\n    datastores:\n      - s3://my-s3-bucket/reports\n```\n\nThe variables available in the `if` section are [here](https://github.com/k1LoW/octocov#if).\n\n### `central.reReport:`\n\nStore collected reports in yet another datastores.\n\n### `central.reReport.if:`\n\nConditions for re storing reports.\n\n### `central.reReport.datastores:`\n\nDatastores where the reports are re-stored.\n\n## Supported coverage report formats\n\noctocov supports multiple coverage report formats.\n\nAnd octocov searches for the default path for each format.\n\nIf you want to specify the path of the report file, set `coverage.path`\n\n``` yaml\ncoverage:\n  paths:\n    - /path/to/coverage.txt\n```\n\n### Go coverage\n\n**Default path:** `coverage.out`\n\n### LCOV\n\n**Default path:** `coverage/lcov.info`\n\nSupport `SF` `DA` only\n\n### SimpleCov\n\n**Default path:** `coverage/.resultset.json`\n\n### Clover\n\n**Default path:** `coverage.xml`\n\n### Cobertura\n\n**Default path:** `coverage.xml`\n\n### JaCoCo\n\n**Default path:** `build/reports/jacoco/test/jacocoTestReport.xml`\n\n## Supported code metrics\n\n- **Code Coverage**\n- **Code to Test Ratio**\n- **Test Execution Time** (on GitHub Actions only)\n\n### Custom metrics\n\n![custom_metrics](docs/custom_metrics.png)\n\noctocov accepts custom metrics in addition to the three supporting metrics.\n\nSpecify the path to the custom metrics JSON file in an environment variable prefixed with `OCTOCOV_CUSTOM_METRICS_` to collect the code metrics at the same time.\n\nThe JSON schema for custom metrics can be found [here](report/custom_metrics_schema.json).\n\nIf there are multiple custom metrics JSON files, specify each file path in a separate environment variable (example [here](https://github.com/k1LoW/octocov/blob/68e007b4164ad6dab4ad978bce8e88c21280900a/.github/workflows/ci.yml#L59-L60)) or [combine the JSONs that satisfy the JSON schema into an array](testdata/custom_metrics/benchmark_0_1.json).\n\n## Detecting pull request number\n\noctocov detect pull request number following order.\n\n1. Get pull request number from `GITHUB_PULL_REQUEST_NUMBER` or `OCTOCOV_GITHUB_PULL_REQUEST_NUMBER`.\n2. Get pull request number from [`GITHUB_REF`](https://docs.github.com/en/actions/learn-github-actions/variables) ( e.g. `refs/pull/1/merge` ).\n3. Get branch name from [`GITHUB_REF`](https://docs.github.com/en/actions/learn-github-actions/variables) ( e.g. `refs/heads/branch/branch/name` ) and detect pull request number using GitHub API.\n\n### Override environment variables\n\nIf an environment variable with prefix `OCTOCOV_` is set, it is used as an unprefixed environment variable in octocov.\n\nFor example, if `OCTOCOV_GITHUB_REF` is set, it is handled as `GITHUB_REF` in octocov.\n\nThis feature allows [environment variables that cannot normally be overridden](https://docs.github.com/en/actions/learn-github-actions/variables#naming-conventions-for-environment-variables) to be changed on octocov.\n\n## Install\n\n**deb:**\n\n``` console\n$ export OCTOCOV_VERSION=X.X.X\n$ curl -o octocov.deb -L https://github.com/k1LoW/octocov/releases/download/v$OCTOCOV_VERSION/octocov_$OCTOCOV_VERSION-1_amd64.deb\n$ dpkg -i octocov.deb\n```\n\n**RPM:**\n\n``` console\n$ export OCTOCOV_VERSION=X.X.X\n$ yum install https://github.com/k1LoW/octocov/releases/download/v$OCTOCOV_VERSION/octocov_$OCTOCOV_VERSION-1_amd64.rpm\n```\n\n**apk:**\n\n``` console\n$ export OCTOCOV_VERSION=X.X.X\n$ curl -o octocov.apk -L https://github.com/k1LoW/octocov/releases/download/v$OCTOCOV_VERSION/octocov_$OCTOCOV_VERSION-1_amd64.apk\n$ apk add octocov.apk\n```\n\n**homebrew tap:**\n\n```console\n$ brew install k1LoW/tap/octocov\n```\n\n**[aqua](https://aquaproj.github.io/):**\n\n```console\n$ aqua g -i k1LoW/octocov\n```\n\n**manually:**\n\nDownload binary from [releases page](https://github.com/k1LoW/octocov/releases)\n\n**go install:**\n\n```console\n$ go install github.com/k1LoW/octocov@latest\n```\n\n**docker:**\n\n```console\n$ docker pull ghcr.io/k1low/octocov:latest\n```\n","funding_links":["https://github.com/sponsors/k1LoW"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1low%2Foctocov","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk1low%2Foctocov","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1low%2Foctocov/lists"}