2019-12-06 10:55:00 +03:00
|
|
|
stages:
|
|
|
|
- lint
|
|
|
|
- test
|
|
|
|
|
|
|
|
variables:
|
|
|
|
POSTGRES_USER: '{{ cookiecutter.project_slug }}'
|
|
|
|
POSTGRES_PASSWORD: ''
|
|
|
|
POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}'
|
2020-03-15 15:23:21 +03:00
|
|
|
POSTGRES_HOST_AUTH_METHOD: trust
|
2023-02-25 15:33:30 +03:00
|
|
|
{%- if cookiecutter.use_celery == 'y' %}
|
2020-03-24 00:43:59 +03:00
|
|
|
CELERY_BROKER_URL: 'redis://redis:6379/0'
|
|
|
|
{%- endif %}
|
2019-12-06 10:55:00 +03:00
|
|
|
|
2023-02-25 15:33:30 +03:00
|
|
|
precommit:
|
2019-12-06 10:55:00 +03:00
|
|
|
stage: lint
|
2024-03-18 21:55:00 +03:00
|
|
|
image: python:3.12
|
2023-02-25 15:33:30 +03:00
|
|
|
variables:
|
|
|
|
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
|
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- ${PRE_COMMIT_HOME}
|
2019-12-06 10:55:00 +03:00
|
|
|
before_script:
|
2023-02-25 15:33:30 +03:00
|
|
|
- pip install -q pre-commit
|
2019-12-06 10:55:00 +03:00
|
|
|
script:
|
2023-02-25 15:33:30 +03:00
|
|
|
- pre-commit run --show-diff-on-failure --color=always --all-files
|
2019-12-06 10:55:00 +03:00
|
|
|
|
|
|
|
pytest:
|
|
|
|
stage: test
|
2023-02-25 15:33:30 +03:00
|
|
|
{%- if cookiecutter.use_docker == 'y' %}
|
2024-04-02 18:22:33 +03:00
|
|
|
image: docker:25.0
|
2019-12-06 10:55:00 +03:00
|
|
|
tags:
|
|
|
|
- docker
|
2020-04-14 18:52:14 +03:00
|
|
|
services:
|
2020-05-30 01:05:44 +03:00
|
|
|
- docker:dind
|
2020-04-14 18:52:14 +03:00
|
|
|
before_script:
|
2023-07-24 12:42:51 +03:00
|
|
|
- docker compose -f local.yml build
|
2024-03-18 22:26:18 +03:00
|
|
|
- docker compose -f docs.yml build
|
2020-04-16 20:34:12 +03:00
|
|
|
# Ensure celerybeat does not crash due to non-existent tables
|
2023-07-24 12:42:51 +03:00
|
|
|
- docker compose -f local.yml run --rm django python manage.py migrate
|
|
|
|
- docker compose -f local.yml up -d
|
2020-04-14 18:52:14 +03:00
|
|
|
script:
|
2023-07-24 12:42:51 +03:00
|
|
|
- docker compose -f local.yml run django pytest
|
2023-02-25 15:33:30 +03:00
|
|
|
{%- else %}
|
2024-03-18 21:55:00 +03:00
|
|
|
image: python:3.12
|
2020-04-14 18:52:14 +03:00
|
|
|
tags:
|
|
|
|
- python
|
2019-12-06 10:55:00 +03:00
|
|
|
services:
|
2020-09-07 15:28:49 +03:00
|
|
|
- postgres:{{ cookiecutter.postgresql_version }}
|
2019-12-06 10:55:00 +03:00
|
|
|
variables:
|
|
|
|
DATABASE_URL: pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres/$POSTGRES_DB
|
|
|
|
before_script:
|
|
|
|
- pip install -r requirements/local.txt
|
|
|
|
script:
|
|
|
|
- pytest
|
2020-04-14 18:52:14 +03:00
|
|
|
{%- endif %}
|