80 lines
2.1 KiB
YAML
80 lines
2.1 KiB
YAML
name: Test
|
|||
|
|
|
||
|
|
on:
|
||
|
|
push:
|
||
|
|
branches: [development]
|
||
|
|
pull_request:
|
||
|
|
branches: [development]
|
||
|
|
|
||
|
|
jobs:
|
||
|
|
vet:
|
||
|
|
runs-on: codeberg-small
|
||
|
|
steps:
|
||
|
|
- uses: https://data.forgejo.org/actions/checkout@v4
|
||
|
|
|
||
|
|
- uses: https://data.forgejo.org/actions/setup-go@v5
|
||
|
|
with:
|
||
|
|
go-version: "1.26"
|
||
|
|
|
||
|
|
- name: Download dependencies
|
||
|
|
run: go mod download
|
||
|
|
|
||
|
|
- name: gofmt
|
||
|
|
# `gofmt -l` prints the names of unformatted files. An empty
|
||
|
|
# output is the only acceptable result.
|
||
|
|
run: gofmt -l cmd internal pkg
|
||
|
|
|
||
|
|
- name: go vet
|
||
|
|
run: go vet ./...
|
||
|
|
|
||
|
|
test:
|
||
|
|
runs-on: codeberg-small
|
||
|
|
needs: vet
|
||
|
|
steps:
|
||
|
|
- uses: https://data.forgejo.org/actions/checkout@v4
|
||
|
|
|
||
|
|
- uses: https://data.forgejo.org/actions/setup-go@v5
|
||
|
|
with:
|
||
|
|
go-version: "1.26"
|
||
|
|
|
||
|
|
- name: Download dependencies
|
||
|
|
run: go mod download
|
||
|
|
|
||
|
|
- name: go test -race
|
||
|
|
run: go test -race -count=1 ./...
|
||
|
|
|
||
|
|
- name: Coverage gate
|
||
|
|
run: |
|
||
|
|
go test -coverprofile=coverage.out ./...
|
||
|
|
coverage=$(go tool cover -func=coverage.out | awk '/^total:/ { gsub("%",""); print $3 }')
|
||
|
|
echo "Total coverage: ${coverage}%"
|
||
|
|
awk -v c="$coverage" 'BEGIN { exit !(c+0 < 40) }' \
|
||
|
|
&& { echo "Coverage ${coverage}% is below 40% threshold"; exit 1; } \
|
||
|
|
|| echo "Coverage ${coverage}% OK (threshold: 40%)"
|
||
|
|
|
||
|
|
fuzz:
|
||
|
|
runs-on: codeberg-small
|
||
|
|
needs: vet
|
||
|
|
steps:
|
||
|
|
- uses: https://data.forgejo.org/actions/checkout@v4
|
||
|
|
|
||
|
|
- uses: https://data.forgejo.org/actions/setup-go@v5
|
||
|
|
with:
|
||
|
|
go-version: "1.26"
|
||
|
|
|
||
|
|
- name: Download dependencies
|
||
|
|
run: go mod download
|
||
|
|
|
||
|
|
- name: go test -fuzz
|
||
|
|
run: |
|
||
|
|
for pkg in $(go list ./...); do
|
||
|
|
fuzz_funcs=$(go test -list='Fuzz.*' "$pkg" 2>/dev/null | grep '^Fuzz' || true)
|
||
|
|
if [ -n "$fuzz_funcs" ]; then
|
||
|
|
echo "==> Fuzzing $pkg"
|
||
|
|
for fn in $fuzz_funcs; do
|
||
|
|
echo " $fn …"
|
||
|
|
go test -parallel=2 -timeout=5m -fuzz="^${fn}$" -fuzztime=8s "$pkg"
|
||
|
|
done
|
||
|
|
fi
|
||
|
|
done
|