diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml index fdf2b1a5238f..5180dacf7b5c 100644 --- a/.github/workflows/docker-tests.yml +++ b/.github/workflows/docker-tests.yml @@ -16,6 +16,12 @@ on: jobs: test_docker_image: + strategy: + # we could run all the flavors in a single pytest job, + # but let's split them (and the image build) in multiple runners for performance + matrix: + flavor: ["slim", "debian"] + runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -30,37 +36,13 @@ jobs: with: config: .github/buildkit.toml - - name: "Build flavor: slim" - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile - tags: crowdsecurity/crowdsec:test-slim - target: slim - platforms: linux/amd64 - load: true - cache-from: type=gha - cache-to: type=gha,mode=min - - - name: "Build flavor: full" - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile - tags: crowdsecurity/crowdsec:test - target: full - platforms: linux/amd64 - load: true - cache-from: type=gha - cache-to: type=gha,mode=min - - - name: "Build flavor: full (debian)" + - name: "Build image" uses: docker/build-push-action@v5 with: context: . - file: ./Dockerfile.debian - tags: crowdsecurity/crowdsec:test-debian - target: full + file: ./Dockerfile${{ matrix.flavor == 'debian' && '.debian' || '' }} + tags: crowdsecurity/crowdsec:test${{ matrix.flavor == 'full' && '' || join('-', matrix.flavor) }} + target: ${{ matrix.flavor == 'debian' && 'full' || matrix.flavor }} platforms: linux/amd64 load: true cache-from: type=gha @@ -95,9 +77,10 @@ jobs: - name: "Run tests" env: CROWDSEC_TEST_VERSION: test - CROWDSEC_TEST_FLAVORS: slim,debian + CROWDSEC_TEST_FLAVORS: ${{ matrix.flavor }} CROWDSEC_TEST_NETWORK: net-test CROWDSEC_TEST_TIMEOUT: 90 + # running serially to reduce test flakiness run: | cd docker/test - pipenv run pytest -n 2 --durations=0 --color=yes + pipenv run pytest -n 1 --durations=0 --color=yes