mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-01 03:12:26 +02:00
add gitlab_ci.yml
This commit is contained in:
parent
fb50cb8b0d
commit
9f17cfee09
1 changed files with 43 additions and 0 deletions
43
.gitlab-ci.yml
Normal file
43
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- export CACHE_PATH="/venvs/${CI_PROJECT_NAME}/$(date +week-%V-%Y)"
|
||||||
|
- if [[ "$CI_COMMIT_BRANCH" == *"--no-cache"* ]] ; then export CACHE_PATH="/venvs/$CI_COMMIT_SHORT_SHA"; fi
|
||||||
|
|
||||||
|
|
||||||
|
venv:
|
||||||
|
stage: build
|
||||||
|
image: registry.gitlab.com/hashbangfr/docker_archlinux:python
|
||||||
|
script:
|
||||||
|
- echo "Creating virtual env..."
|
||||||
|
- if [ ! -d $CACHE_PATH/venv ] ; then virtualenv --python=python3.9 $CACHE_PATH/venv ; fi
|
||||||
|
- $CACHE_PATH/venv/bin/pip install --upgrade pip
|
||||||
|
- echo "Virtual env created."
|
||||||
|
|
||||||
|
tests:
|
||||||
|
stage: test
|
||||||
|
image: registry.gitlab.com/hashbangfr/docker_archlinux:python
|
||||||
|
variables:
|
||||||
|
DJANGO_SETTINGS_MODULE: "la_chariotte.settings"
|
||||||
|
DB_NAME: "postgres"
|
||||||
|
DB_USER: "postgres"
|
||||||
|
DB_PASSWORD: "mysecretpassword"
|
||||||
|
DB_HOST: "postgres"
|
||||||
|
DB_PORT: "5432"
|
||||||
|
POSTGRES_HOST_AUTH_METHOD: "trust"
|
||||||
|
services:
|
||||||
|
- postgres:13
|
||||||
|
dependencies:
|
||||||
|
- venv
|
||||||
|
script:
|
||||||
|
- echo "Running tests..."
|
||||||
|
- source $CACHE_PATH/venv/bin/activate
|
||||||
|
- pip install -U -r requirements.txt
|
||||||
|
- pip install -U -r dev-requirements.txt
|
||||||
|
- pytest --create-db --cov --cov-report=xml
|
||||||
|
- if [ "$CI_COMMIT_REF_NAME" = 'main' ] ; then exit 0 ; fi
|
||||||
|
- if [ "$CI_COMMIT_REF_NAME" = 'develop' ] ; git fetch origin main ; then diff-cover coverage.xml --fail-under=90 && exit 0 ; fi
|
||||||
|
- git fetch origin develop ; diff-cover coverage.xml --fail-under=90 --compare-branch origin/develop
|
||||||
|
- echo "Tests done."
|
Loading…
Reference in a new issue