@@ -15,6 +15,9 @@ LDFLAGS := -X '$(GO_PKG_NAME)/pkg/version.CommitFromGit=$(GIT_COMMIT)' \
15
15
-X '$(GO_PKG_NAME ) /pkg/version.BuildDate=$(BUILD_DATE ) ' \
16
16
-X '$(GO_PKG_NAME ) /pkg/version.GitTreeState=$(GIT_TREE_STATE ) '
17
17
18
+
19
+ METADATA := $(shell pwd) /.openshift-tests-extension/openshift_payload_olmv1.json
20
+
18
21
# SECTION General
19
22
20
23
# The help target prints out all targets with their descriptions organized
@@ -67,3 +70,64 @@ fix-lint: $(GOLANGCI_LINT) #HELP Fix lint issues
67
70
build : # HELP Build the extended tests binary
68
71
@mkdir -p $(TOOLS_BIN_DIR )
69
72
GO_COMPLIANCE_POLICY=" exempt_all" go build -ldflags " $( LDFLAGS) " -mod=vendor -o $(TOOLS_BIN_DIR ) /olmv1-tests-ext ./cmd/...
73
+
74
+ .PHONY : update-metadata
75
+ update-metadata : # HELP Build and run 'update-metadata' to generate test metadata
76
+ $(TOOLS_BIN_DIR ) /olmv1-tests-ext update --component openshift:payload:olmv1
77
+ $(MAKE ) clean-metadata
78
+
79
+
80
+ # A TestID is a unique and stable identity for a test.
81
+ # It is made up of: Component (Product:Type:ComponentName:TestDescription)
82
+ # It is required to ensure unique TestID over time.
83
+ # More info:
84
+ # - https://github.com/openshift/enhancements/blob/master/enhancements/testing/openshift-tests-extension.md#test-id
85
+ # - https://github.com/openshift-eng/ci-test-mapping
86
+ # ──────────────────────────────────────────────────────────────
87
+ # How to rename a test?
88
+ # 1. Run: make list-test-names
89
+ # 2. Find the current full test name (e.g. "[sig-abc] My test does XYZ")
90
+ # 3. Add a Ginkgo label: ginkgo.Label("original-name:[sig-abc] My test does XYZ")
91
+ # 4. Change the test name string and run: make build-update
92
+ # **Example**
93
+ # It("should pass a renamed sanity check",
94
+ # Label("original-name:[sig-olmv1] OLMv1 should pass a trivial sanity check"),
95
+ # func(ctx context.Context) {
96
+ # Expect(len("test")).To(BeNumerically(">", 0))
97
+ # })
98
+ # Note: You only add the label once. Do not update it after future renames.
99
+ # ──────────────────────────────────────────────────────────────
100
+ # How to delete a test?
101
+ # 1. Run: make list-test-names
102
+ # 2. In main.go add:
103
+ # ext.IgnoreObsoleteTests(
104
+ # "[sig-olmv1] My removed test name",
105
+ # )
106
+ # 3. Delete the test code in your suite file (e.g. olmv1.go)
107
+ # 4. Run: make build-update.
108
+ # This will regenerate the metadata without the test entry.
109
+ # ────────────────────────────────────────────────────────────────────
110
+ .PHONY : build-update
111
+ build-update : build update-metadata # HELP Build and update metadata and sanitize output
112
+
113
+ # SECTION Metadata
114
+
115
+ .PHONY : list-test-names
116
+ list-test-names : # HELP Show current full test names (use to capture for original-name label)
117
+ @$(TOOLS_BIN_DIR ) /olmv1-tests-ext list -o names
118
+
119
+ # Remove 'codeLocations' to avoid absolute paths like:
120
+ # "/Users/$(USER)/go/src/.../olmv1.go:12"
121
+ # These are machine-specific and make the metadata non-idempotent.
122
+ # More info: https://issues.redhat.com/browse/TRT-2186
123
+ .PHONY : clean-metadata
124
+ clean-metadata : # HELP Remove 'codeLocations' from metadata JSON
125
+ @echo " Cleaning metadata (removing codeLocations)..."
126
+ @jq ' map(del(.codeLocations))' $(METADATA ) > $(METADATA ) .tmp && mv $(METADATA ) .tmp $(METADATA )
127
+
128
+ .PHONY : verify-metadata # HELP To verify that the metadata was properly update
129
+ verify-metadata : update-metadata
130
+ @if ! git diff --exit-code $(METADATA ) ; then \
131
+ echo " ERROR: Metadata is out of date. Please run 'make build-update' and commit the result." ; \
132
+ exit 1; \
133
+ fi
0 commit comments