From 7990fe949d0fb11b01c3edc42fe6267fa904da3b Mon Sep 17 00:00:00 2001 From: Quan Tian Date: Wed, 24 May 2023 17:03:30 +0800 Subject: [PATCH] Add a parameterized workflow to run conformance tests flexibly Signed-off-by: Quan Tian --- .github/workflows/benchmark.yml | 2 +- .github/workflows/build.yml | 4 +- .github/workflows/codeql.yml | 4 +- .github/workflows/conformance_manual.yml | 79 ++++++++++++++++++++++++ .github/workflows/go.yml | 4 +- .github/workflows/golicense.yml | 4 +- .github/workflows/kind.yml | 4 +- ci/kind/test-e2e-kind.sh | 9 +++ 8 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/conformance_manual.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index a5c59f89f4d..e1e5d465d31 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -3,7 +3,7 @@ name: Go Benchmark Test on: push: branches: - - main + - main123 jobs: go-benchmark-checks: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d7f60ac719..8ac7fb293bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,12 +3,12 @@ name: Build and push latest image if needed on: pull_request: branches: - - main +# - main - release-* - feature/* push: branches: - - main +# - main - release-* - feature/* diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 194466217d4..3fec5020078 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,9 +2,9 @@ name: "Golang Code Analysis" on: push: - branches: [ "main", release-* ] + branches: [ "main123", release-* ] pull_request: - branches: [ "main" ] + branches: [ "main123" ] jobs: analyze-on-linux: diff --git a/.github/workflows/conformance_manual.yml b/.github/workflows/conformance_manual.yml new file mode 100644 index 00000000000..20cd83e22ac --- /dev/null +++ b/.github/workflows/conformance_manual.yml @@ -0,0 +1,79 @@ +name: Manually run upstream conformance test + +on: + workflow_dispatch: + inputs: + antrea-version: + description: The Antrea version to test. It could be a SHA-1 value, a branch, or a tag (e.g. a7b012b, release-1.12, v1.12.0). It defaults to the main branch. + default: main + required: true + k8s-version: + description: K8s version (e.g. v1.27.1). Kind's default K8s version will be used if empty. + required: false + test-suite: + description: The test suite to run. Valid values include "whole-conformance", "conformance", "network-policy, "sig-network", and "all". + default: whole-conformance + required: true + always-upload-logs: + description: Always upload logs regardless of the test result. + type: boolean + default: false + +env: + KIND_VERSION: v0.18.0 + +jobs: + test: + name: Run tests + runs-on: [ubuntu-latest] + steps: + - name: Free disk space + # https://github.com/actions/virtual-environments/issues/709 + run: | + sudo apt-get clean + df -h + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.antrea-version }} + fetch-depth: 0 + - name: Check if it is a released version + id: check-release + run: | + if git show-ref --tags --verify --quiet refs/tags/${{ inputs.antrea-version }}; then + echo "released=true" >> $GITHUB_OUTPUT + else + echo "released=false" >> $GITHUB_OUTPUT + fi + - name: Build Antrea image if required + if: ${{ steps.check-release.outputs.released == 'false' }} + run: | + ./hack/build-antrea-linux-all.sh --pull + - name: Install Kind + run: | + curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64 + chmod +x ./kind + sudo mv kind /usr/local/bin + - name: Create K8s cluster + run: | + ./ci/kind/kind-setup.sh create kind \ + --k8s-version "${{ inputs.k8s-version }}" + - name: Install Antrea + run: | + if [ ${{ steps.check-release.outputs.released }} == 'true' ]; then + helm repo add antrea https://charts.antrea.io + helm repo update + helm install --namespace kube-system antrea antrea/antrea --version "${{ inputs.antrea-version }}" + else + kubectl apply -f build/yamls/antrea.yml + fi + kubectl rollout status -n kube-system ds/antrea-agent --timeout=5m + - name: Run e2e tests + run: | + ./ci/run-k8s-e2e-tests.sh "--e2e-${{ inputs.test-suite }}" + - name: Upload test log + uses: actions/upload-artifact@v3 + if: ${{ failure() || inputs.always-upload-logs }} + with: + name: sonobuoy.tar.gz + path: "*_sonobuoy_*.tar.gz" + retention-days: 7 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 275e4eae7d1..bd7dbc0fd36 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -2,12 +2,12 @@ name: Go on: pull_request: branches: - - main +# - main - release-* - feature/* push: branches: - - main +# - main - release-* - feature/* diff --git a/.github/workflows/golicense.yml b/.github/workflows/golicense.yml index c57360126cb..cc34fe8dab7 100644 --- a/.github/workflows/golicense.yml +++ b/.github/workflows/golicense.yml @@ -2,12 +2,12 @@ name: Golicense on: pull_request: branches: - - main +# - main - release-* - feature/* push: branches: - - main +# - main - release-* - feature/* release: diff --git a/.github/workflows/kind.yml b/.github/workflows/kind.yml index 72a2d595314..532b1014234 100644 --- a/.github/workflows/kind.yml +++ b/.github/workflows/kind.yml @@ -2,12 +2,12 @@ name: Kind on: pull_request: branches: - - main +# - main - release-* - feature/* push: branches: - - main +# - main - release-* - feature/* diff --git a/ci/kind/test-e2e-kind.sh b/ci/kind/test-e2e-kind.sh index a5f641d8ffd..4816cc2cf6a 100755 --- a/ci/kind/test-e2e-kind.sh +++ b/ci/kind/test-e2e-kind.sh @@ -36,6 +36,7 @@ _usage="Usage: $0 [--encap-mode ] [--ip-family ] [--coverage] [--he --setup-only Only perform setting up the cluster and run test. --cleanup-only Only perform cleaning up the cluster. --test-only Only run test on current cluster. Not set up/clean up the cluster. + --k8s-version Specifies the Kubernetes version of the kind cluster, kind's default K8s version will be used if empty. --help, -h Print this message and exit. " @@ -73,6 +74,7 @@ setup_only=false cleanup_only=false test_only=false run="" +k8s_version="" while [[ $# -gt 0 ]] do key="$1" @@ -130,6 +132,10 @@ case $key in test_only=true shift ;; + --k8s-version) + k8s_version="$2" + shift + ;; -h|--help) print_usage exit 0 @@ -215,6 +221,9 @@ function setup_cluster { if $node_ipam; then args="$args --no-kube-node-ipam" fi + if $k8s_version; then + args="$args --k8s-version $k8s_version" + fi echo "creating test bed with args $args" eval "timeout 600 $TESTBED_CMD create kind $args"