-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
85 lines (70 loc) · 2.62 KB
/
.gitlab-ci.yml
File metadata and controls
85 lines (70 loc) · 2.62 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
include:
- local: 'qa-common/retry.yml'
- local: '.gitlab-ci-check-commits.yml'
- local: '.gitlab-ci-check-license.yml'
- local: '.gitlab-ci-github-status-updates.yml'
stages:
- test
variables:
UNVERSIONED_REPOSITORY: "true"
test:unit:
variables:
GIT_STRATEGY: clone # clone entire repo instead of reusing workspace
GIT_DEPTH: 0 # avoid shallow clone, this test requires full git history
tags:
- mender-qa-worker-generic-light
image: golang:1.20
stage: test
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
# Prepare GO path
- mkdir -p /go/src/github.com/mendersoftware
- cp -r $CI_PROJECT_DIR /go/src/github.com/mendersoftware/mendertesting
- cd /go/src/github.com/mendersoftware/mendertesting
# Prepare Git
- git config --global user.name "Test"
- git config --global user.email "test@example.com"
script:
# Test if code was formatted with 'go fmt'
# Command will format code and return modified files
# fail if any have been modified.
- if [ -n "$(go fmt)" ]; then echo 'Code is not formatted with "go fmt"'; false; fi
# Perform static code analysys
- go vet `go list ./... | grep -v vendor`
# go list supply import paths for all sub directories.
# Exclude vendor directory, we don't want to run tests and coverage for all dependencies every time,
# also including their coverage may introduce to much noice. Concentrate on the coverage of local packages.
# Execute go test on every local subpackage (resolved as dependencies) and generate covreage report for each.
# Test packages pararell (xargs -P)
- go list ./... | grep -v vendor | xargs -n1 -I {} -P 4 go test -v -covermode=atomic -coverprofile=../../../{}/coverage.txt {} || exit $?
# Collect coverage report
- cp coverage.txt $CI_PROJECT_DIR/
artifacts:
expire_in: 2w
paths:
- coverage.txt
test:unit:commitlint:
tags:
- k8s-small
image: registry.gitlab.com/northern.tech/mender/mender-test-containers:base-alpine-master
stage: test
before_script:
- apk add --no-cache gawk
script:
- commitlint/testcommitlint.sh
test:unit:commitlint:mac:
tags:
- mac-arm-runner
stage: test
before_script:
- brew install gawk
script:
- commitlint/testcommitlint.sh