Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

test: Adds basic test suite for the project #16

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
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
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@ on:
branches: main

jobs:
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.6.1"
- name: Resolve dependencies
run: poetry export -f requirements.txt --without-hashes --with dev --output requirements.txt
- name: Build & run docker
env:
SUPERUSER_LOGIN: ${{ secrets.SUPERUSER_LOGIN }}
SUPERUSER_ID: ${{ secrets.SUPERUSER_ID }}
SUPERUSER_PWD: ${{ secrets.SUPERUSER_PWD }}
GH_OAUTH_ID: ${{ secrets.GH_OAUTH_ID }}
GH_OAUTH_SECRET: ${{ secrets.GH_OAUTH_SECRET }}
run: docker compose -f docker-compose.test.yml up -d --build
- name: Run docker test
run: |
docker compose -f docker-compose.test.yml exec -T backend pytest --cov=app --cov-report xml tests/
docker compose -f docker-compose.test.yml cp backend:/app/coverage.xml ./coverage-src.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage-src.xml
flags: unittests
fail_ci_if_error: true

headers:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ run:
stop:
docker compose down

run-dev:
poetry export -f requirements.txt --without-hashes --with dev --output requirements.txt
docker compose -f docker-compose.test.yml up -d --build

stop-dev:
docker compose -f docker-compose.test.yml down

# Run tests for the library
test:
poetry export -f requirements.txt --without-hashes --with dev --output requirements.txt
docker compose -f docker-compose.test.yml up -d --build
docker compose exec -T backend pytest --cov=app
docker compose -f docker-compose.test.yml down

add-revision:
docker compose exec backend alembic revision --autogenerate

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:
backend:
build: .
command: uvicorn app.main:app --host 0.0.0.0 --port 8050
volumes:
- ./src/:/app/
ports:
- "8050:8050"
environment:
Expand Down
Loading
Loading