2022-06-10 16:45:04 +01:00
|
|
|
stages:
|
|
|
|
- build
|
|
|
|
- test
|
2022-08-26 10:38:25 +01:00
|
|
|
- deploy
|
2022-06-10 16:45:04 +01:00
|
|
|
|
|
|
|
static:
|
2023-10-20 08:01:31 +01:00
|
|
|
image: node:21-slim
|
2022-06-10 16:45:04 +01:00
|
|
|
stage: build
|
|
|
|
cache:
|
2022-06-10 16:56:07 +01:00
|
|
|
key: npm-$CI_COMMIT_REF_SLUG
|
2022-06-10 16:45:04 +01:00
|
|
|
paths:
|
2022-06-10 16:56:07 +01:00
|
|
|
- "$CI_PROJECT_DIR/.npm-cache"
|
2023-07-16 14:47:27 +01:00
|
|
|
before_script:
|
|
|
|
- apt update && apt install --yes curl
|
2022-06-10 16:45:04 +01:00
|
|
|
script:
|
2022-06-10 16:56:07 +01:00
|
|
|
- npm ci --cache .npm-cache --prefer-offline
|
2022-06-10 16:45:04 +01:00
|
|
|
- npm run build
|
|
|
|
artifacts:
|
|
|
|
name: '$CI_JOB_ID-node_modules'
|
|
|
|
paths:
|
|
|
|
- ./node_modules
|
|
|
|
- ./static/build
|
2022-09-13 08:24:16 +01:00
|
|
|
expire_in: 2 hours
|
2022-06-10 16:45:04 +01:00
|
|
|
|
2022-11-03 13:54:31 +00:00
|
|
|
pip:
|
2023-01-11 08:43:45 +00:00
|
|
|
image: python:3.11-slim
|
2022-06-10 16:45:04 +01:00
|
|
|
stage: build
|
2022-06-10 16:56:07 +01:00
|
|
|
variables:
|
|
|
|
PIP_CACHE_DIR: $CI_PROJECT_DIR/.pip-cache
|
|
|
|
cache:
|
2022-11-03 13:54:31 +00:00
|
|
|
key: pip-$CI_COMMIT_REF_SLUG
|
2022-06-10 16:56:07 +01:00
|
|
|
paths:
|
|
|
|
- "$CI_PROJECT_DIR/.pip-cache"
|
2022-08-27 18:22:58 +01:00
|
|
|
before_script:
|
|
|
|
- apt-get update --yes
|
2022-08-28 17:49:21 +01:00
|
|
|
- apt-get install --yes build-essential libpq-dev git
|
2022-06-10 16:45:04 +01:00
|
|
|
script:
|
|
|
|
- python -m venv env
|
|
|
|
- source env/bin/activate
|
2022-11-03 13:59:09 +00:00
|
|
|
- pip install -r dev-requirements.txt
|
2022-06-10 16:45:04 +01:00
|
|
|
artifacts:
|
2022-11-03 13:54:31 +00:00
|
|
|
name: 'venv-$CI_JOB_ID'
|
2022-06-10 16:45:04 +01:00
|
|
|
paths:
|
|
|
|
- ./env/
|
2022-09-13 08:24:16 +01:00
|
|
|
expire_in: 2 hours
|
2022-06-10 16:45:04 +01:00
|
|
|
|
2022-08-26 00:03:28 +01:00
|
|
|
.python_test_template:
|
2023-01-11 08:43:45 +00:00
|
|
|
image: python:3.11-slim
|
2022-06-10 16:45:04 +01:00
|
|
|
stage: test
|
|
|
|
dependencies:
|
2022-11-03 13:54:31 +00:00
|
|
|
- pip
|
2022-06-10 16:45:04 +01:00
|
|
|
before_script:
|
|
|
|
- source env/bin/activate
|
2022-06-10 16:56:25 +01:00
|
|
|
variables:
|
|
|
|
SECRET_KEY: super-secret
|
2022-06-10 17:14:30 +01:00
|
|
|
|
|
|
|
test_python:
|
2022-08-26 00:03:28 +01:00
|
|
|
extends: .python_test_template
|
2022-07-28 20:41:30 +01:00
|
|
|
services:
|
2022-09-09 17:16:05 +01:00
|
|
|
- postgres:14-alpine
|
2022-07-28 20:41:30 +01:00
|
|
|
variables:
|
2022-08-26 00:08:37 +01:00
|
|
|
POSTGRES_HOST_AUTH_METHOD: trust
|
2022-07-28 20:41:30 +01:00
|
|
|
DATABASE_URL: postgres://postgres@postgres/postgres
|
2022-10-02 19:25:36 +01:00
|
|
|
TEST: "true"
|
2022-06-10 17:14:30 +01:00
|
|
|
script:
|
2022-09-13 21:14:48 +01:00
|
|
|
- apt-get update && apt-get install --yes git libpq-dev
|
2022-06-12 15:58:06 +01:00
|
|
|
- ./manage.py collectstatic --noinput --clear
|
2022-08-17 19:09:07 +01:00
|
|
|
- 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
|
2022-08-03 22:39:28 +01:00
|
|
|
dependencies:
|
2022-11-03 13:54:31 +00:00
|
|
|
- pip
|
2022-08-03 22:39:28 +01:00
|
|
|
- static
|
2022-06-10 17:14:30 +01:00
|
|
|
|
|
|
|
django_checks:
|
2022-08-26 00:03:28 +01:00
|
|
|
extends: .python_test_template
|
2023-07-16 15:02:40 +01:00
|
|
|
dependencies:
|
|
|
|
- pip
|
|
|
|
- static
|
2022-06-10 17:14:30 +01:00
|
|
|
script:
|
2023-06-02 16:11:54 +01:00
|
|
|
- apt-get update && apt-get install --yes libpq-dev
|
2023-07-16 15:11:31 +01:00
|
|
|
- ./manage.py collectstatic --noinput --clear
|
2022-06-10 17:14:30 +01:00
|
|
|
- ./manage.py check
|
|
|
|
- ./manage.py makemigrations --check --noinput
|
2022-06-12 15:17:28 +01:00
|
|
|
|
2022-06-12 15:52:45 +01:00
|
|
|
black:
|
2022-08-26 00:03:28 +01:00
|
|
|
extends: .python_test_template
|
2022-06-12 15:52:45 +01:00
|
|
|
script:
|
2022-07-29 08:46:44 +01:00
|
|
|
- black --check .
|
2022-06-12 15:52:45 +01:00
|
|
|
|
2023-07-15 15:10:05 +01:00
|
|
|
ruff:
|
2022-08-26 00:03:28 +01:00
|
|
|
extends: .python_test_template
|
2022-06-12 15:52:45 +01:00
|
|
|
script:
|
2023-07-15 15:10:05 +01:00
|
|
|
- ruff check .
|
2022-06-12 15:52:45 +01:00
|
|
|
|
|
|
|
mypy:
|
2022-08-26 00:03:28 +01:00
|
|
|
extends: .python_test_template
|
2022-06-12 15:17:28 +01:00
|
|
|
script:
|
2022-07-29 08:46:44 +01:00
|
|
|
- mypy .
|
2022-06-12 19:35:06 +01:00
|
|
|
|
2022-10-05 14:17:00 +01:00
|
|
|
djlint:
|
2022-08-26 00:03:28 +01:00
|
|
|
extends: .python_test_template
|
2022-08-03 20:22:02 +01:00
|
|
|
script:
|
2022-10-05 14:17:00 +01:00
|
|
|
- djlint website/ --lint --check
|
2022-08-03 20:22:02 +01:00
|
|
|
|
2022-09-06 08:39:17 +01:00
|
|
|
gunicorn_check:
|
|
|
|
extends: .python_test_template
|
|
|
|
script:
|
2023-06-02 16:11:54 +01:00
|
|
|
- apt-get update && apt-get install --yes libpq-dev
|
2022-09-06 08:39:17 +01:00
|
|
|
- gunicorn --check-config --config etc/gunicorn.conf.py
|
|
|
|
|
2022-08-03 20:55:09 +01:00
|
|
|
npm_lint:
|
2023-10-20 08:01:31 +01:00
|
|
|
image: node:21-slim
|
2022-08-03 22:35:55 +01:00
|
|
|
stage: test
|
|
|
|
dependencies:
|
|
|
|
- static
|
2022-06-12 19:35:06 +01:00
|
|
|
script:
|
|
|
|
- npm run lint
|
2022-07-28 18:55:47 +01:00
|
|
|
|
2022-08-20 20:48:27 +01:00
|
|
|
crontab:
|
|
|
|
image: alpine
|
|
|
|
stage: test
|
|
|
|
dependencies: []
|
|
|
|
before_script:
|
|
|
|
- apk add --no-cache supercronic
|
|
|
|
script:
|
|
|
|
- supercronic -test etc/crontab
|
2022-08-26 10:38:25 +01:00
|
|
|
|
2022-08-27 16:31:54 +01:00
|
|
|
container:
|
2022-08-26 10:38:25 +01:00
|
|
|
image: docker:stable
|
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
variables:
|
2022-08-27 16:31:54 +01:00
|
|
|
DEV_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
|
|
PROD_IMAGE_TAG: $CI_REGISTRY_IMAGE:latest
|
2022-08-26 10:38:25 +01:00
|
|
|
DOCKER_BUILDKIT: 1
|
|
|
|
dependencies: []
|
|
|
|
stage: deploy
|
2022-09-13 08:59:56 +01:00
|
|
|
only:
|
|
|
|
- master
|
2022-08-26 10:38:25 +01:00
|
|
|
before_script:
|
|
|
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
|
|
script:
|
2022-09-13 08:59:56 +01:00
|
|
|
- docker build --target production -t $DEV_IMAGE_TAG -t $PROD_IMAGE_TAG .
|
|
|
|
- docker push $CI_REGISTRY_IMAGE
|