Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit ad9085f

Browse files
authored
Do not run acceptance tests for PR that does not change SBO images or testing framework (#1150)
Signed-off-by: Pavel Macík <[email protected]>
1 parent 7c2b9fe commit ad9085f

File tree

2 files changed

+118
-12
lines changed

2 files changed

+118
-12
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# action.yml
2+
name: 'Check if acceptance tests can be skipped'
3+
description: 'Check if acceptance tests can be skipped based on the PR content'
4+
outputs:
5+
can_skip:
6+
description: "true if acceptance teststests can be skipped"
7+
value: ${{ steps.check-skip-test.outputs.result }}
8+
runs:
9+
using: "composite"
10+
steps:
11+
- id: check-skip-test
12+
uses: actions/[email protected]
13+
with:
14+
result-encoding: string
15+
script: |
16+
let currentCount = 0;
17+
let currentPage = 1;
18+
let overallCount = 0;
19+
let pageSize = 100;
20+
let maxPages = 30;
21+
22+
do {
23+
const result = await github.rest.pulls.listFiles({
24+
owner: context.payload.repository.owner.login,
25+
repo: context.payload.repository.name,
26+
pull_number: context.payload.number,
27+
per_page: pageSize,
28+
page: currentPage
29+
})
30+
31+
let fileSet = result.data.filter(f =>
32+
f.filename.startsWith(".github/actions/collect-kube-resources") ||
33+
f.filename.startsWith(".github/actions/setup-cli") ||
34+
f.filename.startsWith(".github/actions/setup-podman") ||
35+
f.filename.startsWith(".github/workflows/pr-checks") ||
36+
f.filename.startsWith("apis") ||
37+
f.filename.startsWith("build") ||
38+
f.filename.startsWith("config") ||
39+
f.filename.startsWith("controllers") ||
40+
f.filename.startsWith("hack/get-test-namespace") ||
41+
f.filename.startsWith("hack/remove-sbr-finalizers.sh") ||
42+
f.filename.startsWith("hack/test-cleanup.sh") ||
43+
f.filename.startsWith("controllers") ||
44+
f.filename.startsWith("make/acceptance.mk") ||
45+
f.filename.startsWith("make/build.mk") ||
46+
f.filename.startsWith("make/common.mk") ||
47+
f.filename.startsWith("make/release.mk") ||
48+
f.filename.startsWith("make/version.mk") ||
49+
f.filename.startsWith("pkg") ||
50+
f.filename.startsWith("test/acceptance") ||
51+
f.filename.startsWith("tools") ||
52+
f.filename.startsWith("vendor") ||
53+
f.filename.startsWith("go.mod") ||
54+
f.filename.startsWith("go.sum") ||
55+
f.filename.startsWith("install.sh") ||
56+
f.filename.startsWith("main.go")
57+
)
58+
fileSet.forEach(i => console.log(" > " + i.status + ": " + i.filename))
59+
overallCount = overallCount + fileSet.length
60+
currentCount = result.data.length
61+
if (currentCount == pageSize){
62+
currentPage = currentPage + 1
63+
}
64+
} while (currentCount == pageSize && currentPage <= maxPages)
65+
66+
const canSkip = (overallCount == 0 && currentPage <= maxPages)
67+
if(canSkip){
68+
console.log("The PR changes neither SBO release, images nor manifests, nor the acceptance testing framework, nor the related CI. Execution of the acceptance tests CAN be skipped. (See https://issues.redhat.com/browse/APPSVC-1116)")
69+
} else {
70+
if (currentPage > maxPages) {
71+
console.log("Overall the PR changes more than the maximum number of " + (pageSize * maxPages) + " files and so cannot be determined if any of those beyond effect SBO release, images or manifests, or the acceptance testing framework, or the related CI. The acceptance tests CAN NOT be skipped.")
72+
} else {
73+
console.log("The PR changes files that effect SBO release, images or manifests, or the acceptance testing framework, or the related CI. The acceptance tests CAN NOT be skipped.")
74+
}
75+
}
76+
77+
return canSkip

.github/workflows/pr-checks.yaml

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,25 @@ jobs:
7474
- name: Checkout Git Repository
7575
uses: actions/checkout@v2
7676

77+
- name: Check if acceptance tests can be skipped
78+
id: check-skip-acceptance
79+
uses: ./.github/actions/check-skip-acceptance-tests
80+
7781
- name: Set up Python
82+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
7883
uses: actions/setup-python@v2
7984
with:
8085
python-version: "3.7"
8186
architecture: "x64"
8287

8388
- name: Setup-cli
89+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
8490
uses: ./.github/actions/setup-cli
8591
with:
8692
start-minikube: true
8793

8894
- name: Wait for push
95+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
8996
uses: lewagon/wait-on-check-action@1b1630e169116b58a4b933d5ad7effc46d3d312d
9097
with:
9198
ref: ${{ github.event.pull_request.head.sha }}
@@ -94,11 +101,13 @@ jobs:
94101
wait-interval: 60
95102

96103
- name: Extract image references
104+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
97105
uses: marcofaggian/[email protected]
98106
with:
99107
names: operator-refs-${{github.event.pull_request.number}}-${{github.event.pull_request.head.sha}}
100108

101109
- name: Acceptance tests
110+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
102111
timeout-minutes: 60
103112
run: |
104113
source ./operator.refs
@@ -107,31 +116,31 @@ jobs:
107116
make SKIP_REGISTRY_LOGIN=true -o registry-login test-acceptance-with-bundle
108117
109118
- name: Collect Kube resources
119+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
110120
continue-on-error: true
111121
uses: ./.github/actions/collect-kube-resources
112122
with:
113123
operator-namespace: operators
114124
olm-namespace: olm
115125
test-namespace-file: out/test-namespace
116126
output-path: ${{env.TEST_RESULTS}}
117-
if: always()
118127

119128
- name: Setup Testspace
129+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
120130
uses: testspace-com/setup-testspace@v1
121131
with:
122132
domain: ${{ github.repository_owner }}
123-
if: always()
124133

125134
- name: Publish tests results to Testspace
135+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
126136
run: |
127137
testspace [${{ env.TEST_RUN }}]${{ env.TEST_RESULTS }}/TEST*.xml
128-
if: always()
129138
130139
- uses: actions/upload-artifact@v2
140+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
131141
with:
132142
name: kubernetes-with-olm-test-results
133143
path: ${{ env.TEST_RESULTS }}
134-
if: always()
135144

136145
acceptance-supported-operators:
137146
name: Supported Operators Acceptance Tests with Kubernetes and using OLM
@@ -145,18 +154,25 @@ jobs:
145154
- name: Checkout Git Repository
146155
uses: actions/checkout@v2
147156

157+
- name: Check if acceptance tests can be skipped
158+
id: check-skip-acceptance
159+
uses: ./.github/actions/check-skip-acceptance-tests
160+
148161
- name: Set up Python
162+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
149163
uses: actions/setup-python@v2
150164
with:
151165
python-version: "3.7"
152166
architecture: "x64"
153167

154168
- name: Setup-cli
169+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
155170
uses: ./.github/actions/setup-cli
156171
with:
157172
start-minikube: true
158173

159174
- name: Wait for push
175+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
160176
uses: lewagon/wait-on-check-action@1b1630e169116b58a4b933d5ad7effc46d3d312d
161177
with:
162178
ref: ${{ github.event.pull_request.head.sha }}
@@ -165,11 +181,13 @@ jobs:
165181
wait-interval: 60
166182

167183
- name: Extract image references
184+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
168185
uses: marcofaggian/[email protected]
169186
with:
170187
names: operator-refs-${{github.event.pull_request.number}}-${{github.event.pull_request.head.sha}}
171188

172189
- name: Acceptance tests
190+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
173191
timeout-minutes: 60
174192
run: |
175193
source ./operator.refs
@@ -178,31 +196,31 @@ jobs:
178196
make SKIP_REGISTRY_LOGIN=true -o registry-login test-acceptance-with-bundle
179197
180198
- name: Collect Kube resources
199+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
181200
continue-on-error: true
182201
uses: ./.github/actions/collect-kube-resources
183202
with:
184203
operator-namespace: operators
185204
olm-namespace: olm
186205
test-namespace-file: out/test-namespace
187206
output-path: ${{env.TEST_RESULTS}}
188-
if: always()
189207

190208
- name: Setup Testspace
209+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
191210
uses: testspace-com/setup-testspace@v1
192211
with:
193212
domain: ${{ github.repository_owner }}
194-
if: always()
195213

196214
- name: Publish tests results to Testspace
215+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
197216
run: |
198217
testspace [${{ env.TEST_RUN }}]${{ env.TEST_RESULTS }}/TEST*.xml
199-
if: always()
200218
201219
- uses: actions/upload-artifact@v2
220+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
202221
with:
203222
name: supported-operators-kubernetes
204223
path: ${{ env.TEST_RESULTS }}
205-
if: always()
206224

207225
acceptance_without_olm:
208226
name: Acceptance tests running on Kubernetes without using OLM
@@ -217,29 +235,38 @@ jobs:
217235
- name: Checkout Git Repository
218236
uses: actions/checkout@v2
219237

238+
- name: Check if acceptance tests can be skipped
239+
id: check-skip-acceptance
240+
uses: ./.github/actions/check-skip-acceptance-tests
241+
220242
- name: Set up Python
243+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
221244
uses: actions/setup-python@v2
222245
with:
223246
python-version: "3.7"
224247
architecture: "x64"
225248

226249
- name: Set up CLI
250+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
227251
uses: ./.github/actions/setup-cli
228252
with:
229253
start-minikube: true
230254

231255
- name: Set up Go
256+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
232257
uses: actions/setup-go@v2
233258
with:
234259
go-version: "^1.16"
235260

236261
- name: Setup umoci cli
262+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
237263
run: |
238264
curl -Lo umoci https://github.com/opencontainers/umoci/releases/download/v${UMOCI_VERSION}/umoci.amd64
239265
chmod +x umoci
240266
mv -v umoci $GITHUB_WORKSPACE/bin/
241267
242268
- name: Wait for push
269+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
243270
uses: lewagon/wait-on-check-action@1b1630e169116b58a4b933d5ad7effc46d3d312d
244271
with:
245272
ref: ${{ github.event.pull_request.head.sha }}
@@ -248,11 +275,13 @@ jobs:
248275
wait-interval: 60
249276

250277
- name: Extract image references
278+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
251279
uses: marcofaggian/[email protected]
252280
with:
253281
names: operator-refs-${{github.event.pull_request.number}}-${{github.event.pull_request.head.sha}}
254282

255283
- name: Acceptance tests against vanilla k8s without OLM
284+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
256285
timeout-minutes: 60
257286
run: |
258287
source ./operator.refs
@@ -264,30 +293,30 @@ jobs:
264293
make TEST_ACCEPTANCE_START_SBO=remote test-acceptance
265294
266295
- name: Collect Kube resources
296+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
267297
continue-on-error: true
268298
uses: ./.github/actions/collect-kube-resources
269299
with:
270300
operator-namespace: service-binding-operator
271301
test-namespace-file: out/test-namespace
272302
output-path: ${{env.TEST_RESULTS}}
273-
if: always()
274303

275304
- name: Setup Testspace
305+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
276306
uses: testspace-com/setup-testspace@v1
277307
with:
278308
domain: ${{ github.repository_owner }}
279-
if: always()
280309

281310
- name: Publish tests results to Testspace
311+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
282312
run: |
283313
testspace [${{ env.TEST_RUN }}]${{ env.TEST_RESULTS }}/TEST*.xml
284-
if: always()
285314
286315
- uses: actions/upload-artifact@v2
316+
if: ${{ steps.check-skip-acceptance.outputs.can_skip != 'true' }}
287317
with:
288318
name: kubernetes-without-olm-test-results
289319
path: ${{ env.TEST_RESULTS }}
290-
if: always()
291320

292321
single-commit:
293322
name: Single commit PR

0 commit comments

Comments
 (0)