From 270f83b615017418d9fb2f4eee9311db28deb272 Mon Sep 17 00:00:00 2001 From: Dumitru Ceara Date: Tue, 14 Nov 2023 22:34:56 +0100 Subject: [PATCH] ci: Use per-branch CI container images. That allows us to use different distro bases for different stable branches. Signed-off-by: Dumitru Ceara --- .ci/ci.sh | 9 ++++++++- .github/workflows/containers.yml | 13 ++++++++++--- .github/workflows/test.yml | 7 ++++++- utilities/containers/Makefile | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.ci/ci.sh b/.ci/ci.sh index 3f1b41eadc..ff607b9ed4 100755 --- a/.ci/ci.sh +++ b/.ci/ci.sh @@ -20,7 +20,8 @@ DPDK_PATH=${DPDK_PATH:-$OVN_PATH/dpdk-dir} CONTAINER_CMD=${CONTAINER_CMD:-podman} CONTAINER_WORKSPACE="/workspace" CONTAINER_WORKDIR="/workspace/ovn-tmp" -IMAGE_NAME=${IMAGE_NAME:-"ovn-org/ovn-tests"} +DEFAULT_IMAGE_NAME="ovn-org/ovn-tests-main" +IMAGE_NAME=${IMAGE_NAME:-${DEFAULT_IMAGE_NAME}} # Test variables ARCH=${ARCH:-$(uname -m)} @@ -167,6 +168,12 @@ if [ -z "$DPDK" ]; then mkdir -p "$DPDK_PATH" fi +# Check if the IMAGE_NAME is a real image we can pull, otherwise fall +# back to DEFAULT_IMAGE_NAME. +if ! $CONTAINER_CMD pull $IMAGE_NAME; then + IMAGE_NAME=$DEFAULT_IMAGE_NAME +fi + CONTAINER_ID="$($CONTAINER_CMD run --privileged -d \ --pids-limit=-1 \ --env ASAN_OPTIONS=$ASAN_OPTIONS \ diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index bdd1180872..8027b802c5 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -7,8 +7,6 @@ on: - cron: '0 0 * * 1' env: - IMAGE_REGISTRY: ghcr.io - IMAGE_NAMESPACE: ovn-org IMAGE_NAME: ovn-tests CONTAINERS_PATH: ./utilities/containers DEPENDENCIES: podman @@ -31,11 +29,20 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v2 + - name: Build image name + run: | + echo "IMAGE_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \ + >> $GITHUB_ENV + echo "IMAGE_REGISTRY=ghcr.io" \ + >> $GITHUB_ENV + echo "IMAGE_NAMESPACE=$GITHUB_REPOSITORY_OWNER" \ + >> $GITHUB_ENV + - name: Build container images id: build-image uses: redhat-actions/buildah-build@v2 with: - image: ${{ env.IMAGE_NAME }} + image: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_BRANCH }} archs: amd64, arm64 tags: ${{ matrix.distro }} build-args: CONTAINERS_PATH=${{ env.CONTAINERS_PATH }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2741f4c651..486f457b40 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -83,7 +83,6 @@ jobs: build-linux: needs: build-dpdk env: - IMAGE_NAME: ghcr.io/ovn-org/ovn-tests:ubuntu ARCH: ${{ matrix.cfg.arch }} CC: ${{ matrix.cfg.compiler }} DPDK: ${{ matrix.cfg.dpdk }} @@ -128,6 +127,12 @@ jobs: with: submodules: recursive + - name: Build image name + run: | + IMAGE_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + echo "IMAGE_NAME=ghcr.io/$GITHUB_REPOSITORY_OWNER/ovn-tests-$IMAGE_BRANCH:ubuntu" \ + >> $GITHUB_ENV + # For weekly runs, don't update submodules - name: checkout without submodule if: github.event_name == 'schedule' diff --git a/utilities/containers/Makefile b/utilities/containers/Makefile index d79e4ad5ee..61e9829e9c 100644 --- a/utilities/containers/Makefile +++ b/utilities/containers/Makefile @@ -1,5 +1,5 @@ CONTAINER_CMD ?= podman -IMAGE_NAME ?= "ovn-org/ovn-tests" +IMAGE_NAME ?= "ovn-org/ovn-tests-main" CONTAINERS_PATH ?= "." distros := fedora ubuntu