-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
119 lines (105 loc) · 2.86 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
stages:
- test
- qa
- package
- release
variables:
MKP_FILENAME: 'fileconnector-${CI_COMMIT_REF_SLUG}.mkp'
pylint:
stage: qa
needs: []
image: python:3-slim
before_script:
- pip install pylint
script:
- pylint lib/check_mk/cee/dcd/plugins/connectors/fileconnector.py web/plugins/wato/fileconnector.py
allow_failure: true
flake8:
stage: qa
needs: []
image: python:3-slim
before_script:
- pip install flake8
script:
- flake8 lib/check_mk/cee/dcd/plugins/connectors/fileconnector.py web/plugins/wato/fileconnector.py
allow_failure: true
run tests:
stage: test
image: python:3
before_script:
- pip install pytest pytest-cov
script:
- pytest --cov=fileconnector --cov-report term --cov-report xml:coverage.xml tests/
artifacts:
reports:
junit: coverage.xml
render info:
stage: test
image: python:3-slim
variables:
VERSION: $CI_COMMIT_REF_SLUG
before_script:
- pip install markdown
script:
- echo "Rendering for version ${VERSION}"
# Fill the template with our data
- python create_package_metadata.py
# Converting info into info.json
- python -c 'import json; f = open("info"); exec("j=%s" % f.read()); fj = open("info.json", "w"); json.dump(j, fj)'
artifacts:
paths:
- info
- info.json
rules:
- if: $CI_COMMIT_TAG
variables:
VERSION: $CI_COMMIT_TAG
# Do not render during MR
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- when: always
create mkp:
stage: package
needs:
- run tests
- job: render info
artifacts: true
image: alpine
rules:
- if: $CI_COMMIT_TAG
# when running through a manual start include the commit hash instead of branch name
- if: '$CI_PIPELINE_SOURCE == "api" || $CI_PIPELINE_SOURCE == "web"'
variables:
MKP_FILENAME: 'fileconnector-${CI_COMMIT_SHORT_SHA}.mkp'
script:
# Creating required tar files
- tar -cv -C lib/ -f lib.tar check_mk/
- tar -cv -C web/ -f web.tar plugins/wato/
# Packing the final archive
- tar -czvf ${MKP_FILENAME} info info.json lib.tar web.tar
# Save address for reference during release
- echo "ARTIFACT_JOB_URL=${CI_JOB_URL}/artifacts/raw/${MKP_FILENAME}?inline=false" >> variables.env
artifacts:
paths:
- ${MKP_FILENAME}
reports:
dotenv: variables.env
create release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: create mkp
artifacts: true
rules:
- if: $CI_COMMIT_TAG
script:
- echo 'Creating release for $CI_COMMIT_TAG'
release:
tag_name: '$CI_COMMIT_TAG'
description: 'Automatically created through release-cli'
assets:
links:
- name: '${MKP_FILENAME}'
url: '${ARTIFACT_JOB_URL}'
filepath: '/${MKP_FILENAME}' # nice download URL
link_type: 'package'