Skip to content

Generate badge artifact #71

Generate badge artifact

Generate badge artifact #71

Workflow file for this run

name: Test
on: [push, workflow_dispatch]
jobs:
build:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- name: Test examples
run: go test -v -gcflags="all=-N -l" ./examples/...
- name: Unit tests
run: go test -v -gcflags="all=-N -l" -coverprofile coverage.out .
- id: cover
name: Calculate coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
echo "COVERAGE=$(go tool cover -func coverage.out | grep total: | awk '{ print $3 }')" >> $GITHUB_OUTPUT
- id: gen_badge
name: Generate badge
if: ${{ matrix.os == 'ubuntu-latest' }}
run: echo "BADGE=$(curl https://img.shields.io/badge/Coverage-${{ steps.cover.outputs.COVERAGE }}25-limegreen)" >> coverage.svg
- name: Upload badge
#if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: badge
path: coverage.svg