43 lines
1.0 KiB
YAML
43 lines
1.0 KiB
YAML
name: Coverage
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
coverage:
|
|
name: Test Coverage
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.24"
|
|
check-latest: true
|
|
|
|
- name: Run tests with coverage
|
|
run: go test -tags=integration -coverprofile=coverage.out -covermode=atomic -timeout 20m ./x/...
|
|
|
|
- name: Check coverage threshold
|
|
run: |
|
|
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
|
|
echo "Total coverage: ${COVERAGE}%"
|
|
THRESHOLD=80
|
|
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
|
|
echo "Coverage ${COVERAGE}% is below threshold ${THRESHOLD}%"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload coverage
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-report
|
|
path: coverage.out
|