Skip to content

Commit 342bb26

Browse files
committed
UPSTREAM: <carry>: add OTE into olmv0
1 parent ea4641b commit 342bb26

File tree

1,206 files changed

+568232
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,206 files changed

+568232
-5
lines changed

.bingo/Variables.mk

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,28 @@ GO ?= $(shell which go)
77

88
# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
99
# will be used; reinstalling only if needed.
10-
# For example for helm variable:
10+
# For example for go-bindata variable:
1111
#
1212
# In your main Makefile (for non array binaries):
1313
#
1414
#include .bingo/Variables.mk # Assuming -dir was set to .bingo .
1515
#
16-
#command: $(HELM)
17-
# @echo "Running helm"
18-
# @$(HELM) <flags/args..>
16+
#command: $(GO_BINDATA)
17+
# @echo "Running go-bindata"
18+
# @$(GO_BINDATA) <flags/args..>
1919
#
20+
GO_BINDATA := $(GOBIN)/go-bindata-v3.1.2+incompatible
21+
$(GO_BINDATA): $(BINGO_DIR)/go-bindata.mod
22+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
23+
@echo "(re)installing $(GOBIN)/go-bindata-v3.1.2+incompatible"
24+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=go-bindata.mod -o=$(GOBIN)/go-bindata-v3.1.2+incompatible "github.com/go-bindata/go-bindata/go-bindata"
25+
26+
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.1.6
27+
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
28+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
29+
@echo "(re)installing $(GOBIN)/golangci-lint-v2.1.6"
30+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v2.1.6 "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"
31+
2032
HELM := $(GOBIN)/helm-v3.15.2
2133
$(HELM): $(BINGO_DIR)/helm.mod
2234
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.

.bingo/go-bindata.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.24.4
4+
5+
require github.com/go-bindata/go-bindata v3.1.2+incompatible // go-bindata

.bingo/go-bindata.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE=
2+
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=

.bingo/golangci-lint.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.24.4
4+
5+
require github.com/golangci/golangci-lint/v2 v2.1.6

.bingo/golangci-lint.sum

Lines changed: 418 additions & 0 deletions
Large diffs are not rendered by default.

.bingo/variables.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@ if [ -z "$GOBIN" ]; then
88
fi
99

1010

11+
GO_BINDATA="${GOBIN}/go-bindata-v3.1.2+incompatible"
12+
13+
GOLANGCI_LINT="${GOBIN}/golangci-lint-v2.1.6"
14+
1115
HELM="${GOBIN}/helm-v3.15.2"
1216

operator-lifecycle-manager.Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ COPY .git/refs/heads/. .git/refs/heads
1616
RUN mkdir -p .git/objects
1717

1818
COPY . .
19-
RUN make build/olm bin/cpb
19+
RUN make build/olm bin/cpb && \
20+
# Build the OLMv0 Test Extension binary.
21+
# This is used by openshift/origin to allow us to register the OLMv0 test extension
22+
# The binary needs to be added in the component image and OCP image
23+
cd staging/tests-extension && \
24+
make build && \
25+
mkdir -p /tmp/build && \
26+
cp ./bin/olmv0-tests-ext /tmp/build/olmv0-tests-ext && \
27+
gzip -f /tmp/build/olmv0-tests-ext
2028

2129
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
2230

@@ -31,6 +39,7 @@ COPY --from=builder /build/bin/package-server /bin/package-server
3139
COPY --from=builder /build/bin/cpb /bin/cpb
3240
COPY --from=builder /build/bin/psm /bin/psm
3341
COPY --from=builder /build/bin/copy-content /bin/copy-content
42+
COPY --from=builder /tmp/build/olmv0-tests-ext.gz /usr/bin/olmv0-tests-ext.gz
3443

3544
# This image doesn't need to run as root user.
3645
USER 1001

staging/tests-extension/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"name": "[sig-operator][Jira:OLM] OLMv0 should pass a trivial sanity check",
4+
"labels": {},
5+
"resources": {
6+
"isolation": {}
7+
},
8+
"source": "openshift:payload:olmv0",
9+
"lifecycle": "blocking",
10+
"environmentSelector": {}
11+
}
12+
]

staging/tests-extension/Makefile

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Get the directory where this Makefile is, so we can use it below for including
2+
# Include the same Bingo variables used by the project
3+
DIR := $(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
4+
# Use openshift's Bingo variables
5+
include $(DIR)/../../.bingo/Variables.mk
6+
7+
# Definitions for the extended tests
8+
9+
GO_PKG_NAME := github.com/openshift-eng/openshift-tests-extension
10+
11+
GIT_COMMIT := $(shell git rev-parse --short HEAD)
12+
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
13+
GIT_TREE_STATE := $(shell if git diff --quiet; then echo clean; else echo dirty; fi)
14+
15+
LDFLAGS := -X '$(GO_PKG_NAME)/pkg/version.CommitFromGit=$(GIT_COMMIT)' \
16+
-X '$(GO_PKG_NAME)/pkg/version.BuildDate=$(BUILD_DATE)' \
17+
-X '$(GO_PKG_NAME)/pkg/version.GitTreeState=$(GIT_TREE_STATE)'
18+
19+
20+
METADATA := $(shell pwd)/.openshift-tests-extension/openshift_payload_olmv0.json
21+
22+
#SECTION General
23+
24+
# The help target prints out all targets with their descriptions organized
25+
# beneath their categories. The categories are represented by '#SECTION' and the
26+
# target descriptions by '#HELP' or '#EXHELP'. The awk commands is responsible for reading the
27+
# entire set of makefiles included in this invocation, looking for lines of the
28+
# file as xyz: #HELP something, and then pretty-format the target and help. Then,
29+
# if there's a line with #SECTION something, that gets pretty-printed as a category.
30+
# More info on the usage of ANSI control characters for terminal formatting:
31+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
32+
# More info on the awk command:
33+
# http://linuxcommand.org/lc3_adv_awk.php
34+
# The extended-help target uses '#EXHELP' as the delineator.
35+
36+
.PHONY: help
37+
help: #HELP Display essential help.
38+
@awk 'BEGIN {FS = ":[^#]*#HELP"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z_0-9-]+:.*#HELP / { printf " \033[36m%-17s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST)
39+
40+
#SECTION Tests
41+
TOOLS_BIN_DIR := $(CURDIR)/bin
42+
43+
#SECTION Development
44+
.PHONY: verify #HELP To verify the code
45+
verify: tidy fmt vet lint
46+
47+
.PHONY: tidy #HELP Run go mod tidy.
48+
tidy:
49+
go mod tidy
50+
51+
.PHONY: fmt
52+
fmt: #HELP Run go fmt against code.
53+
go fmt ./...
54+
55+
.PHONY: vet
56+
vet: #HELP Run go vet against code.
57+
go vet ./...
58+
59+
.PHONY: lint
60+
lint: $(GOLANGCI_LINT) #HELP Run golangci linter.
61+
$(GOLANGCI_LINT) run
62+
63+
.PHONY: fix-lint
64+
fix-lint: $(GOLANGCI_LINT) #HELP Fix lint issues
65+
$(GOLANGCI_LINT) run --fix
66+
67+
# Bindata generation
68+
.PHONY: bindata
69+
bindata: $(GO_BINDATA)
70+
71+
bindata: test/extended/testdata/bindata.go
72+
test/extended/testdata/bindata.go: $(shell find test/extended/testdata -type f ! -name 'bindata.go')
73+
mkdir -p $(@D)
74+
$(GO_BINDATA) -nocompress -nometadata \
75+
-pkg testdata -o $@ -prefix "testextended" \
76+
-ignore "test/extended/testdata/bindata.go" test/extended/testdata/...
77+
gofmt -s -w $@
78+
79+
# GO_COMPLIANCE_POLICY="exempt_all" must only be used for test related binaries.
80+
# It prevents various FIPS compliance policies from being applied to this compilation.
81+
# Do not set globally.
82+
.PHONY: build
83+
build: #HELP Build the extended tests binary
84+
@mkdir -p $(TOOLS_BIN_DIR)
85+
GO_COMPLIANCE_POLICY="exempt_all" go build -ldflags "$(LDFLAGS)" -mod=vendor -o $(TOOLS_BIN_DIR)/olmv0-tests-ext ./cmd/...
86+
87+
.PHONY: update-metadata
88+
update-metadata: #HELP Build and run 'update-metadata' to generate test metadata
89+
$(TOOLS_BIN_DIR)/olmv0-tests-ext update --component openshift:payload:olmv0
90+
$(MAKE) clean-metadata
91+
92+
93+
# Ensure TestID is unique over time.
94+
# TestID is built over Product:Type:ComponentName:TestDescription
95+
# (i.e. openshift:payload:olmv0:TestName)
96+
# Details:
97+
# - https://github.com/openshift/enhancements/blob/master/enhancements/testing/openshift-tests-extension.md#test-id
98+
# - https://github.com/openshift-eng/ci-test-mapping
99+
#──────────────────────────────────────────────────────────────
100+
# How to rename a test?
101+
# 1. Run: make list-test-names
102+
# 2. Find the current full test name (e.g. "[sig-abc] My test does XYZ")
103+
# 3. Add a Ginkgo label: ginkgo.Label("original-name:[sig-abc] My test does XYZ")
104+
# 4. Change the test name string and run: make build-update
105+
# **Example**
106+
# It("should pass a renamed sanity check",
107+
# Label("original-name:[sig-operator] OLMv0 should pass a trivial sanity check"),
108+
# func(ctx context.Context) {
109+
# Expect(len("test")).To(BeNumerically(">", 0))
110+
# })
111+
# Note: You only add the label once. Do not update it after future renames.
112+
#──────────────────────────────────────────────────────────────
113+
# How to delete a test?
114+
# 1. Run: make list-test-names
115+
# 2. In main.go add:
116+
# ext.IgnoreObsoleteTests(
117+
# "[sig-operator] My removed test name",
118+
# )
119+
# 3. Delete the test code in your suite file (e.g. olmv0.go)
120+
# 4. Run: make build-update.
121+
# This will regenerate the metadata without the test entry.
122+
#────────────────────────────────────────────────────────────────────
123+
.PHONY: build-update
124+
build-update: bindata build update-metadata #HELP Build and update metadata and sanitize output
125+
126+
#SECTION Metadata
127+
128+
.PHONY: list-test-names
129+
list-test-names: #HELP Show current full test names
130+
@$(TOOLS_BIN_DIR)/olmv0-tests-ext list -o names
131+
132+
# Remove 'codeLocations' to avoid absolute paths like:
133+
# "/Users/$(USER)/go/src/.../olmv0.go:12"
134+
# These are machine-specific and make the metadata non-idempotent.
135+
# More info: https://issues.redhat.com/browse/TRT-2186
136+
.PHONY: clean-metadata
137+
clean-metadata: #HELP Remove 'codeLocations' from metadata JSON
138+
@echo "Cleaning metadata (removing codeLocations)..."
139+
@jq 'map(del(.codeLocations))' $(METADATA) > $(METADATA).tmp && mv $(METADATA).tmp $(METADATA)
140+
141+
.PHONY: verify-metadata #HELP To verify that the metadata was properly update
142+
verify-metadata: update-metadata
143+
@if ! git diff --exit-code $(METADATA); then \
144+
echo "ERROR: Metadata is out of date. Please run 'make build-update' and commit the result."; \
145+
exit 1; \
146+
fi

0 commit comments

Comments
 (0)