Skip to content
Snippets Groups Projects
Commit 248c6c06 authored by Jean-Baptiste Delisle's avatar Jean-Baptiste Delisle
Browse files

gitlab-ci: use a single config section

parent b3850032
No related branches found
No related tags found
No related merge requests found
Pipeline #32811 failed
......@@ -10,18 +10,14 @@ stages:
- staging
- production
.ssh_key_setup:
.setup_env:
before_script:
- apt-get update -y
##
## Install ssh-agent if not already installed, it is required by Docker.
## (change apt-get to yum if you use an RPM-based image)
##
- apt-get update -y
- 'command -v ssh-agent >/dev/null || ( apt-get install openssh-client -y )'
##
##
- apt-get install rsync -y
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
......@@ -39,20 +35,15 @@ stages:
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS_DACECALC1" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
.conda_env_setup:
extends:
.ssh_key_setup
before_script:
- apt-get update -y
- apt-get install build-essential curl -y
## Install necessary packages
- apt-get install build-essential rsync curl -y
## Conda env
- source /opt/conda/etc/profile.d/conda.sh
- mamba env create -f spleaf_env.yml
- conda activate spleaf
Build distribution:
extends:
.conda_env_setup
extends: .setup_env
stage: build
script:
- python setup.py sdist
......@@ -62,8 +53,7 @@ Build distribution:
expire_in: 1 day
Run test:
extends:
.conda_env_setup
extends: .setup_env
stage: test
script:
- pip install dist/*.tar.gz
......@@ -71,8 +61,7 @@ Run test:
- python -m pytest
Generate documentation:
extends:
.conda_env_setup
extends: .setup_env
stage: documentation
script:
- pip install dist/*.tar.gz
......@@ -84,25 +73,22 @@ Generate documentation:
expire_in: 1 day
Deploy on Staging:
extends:
.ssh_key_setup
extends: .setup_env
stage: staging
script:
- rsync -v dist/*.tar.gz dacemgr@${DACECALC1}:/www/people/delisle/public/staging/spleaf/
- rsync -rv --delete doc/build/html/ dacemgr@${DACECALC1}:/www/people/delisle/public/staging/spleaf/doc
Release and deploy on Production:
extends:
.conda_env_setup
extends: .setup_env
stage: production
before_script:
script:
# According to documentation, gitlab uses detached HEAD and we need to go back to master to release.
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/19421
- git checkout -B master origin/master
- git config --global user.name 'Gitlab CI'
- git config --global user.email ''
- git remote set-url origin "https://gitlab-ci-token:$RELEASE_TOKEN@gitlab.unige.ch/jean-baptiste.delisle/spleaf.git"
script:
# Tag
- VERSION=`grep __version__ spleaf/__info__.py | sed 's/.*version__ = "//' | sed 's/"//'`
- TAG_VERSION="v$VERSION"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment