-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
161 lines (117 loc) · 3.51 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
variables:
GIT_SUBMODULE_STRATEGY: recursive
# We want full history so that "git describe" always works correctly.
GIT_DEPTH: 0
FF_ENABLE_BASH_EXIT_CODE_CHECK: "true"
# We always want to run with the Go version installed in a Docker image.
GOTOOLCHAIN: local
test:
stage: test
image: golang:$IMAGE_TAG
before_script:
- apk --update add make bash gcc musl-dev
- (cd /go; go install gotest.tools/[email protected])
- (cd /go; go install github.com/boumenot/[email protected])
- go version
script:
- make test-ci
artifacts:
when: always
reports:
junit: tests.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- tests.xml
- coverage.html
- coverage.xml
expire_in: never
# "\s" at the beginning is important so that we match only output from
# "go tool covdata percent" and not one from "go test" itself.
coverage: '/\scoverage: \d+\.\d+% of statements/'
parallel:
matrix:
- IMAGE_TAG: ['1.23-alpine3.19']
lint:
stage: test
image: golang:1.23-alpine3.19
before_script:
- apk --update add make bash gcc musl-dev jq
- wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.3
script:
- make lint-ci
artifacts:
when: always
reports:
codequality: codeclimate.json
expire_in: never
fmt:
stage: test
image: golang:1.23-alpine3.19
before_script:
- apk --update add make bash git gcc musl-dev grep
- go install mvdan.cc/[email protected]
- go install golang.org/x/tools/cmd/[email protected]
script:
- make fmt-ci
lint_docs:
stage: test
image: node:20.17-alpine3.19
before_script:
- apk --update add make bash git
script:
- make lint-docs-ci
audit:
stage: test
image: golang:1.23-alpine3.19
before_script:
- apk --update add make bash git gcc musl-dev
- go install github.com/sonatype-nexus-community/[email protected]
script:
- make audit
commits:
stage: test
image: golang:1.23-alpine3.19
variables:
GIT_DEPTH: "0"
before_script:
- apk --update add git
script:
- '! git log --oneline "-G^(<<<<<<<|=======|>>>>>>>)" | grep "^"'
publish:
stage: deploy
image: golang:1.23-alpine3.19
script:
- GOPROXY=proxy.golang.org go list -m "gitlab.com/tozd/go/cli@$CI_COMMIT_REF_NAME"
rules:
# Only on protected tags on main repository. Protected tags start with "v".
- if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^v/ && $CI_PROJECT_PATH == "tozd/go/cli"'
# We do not need build artifacts in this job.
dependencies: []
sync_releases:
stage: deploy
image:
name: registry.gitlab.com/tozd/gitlab/release/tag/v0-6-0:latest-debug
entrypoint: [""]
script:
# On branch jobs, just update or remove releases, thus releases are created only on tag jobs.
- /gitlab-release ${CI_COMMIT_BRANCH:+--no-create}
rules:
# Protected tags start with "v".
- if: '$GITLAB_API_TOKEN && ($CI_COMMIT_BRANCH == "main" || ($CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^v/))'
# We do not need build artifacts in this job.
dependencies: []
sync_config:
stage: deploy
image:
name: registry.gitlab.com/tozd/gitlab/config/tag/v0-5-0:latest-debug
entrypoint: [""]
script:
- /gitlab-config set
rules:
- if: '$GITLAB_API_TOKEN && $SOPS_AGE_KEY_FILE && $CI_COMMIT_BRANCH == "main"'
changes:
- .gitlab-conf.yml
# We do not need build artifacts in this job.
dependencies: []