website/.gitlab-ci.yml
2022-06-12 15:24:17 +01:00

104 lines
2.0 KiB
YAML

image: python:3.10-slim
stages:
- build
- test
static:
image: node:alpine
stage: build
cache:
key: npm-$CI_COMMIT_REF_SLUG
paths:
- "$CI_PROJECT_DIR/.npm-cache"
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
just:
stage: build
before_script:
- apt-get update && apt-get install -y curl
script:
- curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to $CI_PROJECT_DIR/.just-bin
artifacts:
name: 'pip-$CI_JOB_ID'
paths:
- $CI_PROJECT_DIR/.just-bin
expire_in: 30 mins
.python_test_template: &python_test_template
stage: test
dependencies:
- pip
- collect_static
- static
- just
before_script:
- source env/bin/activate
- mv $CI_PROJECT_DIR/.just-bin/just /usr/local/bin/just
variables:
SECRET_KEY: super-secret
collect_static:
<<: *python_test_template
stage: build
dependencies:
- pip
- static
- just
needs:
- pip
- static
- just
script:
- ./manage.py collectstatic --noinput -v2 --clear
artifacts:
name: 'static-$CI_JOB_ID'
paths:
- ./collected-static/
expire_in: 30 mins
test_python:
<<: *python_test_template
script:
- ./manage.py check
- ./manage.py makemigrations --check --noinput
- ./manage.py test
django_checks:
<<: *python_test_template
script:
- ./manage.py check
- ./manage.py makemigrations --check --noinput
python_lint:
<<: *python_test_template
script:
- just lint