Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and CI #34

Merged
merged 25 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0a0b6f8
Add first version of tests
joao-p-marques Oct 29, 2020
05ba0be
Expand tests
joao-p-marques Nov 9, 2020
0dec9ac
Add GH CI
joao-p-marques Nov 9, 2020
ffdd442
Apply suggestions
joao-p-marques Nov 25, 2020
c2fc1ff
Apply autopretty template + fix prettier
joao-p-marques Nov 25, 2020
7bd86a5
Fix isort
joao-p-marques Nov 25, 2020
0206be6
Apply autoprettier
joao-p-marques Nov 25, 2020
b21d6d8
Fix VSCode settings
joao-p-marques Nov 25, 2020
0b7c5d9
Make tests run in parallel
joao-p-marques Nov 25, 2020
8d09134
Build docker image before testing
joao-p-marques Nov 25, 2020
38f530a
Update workspace settings
joao-p-marques Nov 25, 2020
d2dad86
Try multi-platform builds and push to ghcr.io
joao-p-marques Nov 25, 2020
856cb49
Push to docker hub as well from ci
joao-p-marques Nov 26, 2020
a7d91ef
Upgrade autopretty
joao-p-marques Nov 26, 2020
f3366b5
Update pyproject configurations
joao-p-marques Nov 26, 2020
0c41d3a
Improve test configuration and execution
joao-p-marques Dec 1, 2020
91c0652
Provide initial conftest
Dec 2, 2020
3cf4ee6
Improve tests
joao-p-marques Dec 2, 2020
1f4bd85
Add python3 in image
joao-p-marques Dec 2, 2020
764ece5
Remove POST rule from proxy
joao-p-marques Dec 3, 2020
d9d5b44
Build image before testing and push at the end
joao-p-marques Dec 3, 2020
47f8f46
Fix python path
joao-p-marques Dec 3, 2020
dc0b60e
Remove build fixture from tests to see if image is built in CI
joao-p-marques Dec 4, 2020
b46fc70
Organize docker tests definition and document
joao-p-marques Dec 4, 2020
15071f7
Restore fixture allowing usage for local testing
Dec 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .copier-answers.autopretty.yml
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
16 changes: 16 additions & 0 deletions .editorconfig
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
4 changes: 4 additions & 0 deletions .flake8
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
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yml
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]
103 changes: 103 additions & 0 deletions .github/workflows/test.yaml
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
Comment on lines +3 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is the time to implement #33 (comment)?

I'm developing for TT25794 a new python lib that will help know that you're currently in the latest tag. I'll notify you when it's done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good suggestion. I agree that it makes sense now. I'll wait for your call then.


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 }}
Loading