Skip to content

Commit

Permalink
Build image before testing and push at the end
Browse files Browse the repository at this point in the history
Builds the image (in single arch) before testing
Loads the image into local docker (See https://github.com/docker/build-push-action#export-image-to-docker)
Rebuilds and pushes the final image in multi-arch at the end.
  • Loading branch information
joao-p-marques committed Dec 3, 2020
1 parent 764ece5 commit d2416e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
36 changes: 22 additions & 14 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
# HACK: Build single platform image for testing. See https://github.com/docker/buildx/issues/59
load: true
push: false
tags: |
${{ env.DOCKER_REPO }}:local
# Set up and run tests
- name: Install python
uses: actions/setup-python@v1
with:
Expand All @@ -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
Expand All @@ -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: .
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
from contextlib import contextmanager
from logging import info
from pathlib import Path
Expand All @@ -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")
Expand Down

0 comments on commit d2416e8

Please sign in to comment.