CI decides merges: coverage ratchet, package/install/e2e on pull requests

- .coverage-min + scripts/coverage-check.sh: coverage of the total and the
  security-relevant packages may not fall; CI says when a minimum can be
  raised. A fixed target would block every PR today; a ratchet only goes up.
- package build, install test (Debian 12/13) and e2e (Chromium + phone)
  now run for pull requests too, so a PR can't be merged untested; only the
  upload to the dev channel stays on main. Short fuzz for PRs as for pushes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nico.stoerzbachandClaude Opus 5.5 committed 2026-11-29 23:07:41 +01:00
1 parent 06bab395dc
commit fdb3cf91a3
4 files changed
+62 -13

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# Minimum test coverage in %, checked by scripts/coverage-check.sh in CI.
# Raise a number when coverage went up (CI prints the new value); never lower it
# without a reason in the commit message.
total 75.0
internal/server 82.0
internal/auth 93.0
internal/domain/share 89.0
internal/rootfs 83.0
internal/adapters/osfs 79.0
internal/format/smbconf 77.0
internal/format/exports 97.0
internal/app/accounts 78.0
+15 -13
View File
@@ -1,6 +1,7 @@
# Quality gates for every push and pull request. Per push: the fast set
# (e2e in Chromium + phone, short fuzz). Nightly and on demand: everything
# (Firefox, WebKit, wide screen, longer fuzz).
# Quality gates for every push and pull request: a pull request can be merged
# when all jobs are green. Per push/PR: the fast set (e2e in Chromium + phone,
# short fuzz). Nightly and on demand: everything (Firefox, WebKit, wide
# screen, longer fuzz).
name: ci
on:
push:
@@ -48,21 +49,23 @@ jobs:
- name: vet
run: go vet ./...
- name: tests (race detector)
run: go test -race -cover ./...
run: go test -race -coverprofile=cover.out ./...
- name: coverage minimums (.coverage-min)
run: scripts/coverage-check.sh cover.out
- name: API description (OpenAPI 3.1) — generate and lint
run: |
mkdir -p dist
go run ./cmd/sharestead -openapi > dist/openapi.json
cd web && npm run lint:api
- name: fuzz
run: make fuzz FUZZTIME=${{ github.event_name == 'push' && '5s' || '2m' }}
run: make fuzz FUZZTIME=${{ (github.event_name == 'push' || github.event_name == 'pull_request') && '5s' || '2m' }}
- name: known vulnerabilities
run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...
package:
# dev packages for every push to main → Gitea Debian registry, channel "dev".
# .deb packages for every run (pull requests test them below); pushes to
# main also go to the Gitea Debian registry, channel "dev".
# Built on Debian 12 so the binaries run on Debian 12, 13 and Raspberry Pi OS.
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
needs: go
runs-on: ubuntu-latest
container:
@@ -89,6 +92,7 @@ jobs:
path: dist/*.deb
retention-days: 14
- name: upload to the dev channel
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
# Needs a token with "package: write" of the package owner, stored as
# repo secret PACKAGE_TOKEN (the automatic Actions token can't write packages).
env:
@@ -108,7 +112,6 @@ jobs:
install-test:
# The amd64 package must install and start on every supported Debian release.
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
needs: package
runs-on: ubuntu-latest
strategy:
@@ -137,10 +140,9 @@ jobs:
test "$(curl -sk -o /dev/null -w '%{http_code}' https://127.0.0.1:8443/api/v1/auth/session)" = 401
e2e:
# Browser tests against the real package, with a real PAM login. Per push:
# Chromium + phone; nightly/on demand: also Firefox, WebKit, wide screen.
# Screenshots are kept as artifact.
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
# Browser tests against the real package, with a real PAM login. Per push
# and pull request: Chromium + phone; nightly/on demand: also Firefox,
# WebKit, wide screen. Screenshots are kept as artifact.
needs: package
runs-on: ubuntu-latest
container:
@@ -169,7 +171,7 @@ jobs:
SST_USER: e2e-admin
run: |
npm ci --no-audit --no-fund
if [ "${{ github.event_name }}" = push ]; then
if [ "${{ github.event_name }}" = push ] || [ "${{ github.event_name }}" = pull_request ]; then
npx playwright test --project=chromium --project=mobile
else
npx playwright test
+1
View File
@@ -11,3 +11,4 @@
# built web UI (npm run build)
/internal/webui/dist/
/web/node_modules/
cover.out
+34
View File
@@ -0,0 +1,34 @@
#!/bin/sh
# Compares a Go coverage profile with the minimums in .coverage-min.
# Usage: scripts/coverage-check.sh cover.out
set -eu
profile=${1:-cover.out}
module=$(go list -m)
# statements and covered statements per package directory, plus the total
awk -v mod="$module/" 'NR > 1 {
split($1, a, ":"); f = a[1]; sub(mod, "", f); sub("/[^/]*$", "", f)
key = f SUBSEP $0
if (seen[key]++) next # a block listed twice (several test binaries) counts once
stmts[f] += $2; all += $2
if ($3 > 0) { cov[f] += $2; allcov += $2 }
} END {
for (p in stmts) printf "%s %.1f\n", p, 100 * cov[p] / stmts[p]
printf "total %.1f\n", 100 * allcov / all
}' "$profile" > /tmp/coverage-now.$$
fail=0
grep -v '^#' .coverage-min | while read -r name min; do
[ -n "$name" ] || continue
now=$(awk -v n="$name" '$1 == n { print $2 }' /tmp/coverage-now.$$)
[ -n "$now" ] || { echo "::error::coverage: $name not in the profile"; echo 1 > /tmp/coverage-fail.$$; continue; }
if awk -v a="$now" -v b="$min" 'BEGIN { exit !(a < b) }'; then
echo "::error::coverage of $name fell to $now% (minimum $min%)"
echo 1 > /tmp/coverage-fail.$$
elif awk -v a="$now" -v b="$min" 'BEGIN { exit !(a >= b + 1) }'; then
echo "coverage of $name is $now% — raise its minimum in .coverage-min (now $min%)"
else
echo "coverage of $name: $now% (minimum $min%)"
fi
done
[ -f /tmp/coverage-fail.$$ ] && fail=1
rm -f /tmp/coverage-now.$$ /tmp/coverage-fail.$$
exit $fail