2018-10-04 19:16:02 +00:00
|
|
|
stages:
|
|
|
|
- test
|
2022-04-27 18:21:48 +00:00
|
|
|
- deploy
|
2018-10-04 19:16:02 +00:00
|
|
|
|
2022-03-26 21:27:20 +00:00
|
|
|
# Installs and launch unittests
|
|
|
|
unittests:
|
2018-10-04 19:35:39 +00:00
|
|
|
stage: test
|
2016-04-18 02:58:15 +00:00
|
|
|
script:
|
2022-03-26 21:27:20 +00:00
|
|
|
# Install dependencies
|
2016-11-08 18:17:42 +00:00
|
|
|
- apt-get update
|
2021-10-15 16:12:56 +00:00
|
|
|
- apt-get install -y gettext libxapian-dev libgraphviz-dev
|
2022-02-28 09:34:15 +00:00
|
|
|
- pip install poetry
|
2022-03-26 21:27:20 +00:00
|
|
|
# Check pyproject.toml validity
|
|
|
|
- poetry check
|
|
|
|
# Install project
|
|
|
|
- poetry install -E testing -E docs
|
|
|
|
# Setup xapian index
|
2021-09-30 08:48:08 +00:00
|
|
|
- mkdir -p /dev/shm/search_indexes
|
|
|
|
- ln -s /dev/shm/search_indexes sith/search_indexes
|
2022-03-26 21:27:20 +00:00
|
|
|
# Setup project
|
2022-02-28 09:34:15 +00:00
|
|
|
- poetry run ./manage.py compilemessages
|
2022-03-26 21:27:20 +00:00
|
|
|
# Run tests and export report
|
2022-02-28 09:34:15 +00:00
|
|
|
- poetry run coverage run ./manage.py test
|
2022-05-08 12:09:37 +00:00
|
|
|
- poetry run coverage xml
|
2022-02-28 09:34:15 +00:00
|
|
|
- poetry run coverage report
|
2022-03-26 21:27:20 +00:00
|
|
|
# Build documentation
|
|
|
|
- cd doc
|
|
|
|
- poetry run make html
|
2021-09-30 09:07:00 +00:00
|
|
|
variables:
|
|
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip_tests"
|
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- .cache/pip_tests
|
2017-08-29 13:13:09 +00:00
|
|
|
artifacts:
|
2022-05-08 12:09:37 +00:00
|
|
|
when: always
|
2017-08-29 13:13:09 +00:00
|
|
|
paths:
|
2022-05-08 12:09:37 +00:00
|
|
|
- coverage.xml
|
2017-08-29 13:13:09 +00:00
|
|
|
- coverage_report/
|
2022-03-26 21:27:20 +00:00
|
|
|
- docs/_build
|
2022-05-08 12:09:37 +00:00
|
|
|
reports:
|
|
|
|
junit: coverage.xml
|
2018-10-04 19:16:02 +00:00
|
|
|
|
2022-03-26 21:27:20 +00:00
|
|
|
# Check black
|
2018-10-04 19:16:02 +00:00
|
|
|
black:
|
|
|
|
stage: test
|
|
|
|
script:
|
2022-03-26 21:27:20 +00:00
|
|
|
- version=$(cat pyproject.toml | grep --color=never black | grep --color=never -oE '[0-9]([0-9.a-z]+)')
|
|
|
|
- pip install black==$version
|
2018-10-04 19:16:02 +00:00
|
|
|
- black --check .
|
2021-09-30 09:07:00 +00:00
|
|
|
variables:
|
|
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip_black"
|
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- .cache/pip_black
|
2022-04-27 18:21:48 +00:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
stage: deploy
|
|
|
|
before_script:
|
|
|
|
##
|
|
|
|
## Install ssh-agent if not already installed, it is required by Docker.
|
|
|
|
## (change apt-get to yum if you use an RPM-based image)
|
|
|
|
##
|
|
|
|
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
|
|
|
|
|
|
|
|
##
|
|
|
|
## Run ssh-agent (inside the build environment)
|
|
|
|
##
|
|
|
|
- eval $(ssh-agent -s)
|
|
|
|
|
|
|
|
##
|
|
|
|
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
|
|
|
|
## We're using tr to fix line endings which makes ed25519 keys work
|
|
|
|
## without extra base64 encoding.
|
|
|
|
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
|
|
|
|
##
|
|
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
|
|
|
|
|
|
|
##
|
|
|
|
## Create the SSH directory and give it the right permissions
|
|
|
|
##
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- chmod 700 ~/.ssh
|
|
|
|
script:
|
|
|
|
- ssh -o StrictHostKeyChecking=accept-new sith@ae-web $SITH_PROD_SCRIPT_PATH
|
|
|
|
environment:
|
|
|
|
name: prod
|
|
|
|
url: https://ae.utbm.fr
|
|
|
|
only:
|
|
|
|
refs:
|
|
|
|
- master
|
|
|
|
when: on_success
|