Skip to content

Commit d573f82

Browse files
committed
Switch to invoking codegen once in general updates
1 parent 5050707 commit d573f82

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

Makefile

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
all: build
22
.PHONY: all
33

4-
update: update-codegen-crds
4+
update: update-non-codegen update-codegen
55

66
RUNTIME ?= podman
77
RUNTIME_IMAGE_NAME ?= registry.ci.openshift.org/openshift/release:rhel-9-release-golang-1.24-openshift-4.20
@@ -57,23 +57,28 @@ verify-lint-fix:
5757
make lint-fix 2>/dev/null || true
5858
git diff --exit-code
5959

60-
.PHONY: verify-scripts
61-
verify-scripts:
62-
bash -x hack/verify-deepcopy.sh
63-
bash -x hack/verify-openapi.sh
60+
# Verify codegen runs all verifiers in the order they are defined in the root.go file.
61+
# This includes all generators defined in update-codegen, but also the crd-schema-checker and crdify verifiers.
62+
.PHONY: verify-codegen
63+
verify-codegen:
64+
EXTRA_ARGS=--verify hack/update-codegen.sh
65+
66+
.PHONY: verify-non-codegen
67+
verify-non-codegen:
6468
bash -x hack/verify-protobuf.sh
65-
bash -x hack/verify-swagger-docs.sh
6669
hack/verify-crds.sh
6770
bash -x hack/verify-types.sh
68-
bash -x hack/verify-compatibility.sh
6971
bash -x hack/verify-integration-tests.sh
7072
bash -x hack/verify-group-versions.sh
7173
bash -x hack/verify-prerelease-lifecycle-gen.sh
7274
hack/verify-payload-crds.sh
7375
hack/verify-payload-featuregates.sh
7476

77+
.PHONY: verify-scripts
78+
verify-scripts: verify-non-codegen verify-codegen
79+
7580
.PHONY: verify
76-
verify: verify-scripts lint verify-crd-schema verify-crdify verify-codegen-crds
81+
verify: verify-scripts lint
7782

7883
.PHONY: verify-codegen-crds
7984
verify-codegen-crds:
@@ -108,6 +113,19 @@ verify-%:
108113
.PHONY: update-scripts
109114
update-scripts: update-compatibility update-openapi update-deepcopy update-protobuf update-swagger-docs tests-vendor update-prerelease-lifecycle-gen update-payload-featuregates
110115

116+
# Update codegen runs all generators in the order they are defined in the root.go file.
117+
# The per group generators are:[compatibility, deepcopy, swagger-docs, empty-partial-schema, schema-patch, crd-manifest-merge]
118+
# The multi group generators are:[openapi]
119+
.PHONY: update-codegen
120+
update-codegen:
121+
hack/update-codegen.sh
122+
123+
# Update non-codegen runs all generators that are not part of the codegen utility, or
124+
# are part of it, but are not run by default when invoking codegen without a specific generator.
125+
# E.g. the payload feature gates which is not part of the generator style, but is still a subcommand.
126+
.PHONY: update-non-codegen
127+
update-non-codegen: update-protobuf tests-vendor update-prerelease-lifecycle-gen update-payload-crds update-payload-featuregates
128+
111129
.PHONY: update-compatibility
112130
update-compatibility:
113131
hack/update-compatibility.sh

tools/codegen/cmd/crdify.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ func newCrdifyCommand() *cobra.Command {
2323
return fmt.Errorf("could not build generation context: %w", err)
2424
}
2525

26-
gen := crdify.NewGenerator(crdify.WithComparisonBase(crdifyComparisonBase))
27-
28-
return executeGenerators(genCtx, gen)
26+
return executeGenerators(genCtx, newCrdifyGenerator())
2927
},
3028
}
3129

@@ -36,3 +34,7 @@ func init() {
3634
rootCmd.AddCommand(newCrdifyCommand())
3735
rootCmd.PersistentFlags().StringVar(&crdifyComparisonBase, "crdify:comparison-base", crdifyComparisonBase, "base branch/commit to compare against")
3836
}
37+
38+
func newCrdifyGenerator() generation.Generator {
39+
return crdify.NewGenerator(crdify.WithComparisonBase(crdifyComparisonBase))
40+
}

tools/codegen/cmd/root.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,23 @@ func allGenerators() []generation.Generator {
136136
newCompatibilityGenerator(),
137137
newDeepcopyGenerator(),
138138
newSwaggerDocsGenerator(),
139+
// The empty partial schema, schema patch and manifest merge must run in order.
140+
newEmptyPartialSchemaGenerator(),
139141
newSchemaPatchGenerator(),
142+
newCRDManifestMerger(),
140143
}
141144
}
142145

143146
// allVerifiers returns an ordered list of verifiers to run when
144147
// the root command is executed with the --verify flag.
145148
func allVerifiers() []generation.Generator {
146149
return []generation.Generator{
147-
newSchemaCheckGenerator(),
150+
// Schema checker and crdify are invoked separately as we can override these
151+
// depending on circumstances.
152+
// All generators/verifiers that are part of codegen and executed with a bare
153+
// codegen invocation must be absolutely required/not overrideable.
154+
// newSchemaCheckGenerator(),
155+
// newCrdifyGenerator(),
148156
}
149157
}
150158

0 commit comments

Comments
 (0)