Files

40 lines
1.2 KiB
YAML

name: pr-test-build
on:
pull_request:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Refresh models catalog
run: curl -fsSL https://raw.githubusercontent.com/router-for-me/models/refs/heads/main/models.json -o internal/registry/models/models.json
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build
run: |
go build -o test-output ./cmd/server
rm -f test-output
- name: Vet
run: go vet ./...
- name: Test with coverage
run: |
go test -coverprofile=coverage.out -covermode=atomic ./... 2>&1 | tee test-output.txt
# Extract total coverage percentage
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%')
echo "Total coverage: ${COVERAGE}%"
# Fail if coverage drops below 30%
THRESHOLD=30
if [ "$(echo "$COVERAGE < $THRESHOLD" | bc -l)" -eq 1 ]; then
echo "ERROR: Coverage ${COVERAGE}% is below threshold ${THRESHOLD}%"
exit 1
fi