website/.gitlab-ci.yml
Jake Howard 97d786e969
Move development into docker
This makes working with related services like redis much easier, and
helps start writing a production container
2022-07-28 14:42:12 +01:00

101 lines
1.8 KiB
YAML

stages:
- build
- test
static:
image: node:alpine
stage: build
cache:
key: npm-$CI_COMMIT_REF_SLUG
paths:
- "$CI_PROJECT_DIR/.npm-cache"
before_script:
- apk add --no-cache bash
script:
- npm ci --cache .npm-cache --prefer-offline
- npm run build
artifacts:
name: '$CI_JOB_ID-node_modules'
paths:
- ./node_modules
- ./static/build
expire_in: 30 mins
pip:
image: python:3.10-slim
stage: build
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.pip-cache
cache:
key: pip-$CI_COMMIT_REF_SLUG
paths:
- "$CI_PROJECT_DIR/.pip-cache"
script:
- python -m venv env
- source env/bin/activate
- pip install -r dev-requirements.txt
artifacts:
name: 'pip-$CI_JOB_ID'
paths:
- ./env/
expire_in: 30 mins
container:
image: docker:stable
stage: test
script:
- docker build -t website .
.python_test_template: &python_test_template
image: python:3.10-slim
stage: test
dependencies:
- pip
- static
before_script:
- source env/bin/activate
variables:
SECRET_KEY: super-secret
.node_test_template: &node_test_template
image: node:alpine
stage: test
dependencies:
- static
test_python:
<<: *python_test_template
script:
- ./manage.py collectstatic --noinput --clear
- ./manage.py test
django_checks:
<<: *python_test_template
script:
- ./manage.py check
- ./manage.py makemigrations --check --noinput
black:
<<: *python_test_template
script:
- black --check website
isort:
<<: *python_test_template
script:
- isort --check website
flake8:
<<: *python_test_template
script:
- flake8 website
mypy:
<<: *python_test_template
script:
- mypy website
prettier:
<<: *node_test_template
script:
- npm run lint