Skip to content

Commit d55677e

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

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

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

+49-4
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,41 @@ 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+
workflow=$(echo ${{ github.workflow_ref }} | awk -F@ '{print $1}' | sed 's@^${{ github.repository }}/@@')
248+
cat > $filter <<EOF
249+
kube-ovn-controller:
250+
- $workflow
251+
- go.mod
252+
- go.sum
253+
EOF
254+
module=$(grep ^module go.mod | awk '{print $2}')
255+
go list -f '{{ join .Deps "\n" }}' pkg/controller | grep ^$module/ | while read pkg; do
256+
echo "- ${pkg#${module}/}/*" >> $filter
257+
done
258+
259+
- uses: dorny/paths-filter@v2
260+
id: filter
261+
with:
262+
base: ${{ github.base_ref || github.ref_name }}
263+
filters: .github/path-filters.yaml
264+
list-files: csv
265+
231266
k8s-conformance-e2e:
232267
name: Kubernetes Conformance E2E
233268
needs:
@@ -328,10 +363,13 @@ jobs:
328363

329364
k8s-netpol-e2e:
330365
name: Kubernetes Network Policy E2E
331-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
366+
if: |
367+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
368+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
332369
needs:
333370
- build-kube-ovn
334371
- build-e2e-binaries
372+
- netpol-path-filter
335373
runs-on: ubuntu-22.04
336374
timeout-minutes: 60
337375
strategy:
@@ -420,10 +458,13 @@ jobs:
420458

421459
k8s-netpol-legacy-e2e:
422460
name: Kubernetes Network Policy Legacy E2E
423-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
461+
if: |
462+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
463+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
424464
needs:
425465
- build-kube-ovn
426466
- build-e2e-binaries
467+
- netpol-path-filter
427468
runs-on: ubuntu-22.04
428469
timeout-minutes: 60
429470
strategy:
@@ -512,8 +553,12 @@ jobs:
512553

513554
cyclonus-netpol-e2e:
514555
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
556+
if: |
557+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
558+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
559+
needs:
560+
- build-kube-ovn
561+
- netpol-path-filter
517562
runs-on: ubuntu-22.04
518563
timeout-minutes: 30
519564
strategy:

0 commit comments

Comments
 (0)