forked from mendersoftware/mender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
174 lines (163 loc) · 5.25 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
stages:
- test
- publish
- trigger_prep
- trigger
variables:
GOLANG_VERSION: "1.17.13"
include:
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-golang-lint.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-github-status-updates.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-commits.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-license.yml'
test:
stage: test
image: golang:1.17
before_script:
- apt-get update && apt-get install -yyq liblzma-dev libssl-dev libglib2.0-dev dbus clang-format-9
- GO111MODULE=off go get -u github.com/jstemmer/go-junit-report
script:
- git ls-tree -r --name-only HEAD | grep -v vendor/ | grep '\.[ch]$' | xargs clang-format-9 -i
- make coverage
- make
- mkdir -p tests/unit-coverage && find . -name 'coverage.txt' -exec cp --parents {} ./tests/unit-coverage \;
- tar -cvf $CI_PROJECT_DIR/unit-coverage.tar tests/unit-coverage
tags:
- mender-qa-slave
artifacts:
expire_in: 2w
reports:
junit: report.xml
paths:
- unit-coverage.tar
test:modules-artifact-gen:
stage: test
image: python:3.9
before_script:
# mender-artifact
- curl https://downloads.mender.io/mender-artifact/master/linux/mender-artifact
-o /usr/local/bin/mender-artifact
- chmod +x /usr/local/bin/mender-artifact
# Test dependencies
- pip install -r support/modules-artifact-gen/tests/requirements.txt
script:
- python -m pytest support/modules-artifact-gen/tests
test:docker:
image: docker
needs: []
services:
- docker:19.03.5-dind
stage: test
script:
- ./tests/build-docker
publish:tests:
stage: publish
image: golang:1.17-alpine3.14
dependencies:
- test
before_script:
# Install dependencies
- apk add --no-cache git
- GO111MODULE=off go get -u github.com/mattn/goveralls
# Coveralls env variables:
# According to https://docs.coveralls.io/supported-ci-services
# we should set CI_NAME, CI_BUILD_NUMBER, etc. But according
# to goveralls source code (https://github.com/mattn/goveralls)
# many of these are not supported. Set CI_BRANCH,
# and pass few others as command line arguments.
# See also https://docs.coveralls.io/api-reference
- export CI_BRANCH=${CI_COMMIT_BRANCH}
script:
- tar -xvf unit-coverage.tar
- goveralls
-repotoken ${COVERALLS_TOKEN}
-service gitlab-ci
-jobid $(git rev-parse HEAD)
-covermode set
-flagname unittests
-parallel
-coverprofile $(find tests/unit-coverage -name 'coverage.txt' | tr '\n' ',' | sed 's/,$//')
generate-qa-trigger:
image: python:alpine
stage: trigger_prep
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|[0-9]+\.[0-9]+\.x)$/'
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
before_script:
- apk add --no-cache git
- pip3 install pyyaml
- wget -q https://raw.githubusercontent.com/mendersoftware/mender-qa/master/scripts/generate_client_publish_job.py
script:
- python generate_client_publish_job.py --trigger ${CI_PROJECT_NAME} --version ${CI_COMMIT_REF_NAME} --filename gitlab-ci-client-qemu-publish-job.yml
artifacts:
paths:
- gitlab-ci-client-qemu-publish-job.yml
trigger:mender-qa:
stage: trigger
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|[0-9]+\.[0-9]+\.x)$/'
# the following is to prevent an endless loop of qa pipelines caused by downstream pipelines
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
trigger:
include:
- artifact: gitlab-ci-client-qemu-publish-job.yml
job: generate-qa-trigger
trigger:mender-dist-packages:
image: alpine
stage: trigger
variables:
GIT_DEPTH: 0
before_script:
- apk add --no-cache curl git
- MENDER_CLIENT_VERSION=$(git tag | egrep -e '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r | head -n1)
script:
- curl -v -f -X POST
-F token=$MENDER_DIST_PACKAGES_TRIGGER_TOKEN
-F ref=master
-F variables[MENDER_VERSION]=$CI_COMMIT_REF_NAME
-F variables[PUBLISH_MENDER_DIST_PACKAGES_AUTOMATIC]=true
https://gitlab.com/api/v4/projects/14968223/trigger/pipeline
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
trigger:mender-docs-site:
image: alpine
stage: trigger
before_script:
- apk add --no-cache curl
script:
- curl -v -f -X POST
-F token=$MENDER_DOCS_SITE_TRIGGER_TOKEN
-F ref=master
https://gitlab.com/api/v4/projects/16842368/trigger/pipeline
- curl -v -f -X POST
-F token=$MENDER_DOCS_SITE_TRIGGER_TOKEN
-F ref=production
https://gitlab.com/api/v4/projects/16842368/trigger/pipeline
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|[0-9]+\.[0-9]+\.x)$/'
changes:
- Documentation/*
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
trigger:integration:
stage: trigger
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
trigger:
project: Northern.tech/Mender/integration
branch: master
strategy: depend