-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add first version of tests From #14 * Expand tests * Add GH CI * Apply suggestions * Apply autopretty template + fix prettier * Fix isort * Apply autoprettier * Fix VSCode settings * Make tests run in parallel * Build docker image before testing * Update workspace settings * Try multi-platform builds and push to ghcr.io * Push to docker hub as well from ci * Upgrade autopretty * Update pyproject configurations * Improve test configuration and execution TT26468 * Provide initial conftest * Improve tests * Add python3 in image * Remove POST rule from proxy * 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. * Fix python path * Remove build fixture from tests to see if image is built in CI * Organize docker tests definition and document * Restore fixture allowing usage for local testing This reverts commit dc0b60e and allows using `--prebuild` CLI flag for pytest when doing local tests. Co-authored-by: Jairo Llopis <[email protected]>
- Loading branch information
1 parent
a07d4ae
commit e84babd
Showing
17 changed files
with
1,255 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Changes here will be overwritten by Copier; do NOT edit manually | ||
_commit: v0.1.0a5 | ||
_src_path: https://github.com/copier-org/autopretty.git | ||
ansible: false | ||
biggest_kbs: 0 | ||
github: true | ||
js: false | ||
protected_branches: | ||
- master | ||
python: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.py] | ||
# For isort | ||
profile = black | ||
|
||
[*.{code-snippets,code-workspace,json,yaml,yml}{,.jinja}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
ignore = E203, E501, W503, B950 | ||
max-line-length = 88 | ||
select = C,E,F,W,B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
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: | ||
build-test-push: | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCKER_REPO: tecnativa/docker-socket-proxy | ||
steps: | ||
# 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: | ||
python-version: "3.9" | ||
- name: Generate cache key CACHE | ||
run: | ||
echo "CACHE=${{ secrets.CACHE_DATE }} ${{ runner.os }} $(python -VV | | ||
sha256sum | cut -d' ' -f1) ${{ hashFiles('pyproject.toml') }} ${{ | ||
hashFiles('poetry.lock') }}" >> $GITHUB_ENV | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
.cache.~ | ||
.venv | ||
~/.local/bin | ||
key: venv ${{ env.CACHE }} | ||
- run: pip install poetry | ||
- name: Patch $PATH | ||
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
- run: poetry install | ||
# Run tests | ||
- run: poetry run pytest | ||
env: | ||
DOCKER_IMAGE_NAME: ${{ env.DOCKER_REPO }}:local | ||
# 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: . | ||
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: | | ||
ghcr.io/${{ env.DOCKER_REPO }} | ||
${{ env.DOCKER_REPO }} |
Oops, something went wrong.