Skip to content

Add coverage report #22

Add coverage report

Add coverage report #22

Workflow file for this run

name: CI/CD
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1.23
- name: Install dependencies
run: go get -v -t ./...
- name: Build
run: go build -v ./...
- name: Test with coverage
run: |
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
go tool cover -html=coverage.out -o coverage.html
COVERAGE=$(go tool cover -func=coverage.out | grep total: | grep -Eo '[0-9]+\.[0-9]+')
echo "{\"coverage\": \"${COVERAGE}%\"}" > coverage.json
mkdir coverage
mv coverage.html coverage.json coverage/
- name: Deploy coverage to GitHub Pages
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverage