diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 616c22f..095f605 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,11 +24,27 @@ env: PYTHONIOENCODING: "UTF-8" jobs: - test: + build-test-push: runs-on: ubuntu-latest + env: + DOCKER_REPO: tecnativa/docker-socket-proxy steps: - # Shared steps - - uses: actions/checkout@v1 + # Prepare Docker environment and build + - uses: actions/checkout@v2 + - uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Build image(s) + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm/v8,linux/arm64,linux/ppc64le,linux/s390x + load: true # Make image available for next steps. See https://github.com/docker/build-push-action#export-image-to-docker + push: false + tags: | + ${{ env.DOCKER_REPO }}:local + # Set up and run tests - name: Install python uses: actions/setup-python@v1 with: @@ -51,17 +67,6 @@ jobs: - run: poetry install # Run tests - run: poetry run pytest - build-push: - runs-on: ubuntu-latest - needs: test - env: - DOCKER_REPO: tecnativa/docker-socket-proxy - steps: - # Prepare - - uses: actions/checkout@v2 - - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 # Build and push - name: Login to DockerHub uses: docker/login-action@v1 @@ -75,6 +80,9 @@ jobs: username: ${{ secrets.BOT_LOGIN }} password: ${{ secrets.BOT_TOKEN }} - name: Build and push + if: + github.repository == 'Tecnativa/docker-socket-proxy' && github.ref == + 'refs/heads/master' uses: docker/build-push-action@v2 with: context: . diff --git a/tests/conftest.py b/tests/conftest.py index 69a779b..7069363 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import json +import os from contextlib import contextmanager from logging import info from pathlib import Path @@ -7,7 +8,8 @@ from plumbum import local from plumbum.cmd import docker -IMAGE_NAME = "docker-socket-proxy:local" +DOCKER_REPO = os.environ.get("DOCKER_REPO", "docker-socket-proxy") +IMAGE_NAME = f"{DOCKER_REPO}:local" @pytest.fixture(autouse=True, scope="session")