-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
109 lines (89 loc) · 2.04 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
default:
image: golang:1.16
before_script:
- echo "CI for ${TOOL_NAME} commit ID ${CI_COMMIT_SHA}"
after_script:
- ls -lR .
# do not forget to set project variables
include:
- template: Jobs/Code-Quality.gitlab-ci.yml # GITLAB_FEATURES = "code_quality"
- template: Security/Dependency-Scanning.gitlab-ci.yml # GITLAB_FEATURES = "dependency_scanning"
- template: Security/License-Scanning.gitlab-ci.yml # GITLAB_FEATURES = "license_scanning"
- template: Security/SAST.gitlab-ci.yml # GITLAB_FEATURES = "sast"
stages:
- build
- test
- release
.ci-vars:
variables:
TOOL_NAME: "go-module-xmcnbiclient"
SAST_DISABLE_DIND: "true"
SAST_GOSEC_LEVEL: 0
.build_command: &build_command
- go build ./...
.test_command: &test_command
- go test ./... -cover
build-tagged:
stage: build
rules:
- if: '$CI_COMMIT_TAG'
when: always
script:
- *build_command
test-tagged:
stage: test
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
script:
- *test_command
release-tagged:
stage: release
rules:
- if: '$CI_COMMIT_TAG'
when: on_success
script:
- echo Release
release:
tag_name: ${CI_COMMIT_TAG}
name: '${TOOL_NAME} ${CI_COMMIT_TAG}'
ref: ${CI_COMMIT_SHA}
description: '${TOOL_NAME} ${CI_COMMIT_TAG} based on commit ID ${CI_COMMIT_SHA}'
build-master:
stage: build
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: $CI_COMMIT_BRANCH == "master"
when: always
script:
- *build_command
test-master:
stage: test
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: $CI_COMMIT_BRANCH == "master"
when: on_success
script:
- *test_command
build-any:
stage: build
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: $CI_COMMIT_BRANCH != "master"
when: always
allow_failure: true
script:
- *build_command
test-any:
stage: test
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: $CI_COMMIT_BRANCH != "master"
when: on_success
allow_failure: true
script:
- *test_command