mirror of
https://github.com/Tecnativa/docker-socket-proxy
synced 2024-12-21 22:28:07 +00:00
Build image before testing and push at the end
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.
This commit is contained in:
parent
764ece57aa
commit
d9d5b44235
42
.github/workflows/test.yaml
vendored
42
.github/workflows/test.yaml
vendored
@ -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:
|
||||
@ -51,30 +67,28 @@ 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
|
||||
if:
|
||||
github.repository == 'Tecnativa/docker-socket-proxy' && github.ref ==
|
||||
'refs/heads/master'
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_LOGIN }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Login to GitHub Container Registry
|
||||
if:
|
||||
github.repository == 'Tecnativa/docker-socket-proxy' && github.ref ==
|
||||
'refs/heads/master'
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
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: .
|
||||
|
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
from logging import info
|
||||
from pathlib import Path
|
||||
@ -7,7 +8,8 @@ import pytest
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user