Make dependency checks offline-safe and guard the CI workflow with tests
scripts/check-deps.sh previously ran `go list -m all`, which fails with "module lookup disabled by GOPROXY=off" whenever the module cache does not hold the full module graph, even though the build only needs part of it. Read the pins with `go mod edit -json` instead: the online branch asks the module proxy about only the pinned modules, and the offline branch compares those pins with the newest versions in the module cache. Neither path loads the whole graph, and an empty cache is reported instead of failing. Run the dependency check from the single check job that already gates pull requests, so one action covers both the code/tests and dependency freshness. Add internal/ci tests that parse .gitea/workflows/ci.yml, fail if the workflow stops running on pull requests or stops invoking the check scripts, and fail if those scripts are not executable. Document the two-step job and the new mise tasks.
This commit is contained in:
1 parent
22e4c96192
commit
050936c6fd
5 files changed
+225
-47
No files matched your search
+16
-12
@@ -21,26 +21,30 @@ It works with any project type and supports monorepos.
|
||||
## Continuous Integration
|
||||
|
||||
Every pull request and every push to `main` runs the `ci` workflow in
|
||||
[`.gitea/workflows/ci.yml`](../.gitea/workflows/ci.yml). Its single `check` job
|
||||
runs [`scripts/check.sh`](../scripts/check.sh), which:
|
||||
[`.gitea/workflows/ci.yml`](../.gitea/workflows/ci.yml). It has a single `check`
|
||||
job with two steps:
|
||||
|
||||
1. fails if any Go file is not `gofmt`-formatted,
|
||||
2. runs `go mod verify` to confirm the dependency modules match `go.sum`,
|
||||
3. runs `go vet ./...` and `go build ./...`,
|
||||
4. runs `go test -cover ./...`.
|
||||
1. [`scripts/check.sh`](../scripts/check.sh) fails if any Go file is not
|
||||
`gofmt`-formatted, then runs `go mod verify`, `go vet ./...`,
|
||||
`go build ./...`, and `go test -cover ./...`.
|
||||
2. [`scripts/check-deps.sh`](../scripts/check-deps.sh) fails when a module
|
||||
pinned in `go.mod` has a newer release. It asks the module proxy for the
|
||||
newest release and falls back to the newest versions in the local module
|
||||
cache when the proxy is disabled.
|
||||
|
||||
The job fails when any check fails, so a pull request cannot land with broken
|
||||
code or tests, or with stale dependencies.
|
||||
|
||||
Run the same checks locally with:
|
||||
|
||||
```sh
|
||||
./scripts/check.sh
|
||||
./scripts/check-deps.sh # or: mise run deps
|
||||
```
|
||||
|
||||
The job fails when any check fails, so a pull request cannot land with broken
|
||||
code or tests.
|
||||
|
||||
Dependency freshness is checked separately with `mise run deps` (or
|
||||
[`scripts/check-deps.sh`](../scripts/check-deps.sh)), which fails when a module
|
||||
pinned in `go.mod` has a newer release available.
|
||||
[`internal/ci/workflow_test.go`](../internal/ci/workflow_test.go) parses the
|
||||
workflow and fails `go test ./...` if it stops running on pull requests or
|
||||
stops invoking those scripts.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user