Skip to content

GitHub Action for limgo to generate badges showing the test coverage

Notifications You must be signed in to change notification settings

GoTestTools/limgo-badge-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

limgo gopher

limgo-badge-action

Show your test coverage

GitHub release unlicense


This action uses the coverage output from limgo to generate a badge visualizing the achieved test coverage. It also pushes the badge to the specified repository/branch so that it can be integrated into any README via:

<img src="https://<repository>/blob/<branch>/<badge-name>.png?raw=true" alt="test coverge" />

The following sample badge is imported from the GoTestTools/limgo repository:

test coverge

Usage

You can use limgo-badge-action with the following configuration:

jobs:
  build:
    name: Test
    runs-on: ubuntu-latest
    steps:
      # Checkout your project with git
      - name: Checkout
        uses: actions/checkout@v2

      # Install Go on the VM running the action.
      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.19

      # Run your tests with -coverprofile
      - name: Run tests
        run: |
          go test ./... -coverprofile=test.cov
        
      # Run the test coverage check using the limgo-action and output the statistic file
      - name: Run test coverage check
        uses: GoTestTools/[email protected]
        with:
          version: "v0.0.0-beta"
          args: "-coverfile=test.cov -outfile=covcheck.tmp -config=.limgo.json -v=3"
      
      # Generate the badge only for commits on the main branch
      - name: Generate test badge
        if: github.ref == 'refs/heads/main'
        uses: GoTestTools/[email protected] 
        with:
          # name of the limgo test coverage file
          limgo_file: covcheck.tmp
          # format of the limgo test coverage file
          limgo_file_format: tab
          # name of the badge
          badge_name: limgo-badge.png
          # repository where the generated badge is pushed to
          repo: github.com/GoTestTools/limgo
          # branch of the repository where the generated badge is pushed to (will be created if it doesn't exist)
          branch: limgo-badge
          # github token which is required to create and push to the repository
          github_token: ${{ secrets.GH_TOKEN }}
          # github user who owns the github_token
          github_token_owner: engelmi
          # flag to show the branch coverage in the generated badge
          badge_enabled_branch: false
          # flag to show the statement coverage in the generated badge
          badge_enabled_stmt: false
          # flag to show the line coverage in the generated badge
          badge_enabled_lines: true

For more information about limgo please see the limgo repository.

For more information about limgo-action please see the limgo-action repository.