forked from mendersoftware/mender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
121 lines (114 loc) · 4.01 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
stages:
- test
- publish
- trigger
include:
- 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.14
variables:
REPO_NAME: github.com/mendersoftware/mender
before_script:
# Rename the branch we're on, so that it's not in the way for the
# subsequent fetch. It's ok if this fails, it just means we're not on any
# branch.
- git branch -m temp-branch || true
# Git trick: Fetch directly into our local branches instead of remote
# branches.
- git fetch -f origin 'refs/heads/*:refs/heads/*'
# Get last remaining tags, if any.
- git fetch --tags origin
- mkdir -p /go/src/$(dirname $REPO_NAME)/mender /go/src/_/builds
- cp -r $CI_PROJECT_DIR /go/src/$(dirname $REPO_NAME)
- cd $GOPATH/src/$REPO_NAME
- apt-get update && apt-get install -yyq liblzma-dev libssl-dev libglib2.0-dev dbus clang-format-6.0
- make get-tools
script:
- git ls-tree -r --name-only HEAD | grep -v vendor/ | grep '\.[ch]$' | xargs clang-format-6.0 -i
- make extracheck
- 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
paths:
- unit-coverage.tar
test:docker:
image: docker
needs: []
services:
- docker:19.03.5-dind
stage: test
script:
- ./tests/build-docker
publish:tests:
stage: publish
image: golang:1.14-alpine3.11
dependencies:
- test
before_script:
- apk add --no-cache git
# Run go get out of the repo to not modify go.mod
- cd / && go get github.com/mattn/goveralls && cd -
# 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, CI_PR_NUMBER,
# and pass few others as command line arguments.
# See also https://docs.coveralls.io/api-reference
- export CI_BRANCH=${CI_COMMIT_BRANCH}
- export CI_PR_NUMBER=${CI_COMMIT_BRANCH#pr_}
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/,$//')
trigger:mender-qa:
image: alpine
stage: trigger
before_script:
- apk add --no-cache git curl bash python3 py3-pip
- pip3 install pyyaml
- git clone https://github.com/mendersoftware/integration.git integration
- git clone https://github.com/mendersoftware/mender-qa.git mender-qa
script:
- export WORKSPACE=$(pwd)
- mender-qa/scripts/gitlab_trigger_client_publish ${CI_COMMIT_REF_NAME} ${CI_PROJECT_NAME}
only:
- /^(master|[0-9]+\.[0-9]+\.x)$/
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)
# This will only be true in the case that we have a new newest client tag
- PUBLISH_LATEST_CLIENT_PACKAGE="false"
- test "${MENDER_CLIENT_VERSION}" = "${CI_COMMIT_REF_NAME}" && PUBLISH_LATEST_CLIENT_PACKAGE="true" || true
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_LATEST_CLIENT_PACKAGE]=$PUBLISH_LATEST_CLIENT_PACKAGE
https://gitlab.com/api/v4/projects/14968223/trigger/pipeline
only:
- tags
- master