/
.gitlab-ci.yml
100 lines (86 loc) · 2.42 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
# This file is a template, and might need editing before it works on your project.
stages:
- prepare
- test
- finalize
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
# Coveralls configuration
CI_NAME: gitlab-ci
CI_BRANCH: $CI_COMMIT_REF_NAME
CI_BUILD_NUMBER: $CI_PIPELINE_ID
CI_BUILD_URL: $CI_PIPELINE_URL
workflow:
rules:
# Restrict the number of times the pipeline runs to save resources/limits
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
variables:
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
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 "you@example.com"
- 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]
variables:
COVERALLS_PARALLEL: "true"
COVERALLS_FLAG_NAME: $CI_JOB_NAME
script:
- tox --installpkg dist/*.whl -- -rFEx --durations 10 --color yes
- pipx run coverage lcov -o coverage.lcov
- pipx run coveralls --submit coverage.lcov
py37:
stage: test
image: "python:3.7"
<<: *test_script
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 tox pipx
<<: *test_script
upload-coverage:
stage: finalize
image: "python:3.10"
script: pipx run coveralls --finish