├── .github ├── release.yml └── workflows │ ├── integration.yml │ ├── tag-v0.yml │ └── tagpr.yml ├── .pinact.yaml ├── .tagpr ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── action.yml ├── docs ├── comment.png └── comment_with_diff.png └── testdata └── path └── to ├── .octocov.yml ├── main.go └── main_test.go /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | labels: 4 | - tagpr 5 | categories: 6 | - title: Breaking Changes 🛠 7 | labels: 8 | - breaking-change 9 | - title: New Features 🎉 10 | labels: 11 | - enhancement 12 | - title: Fix bug 🐛 13 | labels: 14 | - bug 15 | - title: Other Changes 16 | labels: 17 | - "*" 18 | -------------------------------------------------------------------------------- /.github/workflows/integration.yml: -------------------------------------------------------------------------------- 1 | name: Integration 2 | 3 | on: 4 | push: 5 | 6 | jobs: 7 | test-run: 8 | strategy: 9 | matrix: 10 | os: [ubuntu-latest, windows-latest, macos-latest] 11 | runs-on: ${{ matrix.os }} 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | - uses: ./ 15 | with: 16 | config: testdata/path/to/.octocov.yml 17 | env: 18 | ARTIFACT_NAME: "octocov-report-${{ matrix.os }}" 19 | test-run-with-work-dir: 20 | strategy: 21 | matrix: 22 | os: [ubuntu-latest, windows-latest, macos-latest] 23 | runs-on: ${{ matrix.os }} 24 | steps: 25 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 26 | - uses: ./ 27 | with: 28 | work-dir: testdata/path/to 29 | env: 30 | ARTIFACT_NAME: "octocov-report-with-work-dir-${{ matrix.os }}" 31 | test-run-with-install-dir: 32 | strategy: 33 | matrix: 34 | os: [ubuntu-latest, windows-latest, macos-latest] 35 | runs-on: ${{ matrix.os }} 36 | steps: 37 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 38 | - uses: ./ 39 | with: 40 | config: testdata/path/to/.octocov.yml 41 | install-dir: testdata/path/to 42 | env: 43 | ARTIFACT_NAME: "octocov-report-with-install-dir-${{ matrix.os }}" 44 | -------------------------------------------------------------------------------- /.github/workflows/tag-v0.yml: -------------------------------------------------------------------------------- 1 | name: Manage tag for v0 2 | on: 3 | push: 4 | tags: 5 | - "v0+.[0-9]+.[0-9]+" 6 | jobs: 7 | tag: 8 | name: Manage tag 9 | runs-on: ubuntu-latest 10 | steps: 11 | - 12 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 13 | with: 14 | ref: docker-action 15 | - 16 | uses: haya14busa/action-update-semver@fb48464b2438ae82cc78237be61afb4f461265a1 # v1.2.1 17 | with: 18 | major_version_tag_only: true 19 | -------------------------------------------------------------------------------- /.github/workflows/tagpr.yml: -------------------------------------------------------------------------------- 1 | name: tagpr 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | tagpr: 9 | runs-on: ubuntu-latest 10 | outputs: 11 | tagpr-tag: ${{ steps.run-tagpr.outputs.tag }} 12 | env: 13 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 14 | steps: 15 | - name: Check out source code 16 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 17 | 18 | - id: run-tagpr 19 | name: Run tagpr 20 | uses: Songmu/tagpr@e89d37247ca73d3e5620bf074a53fbd5b39e66b0 # v1.5.1 21 | 22 | - uses: haya14busa/action-update-semver@fb48464b2438ae82cc78237be61afb4f461265a1 # v1.2.1 23 | if: "steps.run-tagpr.outputs.tag != ''" 24 | with: 25 | major_version_tag_only: true 26 | tag: ${{ steps.run-tagpr.outputs.tag }} 27 | -------------------------------------------------------------------------------- /.pinact.yaml: -------------------------------------------------------------------------------- 1 | # yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/pinact/refs/heads/main/json-schema/pinact.json 2 | # pinact - https://github.com/suzuki-shunsuke/pinact 3 | files: 4 | - pattern: "^\\.github/workflows/.*\\.ya?ml$" 5 | - pattern: "^(.*/)?action\\.ya?ml$" 6 | 7 | ignore_actions: 8 | # - name: actions/checkout 9 | # - name: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml 10 | -------------------------------------------------------------------------------- /.tagpr: -------------------------------------------------------------------------------- 1 | # config file for the tagpr in git config format 2 | # The tagpr generates the initial configuration, which you can rewrite to suit your environment. 3 | # CONFIGURATIONS: 4 | # tagpr.releaseBranch 5 | # Generally, it is "main." It is the branch for releases. The tagpr tracks this branch, 6 | # creates or updates a pull request as a release candidate, or tags when they are merged. 7 | # 8 | # tagpr.versionFile 9 | # Versioning file containing the semantic version needed to be updated at release. 10 | # It will be synchronized with the "git tag". 11 | # Often this is a meta-information file such as gemspec, setup.cfg, package.json, etc. 12 | # Sometimes the source code file, such as version.go or Bar.pm, is used. 13 | # If you do not want to use versioning files but only git tags, specify the "-" string here. 14 | # You can specify multiple version files by comma separated strings. 15 | # 16 | # tagpr.vPrefix 17 | # Flag whether or not v-prefix is added to semver when git tagging. (e.g. v1.2.3 if true) 18 | # This is only a tagging convention, not how it is described in the version file. 19 | # 20 | # tagpr.changelog (Optional) 21 | # Flag whether or not changelog is added or changed during the release. 22 | # 23 | # tagpr.command (Optional) 24 | # Command to change files just before release. 25 | # 26 | # tagpr.template (Optional) 27 | # Pull request template in go template format 28 | # 29 | # tagpr.release (Optional) 30 | # GitHub Release creation behavior after tagging [true, draft, false] 31 | # If this value is not set, the release is to be created. 32 | # 33 | # tagpr.majorLabels (Optional) 34 | # Label of major update targets. Default is [major] 35 | # 36 | # tagpr.minorLabels (Optional) 37 | # Label of minor update targets. Default is [minor] 38 | # 39 | [tagpr] 40 | vPrefix = true 41 | releaseBranch = main 42 | versionFile = - 43 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [v1.5.0](https://github.com/k1LoW/octocov-action/compare/v1.4.0...v1.5.0) - 2025-03-19 4 | ### Other Changes 5 | - fix: pin dependencies by @k1LoW in https://github.com/k1LoW/octocov-action/pull/16 6 | 7 | ## [v1.4.0](https://github.com/k1LoW/octocov-action/compare/v1.3.0...v1.4.0) - 2024-09-08 8 | ### Other Changes 9 | - Add inputs.args parameter by @lufia in https://github.com/k1LoW/octocov-action/pull/13 10 | 11 | ## [v1.3.0](https://github.com/k1LoW/octocov-action/compare/v1.2.0...v1.3.0) - 2024-01-30 12 | ### Breaking Changes 🛠 13 | - Support for setting install directory by @k1LoW in https://github.com/k1LoW/octocov-action/pull/11 14 | 15 | ## [v1.2.0](https://github.com/k1LoW/octocov-action/compare/v1.1.0...v1.2.0) - 2024-01-29 16 | ### Breaking Changes 🛠 17 | - Force installation by default by @k1LoW in https://github.com/k1LoW/octocov-action/pull/9 18 | 19 | ## [v1.1.0](https://github.com/k1LoW/octocov-action/compare/v1.0.1...v1.1.0) - 2024-01-27 20 | ### New Features 🎉 21 | - Support working directory (`workdir:`) by @k1LoW in https://github.com/k1LoW/octocov-action/pull/6 22 | ### Other Changes 23 | - Set up tagpr by @k1LoW in https://github.com/k1LoW/octocov-action/pull/7 24 | 25 | ## [v1.0.1](https://github.com/k1LoW/octocov-action/compare/v1.0.0...v1.0.1) - 2024-01-25 26 | - Use actions/github-script for using ACTIONS_RUNTIME_URL by @k1LoW in https://github.com/k1LoW/octocov-action/pull/5 27 | 28 | ## [v1.0.0](https://github.com/k1LoW/octocov-action/compare/v0.54.6...v1.0.0) - 2024-01-24 29 | - Use gh-setup action instead of docker image by @k1LoW in https://github.com/k1LoW/octocov-action/pull/4 30 | 31 | ## [v1.0.0](https://github.com/k1LoW/octocov-action/compare/v1.0.0...v1) - 2024-01-25 32 | - Use actions/github-script for using ACTIONS_RUNTIME_URL by @k1LoW in https://github.com/k1LoW/octocov-action/pull/5 33 | 34 | ## [v0.56.3](https://github.com/k1LoW/octocov-action/compare/v0.54.6...v0.56.3) - 2024-01-24 35 | 36 | ## [v0.56.1](https://github.com/k1LoW/octocov-action/compare/v0.54.3...v0.56.1) - 2023-11-03 37 | 38 | ## [v0.54.6](https://github.com/k1LoW/octocov-action/compare/v0.54.3...v0.54.6) - 2023-11-03 39 | 40 | ## [v0.54.3](https://github.com/k1LoW/octocov-action/compare/v0.54.1...v0.54.3) - 2023-10-17 41 | 42 | ## [v0.54.1](https://github.com/k1LoW/octocov-action/compare/v0.54.0...v0.54.1) - 2023-10-02 43 | 44 | ## [v0.54.0](https://github.com/k1LoW/octocov-action/compare/v0.53.0...v0.54.0) - 2023-09-30 45 | 46 | ## [v0.53.0](https://github.com/k1LoW/octocov-action/compare/v0.52.2...v0.53.0) - 2023-09-30 47 | 48 | ## [v0.52.2](https://github.com/k1LoW/octocov-action/compare/v0.52.1...v0.52.2) - 2023-09-29 49 | 50 | ## [v0.52.1](https://github.com/k1LoW/octocov-action/compare/v0.52.0...v0.52.1) - 2023-09-24 51 | 52 | ## [v0.52.0](https://github.com/k1LoW/octocov-action/compare/v0.51.6...v0.52.0) - 2023-09-23 53 | 54 | ## [v0.51.6](https://github.com/k1LoW/octocov-action/compare/v0.51.5...v0.51.6) - 2023-09-06 55 | 56 | ## [v0.51.5](https://github.com/k1LoW/octocov-action/compare/v0.51.3...v0.51.5) - 2023-09-06 57 | 58 | ## [v0.51.3](https://github.com/k1LoW/octocov-action/compare/v0.51.2...v0.51.3) - 2023-09-03 59 | 60 | ## [v0.51.2](https://github.com/k1LoW/octocov-action/compare/v0.51.1...v0.51.2) - 2023-09-03 61 | 62 | ## [v0.51.1](https://github.com/k1LoW/octocov-action/compare/v0.50.1...v0.51.1) - 2023-09-02 63 | 64 | ## [v0.50.1](https://github.com/k1LoW/octocov-action/compare/v0.50.0...v0.50.1) - 2023-08-22 65 | 66 | ## [v0.50.0](https://github.com/k1LoW/octocov-action/compare/v0.48.0...v0.50.0) - 2023-08-21 67 | 68 | ## [v0.48.0](https://github.com/k1LoW/octocov-action/compare/v0.47.4...v0.48.0) - 2023-07-12 69 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guide 2 | 3 | ## Issues 4 | 5 | It is welcome at [issues in octocov](https://github.com/k1LoW/octocov/issues). 6 | 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2021 Ken'ichiro Oyama 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # octocov-action 2 | 3 | :octocat: GitHub Action for [octocov](https://github.com/k1LoW/octocov) 4 | 5 | ![comment](docs/comment_with_diff.png) 6 | 7 | ## Usage 8 | 9 | Add `.octocov.yml` ( or `octocov.yml` ) file to your repository. 10 | 11 | ( `octocov init` is useful for easy generation. ) 12 | 13 | ``` yaml 14 | # .octocov.yml Go example 15 | coverage: 16 | paths: 17 | - path/to/coverage.out 18 | codeToTestRatio: 19 | code: 20 | - '**/*.go' 21 | - '!**/*_test.go' 22 | test: 23 | - '**/*_test.go' 24 | testExecutionTime: 25 | if: true 26 | diff: 27 | datastores: 28 | - artifact://${GITHUB_REPOSITORY} 29 | comment: 30 | if: is_pull_request 31 | report: 32 | if: is_default_branch 33 | datastores: 34 | - artifact://${GITHUB_REPOSITORY} 35 | ``` 36 | 37 | And set up a workflow file as follows and run octocov on GitHub Actions. 38 | 39 | ``` yaml 40 | # .github/workflows/ci.yml 41 | name: Test 42 | 43 | on: 44 | push: 45 | branches: 46 | - main 47 | pull_request: 48 | 49 | jobs: 50 | test: 51 | runs-on: ubuntu-latest 52 | steps: 53 | - 54 | uses: actions/checkout@v4 55 | - 56 | uses: actions/setup-go@v4 57 | with: 58 | go-version-file: go.mod 59 | - 60 | name: Run tests with coverage report output 61 | run: go test ./... -coverprofile=coverage.out 62 | - 63 | uses: k1LoW/octocov-action@v1 64 | ``` 65 | 66 | See [action.yml](action.yml) and [octocov README](https://github.com/k1LoW/octocov) for more details on how to configure it. 67 | 68 | ## [Docker container action](https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action) version 69 | 70 | Use `v0`. 71 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Run octocov' 2 | description: 'GitHub Action for octocov, a tool for collecting code coverage.' 3 | branding: 4 | icon: 'octagon' 5 | color: 'gray-dark' 6 | inputs: 7 | github-token: 8 | description: The GitHub token 9 | default: ${{ github.token }} 10 | required: false 11 | version: 12 | description: Version of octocov 13 | default: latest 14 | required: false 15 | checksum: 16 | description: Checksum of octocov 17 | default: '' 18 | required: false 19 | check-existence: 20 | description: Check for the existence of an existing octocov 21 | default: 'false' 22 | required: false 23 | config: 24 | description: Config path 25 | required: false 26 | workdir: 27 | description: Working directory (Deprecated) 28 | default: '' 29 | required: false 30 | work-dir: 31 | description: Working directory 32 | default: '' 33 | required: false 34 | install-dir: 35 | description: "Install directory" 36 | default: '' 37 | required: false 38 | args: 39 | description: Command line arguments of octocov 40 | default: '' 41 | required: false 42 | runs: 43 | using: 'composite' 44 | steps: 45 | - 46 | uses: k1LoW/gh-setup@e2f12d046abe942ed4e6976980e53e2388238273 # v1.10.0 47 | with: 48 | repo: github.com/k1LoW/octocov 49 | github-token: ${{ inputs.github-token }} 50 | version: ${{ inputs.version }} 51 | bin-dir: ${{ inputs.install-dir }} 52 | bin-match: octocov 53 | checksum: ${{ inputs.checksum }} 54 | strict: true 55 | force: ${{ inputs.check-existence != 'true' }} 56 | - 57 | name: Run octocov 58 | uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 59 | with: 60 | script: | 61 | const path = require('path'); 62 | const inputs = ${{ toJSON(inputs) }}; 63 | const toolpath = inputs['install-dir'] != '' ? path.join(inputs['install-dir'], 'octocov') : await io.which('octocov', true) 64 | const opt = `--config=${inputs.config} ${inputs.args}` 65 | const options = {}; 66 | if (inputs.workdir != '') { 67 | core.warning('Using workdir: to set working directory is deprecated. Use work-dir: instead.') 68 | } 69 | options.cwd = inputs['work-dir'] != '' ? inputs['work-dir'] : inputs.workdir; 70 | await exec.exec(`${toolpath} ${opt}`, [], options) 71 | env: 72 | OCTOCOV_GITHUB_TOKEN: ${{ inputs.github-token }} 73 | -------------------------------------------------------------------------------- /docs/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k1LoW/octocov-action/73d561f65d59e66899ed5c87e4621a913b5d5c20/docs/comment.png -------------------------------------------------------------------------------- /docs/comment_with_diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k1LoW/octocov-action/73d561f65d59e66899ed5c87e4621a913b5d5c20/docs/comment_with_diff.png -------------------------------------------------------------------------------- /testdata/path/to/.octocov.yml: -------------------------------------------------------------------------------- 1 | codeToTestRatio: 2 | code: 3 | - '**/*.go' 4 | - '!**/*_test.go' 5 | test: 6 | - '**/*_test.go' 7 | report: 8 | datastores: 9 | - artifact://${GITHUB_REPOSITORY}/${ARTIFACT_NAME:-octocov-report} 10 | -------------------------------------------------------------------------------- /testdata/path/to/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("called") 7 | } 8 | -------------------------------------------------------------------------------- /testdata/path/to/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestMain(t *testing.T) { 8 | main() 9 | } 10 | --------------------------------------------------------------------------------