Skip to content

Commit

Permalink
ci: update CI pipeline image build tests
Browse files Browse the repository at this point in the history
- Move build-and-test-image to actions
- Run image test on PR and push to main
- Run tests against multiple arch's
  • Loading branch information
ttuffin committed Oct 5, 2023
1 parent 53875da commit d15d9c1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .github/actions/image-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build-and-test-image
description: Build and test the container image

runs:
using: composite
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build container image
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ matrix.build-arch }}
tags: localhost/ansible-rulebook:test
load: true

- name: Run tests
shell: bash
run: >
docker run --rm -u 0 localhost/ansible-rulebook:test bash -c '
pip install -r requirements_test.txt &&
pytest -m "e2e" -n auto'
10 changes: 2 additions & 8 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build local image
run: docker build -t localhost/ansible-rulebook:test .

- name: Run tests
run: >
docker run --rm -u 0 localhost/ansible-rulebook:test bash -c '
pip install -r requirements_test.txt &&
pytest -m "e2e" -n auto'
- name: Build and test the container image
uses: ./.github/actions/image-test

build-and-push-image:
needs: build-and-test-image
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,21 @@ jobs:
flags: "unittests-${{ matrix.python-version }}"
name: codecov-umbrella
verbose: true

build-and-test-image:
# we must use a matrix because buildx load
# does not currently support multi-arch.
# https://docs.docker.com/engine/reference/commandline/buildx_build/#docker
strategy:
matrix:
build-arch:
- linux/amd64
- linux/arm64
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build and test the container image
uses: ./.github/actions/image-test

0 comments on commit d15d9c1

Please sign in to comment.