Skip to content

Commit

Permalink
Move KinD tests for UBI images to a dedicated workflow
Browse files Browse the repository at this point in the history
Create a dedicated workflow for KinD tests of UBI
images to align with the Ubuntu images.

Fixes: antrea-io#6031

Signed-off-by: Xu Liu <xu.liu@broadcom.com>
  • Loading branch information
xliuxu committed Mar 11, 2024
1 parent 23eda62 commit 2f7f74f
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 26 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ jobs:
if: ${{ github.repository != 'antrea-io/antrea' || github.event_name != 'push' || github.ref != 'refs/heads/main' }}
run: |
./hack/build-antrea-linux-all.sh --pull --distro ubi
- name: Clean up docker build cache
# Clean up build cache to avoid running out of disk space in the following go tests.
run: docker builder prune -f
- name: Build and push Antrea UBI8 Docker image to registry
if: ${{ github.repository == 'antrea-io/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
Expand All @@ -102,29 +99,6 @@ jobs:
docker push antrea/antrea-ubi:latest
docker push antrea/antrea-agent-ubi:latest
docker push antrea/antrea-controller-ubi:latest
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
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: Run basic e2e tests
run: |
mkdir log
ANTREA_LOG_DIR=$PWD/log ./ci/kind/test-e2e-kind.sh --encap-mode encap \
--antrea-controller-image antrea/antrea-controller-ubi \
--antrea-agent-image antrea/antrea-agent-ubi \
--run '^TestBasic$'
- name: Tar log files
if: ${{ failure() }}
run: tar -czf log.tar.gz log
- name: Upload test log
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: e2e-kind-ubi-basic.tar.gz
path: log.tar.gz
retention-days: 30
build-scale:
needs: check-changes
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/kind_ubi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: "Kind for UBI"
on:
pull_request:
branches:
- main
- release-*
- feature/*
push:
branches:
- main
- release-*
- feature/*

jobs:
check-changes:
name: Check whether tests need to be run based on diff
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- uses: antrea-io/has-changes@v2
id: check_diff
with:
paths-ignore: docs/* ci/jenkins/* *.md hack/.notableofcontents plugins/*
outputs:
has_changes: ${{ steps.check_diff.outputs.has_changes }}

build-ubi:
needs: check-changes
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
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@v4
with:
show-progress: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Build Antrea UBI8 Docker image without pushing to registry
run: |
./hack/build-antrea-linux-all.sh --pull --distro ubi
- name: Save Antrea image to tarball
run: docker save -o antrea-ubi.tar antrea/antrea-agent-ubi:latest antrea/antrea-controller-ubi:latest
- name: Upload Antrea UBI image for subsequent jobs
uses: actions/upload-artifact@v4
with:
name: antrea-ubi
path: antrea-ubi.tar
retention-days: 1 # minimum value, in case artifact deletion by 'artifact-cleanup' job fails

test-ubi-e2e-basic:
name: Basic e2e tests for UBI image on a Kind cluster on Linux
needs: [build-ubi]
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@v4
with:
show-progress: false
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Download Antrea UBI image from previous job
uses: actions/download-artifact@v4
with:
name: antrea-ubi
- name: Load Antrea UBI image
run: |
docker load -i antrea-ubi.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
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: Run basic e2e tests
run: |
mkdir log
ANTREA_LOG_DIR=$PWD/log ./ci/kind/test-e2e-kind.sh --encap-mode encap \
--antrea-controller-image antrea/antrea-controller-ubi \
--antrea-agent-image antrea/antrea-agent-ubi \
--run '^TestBasic$'
- name: Tar log files
if: ${{ failure() }}
run: tar -czf log.tar.gz log
- name: Upload test log
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: e2e-kind-ubi-basic.tar.gz
path: log.tar.gz
retention-days: 30

artifact-cleanup:
name: Delete uploaded images
needs:
- build-ubi
- test-ubi-e2e-basic
runs-on: [ubuntu-latest]
steps:
- name: Create empty file to overwrite artifacts
run: |
touch empty-artifact
- name: Delete antrea-ubi
if: ${{ needs.build-ubi.result == 'success' }}
uses: actions/upload-artifact@v4
with:
name: antrea-ubi
path: empty-artifact
retention-days: 1 # minimum value
overwrite: true

0 comments on commit 2f7f74f

Please sign in to comment.