-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
115 lines (99 loc) · 2.7 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
# SPDX-FileCopyrightText: Magenta ApS
#
# SPDX-License-Identifier: MPL-2.0
################################################################################
# Changes to this file requires approval from Labs. Please add a person from #
# Labs as required approval to your MR if you have any changes. #
################################################################################
# For `twine upload` to work, the following envionment variables have to set in
# the Gitlab UI.
# RELEASE_PYPI_USERNAME
# RELEASE_PYPI_PASSWORD
stages:
- lint
- test
- release
- deploy
# Lint stage
#############
.lint-default: &lint-default
stage: lint
needs: []
image: python:3.7
services: []
tags:
- docker
TypeCheck Python:
<<: *lint-default
before_script:
- pip3 install -e .[lint]
script:
- python -m mypy --ignore-missing-imports --strict-optional --no-implicit-optional --namespace-packages os2mo_fastapi_utils tests
Lint Python:
<<: *lint-default
before_script:
- pip3 install -e .[lint]
script:
- python -m black --diff --check os2mo_fastapi_utils tests
- python -m isort --profile black --diff --check-only os2mo_fastapi_utils tests
REUSE compliance:
<<: *lint-default
image:
name: fsfe/reuse:latest
entrypoint: [""]
script:
- reuse lint
# Test stage
############
.test-default: &test-default
stage: test
needs: []
services: []
before_script:
- pip3 install -e .[test]
tags:
- docker
Unit-test:
<<: *test-default
image: python:3.7
script:
- pytest
--cov=os2mo_fastapi_utils
--junitxml $CI_PROJECT_DIR/junit.xml
--cov-report html:$CI_PROJECT_DIR/coverage-html
--cov-report term
-p no:cacheprovider
--color=yes
tests/
coverage: '/TOTAL.*\s+(\d+%)$/'
artifacts:
when: always
paths:
- $CI_PROJECT_DIR/coverage-html
reports:
junit: $CI_PROJECT_DIR/junit.xml
# Release stage
###############
.release-default: &release-default
stage: release
needs: ["Unit-test"]
image: python:3.7
services: []
before_script:
- pip3 install -e .[dist]
- python3 -m build
tags:
- docker
Release dev:
<<: *release-default
rules:
- if: $CI_COMMIT_REF_NAME == "master"
script:
- python3 -m twine upload --username ${RELEASE_PYPI_USERNAME} --password ${RELEASE_PYPI_PASSWORD} --repository testpypi dist/*
Release master:
<<: *release-default
rules:
# Matches <version core> from SemVer 2.0.0 BNF grammar. Ex. 2.3.4, but not 2.3.4-rc
- if: $CI_COMMIT_TAG =~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
script:
- python3 -m twine upload --username ${RELEASE_PYPI_USERNAME} --password ${RELEASE_PYPI_PASSWORD} --repository pypi dist/*