Skip to content

Commit 8976081

Browse files
authored
Fixes in Makefile and Workflows (#108)
* Makefile format * Style * Better on pr workflow * Service instead docker setup
1 parent e894bf8 commit 8976081

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

.github/workflows/checks.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
name: Python package
1+
name: Python tests
22

33
on:
44
pull_request:
55

6-
76
jobs:
87
test:
98
name: Unit tests
109
runs-on: ubuntu-latest
10+
services:
11+
postgres:
12+
image: postgres:15
13+
env:
14+
POSTGRES_HOST_AUTH_METHOD: trust
15+
options: >-
16+
--health-cmd pg_isready
17+
--health-interval 10s
18+
--health-timeout 5s
19+
--health-retries 5
20+
-p 5432:5432
1121
steps:
1222
- name: Checkout
1323
uses: actions/checkout@v4
14-
- name: Set up docker
15-
uses: docker-practice/actions-setup-docker@master
16-
- name: Run postgres
17-
run: |
18-
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-test postgres:15-alpine
1924
- uses: actions/setup-python@v4
2025
with:
21-
python-version: '3.11'
26+
python-version: "3.11"
2227
- name: Install dependencies
2328
run: |
2429
python -m ensurepip
@@ -28,8 +33,10 @@ jobs:
2833
run: |
2934
DB_DSN=postgresql://postgres@localhost:5432/postgres alembic upgrade head
3035
- name: Build coverage file
36+
id: pytest
3137
run: |
3238
DB_DSN=postgresql://postgres@localhost:5432/postgres pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=calendar_backend tests/ | tee pytest-coverage.txt
39+
exit ${PIPESTATUS[0]}
3340
- name: Print report
3441
if: always()
3542
run: |
@@ -48,6 +55,10 @@ jobs:
4855
remove-link-from-badge: false
4956
junitxml-path: ./pytest.xml
5057
junitxml-title: Summary
58+
- name: Fail on pytest errors
59+
if: steps.pytest.outcome == 'failure'
60+
run: exit 1
61+
5162
linting:
5263
runs-on: ubuntu-latest
5364
steps:
@@ -60,7 +71,7 @@ jobs:
6071
requirementsFiles: "requirements.txt requirements.dev.txt"
6172
- uses: psf/black@stable
6273
- name: Comment if linting failed
63-
if: ${{ failure() }}
74+
if: failure()
6475
uses: thollander/actions-comment-pull-request@v2
6576
with:
6677
message: |

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ format:
1111
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./calendar_backend
1212
source ./venv/bin/activate && isort ./calendar_backend
1313
source ./venv/bin/activate && black ./calendar_backend
14+
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./tests
15+
source ./venv/bin/activate && isort ./tests
16+
source ./venv/bin/activate && black ./tests
17+
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./migrations
18+
source ./venv/bin/activate && isort ./migrations
19+
source ./venv/bin/activate && black ./migrations
1420

1521
db:
1622
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-timetable_api postgres:15

calendar_backend/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from functools import lru_cache
33

44
from auth_lib.fastapi import UnionAuthSettings
5-
from pydantic import AnyHttpUrl, ConfigDict, DirectoryPath, Json, PostgresDsn
5+
from pydantic import AnyHttpUrl, ConfigDict, DirectoryPath, PostgresDsn
66
from pydantic_settings import BaseSettings
77

88

migrations/versions/63263ee9e08e_fix_photo_paths.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
"""
88

9-
import sqlalchemy as sa
109
from alembic import op
1110

1211

0 commit comments

Comments
 (0)