Skip to content

Instantly share code, notes, and snippets.

@Erotemic
Last active September 16, 2022 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Erotemic/e2e125a6ff6702300c81d684aa664536 to your computer and use it in GitHub Desktop.
Save Erotemic/e2e125a6ff6702300c81d684aa664536 to your computer and use it in GitHub Desktop.
gitlab-ci-example.yml
# Abuse YAML notation to make a heredoc. This will be ignored by the CI.
stages:
- build
- test
- gpgsign
- deploy
### TEMPLATES ###
# Define common templates using YAML anchors
.common_template: &common_template
tags:
# Tags define which runners will accept which jobs
- docker
- linux
- build
- kitware-python-stack
variables:
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
except:
# Don't run the pipeline for new tags
- tags
cache:
paths:
- .cache/pip
.build_template: &build_template
# Tags define which runners will accept which jobs
<<:
- *common_template
stage:
build
before_script:
- python -V # Print out python version for debugging
script:
#- python setup.py bdist_wheel --universal
- python setup.py bdist_wheel
artifacts:
paths:
- dist/*.whl
.common_test_template: &common_test_template
# Tags define which runners will accept which jobs
<<:
- *common_template
variables:
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
stage:
test
script:
- ./run_tests.py
# Coverage is a regex that will parse the coverage from the test stdout
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
# Define anchors to be used in "before_script" parts
._setup_virtualenv_template: &_setup_virtualenv_template |-
python -V # Print out python version for debugging
export PYVER=$(python -c "import sys; print('{}{}'.format(*sys.version_info[0:2]))")
pip install virtualenv
virtualenv venv$PYVER
source venv$PYVER/bin/activate
pip install pip -U
pip install pip setuptools -U
python -V # Print out python version for debugging
.test_full_loose_template: &test_full_loose_template
# Tags define which runners will accept which jobs
<<:
- *common_test_template
before_script:
- *_setup_virtualenv_template
- pip install .[all]
# Aliases for the images that run the tests
.image_python3_10: &image_python3_10
#gitlab.kitware.com:4567/computer-vision/ci-docker/gl-python:3.10
python:3.10
.image_python39: &image_python39
#gitlab.kitware.com:4567/computer-vision/ci-docker/gl-python:3.9
python:3.9
.image_python38: &image_python38
#gitlab.kitware.com:4567/computer-vision/ci-docker/gl-python:3.8
python:3.8
.image_python37: &image_python37
#gitlab.kitware.com:4567/computer-vision/ci-docker/gl-python:3.7
python:3.7
.image_python36: &image_python36
#gitlab.kitware.com:4567/computer-vision/ci-docker/gl-python:3.6
python:3.6
.image_python35: &image_python35
#gitlab.kitware.com:4567/computer-vision/ci-docker/gl-python:3.5
python:3.5
.image_python27: &image_python27
#gitlab.kitware.com:4567/computer-vision/ci-docker/gl-python:2.7
python:2.7
### JOBS ###
# Define the actual jobs
# ---------------
# Python 3.10 Jobs
build/cp3_10-cp3_10-linux:
<<:
- *build_template
image:
*image_python3_10
test_full_loose/cp3_10-cp3_10-linux:
<<:
- *test_full_loose_template
image:
*image_python3_10
needs:
- build/cp3_10-cp3_10-linux
# ---------------
# Python 3.9 Jobs
build/cp39-cp39-linux:
<<:
- *build_template
image:
*image_python39
test_full_loose/cp39-cp39-linux:
<<:
- *test_full_loose_template
image:
*image_python39
needs:
- build/cp39-cp39-linux
# ---------------
# Python 3.8 Jobs
build/cp38-cp38-linux:
<<:
- *build_template
image:
*image_python38
test_full_loose/cp38-cp38-linux:
<<:
- *test_full_loose_template
image:
*image_python38
needs:
- build/cp38-cp38-linux
# ---------------
# Python 3.7 Jobs
build/cp37-cp37-linux:
<<:
- *build_template
image:
*image_python37
test_full_loose/cp37-cp37-linux:
<<:
- *test_full_loose_template
image:
*image_python37
needs:
- build/cp37-cp37-linux
# ---------------
# Python 3.6 Jobs
build/cp36-cp36m-linux:
<<:
- *build_template
image:
*image_python36
test_full_loose/cp36-cp36m-linux:
<<:
- *test_full_loose_template
image:
*image_python36
needs:
- build/cp36-cp36m-linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment