cookiecutter-django/{{cookiecutter.project_slug}}/.gitlab-ci.yml

55 lines
1.3 KiB
YAML
Raw Normal View History

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 }}'
POSTGRES_HOST_AUTH_METHOD: trust
{%- if cookiecutter.use_celery == 'y' %}
CELERY_BROKER_URL: 'redis://redis:6379/0'
{%- endif %}
2019-12-06 10:55:00 +03:00
precommit:
2019-12-06 10:55:00 +03:00
stage: lint
image: python:3.10
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:
- pip install -q pre-commit
2019-12-06 10:55:00 +03:00
script:
- pre-commit run --show-diff-on-failure --color=always --all-files
2019-12-06 10:55:00 +03:00
pytest:
stage: test
{%- if cookiecutter.use_docker == 'y' %}
image: docker/compose:1.29.2
2019-12-06 10:55:00 +03:00
tags:
- docker
services:
2020-05-30 01:05:44 +03:00
- docker:dind
before_script:
- docker-compose -f local.yml build
# Ensure celerybeat does not crash due to non-existent tables
- docker-compose -f local.yml run --rm django python manage.py migrate
- docker-compose -f local.yml up -d
script:
- docker-compose -f local.yml run django pytest
{%- else %}
image: python:3.10
tags:
- python
2019-12-06 10:55:00 +03:00
services:
- 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
{%- endif %}