Poindexter/.github/workflows/ci.yml

95 lines
2.3 KiB
YAML

name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.22.x', '1.23.x' ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Go env
run: go env
- name: Tidy check
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum
- name: Build
run: go build ./...
- name: Vet
run: go vet ./...
- name: Test (race + coverage)
run: go test -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./... ./...
- name: Fuzz (10s)
run: |
set -e
for pkg in $(go list ./...); do
if go test -list '^Fuzz' "$pkg" | grep -q '^Fuzz'; then
echo "==> Fuzzing $pkg for 10s"
go test -run=NONE -fuzz=Fuzz -fuzztime=10s "$pkg"
else
echo "==> Skipping $pkg (no fuzz targets)"
fi
done
- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.go-version }}
path: coverage.out
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
files: coverage.out
flags: unit
fail_ci_if_error: false
- name: Build examples
run: |
if [ -d examples ]; then
go build ./examples/...
fi
- name: Benchmarks (benchmem)
run: |
go test -bench . -benchmem -run=^$ ./... | tee bench-${{ matrix.go-version }}.txt
- name: Upload benchmark artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: bench-${{ matrix.go-version }}
path: bench-${{ matrix.go-version }}.txt
- name: Vulncheck
uses: golang/govulncheck-action@v1
with:
go-version-input: ${{ matrix.go-version }}
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout=5m