2323 type : string
2424 - description : OpenShift version to provision
2525 name : OPENSHIFT_VERSION
26- default : " 4.14 "
26+ default : " 4.20 "
2727 type : string
2828 - description : Operator channel to query in catalog
2929 name : OPERATOR_CHANNEL
5151 type : string
5252 - description : Pre-built test runner image. Build locally with .tekton/test-image/build-and-push.sh
5353 name : TEST_IMAGE_URL
54- default : " quay.io/devtools_gitops/test_image:final-amd64-c1bd193939ae"
54+ default : " quay.io/devtools_gitops/test_image:konflux_v1.21.0"
55+ type : string
56+ - description : PR label required to run tests (empty = no gating, always run). When set, push events always proceed but pull_request events require this label on the PR.
57+ name : GATE_LABEL
58+ default : " "
59+ type : string
60+ - description : Build the test runner image from source instead of using TEST_IMAGE_URL
61+ name : BUILD_TEST_IMAGE
62+ default : " false"
5563 type : string
5664
5765 finally :
7381 - name : pipelineRunName
7482 value : " $(context.pipelineRun.name)"
7583 - name : testImageUrl
76- value : " $(params.TEST_IMAGE_URL )"
84+ value : " $(tasks.resolve-test-image.results.image-url )"
7785 - name : aggregateStatus
7886 value : " $(tasks.status)"
7987 - name : logUrl
@@ -114,9 +122,150 @@ spec:
114122 - name : SNAPSHOT
115123 value : $(params.SNAPSHOT)
116124
117- - name : provision-eaas-space
125+ - name : check-gate
118126 runAfter :
119127 - parse-metadata
128+ taskSpec :
129+ params :
130+ - name : event-type
131+ type : string
132+ - name : pull-request-number
133+ type : string
134+ - name : source-git-url
135+ type : string
136+ - name : gate-label
137+ type : string
138+ results :
139+ - name : proceed
140+ description : " true if tests should run, false to skip"
141+ steps :
142+ - name : check
143+ image : registry.access.redhat.com/ubi9/ubi-minimal:latest
144+ env :
145+ - name : EVENT_TYPE
146+ value : $(params.event-type)
147+ - name : PR_NUMBER
148+ value : $(params.pull-request-number)
149+ - name : SOURCE_GIT_URL
150+ value : $(params.source-git-url)
151+ - name : GATE_LABEL
152+ value : $(params.gate-label)
153+ script : |
154+ #!/bin/sh
155+ set -eu
156+
157+ if [ -z "${GATE_LABEL}" ]; then
158+ echo "No gate label configured, proceeding"
159+ echo -n "true" > $(results.proceed.path)
160+ exit 0
161+ fi
162+
163+ if [ "${EVENT_TYPE}" = "push" ]; then
164+ echo "Push event, proceeding"
165+ echo -n "true" > $(results.proceed.path)
166+ exit 0
167+ fi
168+
169+ if [ "${EVENT_TYPE}" != "pull_request" ] || [ -z "${PR_NUMBER}" ]; then
170+ echo "Not a pull_request event or no PR number, proceeding"
171+ echo -n "true" > $(results.proceed.path)
172+ exit 0
173+ fi
174+
175+ # Extract owner/repo from git URL
176+ REPO_SLUG=$(echo "${SOURCE_GIT_URL}" | sed 's|.*github.com/||' | sed 's|\.git$||')
177+ echo "Checking PR #${PR_NUMBER} on ${REPO_SLUG} for label '${GATE_LABEL}'..."
178+
179+ LABELS=$(curl -sf "https://api.github.com/repos/${REPO_SLUG}/pulls/${PR_NUMBER}" \
180+ | grep -o '"name":"[^"]*"' | sed 's/"name":"//;s/"$//' || true)
181+
182+ echo "PR labels: ${LABELS:-none}"
183+
184+ if echo "${LABELS}" | grep -qx "${GATE_LABEL}"; then
185+ echo "Label '${GATE_LABEL}' found, proceeding"
186+ echo -n "true" > $(results.proceed.path)
187+ else
188+ echo "Label '${GATE_LABEL}' NOT found, skipping tests"
189+ echo -n "false" > $(results.proceed.path)
190+ fi
191+ params :
192+ - name : event-type
193+ value : $(tasks.parse-metadata.results.test-event-type)
194+ - name : pull-request-number
195+ value : $(tasks.parse-metadata.results.pull-request-number)
196+ - name : source-git-url
197+ value : $(tasks.parse-metadata.results.source-git-url)
198+ - name : gate-label
199+ value : $(params.GATE_LABEL)
200+
201+ - name : build-test-image
202+ runAfter :
203+ - check-gate
204+ when :
205+ - input : $(tasks.check-gate.results.proceed)
206+ operator : in
207+ values : ["true"]
208+ - input : $(params.BUILD_TEST_IMAGE)
209+ operator : in
210+ values : ["true"]
211+ taskRef :
212+ resolver : git
213+ params :
214+ - name : url
215+ value : $(params.CATALOG_TASK_URL)
216+ - name : revision
217+ value : $(params.CATALOG_TASK_REVISION)
218+ - name : pathInRepo
219+ value : .tekton/tasks/build-ginkgo-test-image.yaml
220+ params :
221+ - name : SOURCE_URL
222+ value : $(params.CATALOG_TASK_URL)
223+ - name : SOURCE_REVISION
224+ value : $(params.CATALOG_TASK_REVISION)
225+ - name : IMAGE_EXPIRES_AFTER
226+ value : " 7d"
227+
228+ - name : resolve-test-image
229+ runAfter :
230+ - check-gate
231+ when :
232+ - input : $(tasks.check-gate.results.proceed)
233+ operator : in
234+ values : ["true"]
235+ taskSpec :
236+ params :
237+ - name : build-image-url
238+ type : string
239+ - name : fallback-image-url
240+ type : string
241+ results :
242+ - name : image-url
243+ description : Resolved test image URL
244+ steps :
245+ - name : resolve
246+ image : registry.access.redhat.com/ubi9/ubi-minimal:latest
247+ script : |
248+ #!/bin/sh
249+ if [ -n "$(params.build-image-url)" ]; then
250+ echo "Using built image: $(params.build-image-url)"
251+ echo -n "$(params.build-image-url)" > $(results.image-url.path)
252+ else
253+ echo "Using pre-built image: $(params.fallback-image-url)"
254+ echo -n "$(params.fallback-image-url)" > $(results.image-url.path)
255+ fi
256+ params :
257+ - name : build-image-url
258+ value : $(tasks.build-test-image.results.IMAGE_URL)
259+ - name : fallback-image-url
260+ value : $(params.TEST_IMAGE_URL)
261+
262+ - name : provision-eaas-space
263+ runAfter :
264+ - resolve-test-image
265+ when :
266+ - input : $(tasks.check-gate.results.proceed)
267+ operator : in
268+ values : ["true"]
120269 taskRef :
121270 resolver : git
122271 params :
@@ -164,7 +313,7 @@ spec:
164313
165314 - name : extract-argocd-image
166315 runAfter :
167- - parse-metadata
316+ - resolve-test-image
168317 taskRef :
169318 resolver : git
170319 params :
@@ -180,7 +329,7 @@ spec:
180329 - name : operatorChannel
181330 value : $(params.OPERATOR_CHANNEL)
182331 - name : testImageUrl
183- value : $(params.TEST_IMAGE_URL )
332+ value : $(tasks.resolve-test-image.results.image-url )
184333 - name : pipelineRunName
185334 value : $(context.pipelineRun.name)
186335
@@ -202,7 +351,7 @@ spec:
202351 - name : argoCDVersion
203352 value : $(params.ARGOCD_VERSION)
204353 - name : testImageUrl
205- value : $(params.TEST_IMAGE_URL )
354+ value : $(tasks.resolve-test-image.results.image-url )
206355 - name : eaasSpaceSecretRef
207356 value : $(tasks.provision-eaas-space.results.secretRef)
208357 - name : clusterName
@@ -230,7 +379,7 @@ spec:
230379 - name : testRepoBranch
231380 value : $(params.TEST_REPO_BRANCH)
232381 - name : testImageUrl
233- value : $(params.TEST_IMAGE_URL )
382+ value : $(tasks.resolve-test-image.results.image-url )
234383 - name : eaasSpaceSecretRef
235384 value : $(tasks.provision-eaas-space.results.secretRef)
236385 - name : clusterName
0 commit comments