-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
125 lines (114 loc) · 3.55 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
118
119
120
121
122
123
124
125
# SPDX-FileCopyRightText: 2023 Jürgen Mülbert <juergen.muelbert@web.de>
#
# SPDX-License-Identifier: EUPL-1.2
#
# GitLab continuous integration file to build and deploy repository.
#
# For a reference of the CI file syntax, visit
# https://docs.gitlab.com/ee/ci/yaml/.
# Workflow rules define when the CI pipeline is created. Rule order matters
# since they are evaluated until first match.
workflow:
# Makes pipeline run on Git tags, any branch commit, and on expected result of
# merge request branches. For more information, visit
# https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html and
# https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines.
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
# Jobs of the same stage run in parallel. Jobs of the next stage only run after
# all current jobs have completed successfully.
stages:
- build
- deploy
- test
# Environment variables that apply to all jobs.
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
PIP_DISABLE_PIP_VERSION_CHECK: 1
PIP_ROOT_USER_ACTION: ignore
POETRY_VIRTUALENVS_IN_PROJECT: 1
PYTHON_VERSION_DEFAULT: '3.10'
TMATE_DEBUG: 'false'
# Contains settings that apply to all jobs unless overridden.
default:
# Allows for debugging via SSH session for failed jobs in manual pipelines.
after_script:
- |
if [[ $CI_JOB_STATUS == 'failed' && $TMATE_DEBUG == 'true' ]]; then
bash scripts/setup_tmate.sh
fi
before_script:
- python --version | ts
- pip install -r .github/workflow/constraints.txt | ts
- poetry install --verbose | ts
# Creates a dependencies cache for each unique Docker image and Poetry lock
# file hash pair to speed up dependency installations. Since caches are shared
# between jobs and branches, cache keys must not apply to multiple version
# targets to avoid installation errors. For more information, visit
# https://docs.gitlab.com/ee/ci/caching.
cache:
key:
files:
- poetry.lock
prefix: $CI_JOB_IMAGE
paths:
- .cache/pip
- .venv
config:
before_script:
- node --version
- npm install --global prettier
# Disable cache for job.
cache: []
image: 'node:18'
# Makes job only run on every Git event except for tags.
rules:
- if: $CI_COMMIT_TAG
when: never
- when: always
script:
- prettier --check .
stage: build
test_safety:
stage: test
script:
- nox -rs "safety"
test_typeguard:
stage: test
- nox -rs "typeguard"
test_mypy:
stage: test
- nox -rs "mypy"
test_tests:
stage: test
- nox -rs "tests"
package:
# Uploads packages as release files for Git tags.
artifacts:
paths:
- dist/{{ cookiecutter.project_slug }}-$CI_COMMIT_TAG-py-none-any.whl
image: 'python:$PYTHON_VERSION_DEFAULT'
# Makes job only run on release commit tags, i.e. 1.0.4 or v0.4.1.
rules:
- if: $CI_COMMIT_TAG =~ /^v?[0-9]+\.[0-9]+\.[0-9]+$/
script:
- poetry build
- poetry publish --username ${PYPI_USERNAME?} --password ${PYPI_PASSWORD?}
stage: deploy
pages:
# GitLab Pages uploads files inside the "public" folder after job completes.
artifacts:
paths:
- public
image: 'python:$PYTHON_VERSION_DEFAULT'
# Makes job only run on the default repository branch.
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- poetry run python scripts/build_docs.py
- mv site public
stage: deploy