Skip to content

Commit

Permalink
Add pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
cxrxixs committed May 11, 2024
1 parent 7da9c02 commit ee03b16
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 4 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: test

on: push

jobs:
test:
runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: ["3.11"]

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_DB: db_test
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
# set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout project code
uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
# python-version: ${{ matrix.python-version }}
python-version: 3.11.9

- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
- id: chache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs/
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}

- name: Install dependencies
if: steps.chache-pipenv.outputs.cache-hit != 'true'
run: |
python -m pipenv install --dev && pip install -r requirements/base.txt
- name: Apply DB migrations
run: |
pipenv run python manage.py migrate
- name: Run tests
run: |
pipenv run pytest -v
7 changes: 5 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ verify_ssl = true
ruff = "==0.4.3"
ruff-lsp = "==0.0.53"
pre-commit = "==3.7.0"
djlint = "==1.34.1"
pytest = "==8.2.0"
pytest-dotenv = "*"
pytest-django = "*"

[packages]
pip = "24.0"

[requires]
python_version = "3.11"


[scripts]
test = "pytest"
pre-commit = "pre-commit run --show-diff-on-failure --color=always --all-files"
pre-commit = "pre-commit run --show-diff-on-failure --color=always --all-files"
239 changes: 238 additions & 1 deletion Pipfile.lock

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

9 changes: 9 additions & 0 deletions docker/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DJANGO_SETTINGS_MODULE=core.settings
DB_NAME=db_test
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=db
DB_PORT=5432
POSTGRES_PASSWORD=postgres
REDIS_HOST=broker
REDIS_PORT=6379
Loading

0 comments on commit ee03b16

Please sign in to comment.