-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
122 lines (107 loc) · 3.94 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
variables:
PACKAGE: template
WHEEL_NAME: template
JOB_WITH_COVERAGE: test_functional
GITLAB_URL: https://scm.atosresearch.eu
#SNS_REGISTRY_COMMON: registry.atosresearch.eu:18467
TMT_REGISTRY_COMMON: registry.atosresearch.eu:18488
stages:
- build
- unit_functional_tests
- release
build_wheel:
image: $TMT_REGISTRY_COMMON/python:3.8-slim
stage: build
only:
- master
- develop
- merge_requests
before_script: # Cannot be added due to CI_JOB_TOKEN policy?
# Used to install sns.logger from git+https instead of --extra-index-url ${NEXUS_PYPI_URL_DOWNLOAD}
- echo "USER_PASSWORD=${CI_JOB_TOKEN}" >> .env
- echo "USER_NAME=gitlab-ci-token" >> .env
- echo "This has been executed"
script: # TODO: learn how to share venv
- pip install -e .
test_functional:
image: $TMT_REGISTRY_COMMON/python:3.8-slim
stage: unit_functional_tests
dependencies:
- build_wheel
only:
- master
- develop
- merge_requests
before_script: # Cannot be added to parent due to CI_JOB_TOKEN policy?
# Used to install sns.logger from git+https instead of --extra-index-url ${NEXUS_PYPI_URL_DOWNLOAD}
- echo "USER_PASSWORD=${CI_JOB_TOKEN}" >> .env
- echo "USER_NAME=gitlab-ci-token" >> .env
- echo "This has been executed"
script:
- echo "Installing ${PACKAGE} in develop mode for coverage purpose"
- cat .env
- mkdir reports
- pip install -e . # tests need to run in develop-mode installed to be able to read coverage
- pytest tests --cov=${PACKAGE} --cov-report html --cov-report term-missing
- cp -r htmlcov reports
coverage: '/TOTAL.+?(\d+%)/'
artifacts:
paths:
- reports/htmlcov
test_pylint:
image: $TMT_REGISTRY_COMMON/cython:3.8-cicd
stage: unit_functional_tests
dependencies:
- build_wheel
only:
- master
- develop
- merge_requests
before_script: # Cannot be added to parent due to CI_JOB_TOKEN policy?
# Used to install sns.logger from git+https instead of --extra-index-url ${NEXUS_PYPI_URL_DOWNLOAD}
- echo "USER_PASSWORD=${CI_JOB_TOKEN}" >> .env
- echo "USER_NAME=gitlab-ci-token" >> .env
- echo "This has been executed"
script:
- pip install -e .
# pylint will fail return non-zero even if only warnings are found
- pylint $PACKAGE tests --exit-zero --reports y >> qa_report.txt
- cat qa_report.txt
- pylint_wrapper --pylint-report-path qa_report.txt raise-for-code
- mkdir reports/
- cp qa_report.txt reports/
artifacts:
paths:
- reports/qa_report.txt
make_badges: # Only update when merged to main branches
image: $TMT_REGISTRY_COMMON/cython:3.8-cicd
stage: release
dependencies:
- test_pylint
- build_wheel
only:
- master
- develop
- merge_requests
before_script: # Cannot be added to parent due to CI_JOB_TOKEN policy?
# Used to install sns.logger from git+https instead of --extra-index-url ${NEXUS_PYPI_URL_DOWNLOAD}
- echo "USER_PASSWORD=${CI_JOB_TOKEN}" >> .env
- echo "USER_NAME=gitlab-ci-token" >> .env
- echo "This has been executed"
script:
- apt-get update
- pip install -e .
- QA=$(pylint_wrapper --pylint-report-path reports/qa_report.txt get-qa-value | tail -1)
- echo ${QA}
- VERSION=$(python -c "import pkg_resources; print(pkg_resources.get_distribution('$WHEEL_NAME').version)") # TODO: parse from dist/
- echo ${VERSION}
- gitlab_wrapper create-badge-file --url $GITLAB_URL --api-token ${API_TOKEN}
--project-id ${CI_PROJECT_ID} --pipeline-id ${CI_PIPELINE_ID} --badge-key Coverage --file-name Coverage.svg --badge-colour COVERAGE
--test-job-name $JOB_WITH_COVERAGE
- gitlab_wrapper create-badge-file --badge-key Pylint --badge-value ${QA} --file-name Pylint.svg --badge-colour QA
- gitlab_wrapper create-badge-file --badge-key Version --badge-value ${VERSION} --file-name Version.svg --badge-colour VERSION
artifacts:
paths:
- Coverage.svg
- Version.svg
- Pylint.svg