Skip to content

Commit 5eff066

Browse files
committed
ci: skip netpol e2e automatically for push events
1 parent ff83611 commit 5eff066

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
@@ -228,6 +228,39 @@ jobs:
228228
- run: make e2e-build
229229
working-directory: ${{ env.E2E_DIR }}
230230

231+
netpol-path-filter:
232+
name: Network Policy Path Filter
233+
if: github.event_name != 'pull_request'
234+
runs-on: ubuntu-22.04
235+
outputs:
236+
test-netpol: ${{ steps.filter.outputs.kube-ovn-controller }}
237+
steps:
238+
- uses: actions/checkout@v3
239+
- uses: actions/setup-go@v3
240+
with:
241+
go-version-file: go.mod
242+
check-latest: true
243+
244+
- name: Generate path filter
245+
run: |
246+
filter=".github/path-filters.yaml"
247+
cat > $filter <<EOF
248+
kube-ovn-controller:
249+
- go.mod
250+
- go.sum
251+
EOF
252+
module=$(grep ^module go.mod | awk '{print $2}')
253+
go list -f '{{ join .Deps "\n" }}' pkg/controller | grep ^$module/ | while read pkg; do
254+
echo "- ${pkg#${module}/}/*" >> $filter
255+
done
256+
257+
- uses: dorny/paths-filter@v2
258+
id: filter
259+
with:
260+
base: ${{ github.base_ref || github.ref_name }}
261+
filters: .github/path-filters.yaml
262+
list-files: csv
263+
231264
k8s-conformance-e2e:
232265
name: Kubernetes Conformance E2E
233266
needs:
@@ -328,10 +361,13 @@ jobs:
328361

329362
k8s-netpol-e2e:
330363
name: Kubernetes Network Policy E2E
331-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
364+
if: |
365+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
366+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
332367
needs:
333368
- build-kube-ovn
334369
- build-e2e-binaries
370+
- netpol-path-filter
335371
runs-on: ubuntu-22.04
336372
timeout-minutes: 60
337373
strategy:
@@ -420,10 +456,13 @@ jobs:
420456

421457
k8s-netpol-legacy-e2e:
422458
name: Kubernetes Network Policy Legacy E2E
423-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
459+
if: |
460+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
461+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
424462
needs:
425463
- build-kube-ovn
426464
- build-e2e-binaries
465+
- netpol-path-filter
427466
runs-on: ubuntu-22.04
428467
timeout-minutes: 60
429468
strategy:
@@ -512,8 +551,12 @@ jobs:
512551

513552
cyclonus-netpol-e2e:
514553
name: Cyclonus Network Policy E2E
515-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
516-
needs: build-kube-ovn
554+
if: |
555+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
556+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
557+
needs:
558+
- build-kube-ovn
559+
- netpol-path-filter
517560
runs-on: ubuntu-22.04
518561
timeout-minutes: 30
519562
strategy:

0 commit comments

Comments
 (0)