Jake Howard
830def684b
This reverts commit 8ab7e3d70e
.
The registry is remote, so this takes a while
169 lines
3.3 KiB
YAML
169 lines
3.3 KiB
YAML
stages:
|
|
- build
|
|
- test
|
|
- deploy
|
|
|
|
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
|
|
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 requirements/dev.txt
|
|
artifacts:
|
|
name: 'pip-$CI_JOB_ID'
|
|
paths:
|
|
- ./env/
|
|
expire_in: 30 mins
|
|
|
|
build_container:
|
|
image: docker:stable
|
|
services:
|
|
- docker:dind
|
|
variables:
|
|
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
DOCKER_BUILDKIT: 1
|
|
dependencies: []
|
|
stage: test
|
|
before_script:
|
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
script:
|
|
- docker build -t website --target production -t $IMAGE_TAG .
|
|
- docker push $IMAGE_TAG
|
|
|
|
.python_test_template:
|
|
image: python:3.10
|
|
stage: test
|
|
dependencies:
|
|
- pip
|
|
before_script:
|
|
- source env/bin/activate
|
|
variables:
|
|
SECRET_KEY: super-secret
|
|
|
|
test_python:
|
|
extends: .python_test_template
|
|
services:
|
|
- postgres:13-alpine
|
|
variables:
|
|
POSTGRES_HOST_AUTH_METHOD: trust
|
|
DATABASE_URL: postgres://postgres@postgres/postgres
|
|
script:
|
|
- ./manage.py collectstatic --noinput --clear
|
|
- coverage run ./manage.py test
|
|
- coverage report
|
|
- coverage xml
|
|
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
|
|
artifacts:
|
|
reports:
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coverage.xml
|
|
dependencies:
|
|
- pip
|
|
- static
|
|
|
|
django_checks:
|
|
extends: .python_test_template
|
|
script:
|
|
- ./manage.py check
|
|
- ./manage.py makemigrations --check --noinput
|
|
|
|
black:
|
|
extends: .python_test_template
|
|
script:
|
|
- black --check .
|
|
|
|
isort:
|
|
extends: .python_test_template
|
|
script:
|
|
- isort --check .
|
|
|
|
flake8:
|
|
extends: .python_test_template
|
|
script:
|
|
- flake8
|
|
|
|
mypy:
|
|
extends: .python_test_template
|
|
script:
|
|
- mypy .
|
|
|
|
curlylint:
|
|
extends: .python_test_template
|
|
script:
|
|
- curlylint .
|
|
|
|
djhtml:
|
|
extends: .python_test_template
|
|
script:
|
|
- git ls-files '*.html' | xargs djhtml --check --tabwidth 2
|
|
|
|
npm_lint:
|
|
image: node:alpine
|
|
stage: test
|
|
dependencies:
|
|
- static
|
|
script:
|
|
- npm run lint
|
|
|
|
pip_tools:
|
|
extends: .python_test_template
|
|
script:
|
|
- ./scripts/compile-requirements.sh
|
|
- git diff
|
|
- git diff-index --quiet HEAD --
|
|
|
|
crontab:
|
|
image: alpine
|
|
stage: test
|
|
dependencies: []
|
|
before_script:
|
|
- apk add --no-cache supercronic
|
|
script:
|
|
- supercronic -test etc/crontab
|
|
|
|
deploy_container:
|
|
image: docker:stable
|
|
services:
|
|
- docker:dind
|
|
variables:
|
|
SRC_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
DEST_IMAGE_TAG: $CI_REGISTRY_IMAGE:latest
|
|
DOCKER_BUILDKIT: 1
|
|
dependencies: []
|
|
stage: deploy
|
|
before_script:
|
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
script:
|
|
- docker pull $SRC_IMAGE_TAG
|
|
- docker tag $SRC_IMAGE_TAG $DEST_IMAGE_TAG
|
|
- docker push $DEST_IMAGE_TAG
|
|
only:
|
|
refs:
|
|
- master
|