Skip to content

Commit 064df25

Browse files
committed
ci: skip netpol e2e automatically for push events (#2379)
1 parent d5005b7 commit 064df25

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

.github/workflows/build-x86-image.yaml

+47-4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,39 @@ jobs:
169169
- run: make e2e-build
170170
working-directory: ${{ env.E2E_DIR }}
171171

172+
netpol-path-filter:
173+
name: Network Policy Path Filter
174+
if: github.event_name != 'pull_request'
175+
runs-on: ubuntu-22.04
176+
outputs:
177+
test-netpol: ${{ steps.filter.outputs.kube-ovn-controller }}
178+
steps:
179+
- uses: actions/checkout@v3
180+
- uses: actions/setup-go@v3
181+
with:
182+
go-version-file: go.mod
183+
check-latest: true
184+
185+
- name: Generate path filter
186+
run: |
187+
filter=".github/path-filters.yaml"
188+
cat > $filter <<EOF
189+
kube-ovn-controller:
190+
- go.mod
191+
- go.sum
192+
EOF
193+
194+
sh hack/go-list.sh pkg/controller | while read f; do
195+
echo "- $f" | tee -a $filter
196+
done
197+
198+
- uses: dorny/paths-filter@v2
199+
id: filter
200+
with:
201+
base: ${{ github.base_ref || github.ref_name }}
202+
filters: .github/path-filters.yaml
203+
list-files: csv
204+
172205
k8s-conformance-e2e:
173206
name: Kubernetes Conformance E2E
174207
needs:
@@ -269,10 +302,13 @@ jobs:
269302

270303
k8s-netpol-e2e:
271304
name: Kubernetes Network Policy E2E
272-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
305+
if: |
306+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
307+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
273308
needs:
274309
- build-kube-ovn
275310
- build-e2e-binaries
311+
- netpol-path-filter
276312
runs-on: ubuntu-22.04
277313
timeout-minutes: 60
278314
strategy:
@@ -361,10 +397,13 @@ jobs:
361397

362398
k8s-netpol-legacy-e2e:
363399
name: Kubernetes Network Policy Legacy E2E
364-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
400+
if: |
401+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
402+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
365403
needs:
366404
- build-kube-ovn
367405
- build-e2e-binaries
406+
- netpol-path-filter
368407
runs-on: ubuntu-22.04
369408
timeout-minutes: 60
370409
strategy:
@@ -453,8 +492,12 @@ jobs:
453492

454493
cyclonus-netpol-e2e:
455494
name: Cyclonus Network Policy E2E
456-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
457-
needs: build-kube-ovn
495+
if: |
496+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
497+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
498+
needs:
499+
- build-kube-ovn
500+
- netpol-path-filter
458501
runs-on: ubuntu-22.04
459502
timeout-minutes: 30
460503
strategy:

0 commit comments

Comments
 (0)