-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
125 lines (110 loc) · 3.13 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
stages:
- test
- docs
- release
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
POETRY_CACHE_DIR: "$CI_PROJECT_DIR/.cache/poetry"
PYIMAGE: py311
.rules_mrs_and_protected:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == "true"
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
.rules_only_mrs:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
.rules_only_master:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_REF_PROTECTED == "true"
.rules_only_protected_tags:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
.needs_all_tests:
- test:sqlite
- test:postgres
.script_build_docs:
- make docs
.base_job: &base_job
image: "registry.gitlab.com/thelabnyc/python:${PYIMAGE}"
.dev_dependency_job: &dev_dependency_job
<<: *base_job
before_script:
# Setup Poetry to allow caching between jobs
- poetry config cache-dir $POETRY_CACHE_DIR
- poetry config virtualenvs.create true
- poetry config virtualenvs.in-project true
# Install dependencies
- poetry install
cache:
key: devdependencies-${PYIMAGE}
paths:
- .cache/pip/
- .cache/poetry/
- .venv/
include:
- component: gitlab.com/thelabnyc/thelab-ci-components/[email protected]
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED == "true"
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- component: gitlab.com/thelabnyc/thelab-ci-components/[email protected]
- component: gitlab.com/thelabnyc/thelab-ci-components/[email protected]
inputs:
image: "registry.gitlab.com/thelabnyc/python:${PYIMAGE}"
test:sqlite: &test_sqlite
<<: *dev_dependency_job
rules:
- !reference [.rules_mrs_and_protected]
stage: test
needs: []
variables:
DJANGO_SETTINGS_MODULE: thelabdb.tests.settings.sqlite
TEST_PKGS: thelabdb.tests.testsuniv
parallel:
matrix:
- PYIMAGE: py310
TOX_SKIP_ENV: "^(?!py310-)"
- PYIMAGE: py311
TOX_SKIP_ENV: "^(?!py311-)"
script:
- poetry run tox
coverage: '/^TOTAL.+?(\d+\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
test:postgres:
<<: *test_sqlite
variables:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: 'trust'
DJANGO_SETTINGS_MODULE: thelabdb.tests.settings.pg
TEST_PKGS: thelabdb.tests.testsuniv thelabdb.tests.testspg
services:
- postgres:latest
test:docs:
<<: *dev_dependency_job
rules:
- !reference [.rules_only_mrs]
stage: test
needs: []
script:
- !reference [.script_build_docs]
pages:
<<: *dev_dependency_job
rules:
- !reference [.rules_only_master]
stage: docs
needs:
- !reference [.needs_all_tests]
script:
- !reference [.script_build_docs]
artifacts:
paths:
- public