@@ -37,6 +37,21 @@ images:
3737 - dockerfile_path : Dockerfile.mustgather
3838 from : ocp_4.14_cli
3939 to : secrets-store-csi-mustgather
40+ - dockerfile_literal : |
41+ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS builder
42+ WORKDIR /go/src/github.com/openshift/secrets-store-csi-driver-operator
43+ COPY . .
44+ RUN CGO_ENABLED=1 GOEXPERIMENT=strictfipsruntime go build \
45+ -mod=vendor -trimpath \
46+ -tags strictfipsruntime,openssl \
47+ -cover -covermode=atomic -coverpkg=./... \
48+ -o secrets-store-csi-driver-operator \
49+ ./cmd/secrets-store-csi-driver-operator
50+ FROM registry.ci.openshift.org/ocp/4.22:base-rhel9
51+ COPY --from=builder /go/src/github.com/openshift/secrets-store-csi-driver-operator/secrets-store-csi-driver-operator /usr/bin/
52+ ENV GOCOVERDIR=/tmp/e2e-cover
53+ ENTRYPOINT ["/bin/sh", "-c", "mkdir -p /tmp/e2e-cover && exec /usr/bin/secrets-store-csi-driver-operator \"$@\"", "--"]
54+ to: secrets-store-csi-driver-operator-coverage
4055operator :
4156 bundles :
4257 - as : secrets-store-csi-driver-operator-bundle
@@ -96,9 +111,136 @@ tests:
96111 OO_INSTALL_NAMESPACE : openshift-cluster-csi-drivers
97112 OO_PACKAGE : secrets-store-csi-driver-operator
98113 OO_TARGET_NAMESPACES : ' !all'
114+ post :
115+ - as : collect-coverage
116+ best_effort : true
117+ cli : latest
118+ commands : |
119+ set -euo pipefail
120+ NAMESPACE="openshift-cluster-csi-drivers"
121+ DEPLOYMENT="secrets-store-csi-driver-operator"
122+ POD_LABEL="app=secrets-store-csi-driver-operator"
123+ GOCOVERDIR_PATH="/tmp/e2e-cover"
124+ CODECOV_SECRET="/var/run/secrets/codecov/CODECOV_TOKEN"
125+
126+ artifact_dir="${ARTIFACT_DIR:-.}"
127+ coverage_dir="${artifact_dir}/e2e-cover-data"
128+ coverage_profile="${artifact_dir}/coverage-e2e.out"
129+
130+ if [ -z "${CODECOV_TOKEN:-}" ] && [ -f "${CODECOV_SECRET}" ]; then
131+ CODECOV_TOKEN=$(cat "${CODECOV_SECRET}")
132+ export CODECOV_TOKEN
133+ fi
134+
135+ pod=$(oc get pods -n "${NAMESPACE}" -l "${POD_LABEL}" \
136+ -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
137+ if [ -z "${pod}" ]; then
138+ echo "Error: no operator pod found"; exit 1
139+ fi
140+ echo "Found operator pod: ${pod}"
141+
142+ echo "Sending SIGTERM to flush coverage data (container will restart)..."
143+ oc exec -n "${NAMESPACE}" "${pod}" -- /bin/sh -c 'kill -TERM 1' 2>/dev/null || true
144+
145+ echo "Waiting for container to restart and become ready..."
146+ sleep 5
147+ oc wait pod "${pod}" -n "${NAMESPACE}" --for=condition=Ready --timeout=120s
148+
149+ echo "Copying coverage data from restarted container..."
150+ mkdir -p "${coverage_dir}"
151+ oc cp "${NAMESPACE}/${pod}:${GOCOVERDIR_PATH}/." "${coverage_dir}"
152+
153+ echo "Coverage files:"
154+ ls -la "${coverage_dir}/" 2>/dev/null || true
155+
156+ if ls "${coverage_dir}"/covmeta.* >/dev/null 2>&1; then
157+ echo "Converting coverage data..."
158+ go tool covdata textfmt -i="${coverage_dir}" -o="${coverage_profile}"
159+ echo "=== E2E Coverage Summary ==="
160+ go tool covdata percent -i="${coverage_dir}"
161+ echo "============================="
162+
163+ if [ -n "${CODECOV_TOKEN:-}" ]; then
164+ echo "Uploading to Codecov..."
165+ codecov_bin="${artifact_dir}/codecov"
166+ curl -sS -o "${codecov_bin}" https://uploader.codecov.io/latest/linux/codecov
167+ curl -sS -o "${codecov_bin}.SHA256SUM" https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
168+ cd "$(dirname "${codecov_bin}")" && sha256sum -c "$(basename "${codecov_bin}").SHA256SUM" && cd - >/dev/null
169+ chmod +x "${codecov_bin}"
170+
171+ codecov_flags="--file=${coverage_profile} --flags=e2e --name=E2E-Coverage --verbose"
172+ job_type="${JOB_TYPE:-local}"
173+ if [ "${job_type}" = "presubmit" ]; then
174+ [ -n "${PULL_NUMBER:-}" ] && codecov_flags="${codecov_flags} --pr ${PULL_NUMBER}"
175+ [ -n "${PULL_PULL_SHA:-}" ] && codecov_flags="${codecov_flags} --sha ${PULL_PULL_SHA}"
176+ [ -n "${PULL_BASE_REF:-}" ] && codecov_flags="${codecov_flags} --branch ${PULL_BASE_REF}"
177+ [ -n "${REPO_OWNER:-}" ] && [ -n "${REPO_NAME:-}" ] && codecov_flags="${codecov_flags} --slug ${REPO_OWNER}/${REPO_NAME}"
178+ elif [ "${job_type}" = "postsubmit" ]; then
179+ [ -n "${PULL_BASE_SHA:-}" ] && codecov_flags="${codecov_flags} --sha ${PULL_BASE_SHA}"
180+ [ -n "${PULL_BASE_REF:-}" ] && codecov_flags="${codecov_flags} --branch ${PULL_BASE_REF}"
181+ [ -n "${REPO_OWNER:-}" ] && [ -n "${REPO_NAME:-}" ] && codecov_flags="${codecov_flags} --slug ${REPO_OWNER}/${REPO_NAME}"
182+ fi
183+
184+ ${codecov_bin} ${codecov_flags} || echo "Warning: Codecov upload failed (non-fatal)"
185+ rm -f "${codecov_bin}" "${codecov_bin}.SHA256SUM"
186+ else
187+ echo "CODECOV_TOKEN not set -- skipping upload. Profile saved: ${coverage_profile}"
188+ fi
189+ else
190+ echo "Warning: No coverage data found"
191+ fi
192+ credentials :
193+ - mount_path : /var/run/secrets/codecov
194+ name : sscsi-driver-operator-codecov-token
195+ namespace : test-credentials
196+ from : src
197+ resources :
198+ requests :
199+ cpu : 100m
200+ timeout : 15m0s
201+ - chain : gather
99202 test :
100203 - ref : fips-check-fips-or-die
101204 - ref : fips-check-node-scan
205+ - as : setup-coverage
206+ cli : latest
207+ commands : |
208+ set -euo pipefail
209+ NAMESPACE="openshift-cluster-csi-drivers"
210+ DEPLOYMENT="secrets-store-csi-driver-operator"
211+ GOCOVERDIR_PATH="/tmp/e2e-cover"
212+
213+ echo "--- E2E Coverage Setup ---"
214+ echo "Coverage image: ${COVERAGE_IMAGE}"
215+
216+ echo "Discovering CSV from deployment ownerReference..."
217+ csv=$(oc get deployment "${DEPLOYMENT}" -n "${NAMESPACE}" \
218+ -o jsonpath='{.metadata.ownerReferences[?(@.kind=="ClusterServiceVersion")].name}')
219+ if [ -z "${csv}" ]; then
220+ echo "Error: no CSV found for ${DEPLOYMENT}"; exit 1
221+ fi
222+ echo "Found CSV: ${csv}"
223+
224+ echo "Patching CSV with coverage image and GOCOVERDIR env..."
225+ oc patch csv "${csv}" -n "${NAMESPACE}" --type=json -p "[
226+ {\"op\": \"replace\", \"path\": \"/spec/install/spec/deployments/0/spec/template/spec/containers/0/image\", \"value\": \"${COVERAGE_IMAGE}\"},
227+ {\"op\": \"add\", \"path\": \"/spec/install/spec/deployments/0/spec/template/spec/containers/0/env/-\", \"value\": {\"name\": \"GOCOVERDIR\", \"value\": \"${GOCOVERDIR_PATH}\"}}
228+ ]"
229+
230+ echo "Waiting for operator rollout with coverage image..."
231+ sleep 5
232+ oc rollout status "deployment/${DEPLOYMENT}" -n "${NAMESPACE}" --timeout=180s
233+
234+ oc exec -n "${NAMESPACE}" "deploy/${DEPLOYMENT}" -- env | grep GOCOVERDIR || \
235+ echo "Warning: GOCOVERDIR not found in pod env (non-fatal)"
236+ echo "--- Coverage setup complete ---"
237+ dependencies :
238+ - env : COVERAGE_IMAGE
239+ name : secrets-store-csi-driver-operator-coverage
240+ from : src
241+ resources :
242+ requests :
243+ cpu : 100m
102244 - as : test-e2e
103245 cli : latest
104246 commands : make test-e2e
0 commit comments