Generate a test coverage badge like this one for your go projects.

coverage-badge-go

CI Coverage Update release version. Public workflows that use this action. Ubuntu Mac OS Windows

              👆

Generate a test coverage badge like this one for your go projects.

Usage

on:
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest
    name: Update coverage badge
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
          fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
      
      - name: Setup go
        uses: actions/setup-go@v2
        with:
          go-version: '1.14.4'

      - uses: actions/cache@v2
        with:
          path: ~/go/pkg/mod
          key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-

      - name: Run Test  # Pass the `coverage.out` output to this action
        run:
          go test -v ./... -covermode=count -coverprofile=coverage.out
          go tool cover -func=coverage.out -o=coverage.out

      - name: Go Coverage Badge
        uses: tj-actions/coverage-badge-go@v1
        with:
          filename: coverage.out

      - name: Verify Changed files
        uses: tj-actions/[email protected]
        id: verify-changed-files
        with:
          files: README.md

      - name: Push changes
        if: steps.changed_files.outputs.files_changed == 'true'
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ github.token }}
          branch: ${{ github.head_ref }}

Features

  • Generate coverage badge from a coverage report.

Inputs

Input type required default description
filename string true coverage.out File containing the
tests output
(default: "coverage.out")

If you feel generous and want to show some extra appreciation:

Buy me a coffee

Credits

This package was created with Cookiecutter using cookiecutter-action

Report Bugs

Report bugs at https://github.com/tj-actions/coverage-badge-go/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your workflow that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.
Comments
  • [BUG] How do I signed commits generated by this actions

    [BUG] How do I signed commits generated by this actions

    Is there an existing issue for this?

    • [X] I have searched the existing issues

    Does this issue exist in the latest version?

    • [X] I'm using the latest release

    Describe the bug?

    The below script works properly, creating a commit with updated coverage info in README.md. The problem is that the Pull Request is not able to be merged because the badge commit is not signed:

    Merging is blocked
    The base branch requires all commits to be signed.
    

    My coverage_badge.yml

    # https://github.com/tj-actions/coverage-badge-go
    name: "Coverage Badge"
    on:
      pull_request:
        branches:
          - develop
    
    jobs:
      test:
        runs-on: ubuntu-latest
        name: Update coverage badge
        steps:
          - name: Checkout
            uses: actions/checkout@v3
            with:
              persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
              fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
    
          - name: Setup go
            uses: actions/setup-go@v3
            with:
              go-version: "1.18"
    
          - name: Install OS dependencies
            run: sudo apt-get update && sudo apt-get install libgl1-mesa-dev xorg-dev
    
          - uses: actions/cache@v3
            with:
              path: ~/go/pkg/mod
              key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
              restore-keys: |
                ${{ runner.os }}-go-
    
          - name: Run Test
            run: |
              go test -v ./... -covermode=count -coverprofile=coverage.out
              go tool cover -func=coverage.out -o=coverage.out
    
          - name: Go Coverage Badge # Pass the `coverage.out` output to this action
            uses: tj-actions/coverage-badge-go@v2
            with:
              filename: coverage.out
    
          - name: Verify Changed files
            uses: tj-actions/[email protected]
            id: verify-changed-files
            with:
              files: README.md
    
          - name: Commit changes
            if: steps.verify-changed-files.outputs.files_changed == 'true'
            run: |
              git config --local user.email "[email protected]"
              git config --local user.name "GitHub Action"
              git add README.md
              git commit -m "chore: Updated coverage badge."
    
          - name: Push changes
            if: steps.verify-changed-files.outputs.files_changed == 'true'
            uses: ad-m/github-push-action@master
            with:
              github_token: ${{ github.token }}
              branch: ${{ github.head_ref }}
    

    To Reproduce

    1. Add above script to project and commit
    2. Create a PR on a branch that requires commits to be signed
    3. Observe that GitHub will not allow the PR to be merged

    What OS are you seeing the problem on?

    macos-latest or macos-10.15

    Expected behavior?

    I expected the commit to be signed

    Relevant log output

    No response

    Anything else?

    No response

    Code of Conduct

    • [X] I agree to follow this project's Code of Conduct
  • [BUG] <why my badge generated not in % form>

    [BUG]

    Is there an existing issue for this?

    • [X] I have searched the existing issues

    Does this issue exist in the latest version?

    • [X] I'm using the latest release

    Describe the bug?

    why my badge generated not in % form

    image

    To Reproduce

    use your .yml

    What OS are you seeing the problem on?

    all

    Expected behavior?

    become % form.

    Relevant log output

    No response

    Anything else?

    No response

    Code of Conduct

    • [X] I agree to follow this project's Code of Conduct
  • [BUG] <cannot use -o flag with multiple packages>

    [BUG]

    Is there an existing issue for this?

    • [X] I have searched the existing issues

    Does this issue exist in the latest version?

    • [X] I'm using the latest release

    Describe the bug?

    when use the yml file you provide, workflow will exit with this message

    image

    To Reproduce

    when i change go version to 1.17, error will disappear.

    What OS are you seeing the problem on?

    all

    Expected behavior?

    fix this

    Relevant log output

    No response

    Anything else?

    No response

    Code of Conduct

    • [X] I agree to follow this project's Code of Conduct
  • Doc error

    Doc error

    Is there an existing issue for this?

    • [X] I have searched the existing issues

    Does this issue exist in the latest version?

    • [X] I'm using the latest release

    Describe the bug?

    In your doc, you are using the wrong id for verify-changes:

        if: steps.changed_files.outputs.files_changed == 'true'
    

    Should be:

        if: steps.verify-changed-files.outputs.files_changed == 'true'
    

    To Reproduce

    See doc

    What OS are you seeing the problem on?

    all

    Expected behavior?

        if: steps.verify-changed-files.outputs.files_changed == 'true'
    

    Relevant log output

    No response

    Anything else?

    No response

    Code of Conduct

    • [X] I agree to follow this project's Code of Conduct
  • Update tj-actions/auto-doc action to v1.7.2

    Update tj-actions/auto-doc action to v1.7.2

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tj-actions/auto-doc | action | patch | v1.7.1 -> v1.7.2 |


    Release Notes

    tj-actions/auto-doc

    v1.7.2

    Compare Source

    Full Changelog

    Merged pull requests:


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update tj-actions/auto-doc action to v1.7.1

    Update tj-actions/auto-doc action to v1.7.1

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tj-actions/auto-doc | action | minor | v1.6.0 -> v1.7.1 |


    Release Notes

    tj-actions/auto-doc

    v1.7.1

    Compare Source

    Full Changelog

    v1.7.0

    Compare Source

    Full Changelog

    Closed issues:

    • Dependency Dashboard #​2

    Merged pull requests:


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update tj-actions/github-changelog-generator action to v1.17

    Update tj-actions/github-changelog-generator action to v1.17

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tj-actions/github-changelog-generator | action | minor | v1.15 -> v1.17 |


    Release Notes

    tj-actions/github-changelog-generator

    v1.17

    Compare Source

    What's Changed

    Full Changelog: https://github.com/tj-actions/github-changelog-generator/compare/v1...v1.17

    v1.16

    Compare Source

    Full Changelog

    Merged pull requests:


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update tj-actions/verify-changed-files action to v13

    Update tj-actions/verify-changed-files action to v13

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tj-actions/verify-changed-files | action | major | v12 -> v13 |


    Release Notes

    tj-actions/verify-changed-files

    v13

    Compare Source

    Full Changelog

    Closed issues:

    Merged pull requests:


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update tj-actions/auto-doc action to v1.6.0

    Update tj-actions/auto-doc action to v1.6.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tj-actions/auto-doc | action | minor | v1.5.0 -> v1.6.0 |


    Release Notes

    tj-actions/auto-doc

    v1.6.0

    Compare Source

    Full Changelog


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update cirrus-actions/rebase action to v1.8

    Update cirrus-actions/rebase action to v1.8

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | cirrus-actions/rebase | action | minor | 1.7 -> 1.8 |


    Release Notes

    cirrus-actions/rebase

    v1.8

    Compare Source

    What's Changed

    New Contributors

    Full Changelog: https://github.com/cirrus-actions/rebase/compare/1.7...1.8


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update tj-actions/auto-doc action to v1.5.0

    Update tj-actions/auto-doc action to v1.5.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tj-actions/auto-doc | action | minor | v1.4.3 -> v1.5.0 |


    Release Notes

    tj-actions/auto-doc

    v1.5.0

    Compare Source

    What's Changed

    Full Changelog: https://github.com/tj-actions/auto-doc/compare/v1...v1.5.0


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

Test coverage in Go, the whole package

Test coverage in Go, the whole package

Jan 20, 2022
go-test-trace is like go test but it also generates distributed traces.
go-test-trace is like go test but it also generates distributed traces.

go-test-trace go-test-trace is like go test but it also generates distributed traces. Generated traces are exported in OTLP to a OpenTelemetry collect

Jan 5, 2023
Automatically generate Go test boilerplate from your source code.
Automatically generate Go test boilerplate from your source code.

gotests gotests makes writing Go tests easy. It's a Golang commandline tool that generates table driven tests based on its target source files' functi

Jan 8, 2023
The portal gates to coverage reports
The portal gates to coverage reports

Covergates - Portal Gates to Coverage Reports Purpose Covergates is to make the easiest way to setup a self-hosted coverage report service. It's an al

Dec 18, 2022
A Comprehensive Coverage Testing System for The Go Programming Language
A Comprehensive Coverage Testing System for The Go Programming Language

goc 中文页 | goc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scenarios, like system testing c

Jan 8, 2023
Coverage testing tool for The Go Programming Language

gocov Coverage reporting tool for The Go Programming Language Installation go get github.com/axw/gocov/gocov Usage There are currently four gocov comm

Jan 3, 2023
Hsuan-Fuzz: REST API Fuzzing by Coverage Level Guided Blackbox Testing
Hsuan-Fuzz: REST API Fuzzing by Coverage Level Guided Blackbox Testing

Hsuan-Fuzz: REST API Fuzzing by Coverage Level Guided Blackbox Testing Architecture Usage package main import ( restAPI "github.com/iasthc/hsuan-

Nov 30, 2022
This is a simple test application that sends fake video data from one pion instance to another

Pion test app for BWE This is a simple test application that sends fake video data from one pion instance to another. It is a modified version of the

Jun 8, 2022
An assert function for Go that works like the one in C.

Assert This package provides an assert function for Go. It's designed to work like assert in C.

Nov 16, 2022
Flugel Test Documentation for steps to run and test the automatio
Flugel Test Documentation for steps to run and test the automatio

Flugel Test Documentation Documentation for steps to run and test the automation #Test-01 1 - Local Test Using Terratest (End To End) 1- By runing " t

Nov 13, 2022
Test-assignment - Test assignment with golang
Test-assignment - Test assignment with golang

test-assignment We have a two steam of data and we need to save it in the map: I

Jan 19, 2022
This repository includes consumer driven contract test for provider, unit test and counter api.

This repository includes consumer driven contract test for provider, unit test and counter api.

Feb 1, 2022
Ruby on Rails like test fixtures for Go. Write tests against a real database

testfixtures Warning: this package will wipe the database data before loading the fixtures! It is supposed to be used on a test database. Please, doub

Jan 8, 2023
Test your command line interfaces on windows, linux and osx and nodes viá ssh and docker

Commander Define language independent tests for your command line scripts and programs in simple yaml files. It runs on windows, osx and linux It can

Dec 17, 2022
Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻

Gnomock – tests without mocks ??️ Spin up entire dependency stack ?? Setup initial dependency state – easily! ?? Test against actual, close to product

Dec 29, 2022
Cloud Spanner load generator to load test your application and pre-warm the database before launch

GCSB GCSB Quickstart Create a test table Load data into table Run a load test Operations Load Single table load Multiple table load Loading into inter

Nov 30, 2022
Small program that takes in commands and moves one or more robots around the surface of Mars!

Mars Rover Build and Run the Image Build image from current directory: docker build -t marsrover . Run image interactively: docker run -i marsrover

Jan 2, 2022
Wise-mars-rover - Write a program that takes in commands and moves one or more robots around the surface of Mars

wise-mars-rover Write a program that takes in commands and moves one or more rob

Feb 9, 2022
Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test
Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test

embedded-postgres Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test. When testing this provides

Dec 27, 2022