Skip to content

Commit 9d552d4

Browse files
ci(api): broaden codegen drift trigger paths and detect untracked files
- Add generated-output dirs (pkg/generated, internal/crdinstall/manifests, packages/system/*/definitions) and Makefile to the workflow paths: filter so PRs that modify only generated artifacts still trigger the drift check. - Mirror the same paths in the root pre-commit hook's files: regex so manual edits to generated files or changes to the root generate target re-run make generate through pre-commit. - Switch drift detection in the workflow from `git diff --exit-code` to `git status --porcelain` so new untracked files produced by make generate (e.g. generated YAML/Go for a new API type) also fail the job; dump `git diff --color=always` on failure for easier debugging. Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 9222b6f commit 9d552d4

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎.github/workflows/codegen-drift.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ on:
66
paths:
77
- 'api/**'
88
- 'pkg/apis/**'
9+
- 'pkg/generated/**'
10+
- 'internal/crdinstall/manifests/**'
11+
- 'packages/system/cozystack-controller/definitions/**'
12+
- 'packages/system/application-definition-crd/definition/**'
13+
- 'packages/system/backup-controller/definitions/**'
14+
- 'packages/system/backupstrategy-controller/definitions/**'
915
- 'hack/update-codegen.sh'
1016
- 'hack/boilerplate.go.txt'
17+
- 'Makefile'
1118
- 'go.mod'
1219
- 'go.sum'
1320
- '.github/workflows/codegen-drift.yml'
@@ -46,8 +53,9 @@ jobs:
4653

4754
- name: Fail on drift
4855
run: |
49-
if ! git diff --exit-code; then
56+
if [ -n "$(git status --porcelain)" ]; then
5057
echo "::error::'make generate' produced changes. Run 'make generate' locally and commit the result."
5158
git status --short
59+
git diff --color=always
5260
exit 1
5361
fi

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
git diff --color=always | cat
1111
'
1212
language: system
13-
files: ^(api/|pkg/apis/|hack/update-codegen\.sh$|hack/boilerplate\.go\.txt$)
13+
files: ^(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$)
1414
pass_filenames: false
1515
- id: run-make-generate
1616
name: Run 'make generate' in all app directories

0 commit comments

Comments
 (0)