2020-11-09 16:34:11 +00:00
|
|
|
name: test
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
2020-11-25 07:40:58 +00:00
|
|
|
- master
|
2020-11-09 16:34:11 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
pytest_addopts:
|
|
|
|
description:
|
|
|
|
Extra options for pytest; use -vv for full details; see
|
|
|
|
https://docs.pytest.org/en/latest/example/simple.html#how-to-change-command-line-options-defaults
|
|
|
|
required: false
|
|
|
|
|
|
|
|
env:
|
|
|
|
LANG: "en_US.utf-8"
|
|
|
|
LC_ALL: "en_US.utf-8"
|
|
|
|
PIP_CACHE_DIR: ${{ github.workspace }}/.cache.~/pip
|
|
|
|
PIPX_HOME: ${{ github.workspace }}/.cache.~/pipx
|
|
|
|
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache.~/pypoetry
|
|
|
|
POETRY_VIRTUALENVS_IN_PROJECT: "true"
|
|
|
|
PYTEST_ADDOPTS: ${{ github.event.inputs.pytest_addopts }}
|
|
|
|
PYTHONIOENCODING: "UTF-8"
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
# Shared steps
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- name: Install python
|
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
2020-11-25 07:52:57 +00:00
|
|
|
python-version: "3.9"
|
2020-11-09 16:34:11 +00:00
|
|
|
- name: Generate cache key CACHE
|
|
|
|
run:
|
2020-11-25 07:52:57 +00:00
|
|
|
echo "CACHE=${{ secrets.CACHE_DATE }} ${{ runner.os }} $(python -VV |
|
|
|
|
sha256sum | cut -d' ' -f1) ${{ hashFiles('pyproject.toml') }} ${{
|
|
|
|
hashFiles('poetry.lock') }}" >> $GITHUB_ENV
|
2020-11-25 07:40:58 +00:00
|
|
|
- uses: actions/cache@v2
|
2020-11-09 16:34:11 +00:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
.cache.~
|
|
|
|
.venv
|
|
|
|
~/.local/bin
|
|
|
|
key: venv ${{ env.CACHE }}
|
|
|
|
- run: pip install poetry
|
|
|
|
- name: Patch $PATH
|
2020-11-26 09:39:56 +00:00
|
|
|
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
2020-11-09 16:34:11 +00:00
|
|
|
- run: poetry install
|
|
|
|
# Run tests
|
|
|
|
- run: poetry run pytest
|
2020-11-25 11:09:46 +00:00
|
|
|
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
|
2020-11-26 09:39:56 +00:00
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_LOGIN }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2020-11-25 11:09:46 +00:00
|
|
|
- name: Login to GitHub Container Registry
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
2020-11-26 09:39:56 +00:00
|
|
|
username: ${{ secrets.BOT_LOGIN }}
|
|
|
|
password: ${{ secrets.BOT_TOKEN }}
|
2020-11-25 11:09:46 +00:00
|
|
|
- name: Build and push
|
|
|
|
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: false
|
|
|
|
push: true
|
|
|
|
tags: |
|
2020-11-26 09:39:56 +00:00
|
|
|
ghcr.io/${{ env.DOCKER_REPO }}
|
|
|
|
${{ env.DOCKER_REPO }}
|