Skip to content

Commit

Permalink
ci: Use per-branch CI container images.
Browse files Browse the repository at this point in the history
That allows us to use different distro bases for different stable
branches.

Signed-off-by: Dumitru Ceara <[email protected]>
  • Loading branch information
dceara committed Nov 15, 2023
1 parent 43842a2 commit 5b0e4f7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
9 changes: 8 additions & 1 deletion .ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-fedora"
IMAGE_NAME=${IMAGE_NAME:-${DEFAULT_IMAGE_NAME}}

# Test variables
ARCH=${ARCH:-$(uname -m)}
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
arm_unit_tests_task:

arm_container:
image: ghcr.io/ovn-org/ovn-tests:fedora
image: ghcr.io/ovn-org/ovn-tests:main-fedora
memory: 4G
cpu: 2

Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,13 +32,22 @@ 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 }}
archs: amd64, arm64
tags: ${{ matrix.distro }}
tags: ${{ env.IMAGE_BRANCH }}-${{ matrix.distro }}
build-args: CONTAINERS_PATH=${{ env.CONTAINERS_PATH }}
dockerfiles: ${{ env.CONTAINERS_PATH }}/${{ matrix.distro }}/Dockerfile

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -134,6 +133,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'
Expand Down
4 changes: 2 additions & 2 deletions utilities/containers/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CONTAINER_CMD ?= podman
IMAGE_NAME ?= "ovn-org/ovn-tests"
IMAGE_NAME ?= "ovn-org/ovn-tests:main"
CONTAINERS_PATH ?= "."

distros := fedora ubuntu

.PHONY: $(distros)

$(distros):
$(CONTAINER_CMD) build --no-cache --rm -t $(IMAGE_NAME):$@ \
$(CONTAINER_CMD) build --no-cache --rm -t $(IMAGE_NAME)-$@ \
-f $@/Dockerfile . --build-arg=CONTAINERS_PATH=$(CONTAINERS_PATH)

0 comments on commit 5b0e4f7

Please sign in to comment.