Skip to content

Commit

Permalink
ci: skip netpol e2e automatically for push events (#2379)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Feb 27, 2023
1 parent d2dfd10 commit 0b7e72f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
46 changes: 43 additions & 3 deletions .github/workflows/build-x86-image.yaml
Expand Up @@ -144,6 +144,39 @@ jobs:
- run: make e2e-build
working-directory: ${{ env.E2E_DIR }}

netpol-path-filter:
name: Network Policy Path Filter
if: github.event_name != 'pull_request'
runs-on: ubuntu-22.04
outputs:
test-netpol: ${{ steps.filter.outputs.kube-ovn-controller }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
check-latest: true

- name: Generate path filter
run: |
filter=".github/path-filters.yaml"
cat > $filter <<EOF
kube-ovn-controller:
- go.mod
- go.sum
EOF
sh hack/go-list.sh pkg/controller | while read f; do
echo "- $f" | tee -a $filter
done
- uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.base_ref || github.ref_name }}
filters: .github/path-filters.yaml
list-files: csv

k8s-conformance-e2e:
name: Kubernetes Conformance E2E
needs:
Expand Down Expand Up @@ -244,10 +277,13 @@ jobs:

k8s-netpol-e2e:
name: Kubernetes Network Policy E2E
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
if: |
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
needs:
- build-kube-ovn
- build-e2e-binaries
- netpol-path-filter
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
Expand Down Expand Up @@ -336,8 +372,12 @@ jobs:

cyclonus-netpol-e2e:
name: Cyclonus Network Policy E2E
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
needs: build-kube-ovn
if: |
always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') &&
(needs.netpol-path-filter.outputs.test-netpol == 1 || contains(github.event.pull_request.labels.*.name, 'network policy'))
needs:
- build-kube-ovn
- netpol-path-filter
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
Expand Down
12 changes: 12 additions & 0 deletions hack/go-list.sh
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

path=$1
module=$(grep ^module "$(dirname $0)/../go.mod" | awk '{print $2}')
go list -f '{{ join .Deps "\n" }}' -compiled ./$path/... | grep ^$module/ | while read pkg; do
d="${pkg#${module}/}"
go list -f '{{ join .CompiledGoFiles "\n" }}' -compiled ./$d | while read f; do
echo "$d/$f"
done
done

0 comments on commit 0b7e72f

Please sign in to comment.