Skip to content

Commit

Permalink
fix github actions workflows (#2363)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Feb 22, 2023
1 parent 6ac19b9 commit bb91456
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 41 deletions.
109 changes: 81 additions & 28 deletions .github/workflows/build-x86-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ concurrency:
cancel-in-progress: true

env:
GOSEC_VERSION: '2.14.0'
HELM_VERSION: v3.10.1
GOSEC_VERSION: '2.15.0'
HELM_VERSION: v3.10.3

jobs:
build-kube-ovn:
Expand Down Expand Up @@ -60,7 +60,12 @@ jobs:
- name: Install gosec
run: |
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin 'v${{ env.GOSEC_VERSION }}'
tmp=$(mktemp -d)
archive="gosec_${{ env.GOSEC_VERSION }}_$(go env GOHOSTOS)_$(go env GOHOSTARCH).tar.gz"
wget -q -O "$tmp/$archive" https://github.com/securego/gosec/releases/download/v${{ env.GOSEC_VERSION }}/$archive
tar --no-same-owner -C "$tmp" -xzf "$tmp/$archive"
install "$tmp/gosec" /usr/local/bin
rm -rf $tmp
- name: Build
run: |
Expand Down Expand Up @@ -93,9 +98,57 @@ jobs:
name: vpc-nat-gateway
path: vpc-nat-gateway.tar

build-e2e-binaries:
name: Build E2E Binaries
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v3

- name: Create the default branch directory
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
run: mkdir -p test/e2e/source

- name: Check out the default branch
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 1
path: test/e2e/source

- name: Export E2E directory
run: |
if [ '${{ github.base_ref || github.ref_name }}' = '${{ github.event.repository.default_branch }}' ]; then
echo "E2E_DIR=." >> "$GITHUB_ENV"
else
echo "E2E_DIR=test/e2e/source" >> "$GITHUB_ENV"
fi
- uses: actions/setup-go@v3
with:
go-version-file: ${{ env.E2E_DIR }}/go.mod
check-latest: true

- name: Export Go full version
run: echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"

- name: Go cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
restore-keys: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-

- run: make e2e-compile

k8s-conformance-e2e:
name: Kubernetes Conformance E2E
needs: build-kube-ovn
needs:
- build-kube-ovn
- build-e2e-binaries
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
Expand All @@ -112,9 +165,11 @@ jobs:
- uses: actions/checkout@v3

- name: Create the default branch directory
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
run: mkdir -p test/e2e/source

- name: Check out the default branch
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
Expand Down Expand Up @@ -143,18 +198,14 @@ jobs:
run: echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"

- name: Go cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
key: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
restore-keys: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-

- name: Build e2e binaries
working-directory: ${{ env.E2E_DIR }}
run: make e2e-compile

- name: Install kind
uses: helm/kind-action@v1
with:
Expand Down Expand Up @@ -190,7 +241,9 @@ jobs:
k8s-netpol-e2e:
name: Kubernetes Network Policy E2E
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'network policy')
needs: build-kube-ovn
needs:
- build-kube-ovn
- build-e2e-binaries
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
Expand All @@ -204,9 +257,11 @@ jobs:
- uses: actions/checkout@v3

- name: Create the default branch directory
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
run: mkdir -p test/e2e/source

- name: Check out the default branch
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
Expand Down Expand Up @@ -235,18 +290,14 @@ jobs:
run: echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"

- name: Go cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
restore-keys: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-

- name: Build e2e binaries
working-directory: ${{ env.E2E_DIR }}
run: make e2e-compile

- name: Install kind
uses: helm/kind-action@v1
with:
Expand Down Expand Up @@ -292,9 +343,11 @@ jobs:
- uses: actions/checkout@v3

- name: Create the default branch directory
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
run: mkdir -p test/e2e/source

- name: Check out the default branch
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
Expand Down Expand Up @@ -339,7 +392,9 @@ jobs:

kube-ovn-conformance-e2e:
name: Kube-OVN Conformance E2E
needs: build-kube-ovn
needs:
- build-kube-ovn
- build-e2e-binaries
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
Expand All @@ -353,9 +408,11 @@ jobs:
- uses: actions/checkout@v3

- name: Create the default branch directory
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
run: mkdir -p test/e2e/source

- name: Check out the default branch
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
Expand All @@ -379,18 +436,14 @@ jobs:
run: echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"

- name: Go cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
restore-keys: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-

- name: Build e2e binaries
working-directory: ${{ env.E2E_DIR }}
run: make e2e-compile

- name: Install kind
uses: helm/kind-action@v1
with:
Expand Down Expand Up @@ -570,8 +623,10 @@ jobs:
run: sh dist/images/cleanup.sh

cilium-chaining-e2e:
needs: build-kube-ovn
name: Cilium Chaining E2E
needs:
- build-kube-ovn
- build-e2e-binaries
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
Expand All @@ -581,9 +636,11 @@ jobs:
version: '${{ env.HELM_VERSION }}'

- name: Create the default branch directory
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
run: mkdir -p test/e2e/source

- name: Check out the default branch
if: github.base_ref == github.event.repository.default_branch || github.ref_name == github.event.repository.default_branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
Expand Down Expand Up @@ -612,18 +669,14 @@ jobs:
run: echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"

- name: Go cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
restore-keys: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-

- name: Build e2e binaries
working-directory: ${{ env.E2E_DIR }}
run: make e2e-compile

- name: Install kind
uses: helm/kind-action@v1
with:
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
# a pull request then we can checkout the head.
fetch-depth: 2

- uses: actions/setup-go@v3
with:
go-version-file: go.mod
check-latest: true

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand All @@ -48,8 +53,8 @@ jobs:

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# - name: Autobuild
# uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -58,9 +63,9 @@ jobs:
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
- name: Build
run: |
make build-go
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,12 @@ kind-untaint-control-plane:
kind-install: kind-load-image
kubectl config use-context kind-kube-ovn
@$(MAKE) kind-untaint-control-plane
bash dist/images/install.sh
sed 's/VERSION=.*/VERSION=$(VERSION)/' dist/images/install.sh | bash
kubectl describe no

.PHONY: kind-install-dev
kind-install-dev:
$(call kind_load_image,kube-ovn,$(REGISTRY)/kube-ovn:$(DEV_TAG))
kubectl config use-context kind-kube-ovn
@$(MAKE) kind-untaint-control-plane
sed 's/VERSION=.*/VERSION=$(DEV_TAG)/' dist/images/install.sh | bash
@VERSION=$(DEV_TAG) $(MAKE) kind-install

.PHONY: kind-install-ipv4
kind-install-ipv4: kind-install-overlay-ipv4
Expand All @@ -268,8 +265,8 @@ kind-install-ovn-ic: kind-load-image kind-install
sed -e 's/10.16.0/10.18.0/g' \
-e 's/10.96.0/10.98.0/g' \
-e 's/100.64.0/100.68.0/g' \
dist/images/install.sh | \
bash
-e 's/VERSION=.*/VERSION=$(VERSION)/' \
dist/images/install.sh | bash
kubectl describe no

docker run -d --name ovn-ic-db --network kind $(REGISTRY)/kube-ovn:$(VERSION) bash start-ic-db.sh
Expand Down Expand Up @@ -300,6 +297,7 @@ kind-install-underlay-ipv4: kind-disable-hairpin kind-load-image kind-untaint-co
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
-e 's/VERSION=.*/VERSION=$(VERSION)/' \
dist/images/install.sh | \
ENABLE_VLAN=true VLAN_NIC=eth0 bash
kubectl describe no
Expand All @@ -311,6 +309,7 @@ kind-install-underlay-hairpin-ipv4: kind-enable-hairpin kind-load-image kind-unt
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
-e 's/VERSION=.*/VERSION=$(VERSION)/' \
dist/images/install.sh | \
ENABLE_VLAN=true VLAN_NIC=eth0 bash
kubectl describe no
Expand All @@ -329,6 +328,7 @@ kind-install-underlay-ipv6: kind-disable-hairpin kind-load-image kind-untaint-co
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV6_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
-e 's/VERSION=.*/VERSION=$(VERSION)/' \
dist/images/install.sh | \
IPV6=true ENABLE_VLAN=true VLAN_NIC=eth0 bash

Expand All @@ -339,6 +339,7 @@ kind-install-underlay-hairpin-ipv6: kind-enable-hairpin kind-load-image kind-unt
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV6_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
-e 's/VERSION=.*/VERSION=$(VERSION)/' \
dist/images/install.sh | \
IPV6=true ENABLE_VLAN=true VLAN_NIC=eth0 bash

Expand All @@ -356,6 +357,7 @@ kind-install-underlay-dual: kind-disable-hairpin kind-load-image kind-untaint-co
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY),$(KIND_IPV6_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS),$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
-e 's/VERSION=.*/VERSION=$(VERSION)/' \
dist/images/install.sh | \
DUAL_STACK=true ENABLE_VLAN=true VLAN_NIC=eth0 bash

Expand All @@ -366,6 +368,7 @@ kind-install-underlay-hairpin-dual: kind-enable-hairpin kind-load-image kind-unt
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY),$(KIND_IPV6_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS),$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
-e 's/VERSION=.*/VERSION=$(VERSION)/' \
dist/images/install.sh | \
DUAL_STACK=true ENABLE_VLAN=true VLAN_NIC=eth0 bash

Expand Down Expand Up @@ -396,7 +399,8 @@ kind-install-cilium: kind-load-image kind-untaint-control-plane
--set cni.configMap=cni-configuration
kubectl -n kube-system rollout status ds cilium --timeout 300s
bash dist/images/cilium.sh
ENABLE_LB=false ENABLE_NP=false WITHOUT_KUBE_PROXY=true CNI_CONFIG_PRIORITY=10 bash dist/images/install.sh
sed 's/VERSION=.*/VERSION=$(VERSION)/' dist/images/install.sh | \
ENABLE_LB=false ENABLE_NP=false WITHOUT_KUBE_PROXY=true CNI_CONFIG_PRIORITY=10 bash
kubectl describe no

.PHONY: kind-reload
Expand Down

0 comments on commit bb91456

Please sign in to comment.