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.
105 lines
4.2 KiB
Bash
Executable File
105 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# test-check-deps.sh exercises scripts/check-deps.sh without a module proxy or
|
|
# network access. It builds throwaway manifests in a temporary directory and
|
|
# asserts the script's exit status and diagnostics.
|
|
|
|
set -euo pipefail
|
|
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
script="$here/check-deps.sh"
|
|
tmp="$(mktemp -d)"
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
|
|
failures=0
|
|
expect_status() {
|
|
local want="$1" got
|
|
shift
|
|
set +e
|
|
"$@" >"$tmp/out" 2>&1
|
|
got=$?
|
|
set -e
|
|
if [ "$got" -ne "$want" ]; then
|
|
echo "FAIL: expected exit $want, got $got: $*" >&2
|
|
cat "$tmp/out" >&2
|
|
failures=$((failures + 1))
|
|
fi
|
|
}
|
|
|
|
# fixture sets up $tmp/repo/go.mod and prints the go.mod path.
|
|
fixture() {
|
|
mkdir -p "$tmp/repo"
|
|
cat >"$tmp/repo/go.mod" <<'EOF'
|
|
module example.com/fixture
|
|
|
|
go 1.27.1
|
|
|
|
require (
|
|
github.com/a/b v1.0.0
|
|
github.com/c/d v1.3.0
|
|
)
|
|
EOF
|
|
}
|
|
|
|
# facts writes a dependency-facts document to $tmp/facts.json.
|
|
# Arguments: <freshness_status> <item-json...>
|
|
facts() {
|
|
local freshness="$1"
|
|
shift
|
|
local items=''
|
|
local item
|
|
for item in "$@"; do
|
|
[ -z "$items" ] || items+=','
|
|
items+="$item"
|
|
done
|
|
cat >"$tmp/facts.json" <<EOF
|
|
{"schema_version":1,"observations":[{"ecosystem":"go","source":"https://proxy.golang.org","observed_at":"2026-10-28T09:00:00Z","manifest_digest":"abc123","command":["go","list","-m","-e","-json"],"items":[$items],"metadata":{"checksum_database":"sum.golang.org","freshness_status":"$freshness","graph_command":"go list -m -json all","query_scope":"module_path_latest"}}]}
|
|
EOF
|
|
}
|
|
|
|
up_to_date='{"name":"github.com/a/b","current":"v1.0.0","latest":"v1.0.0","status":"observed"},{"name":"github.com/c/d","current":"v1.3.0","latest":"v1.3.0","status":"observed"}'
|
|
|
|
# 1. Every pin matches the latest observation.
|
|
fixture
|
|
facts available "$up_to_date"
|
|
expect_status 0 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
|
grep -q 'ok: 2 go.mod requirements' "$tmp/out" || { echo 'FAIL: missing success summary' >&2; failures=$((failures + 1)); }
|
|
|
|
# 2. A stale pin is reported and fails.
|
|
fixture
|
|
facts available '{"name":"github.com/a/b","current":"v1.0.0","latest":"v1.2.0","status":"observed"},{"name":"github.com/c/d","current":"v1.3.0","latest":"v1.3.0","status":"observed"}'
|
|
expect_status 1 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
|
grep -q 'github.com/a/b v1.0.0 (latest observed: v1.2.0)' "$tmp/out" || { echo 'FAIL: stale module not named' >&2; failures=$((failures + 1)); }
|
|
|
|
# 3. A pin that is newer than the observation cannot be verified.
|
|
fixture
|
|
facts available '{"name":"github.com/a/b","current":"v1.0.0","latest":"v1.0.0","status":"observed"}'
|
|
expect_status 1 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
|
grep -q 'not covered by the dependency facts' "$tmp/out" || { echo 'FAIL: uncovered module not reported' >&2; failures=$((failures + 1)); }
|
|
|
|
# 4. Without a proxy and without facts nothing is verified.
|
|
fixture
|
|
expect_status 2 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/missing.json" GOPROXY=off "$script"
|
|
grep -q 'cannot verify dependency freshness' "$tmp/out" || { echo 'FAIL: unverified run did not explain itself' >&2; failures=$((failures + 1)); }
|
|
|
|
# 5. Incomplete dependency facts are not trusted.
|
|
fixture
|
|
facts unavailable "$up_to_date"
|
|
expect_status 2 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
|
|
|
# 6. Items that were not observed are not treated as current.
|
|
fixture
|
|
facts available '{"name":"github.com/a/b","current":"v1.0.0","latest":"v1.0.0","status":"not_found"},{"name":"github.com/c/d","current":"v1.3.0","latest":"v1.3.0","status":"observed"}'
|
|
expect_status 1 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
|
|
|
# 7. A facts document from a different source is rejected.
|
|
fixture
|
|
sed 's#https://proxy.golang.org#https://example.invalid#' "$tmp/facts.json" >"$tmp/other.json"
|
|
expect_status 2 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/other.json" GOPROXY=off "$script"
|
|
|
|
if [ "$failures" -ne 0 ]; then
|
|
echo "$failures check-deps test(s) failed" >&2
|
|
exit 1
|
|
fi
|
|
echo 'ok: check-deps.sh behaviour is covered'
|