Skip to content

Commit

Permalink
ci: generalize container test step
Browse files Browse the repository at this point in the history
Generalize container test step by using include feature of matrix
strategy and defining additional values for container command test and
config verification.

Signed-off-by: Christian Marangi <[email protected]>
  • Loading branch information
Ansuel authored and ynezz committed Nov 14, 2023
1 parent 7a5c3c3 commit b9790bc
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ jobs:
strategy:
fail-fast: ${{ github.event_name == 'pull_request' }}
matrix:
container_flavor:
- master
- worker
include:
- container_flavor: master
container_verify_string: "buildmaster configured in /master"
- container_flavor: worker
container_test_command: "--env BUILDWORKER_NAME=X --env BUILDWORKER_PASSWORD=Y"
container_verify_string: "worker configured in /builder"

steps:
- name: Checkout
Expand All @@ -76,21 +79,12 @@ jobs:
BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }}
OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }}
- name: Test master Docker container
if: matrix.container_flavor == 'master'
- name: Test ${{ matrix.container_flavor }} Docker container
run: |
docker run --detach --name test-master local/master
docker run --detach ${{ matrix.container_test_command }} --name test-${{ matrix.container_flavor }} local/${{ matrix.container_flavor }}
sleep 5
docker logs test-master | tee master.log
grep "buildmaster configured in /master" master.log
- name: Test worker Docker container
if: matrix.container_flavor == 'worker'
run: |
docker run --detach --env BUILDWORKER_NAME=X --env BUILDWORKER_PASSWORD=Y --name test-worker local/worker
sleep 5
docker logs test-worker | tee worker.log
grep "worker configured in /builder" worker.log
docker logs test-${{ matrix.container_flavor }} | tee ${{ matrix.container_flavor }}.log
grep "${{ matrix.container_verify_string }}" ${{ matrix.container_flavor }}.log
- name: Docker meta
id: meta
Expand Down

0 comments on commit b9790bc

Please sign in to comment.