Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 16 additions & 4 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@ GO ?= $(shell which go)

# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
# will be used; reinstalling only if needed.
# For example for helm variable:
# For example for go-bindata variable:
#
# In your main Makefile (for non array binaries):
#
#include .bingo/Variables.mk # Assuming -dir was set to .bingo .
#
#command: $(HELM)
# @echo "Running helm"
# @$(HELM) <flags/args..>
#command: $(GO_BINDATA)
# @echo "Running go-bindata"
# @$(GO_BINDATA) <flags/args..>
#
GO_BINDATA := $(GOBIN)/go-bindata-v3.1.2+incompatible
$(GO_BINDATA): $(BINGO_DIR)/go-bindata.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/go-bindata-v3.1.2+incompatible"
@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"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.1.6
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golangci-lint-v2.1.6"
@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"

HELM := $(GOBIN)/helm-v3.15.2
$(HELM): $(BINGO_DIR)/helm.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
Expand Down
5 changes: 5 additions & 0 deletions .bingo/go-bindata.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.24.4

require github.com/go-bindata/go-bindata v3.1.2+incompatible // go-bindata
2 changes: 2 additions & 0 deletions .bingo/go-bindata.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE=
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
5 changes: 5 additions & 0 deletions .bingo/golangci-lint.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.24.4

require github.com/golangci/golangci-lint/v2 v2.1.6
418 changes: 418 additions & 0 deletions .bingo/golangci-lint.sum

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ if [ -z "$GOBIN" ]; then
fi


GO_BINDATA="${GOBIN}/go-bindata-v3.1.2+incompatible"

GOLANGCI_LINT="${GOBIN}/golangci-lint-v2.1.6"

HELM="${GOBIN}/helm-v3.15.2"

11 changes: 10 additions & 1 deletion operator-lifecycle-manager.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ COPY .git/refs/heads/. .git/refs/heads
RUN mkdir -p .git/objects

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

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

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

# This image doesn't need to run as root user.
USER 1001
Expand Down
1 change: 1 addition & 0 deletions staging/tests-extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"name": "[sig-operator][Jira:OLM] OLMv0 should pass a trivial sanity check",
"labels": {},
"resources": {
"isolation": {}
},
"source": "openshift:payload:olmv0",
"lifecycle": "blocking",
"environmentSelector": {}
}
]
146 changes: 146 additions & 0 deletions staging/tests-extension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Get the directory where this Makefile is, so we can use it below for including
# Include the same Bingo variables used by the project
DIR := $(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
# Use openshift's Bingo variables
include $(DIR)/../../.bingo/Variables.mk

# Definitions for the extended tests

GO_PKG_NAME := github.com/openshift-eng/openshift-tests-extension

GIT_COMMIT := $(shell git rev-parse --short HEAD)
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_TREE_STATE := $(shell if git diff --quiet; then echo clean; else echo dirty; fi)

LDFLAGS := -X '$(GO_PKG_NAME)/pkg/version.CommitFromGit=$(GIT_COMMIT)' \
-X '$(GO_PKG_NAME)/pkg/version.BuildDate=$(BUILD_DATE)' \
-X '$(GO_PKG_NAME)/pkg/version.GitTreeState=$(GIT_TREE_STATE)'


METADATA := $(shell pwd)/.openshift-tests-extension/openshift_payload_olmv0.json

#SECTION General

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '#SECTION' and the
# target descriptions by '#HELP' or '#EXHELP'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: #HELP something, and then pretty-format the target and help. Then,
# if there's a line with #SECTION something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
# The extended-help target uses '#EXHELP' as the delineator.

.PHONY: help
help: #HELP Display essential help.
@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)

#SECTION Tests
TOOLS_BIN_DIR := $(CURDIR)/bin

#SECTION Development
.PHONY: verify #HELP To verify the code
verify: tidy fmt vet lint

.PHONY: tidy #HELP Run go mod tidy.
tidy:
go mod tidy

.PHONY: fmt
fmt: #HELP Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: #HELP Run go vet against code.
go vet ./...

.PHONY: lint
lint: $(GOLANGCI_LINT) #HELP Run golangci linter.
$(GOLANGCI_LINT) run

.PHONY: fix-lint
fix-lint: $(GOLANGCI_LINT) #HELP Fix lint issues
$(GOLANGCI_LINT) run --fix

# Bindata generation
.PHONY: bindata
bindata: $(GO_BINDATA)

bindata: test/extended/testdata/bindata.go
test/extended/testdata/bindata.go: $(shell find test/extended/testdata -type f ! -name 'bindata.go')
mkdir -p $(@D)
$(GO_BINDATA) -nocompress -nometadata \
-pkg testdata -o $@ -prefix "testextended" \
-ignore "test/extended/testdata/bindata.go" test/extended/testdata/...
gofmt -s -w $@

# GO_COMPLIANCE_POLICY="exempt_all" must only be used for test related binaries.
# It prevents various FIPS compliance policies from being applied to this compilation.
# Do not set globally.
.PHONY: build
build: #HELP Build the extended tests binary
@mkdir -p $(TOOLS_BIN_DIR)
GO_COMPLIANCE_POLICY="exempt_all" go build -ldflags "$(LDFLAGS)" -mod=vendor -o $(TOOLS_BIN_DIR)/olmv0-tests-ext ./cmd/...

.PHONY: update-metadata
update-metadata: #HELP Build and run 'update-metadata' to generate test metadata
$(TOOLS_BIN_DIR)/olmv0-tests-ext update --component openshift:payload:olmv0
$(MAKE) clean-metadata


# Ensure TestID is unique over time.
# TestID is built over Product:Type:ComponentName:TestDescription
# (i.e. openshift:payload:olmv0:TestName)
# Details:
# - https://github.com/openshift/enhancements/blob/master/enhancements/testing/openshift-tests-extension.md#test-id
# - https://github.com/openshift-eng/ci-test-mapping
#──────────────────────────────────────────────────────────────
# How to rename a test?
# 1. Run: make list-test-names
# 2. Find the current full test name (e.g. "[sig-abc] My test does XYZ")
# 3. Add a Ginkgo label: ginkgo.Label("original-name:[sig-abc] My test does XYZ")
# 4. Change the test name string and run: make build-update
# **Example**
# It("should pass a renamed sanity check",
# Label("original-name:[sig-operator] OLMv0 should pass a trivial sanity check"),
# func(ctx context.Context) {
# Expect(len("test")).To(BeNumerically(">", 0))
# })
# Note: You only add the label once. Do not update it after future renames.
#──────────────────────────────────────────────────────────────
# How to delete a test?
# 1. Run: make list-test-names
# 2. In main.go add:
# ext.IgnoreObsoleteTests(
# "[sig-operator] My removed test name",
# )
# 3. Delete the test code in your suite file (e.g. olmv0.go)
# 4. Run: make build-update.
# This will regenerate the metadata without the test entry.
#────────────────────────────────────────────────────────────────────
.PHONY: build-update
build-update: bindata build update-metadata #HELP Build and update metadata and sanitize output

#SECTION Metadata

.PHONY: list-test-names
list-test-names: #HELP Show current full test names
@$(TOOLS_BIN_DIR)/olmv0-tests-ext list -o names

# Remove 'codeLocations' to avoid absolute paths like:
# "/Users/$(USER)/go/src/.../olmv0.go:12"
# These are machine-specific and make the metadata non-idempotent.
# More info: https://issues.redhat.com/browse/TRT-2186
.PHONY: clean-metadata
clean-metadata: #HELP Remove 'codeLocations' from metadata JSON
@echo "Cleaning metadata (removing codeLocations)..."
@jq 'map(del(.codeLocations))' $(METADATA) > $(METADATA).tmp && mv $(METADATA).tmp $(METADATA)

.PHONY: verify-metadata #HELP To verify that the metadata was properly update
verify-metadata: update-metadata
@if ! git diff --exit-code $(METADATA); then \
echo "ERROR: Metadata is out of date. Please run 'make build-update' and commit the result."; \
exit 1; \
fi
11 changes: 11 additions & 0 deletions staging/tests-extension/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
approvers:
- Xia-Zhao-rh
- kuiwang02
- bandrade
- jianzhangbjz
reviewers:
- Xia-Zhao-rh
- kuiwang02
- bandrade
- jianzhangbjz

Loading