@@ -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,74 @@ 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
+ # OpenShift Extended TestID Policy: Stability & Traceability
81
+ # ────────────────────────────────────────────────────────────────────
82
+ # A TestID is a unique and stable identity for a test.
83
+ # It is made up of: Component (Product:Type:ComponentName:TestDescription)
84
+ # Reference: https://github.com/openshift/enhancements/blob/master/enhancements/testing/openshift-tests-extension.md#test-id
85
+ #
86
+ # What Happens If You Rename or Delete Tests Without Tracking:
87
+ # - Component readiness will show unknown or missing tests
88
+ # - ci-test-mapping will not match old and new test names
89
+ # - TRT must manually fix test records
90
+ # More info: https://github.com/openshift-eng/ci-test-mapping/blob/main/README.md#renaming-tests
91
+ #
92
+ # ──────────────────────────────────────────────────────────────
93
+ # If You Need to Rename a Test:
94
+ # ──────────────────────────────────────────────────────────────
95
+ # 1. Run: make list-test-names
96
+ # 2. Find the current full test name (e.g. "[sig-abc] My test does XYZ")
97
+ # 3. Add a Ginkgo label: ginkgo.Label("original-name:[sig-abc] My test does XYZ")
98
+ # 4. Change the test name string and run: make build-update
99
+ # **Example**
100
+ # It("should pass a renamed sanity check",
101
+ # Label("original-name:[sig-olmv1] OLMv1 should pass a trivial sanity check"),
102
+ # func(ctx context.Context) {
103
+ # Expect(len("test")).To(BeNumerically(">", 0))
104
+ # })
105
+ # Note: You only add the label once. Do not update it after future renames.
106
+ #
107
+ # ──────────────────────────────────────────────────────────────
108
+ # If You Want to Delete a Test:
109
+ # ──────────────────────────────────────────────────────────────
110
+ # 1. Run: make list-test-names
111
+ # 2. In main.go add:
112
+ # ext.IgnoreObsoleteTests(
113
+ # "[sig-olmv1] My removed test name",
114
+ # )
115
+ # 3. Delete the test code in your suite file (e.g. olmv1.go)
116
+ # 4. Run: make build-update
117
+ # This will regenerate the metadata without the test entry.
118
+ # ────────────────────────────────────────────────────────────────────
119
+ .PHONY : build-update
120
+ build-update : build update-metadata # HELP Build and update metadata and sanitize output
121
+
122
+ # SECTION Metadata
123
+
124
+ .PHONY : list-test-names
125
+ list-test-names : # HELP Show current full test names (use to capture for original-name label)
126
+ @$(TOOLS_BIN_DIR ) /olmv1-tests-ext list -o names
127
+
128
+ # Remove 'codeLocations' to avoid absolute paths like:
129
+ # "/Users/$(USER)/go/src/.../olmv1.go:12"
130
+ # These are machine-specific and make the metadata non-idempotent.
131
+ # This prevents proper diffs, validation, and committing metadata across environments.
132
+ # More info: https://issues.redhat.com/browse/TRT-2186
133
+ .PHONY : clean-metadata
134
+ clean-metadata : # HELP Remove 'codeLocations' from metadata JSON
135
+ @echo " Cleaning metadata (removing codeLocations)..."
136
+ @jq ' map(del(.codeLocations))' $(METADATA ) > $(METADATA ) .tmp && mv $(METADATA ) .tmp $(METADATA )
137
+
138
+ .PHONY : verify-metadata # HELP To verify that the metadata was properly update
139
+ verify-metadata : update-metadata
140
+ @if ! git diff --exit-code $(METADATA ) ; then \
141
+ echo " ERROR: Metadata is out of date. Please run 'make build-update' and commit the result." ; \
142
+ exit 1; \
143
+ fi
0 commit comments