Skip to content

skip run on pull

skip run on pull #17

Workflow file for this run

name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.22', '1.23']
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Download dependencies
run: go mod download
- name: Build
run: go build ./...
- name: Run tests
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Check coverage
run: |
total=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Total coverage: ${total}%"
threshold=80
if [ "$(echo "$total < $threshold" | bc -l)" -eq 1 ]; then
echo "::error::Coverage ${total}% is below ${threshold}% threshold"
exit 1
fi
- name: Vet
run: go vet ./...
- name: Verify modules index
run: |
# Generate index.yaml from module files
echo "modules:" > /tmp/index.yaml
for f in modules/*.yaml; do
[ "$(basename "$f")" = "index.yaml" ] && continue
name=$(grep '^name:' "$f" | head -1 | sed 's/^name: *//')
version=$(grep '^version:' "$f" | head -1 | sed 's/^version: *//')
echo " - name: $name" >> /tmp/index.yaml
echo " version: $version" >> /tmp/index.yaml
done
if ! diff -u modules/index.yaml /tmp/index.yaml; then
echo "::error::modules/index.yaml is out of date. Run 'make index' to regenerate."
exit 1
fi