Skip to content

Commit

Permalink
ci: Build container image before very job
Browse files Browse the repository at this point in the history
Build the image before every job to allow more
fine-grained dependency pinning. This is especially
useful for stable branches as they might need to stay
on specific distribution or Python version.

This also allows us to switch to Ubuntu instead
of Fedora in the Cirrus CI for consistency reasons.

Signed-off-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
  • Loading branch information
almusil authored and dceara committed Jan 9, 2024
1 parent 66ef670 commit 910efaf
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 10 deletions.
44 changes: 37 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
arm_unit_tests_task:
compute_engine_instance:
image_project: ubuntu-os-cloud
image: family/ubuntu-2304-arm64
architecture: arm64
platform: linux
memory: 4G

# Run separate task for the image build, so it's running only once outside
# the test matrix.
build_image_task:
install_dependencies_script:
- sudo apt update
- sudo apt install -y podman make

build_container_script:
- cd utilities/containers
- make ubuntu
- podman save -o /tmp/image.tar ovn-org/ovn-tests:ubuntu

upload_image_script:
- curl -s -X POST -T /tmp/image.tar http://$CIRRUS_HTTP_CACHE_HOST/${CIRRUS_CHANGE_IN_REPO}

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

env:
ARCH: aarch64
CIRRUS_CLONE_SUBMODULES: true
PATH: ${HOME}/bin:${HOME}/.local/bin:${PATH}
RECHECK: yes
IMAGE_NAME: ovn-org/ovn-tests:ubuntu
matrix:
- CC: gcc
TESTSUITE: test
Expand All @@ -34,5 +53,16 @@ arm_unit_tests_task:

name: ARM64 ${CC} ${TESTSUITE} ${TEST_RANGE}

install_dependencies_script:
- sudo apt update
- sudo apt install -y podman

download_cache_script:
- curl http://$CIRRUS_HTTP_CACHE_HOST/${CIRRUS_CHANGE_IN_REPO} -o /tmp/image.tar

load_image_script:
- podman load -i /tmp/image.tar
- rm -rf /tmp/image.tar

build_script:
- ./.ci/linux-build.sh
- ./.ci/ci.sh --archive-logs
46 changes: 43 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,38 @@ jobs:
if: steps.dpdk_cache.outputs.cache-hit != 'true'
run: ./.ci/dpdk-build.sh

prepare-container:
env:
DEPENDENCIES: podman
name: Prepare container
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Update APT cache
run: sudo apt update

- name: Install dependencies
run: sudo apt install -y ${{ env.DEPENDENCIES }}

- name: Build container
run: make ubuntu
working-directory: utilities/containers

- name: Export image
run: podman save -o /tmp/image.tar ovn-org/ovn-tests

- name: Cache image
id: image_cache
uses: actions/cache@v3
with:
path: /tmp/image.tar
key: ${{ github.sha }}

build-linux:
needs: build-dpdk
needs: [build-dpdk, prepare-container]
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 @@ -152,13 +180,25 @@ jobs:
sort -V | tail -1)
working-directory: ovs

- name: cache
- name: cache dpdk
if: matrix.cfg.dpdk != ''
uses: actions/cache@v3
with:
path: dpdk-dir
key: ${{ needs.build-dpdk.outputs.dpdk_key }}

- name: image cache
uses: actions/cache@v3
with:
path: /tmp/image.tar
key: ${{ github.sha }}

- name: load image
run: |
sudo podman load -i /tmp/image.tar
podman load -i /tmp/image.tar
rm -rf /tmp/image.tar
- name: build
if: ${{ startsWith(matrix.cfg.testsuite, 'system-test') }}
run: sudo -E ./.ci/ci.sh --archive-logs
Expand Down

0 comments on commit 910efaf

Please sign in to comment.