104 lines
2.6 KiB
YAML
104 lines
2.6 KiB
YAML
stages:
|
|
- build
|
|
- test
|
|
- lint
|
|
- deploy
|
|
|
|
javascript build:
|
|
image: node:12
|
|
stage: build
|
|
cache:
|
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
|
paths:
|
|
- node_modules/
|
|
before_script:
|
|
- npm install
|
|
script:
|
|
- npm run build
|
|
|
|
python tests:
|
|
services:
|
|
- postgres:11
|
|
- memcached:1.5.22
|
|
image: python:3.7.4-slim-stretch
|
|
stage: test
|
|
variables:
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
DJANGO_SETTINGS_MODULE: "newsreader.conf.gitlab"
|
|
POSTGRES_HOST: "$POSTGRES_HOST"
|
|
POSTGRES_DB: "$POSTGRES_NAME"
|
|
POSTGRES_NAME: "$POSTGRES_NAME"
|
|
POSTGRES_USER: "$POSTGRES_USER"
|
|
POSTGRES_PASSWORD: "$POSTGRES_PASSWORD"
|
|
cache:
|
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
|
paths:
|
|
- .cache/pip
|
|
- env/
|
|
before_script:
|
|
- python3 -m venv env
|
|
- source env/bin/activate
|
|
- pip install -r requirements/gitlab.txt
|
|
script:
|
|
- python src/manage.py test newsreader
|
|
|
|
javascript tests:
|
|
image: node:12
|
|
stage: test
|
|
cache:
|
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
|
paths:
|
|
- node_modules/
|
|
before_script:
|
|
- npm install
|
|
script:
|
|
- npm test
|
|
|
|
javascript linting:
|
|
image: node:12
|
|
stage: lint
|
|
cache:
|
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
|
paths:
|
|
- node_modules/
|
|
before_script:
|
|
- npm install
|
|
script:
|
|
- npm run lint
|
|
|
|
python linting:
|
|
image: python:3.7.4-slim-stretch
|
|
stage: lint
|
|
variables:
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
DJANGO_SETTINGS_MODULE: "newsreader.conf.gitlab"
|
|
cache:
|
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
|
paths:
|
|
- .cache/pip
|
|
- env/
|
|
before_script:
|
|
- python3 -m venv env
|
|
- source env/bin/activate
|
|
- pip install -r requirements/gitlab.txt
|
|
script:
|
|
- isort src/ --check-only --recursive
|
|
- black src/ --line-length 88 --check
|
|
- autoflake src/ --check --recursive --remove-all-unused-imports --ignore-init-module-imports
|
|
|
|
deploy:
|
|
stage: deploy
|
|
image: debian:buster
|
|
environment:
|
|
name: production
|
|
url: rss.fudiggity.nl
|
|
before_script:
|
|
- apt-get update && apt-get install -y ansible git
|
|
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.fudiggity.nl/sonny/ansible-playbooks.git deployment
|
|
- mkdir /root/.ssh
|
|
- echo "192.168.178.63 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILbtcdgJBhVCKsO88cV19EYefDTopdYejEQCp1pYr1Ga" > /root/.ssh/known_hosts
|
|
- echo "$DEPLOY_KEY" > deployment/deploy_key && chmod 0600 deployment/deploy_key
|
|
script:
|
|
- ansible-playbook deployment/playbook.yml --inventory deployment/apps.yml --limit newsreader --user ansible --private-key deployment/deploy_key
|
|
only:
|
|
- development
|