.github/workflows/go-tests-coverage.yml
name: deepSentinel golang tests and coverage
on:
workflow_dispatch:
workflow_call:
push:
branches:
- master
permissions: read-all
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.2
- name: Install gocover-cobertura
run: |
go get github.com/boumenot/gocover-cobertura && go install github.com/boumenot/gocover-cobertura
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.0.0
- name: Run tests
run: go test -race -json -v -coverprofile=coverage.txt ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Convert go coverage to corbetura format
run: gocover-cobertura < coverage.txt > coverage.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: equals215/deepsentinel
files: ./coverage.xml
- name: Generate code coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
badge: false
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md