Skip to content

Commit

Permalink
Modify GitHub Action Python application
Browse files Browse the repository at this point in the history
+ poetry changes
  • Loading branch information
BraunRudolf committed Jul 29, 2024
1 parent 907ab45 commit da1a776
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 12 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/python_app.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application
name: FastAPI Backend

on:
push:
Expand All @@ -14,8 +11,8 @@ permissions:

jobs:
build:

runs-on: ubuntu-latest
working-directory: backend-app
env:
FASTAPI_SECRET_KEY: ${{secrets.FASTAPI_SECRET_KEY}}
FASTAPI_HASH_ALGORITHM: ${{secrets.FASTAPI_HASH_ALGORITHM}}
Expand All @@ -25,24 +22,33 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install poetry==1.8.3
poetry install --no-cache
if [ -f pyproject.toml]; then poetry install
elif [-f requirements.txt ]; then pip install -r requirements.txt;
fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Black check
run: |
black --check app/
enforce:
always:
- name: Test with pytest
run: |
# Test backend
cd backend-app
pytest --cov=app tests
coverage run --source=app -m pytest tests
coverage report -m
84 changes: 83 additions & 1 deletion backend-app/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions backend-app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ psycopg2-binary = "^2.9.9"
[tool.poetry.group.dev.dependencies]
pytest = "^8.3.2"
black = "^24.4.2"
coverage = "^7.6.0"
pytest-cov = "^5.0.0"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit da1a776

Please sign in to comment.