mirror of
https://github.com/cozystack/cozystack.git
synced 2026-10-25 04:27:04 +09:00
The unit and controller test job has no module cache and runs on an ephemeral runner, so every run fetches every module from proxy.golang.org, and one transient stream reset fails the job. It now restores the module cache keyed on every go.sum in the tree and prefetches the modules of every tracked go.mod through a bounded retry, hack/go-mod-download.sh. The cache is written from main by the build cache warmer under the same key, because a cache saved by a PR run is visible to that PR only, while one saved on the default branch is readable from every PR. Every job that runs Go on the runner sets GOPROXY=https://proxy.golang.org|direct so any proxy error falls back to the origin. The release jobs get only that, not a cache. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
72 lines
2.3 KiB
YAML
72 lines
2.3 KiB
YAML
name: Codegen Drift Check
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
paths:
|
|
- 'api/**'
|
|
- 'pkg/apis/**'
|
|
- 'pkg/generated/**'
|
|
- 'internal/crdinstall/manifests/**'
|
|
- 'packages/system/cozystack-controller/definitions/**'
|
|
- 'packages/system/application-definition-crd/definition/**'
|
|
- 'packages/system/backup-controller/definitions/**'
|
|
- 'packages/system/backupstrategy-controller/definitions/**'
|
|
- 'hack/update-codegen.sh'
|
|
- 'hack/boilerplate.go.txt'
|
|
- 'Makefile'
|
|
- 'go.mod'
|
|
- 'go.sum'
|
|
- '.github/workflows/codegen-drift.yml'
|
|
|
|
concurrency:
|
|
group: codegen-drift-${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
# Top-level token defaults to read-only. A job-level block replaces this one
|
|
# rather than adding to it, so each job restates every scope it needs.
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
codegen-drift:
|
|
name: Verify generated code is up to date
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
# The pipe falls back to direct on any proxy error (hack/common-envs.mk).
|
|
GOPROXY: "https://proxy.golang.org|direct"
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Pre-fetch k8s.io/code-generator module
|
|
# hack/update-codegen.sh sources kube_codegen.sh from the Go module cache.
|
|
# The module is not declared in go.mod, so fetch it explicitly at the
|
|
# version pinned in the script.
|
|
run: |
|
|
version=$(grep -oP 'code-generator@\Kv[0-9.]+' hack/update-codegen.sh)
|
|
tmpdir=$(mktemp -d)
|
|
cd "$tmpdir"
|
|
go mod init codegen-fetch
|
|
go get "k8s.io/code-generator@${version}"
|
|
|
|
- name: Run make generate
|
|
run: make generate
|
|
|
|
- name: Fail on drift
|
|
run: |
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
echo "::error::'make generate' produced changes. Run 'make generate' locally and commit the result."
|
|
git status --short
|
|
git diff --color=always
|
|
exit 1
|
|
fi
|