ci / build and test (pull_request) Successful in 1m4s
The require blocks were unchanged from the base manifest even though newer releases are available for most modules. Pin every module to the newest release observed on proxy.golang.org, add the checksums published by sum.golang.org, and add the transitive modules the upgraded graph now needs (bitset, clipperhouse/displaywidth, clipperhouse/stringish, clipperhouse/uax29/v2, go.yaml.in/yaml/v3). charmbracelet/huh is a direct import and is recorded as such. Rewrite scripts/check-deps.sh so it never treats the local module cache as evidence of what the newest release is. It uses `go list -m -u` when the proxy is reachable and otherwise compares every go.mod pin with the dependency facts prepared by the execution profile, validating the report source, freshness status and query scope. If neither source is available it exits with status 2 instead of reporting success. Add scripts/test-check-deps.sh, which covers stale, uncovered and unverifiable pins without network access, and scripts/test-ci-workflow.sh, which checks that the single Gitea Actions job still runs on pull requests and invokes the checks. Both run from scripts/check.sh, so one pass verifies formatting, vet, build, tests, the CI workflow and dependency freshness. `go build ./...`, `go vet ./...`, `go test -cover ./...`, `go mod verify` and the new scripts all pass in the sandbox.
45 lines
1.3 KiB
Bash
Executable File
45 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# test-ci-workflow.sh checks the properties of .gitea/workflows/ci.yml that
|
|
# gate pull requests. It runs without Go modules so CI configuration can be
|
|
# validated even when the module proxy is unavailable; the equivalent Go test
|
|
# in internal/ci/workflow_test.go parses the same file as YAML.
|
|
|
|
set -euo pipefail
|
|
|
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
workflow="$root/.gitea/workflows/ci.yml"
|
|
|
|
if [ ! -f "$workflow" ]; then
|
|
echo "missing workflow: $workflow" >&2
|
|
exit 1
|
|
fi
|
|
|
|
failures=0
|
|
require_line() {
|
|
if ! grep -qF "$1" "$workflow"; then
|
|
echo "workflow is missing: $1" >&2
|
|
failures=$((failures + 1))
|
|
fi
|
|
}
|
|
|
|
require_line 'on:'
|
|
require_line ' pull_request:'
|
|
require_line ' push:'
|
|
require_line 'branches: [main]'
|
|
require_line 'run: ./scripts/check.sh'
|
|
require_line 'run: ./scripts/check-deps.sh'
|
|
require_line 'go-version-file: go.mod'
|
|
|
|
# The workflow must be a single action so "all checks passed" has one meaning.
|
|
jobs="$(awk '/^jobs:/{j=1;next} j && /^ [a-z0-9_-]+:$/{n++} END{print n+0}' "$workflow")"
|
|
if [ "$jobs" -ne 1 ]; then
|
|
echo "workflow must define exactly one job, found $jobs" >&2
|
|
failures=$((failures + 1))
|
|
fi
|
|
|
|
if [ "$failures" -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
echo 'ok: the pull request workflow runs the repository checks'
|