Skip to content

Merge pull request #7 from nyxsola/dependabot/go_modules/github.com/e… #82

Merge pull request #7 from nyxsola/dependabot/go_modules/github.com/e…

Merge pull request #7 from nyxsola/dependabot/go_modules/github.com/e… #82

Workflow file for this run

name: Go CI
on:
push:
branches: [main, develop]
pull_request:
concurrency:
group: go-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
test:
name: Test (Go ${{ matrix.go }} | ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
go: [1.24.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: true
- name: Verify go.mod tidy
run: go mod tidy
- name: Vet
run: go vet ./...
- name: Build
run: go build -v ./...
- name: Test with race
run: go test -v -race -coverprofile=coverage.out ./...
- name: Enforce Coverage >= 80%
id: coverage
run: |
total=$(go tool cover -func=coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
echo "Coverage: $total%"
echo "coverage=$total" >> $GITHUB_OUTPUT
awk "BEGIN {exit !($total >= 80)}"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
fail_ci_if_error: true
verbose: true
name: "Go-${{ matrix.go }}-${{ matrix.os }}"
- name: Comment coverage on PR
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Go Test Coverage: **${{ steps.coverage.outputs.coverage }}%**