Skip to content

Commit 7365a4c

Browse files
committed
ci: skip netpol e2e automatically for push events (#2379)
1 parent 18ef2f2 commit 7365a4c

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

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

+43-3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,39 @@ jobs:
144144
- run: make e2e-build
145145
working-directory: ${{ env.E2E_DIR }}
146146

147+
netpol-path-filter:
148+
name: Network Policy Path Filter
149+
if: github.event_name != 'pull_request'
150+
runs-on: ubuntu-22.04
151+
outputs:
152+
test-netpol: ${{ steps.filter.outputs.kube-ovn-controller }}
153+
steps:
154+
- uses: actions/checkout@v3
155+
- uses: actions/setup-go@v3
156+
with:
157+
go-version-file: go.mod
158+
check-latest: true
159+
160+
- name: Generate path filter
161+
run: |
162+
filter=".github/path-filters.yaml"
163+
cat > $filter <<EOF
164+
kube-ovn-controller:
165+
- go.mod
166+
- go.sum
167+
EOF
168+
169+
sh hack/go-list.sh pkg/controller | while read f; do
170+
echo "- $f" | tee -a $filter
171+
done
172+
173+
- uses: dorny/paths-filter@v2
174+
id: filter
175+
with:
176+
base: ${{ github.base_ref || github.ref_name }}
177+
filters: .github/path-filters.yaml
178+
list-files: csv
179+
147180
k8s-conformance-e2e:
148181
name: Kubernetes Conformance E2E
149182
needs:
@@ -244,10 +277,13 @@ jobs:
244277

245278
k8s-netpol-e2e:
246279
name: Kubernetes Network Policy E2E
247-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
280+
if: |
281+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
282+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
248283
needs:
249284
- build-kube-ovn
250285
- build-e2e-binaries
286+
- netpol-path-filter
251287
runs-on: ubuntu-22.04
252288
timeout-minutes: 60
253289
strategy:
@@ -336,8 +372,12 @@ jobs:
336372

337373
cyclonus-netpol-e2e:
338374
name: Cyclonus Network Policy E2E
339-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
340-
needs: build-kube-ovn
375+
if: |
376+
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
377+
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
378+
needs:
379+
- build-kube-ovn
380+
- netpol-path-filter
341381
runs-on: ubuntu-22.04
342382
timeout-minutes: 30
343383
strategy:

hack/go-list.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
path=$1
6+
module=$(grep ^module "$(dirname $0)/../go.mod" | awk '{print $2}')
7+
go list -f '{{ join .Deps "\n" }}' -compiled ./$path/... | grep ^$module/ | while read pkg; do
8+
d="${pkg#${module}/}"
9+
go list -f '{{ join .CompiledGoFiles "\n" }}' -compiled ./$d | while read f; do
10+
echo "$d/$f"
11+
done
12+
done

0 commit comments

Comments
 (0)