cookiecutter-django/{{cookiecutter.project_slug}}/.gitlab-ci.yml
Matthew Foster Walsh 10c85ce3d6
Rename docker compose files to include 'docker-compose' (#4995)
* Renamed local.yml to docker-compose.local.yml

* Renamed production.yml to docker-compose.production.yml

* Rename docs.yml to docker-compose.docs.yml

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
2024-05-13 18:18:56 +01:00

56 lines
1.4 KiB
YAML

stages:
- lint
- test
variables:
POSTGRES_USER: '{{ cookiecutter.project_slug }}'
POSTGRES_PASSWORD: ''
POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}'
POSTGRES_HOST_AUTH_METHOD: trust
{%- if cookiecutter.use_celery == 'y' %}
CELERY_BROKER_URL: 'redis://redis:6379/0'
{%- endif %}
precommit:
stage: lint
image: python:3.12
variables:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
cache:
paths:
- ${PRE_COMMIT_HOME}
before_script:
- pip install -q pre-commit
script:
- pre-commit run --show-diff-on-failure --color=always --all-files
pytest:
stage: test
{%- if cookiecutter.use_docker == 'y' %}
image: docker:25.0
tags:
- docker
services:
- docker:dind
before_script:
- docker compose -f docker-compose.local.yml build
- docker compose -f docker-compose.docs.yml build
# Ensure celerybeat does not crash due to non-existent tables
- docker compose -f docker-compose.local.yml run --rm django python manage.py migrate
- docker compose -f docker-compose.local.yml up -d
script:
- docker compose -f docker-compose.local.yml run django pytest
{%- else %}
image: python:3.12
tags:
- python
services:
- postgres:{{ cookiecutter.postgresql_version }}
variables:
DATABASE_URL: pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres/$POSTGRES_DB
before_script:
- pip install -r requirements/local.txt
script:
- pytest
{%- endif %}