-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
117 lines (102 loc) · 2.8 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
stages:
- prepare
- test
- finalize
- release
variables:
# Change cache dirs to be inside the project (can only cache local items)
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
PIPX_HOME: $CI_PROJECT_DIR/.cache/pipx
PRE_COMMIT_HOME: $CI_PROJECT_DIR/.cache/pre-commit
workflow:
rules:
# Restrict the number of times the pipeline runs to save resources/limits
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
variables:
# Specific merge request configurations for coveralls
CI_BRANCH: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
CI_PULL_REQUEST: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == 'push'
when: never # Avoid running the pipeline twice (push + merge request)
- if: $CI_COMMIT_BRANCH || $CI_COMMIT_TAG
# You can also set recurring execution of the pipeline, see:
# https://docs.gitlab.com/ee/ci/pipelines/schedules.html
cache:
key: pip-pipx-pre-commit-$CI_JOB_IMAGE
paths:
- .cache/pip
- .cache/pipx
- .cache/pre-commit
default:
before_script:
- python --version # useful for debugging
# Setup git (used for setuptools-scm)
- git config --global user.email "[email protected]"
- git config --global user.name "Your Name"
# Install dependencies for the testing environment
- pip install -U pip tox pipx
check:
stage: prepare
image: "python:3.10"
script:
- pipx run pre-commit run --all-files --show-diff-on-failure
build:
stage: prepare
image: "python:3.10"
script:
- tox -e clean,build
variables:
GIT_DEPTH: "0" # deep-clone
artifacts:
expire_in: 1 day
paths: [dist]
.test_script: &test_script
dependencies: [build]
script:
- tox --installpkg dist/*.whl -- -rFEx --durations 10 --color yes
py38:
stage: test
image: "python:3.8"
<<: *test_script
py39:
stage: test
image: "python:3.9"
<<: *test_script
py310:
stage: test
image: "python:3.10"
<<: *test_script
mamba:
stage: test
image: "condaforge/mambaforge"
before_script:
- mamba install -y pip pipx 'tox!=4.0.*,!=4.1.*'
<<: *test_script
static_tests:
stage: test
image: "python:3.10"
script:
- tox -e lint
pages:
image: "python:3.10"
script:
- tox -e docs
- cp -r docs/_build/html public
artifacts:
paths:
- public
publish:
stage: release
dependencies: [build]
image: "python:3.10"
rules: [if: $CI_COMMIT_TAG]
variables:
# See: https://pypi.org/help/#apitoken
# Needs a PYPI_TOKEN protected variable to be configured for `v*` tags, see:
# https://docs.gitlab.com/ee/ci/variables/#add-a-cicd-variable-to-a-project
# https://docs.gitlab.com/ee/user/project/protected_tags.html
TWINE_REPOSITORY: pypi
TWINE_USERNAME: __token__
TWINE_PASSWORD: $PYPI_TOKEN
script:
- tox -e publish