Validate 45/merge by @dependabot[bot] #133
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run tests with coverage | |
run-name: Validate ${{github.ref_name}} by @${{ github.actor }} | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
name: Validate code | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23.*' | |
- name: Check Format | |
run: gofmt -d ./ | |
- name: Verify dependencies | |
run: go mod verify | |
- name: Install dependencies | |
run: go mod vendor | |
- name: Run go vet | |
run: go vet ./... | |
- name: Build | |
run: go build -v ./... | |
- name: Lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: v1.60 | |
- name: Test | |
run: go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./... | |
- name: Visualise Coverage | |
if: ${{ github.ref != 'refs/heads/main' && always() }} | |
run: go tool cover -html=cover.out -o=cover.html | |
- name: Upload Coverage | |
if: ${{ github.ref != 'refs/heads/main' && always() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage | |
path: cover.html | |
retention-days: 1 | |
id: cover | |
- name: Post Coverage | |
if: ${{ github.ref != 'refs/heads/main' && always() }} | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ github.event.number }} | |
body: | | |
New [coverage report](${{ steps.cover.outputs.artifact-url }}) available :sparkles: | |
- name: Check Coverage | |
uses: vladopajic/go-test-coverage@v2 | |
with: | |
config: ./.testcoverage.yml | |
## badge is created and committed only for main branch | |
git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }} | |
## name of branch where badges are stored | |
## ideally this should be orphan branch (see below how to create this branch) | |
git-branch: badges |