Skip to content
Merged
Changes from all commits
Commits
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
51 changes: 41 additions & 10 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,60 @@ jobs:
test:
name: Unit tests
runs-on: ubuntu-latest
env:
DB_DSN: postgresql://postgres@localhost:5432/postgres
REDIS_DSN: redis://localhost:6379/0

services:
postgres:
image: postgres:15
ports:
- 5432:5432
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up docker
uses: docker-practice/actions-setup-docker@master

- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m ensurepip
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements.dev.txt
- name: Run postgres
run: |
make db

- name: Migrate DB
run: |
make migrate
- name: Run redis
run: |
make redis
alembic upgrade head

- name: Build coverage file
run: |
DB_DSN=postgresql://postgres@localhost:5432/postgres pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=print_service tests/ | tee pytest-coverage.txt
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=print_service tests/ | tee pytest-coverage.txt

- name: Print report
if: always()
run: |
cat pytest-coverage.txt

- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
Expand All @@ -51,17 +76,23 @@ jobs:
remove-link-from-badge: false
junitxml-path: ./pytest.xml
junitxml-title: Summary


linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v2
with:
python-version: 3.11

- uses: isort/isort-action@master
with:
requirementsFiles: "requirements.txt requirements.dev.txt"

- uses: psf/black@stable

- name: Comment if linting failed
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@v2
Expand Down