-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy path.gitlab-ci-check-license.yml
More file actions
146 lines (140 loc) · 4.74 KB
/
.gitlab-ci-check-license.yml
File metadata and controls
146 lines (140 loc) · 4.74 KB
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
# .gitlab-ci-check-license.yml
#
# This gitlab-ci template runs license tests
#
# Add it to the project in hand through Gitlab's include functionality.
#
# include:
# - project: 'Northern.tech/Mender/mendertesting'
# file: '.gitlab-ci-check-license.yml'
#
# If the repository includes enterprise (aka, non-Open-Source) Go lang code, you
# can specify the first git commit SHA of the enterprise code, also known as
# forking commit, setting the FIRST_ENT_COMMIT env variable.
#
# You can add known license files setting the KNOWN_LICENSE_FILES env variable
# to a list of space separated files to include to the list of auto-detected
# license files.
#
# With regards to source code files, you can exclude files via regular
# expression with the variable LICENSE_HEADERS_IGNORE_FILES_REGEXP.
#
# test:check-license:
# variables:
# FIRST_ENT_COMMIT: "<sha>"
# KNOWN_LICENSE_FILES: "path/to/README.md path/to-another/LICENSE.md"
# LICENSE_HEADERS_IGNORE_FILES_REGEXP: '\./exclude-this/.*\.py'
#
include:
- project: 'Northern.tech/Mender/mendertesting'
file: 'qa-common/retry.yml'
variables:
# Variables defined here are fallbacks if not defined elsewhere.
GOLANG_VERSION:
description: "Container image version for golang used in jobs"
value: "1.24"
stages:
- test
test:check-license:
tags:
- k8s-small
stage: test
needs: []
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
rules:
- exists:
- licenses.csv
when: never
- when: always
image: registry.gitlab.com/northern.tech/mender/mender-test-containers:base-alpine-master
variables:
GIT_STRATEGY: clone # clone entire repo instead of reusing workspace
GIT_DEPTH: 0 # avoid shallow clone, this test requires full git history
before_script:
- !reference [.qa-common-network-git-clone-retry, before_script]
# Install dependencies
- apk add --no-cache bash perl-utils
# 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
- if [ "$CI_PROJECT_NAME" = "mendertesting" ]; then
- SCRIPT_PATH=$PWD
- else
- git clone --depth=1 https://github.com/mendersoftware/mendertesting /tmp/mendertesting
- SCRIPT_PATH=/tmp/mendertesting
- fi
script:
# Check licenses
- $SCRIPT_PATH/check_license.sh
test:check-license:golang:
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/golang:${GOLANG_VERSION}
tags:
- k8s-small
stage: test
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
rules:
- exists:
- licenses.csv
when: always
- exists:
- LIC_FILES_CHKSUM.sha256
when: never
needs: []
before_script:
- !reference [.qa-common-network-go-retry, before_script]
- !reference [.qa-common-network-git-clone-retry, before_script]
- go install github.com/google/go-licenses@latest
- git clone --no-tags --depth=1 --single-branch https://github.com/mendersoftware/mendertesting /tmp/mendertesting
script:
- go-licenses report . --ignore github.com/mendersoftware --template /tmp/mendertesting/go_licenses_format.tpl > licenses.csv
- git diff --exit-code
test:check-license-source:
tags:
- k8s-small
stage: test
needs: []
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
image: registry.gitlab.com/northern.tech/mender/mender-test-containers:base-alpine-master
variables:
GIT_STRATEGY: clone # clone entire repo instead of reusing workspace
GIT_DEPTH: 0 # avoid shallow clone, this test requires full git history
before_script:
- !reference [.qa-common-network-git-clone-retry, before_script]
# Install dependencies
- apk add --no-cache bash perl-utils grep
# 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
- if [ "$CI_PROJECT_NAME" = "mendertesting" ]; then
- SCRIPT_PATH=$PWD
- else
- git clone --depth=1 https://github.com/mendersoftware/mendertesting /tmp/mendertesting
- SCRIPT_PATH=/tmp/mendertesting
- fi
script:
# Check licenses
- $SCRIPT_PATH/check_license_source_files.sh