From bc6b4df9236bc0701e20305627b5234a340170c4 Mon Sep 17 00:00:00 2001 From: fliiiix Date: Tue, 12 Nov 2019 15:30:19 +0100 Subject: [PATCH 1/3] feat(workflow): run python tests --- .github/workflows/backend-test.yml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/backend-test.yml diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml new file mode 100644 index 000000000..a4015c035 --- /dev/null +++ b/.github/workflows/backend-test.yml @@ -0,0 +1,36 @@ +name: Python package + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + - name: Lint with flake8 + working-directory: backend + run: | + pip install flake8 + flake8 --show-source app.py + - name: Lint with black + working-directory: backend + run: | + pip install black + black --check app.py + - name: Lint with isort + working-directory: backend + run: | + pip install isort + isort --check-only app.py From e48a384cb7c6b70771e5a7fbe11f49529db560af Mon Sep 17 00:00:00 2001 From: fliiiix Date: Tue, 12 Nov 2019 15:52:59 +0100 Subject: [PATCH 2/3] fix(backend): reformat app.py --- backend/app.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/app.py b/backend/app.py index e97cc1fa7..f16b12c81 100644 --- a/backend/app.py +++ b/backend/app.py @@ -74,10 +74,15 @@ def tag(project, version, new_tag): # overwrite the tag dst.unlink() dst.symlink_to(src) - return { - "message": f"Tag {new_tag} -> {version} successfully created" - }, HTTPStatus.CREATED + return ( + {"message": f"Tag {new_tag} -> {version} successfully created"}, + HTTPStatus.CREATED, + ) else: - return { - "message": f"Tag {new_tag} could not be created, because it would overwrite a version!" - }, HTTPStatus.CONFLICT + msg = ( + f"Tag {new_tag} could not be created, because it would overwrite a version!" + ) + return ( + {"message": msg}, + HTTPStatus.CONFLICT, + ) From 001adc3e39cd920bdfc62dec0f9b7b9275665b69 Mon Sep 17 00:00:00 2001 From: Benj Fassbind Date: Tue, 12 Nov 2019 18:39:14 +0100 Subject: [PATCH 3/3] build: use tox and combine workflows combine workflows so that tests are executed before a container is deployed --- .github/workflows/backend-test.yml | 36 -------------------- .github/workflows/{docker.yml => docat.yml} | 37 +++++++++++++++++++-- backend/tox.ini | 18 +++++----- 3 files changed, 45 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/backend-test.yml rename .github/workflows/{docker.yml => docat.yml} (52%) diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml deleted file mode 100644 index a4015c035..000000000 --- a/.github/workflows/backend-test.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Python package - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - - name: Lint with flake8 - working-directory: backend - run: | - pip install flake8 - flake8 --show-source app.py - - name: Lint with black - working-directory: backend - run: | - pip install black - black --check app.py - - name: Lint with isort - working-directory: backend - run: | - pip install isort - isort --check-only app.py diff --git a/.github/workflows/docker.yml b/.github/workflows/docat.yml similarity index 52% rename from .github/workflows/docker.yml rename to .github/workflows/docat.yml index b8a5e1c79..585216721 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docat.yml @@ -1,11 +1,44 @@ -name: docker ci +name: docat ci on: [push] jobs: - build: + test: + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + - name: lint with flake8 + working-directory: backend + run: | + tox -e flake8 + + - name: lint with black + working-directory: backend + run: | + tox -e black + + - name: lint with isort + working-directory: backend + run: | + tox -e isort + docker: runs-on: ubuntu-latest steps: diff --git a/backend/tox.ini b/backend/tox.ini index a10a93d4a..e1e658c74 100644 --- a/backend/tox.ini +++ b/backend/tox.ini @@ -1,12 +1,14 @@ [tox] -envlist = lint -skip_missing_interpreters = True skipsdist = True -[testenv:lint] +[testenv:flake8] deps = flake8 - black - isort -commands = flake8 --show-source app.py - black --check app.py - isort --check-only app.py +commands = flake8 --show-source app.py {posargs} + +[testenv:black] +deps = black +commands = black --check app.py {posargs} + +[testenv:isort] +deps = isort +commands = isort --check-only app.py {posargs}