Skip to content

Commit

Permalink
Fixes in Makefile and Workflows (#28)
Browse files Browse the repository at this point in the history
* Makefile format

* Better on pr workflow

* Makefile

* Service instead docker setup
  • Loading branch information
dyakovri authored Apr 6, 2024
1 parent 74797ae commit 174c4f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/tests.yml → .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
name: Python package
name: Python tests

on:
pull_request:


jobs:
test:
name: Unit tests
runs-on: ubuntu-latest
continue-on-error: true
services:
postgres:
image: postgres:15
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
-p 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up docker
uses: docker-practice/actions-setup-docker@master
- name: Run postgres
run: |
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-test postgres:15-alpine
- uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: "3.11"
- name: Install dependencies
run: |
python -m ensurepip
Expand All @@ -29,8 +33,10 @@ jobs:
run: |
DB_DSN=postgresql://postgres@localhost:5432/postgres alembic upgrade head
- name: Build coverage file
id: pytest
run: |
DB_DSN=postgresql://postgres@localhost:5432/postgres pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=userdata_api tests/ | tee pytest-coverage.txt
exit ${PIPESTATUS[0]}
- name: Print report
if: always()
run: |
Expand All @@ -50,6 +56,10 @@ jobs:
unique-id-for-comment: python3.11
junitxml-path: ./pytest.xml
junitxml-title: Summary
- name: Fail on pytest errors
if: steps.pytest.outcome == 'failure'
run: exit 1

linting:
runs-on: ubuntu-latest
steps:
Expand All @@ -62,7 +72,7 @@ jobs:
requirementsFiles: "requirements.txt requirements.dev.txt"
- uses: psf/black@stable
- name: Comment if linting failed
if: ${{ failure() }}
if: failure()
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Expand Down
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ venv:
python3.11 -m venv venv

format:
autoflake -r --in-place --remove-all-unused-imports ./userdata_api
isort ./userdata_api
black ./userdata_api

dev-format: format
autoflake -r --in-place --remove-all-unused-imports ./tests
isort ./tests
black ./tests
autoflake -r --in-place --remove-all-unused-imports ./migrations
isort ./migrations
black ./migrations

source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./userdata_api
source ./venv/bin/activate && isort ./userdata_api
source ./venv/bin/activate && black ./userdata_api
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./tests
source ./venv/bin/activate && isort ./tests
source ./venv/bin/activate && black ./tests
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./migrations
source ./venv/bin/activate && isort ./migrations
source ./venv/bin/activate && black ./migrations

db:
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-userdata_api postgres:15
Expand Down

0 comments on commit 174c4f4

Please sign in to comment.