-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlab-ci.yml
197 lines (197 loc) · 5.58 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
---
variables:
GO_VERSION: '1.18'
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: "$CI_COMMIT_TAG"
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
default:
image: golang:${GO_VERSION}
stages:
- build
- test
- deploy
include:
- remote: https://gitlab.com/gitlab-org/incubation-engineering/five-minute-production/library/-/raw/main/gcp/cloud-run.gitlab-ci.yml
".go-cache":
variables:
GOPATH: "$CI_PROJECT_DIR/.go"
GOLANGCI_LINT_CACHE: "$CI_PROJECT_DIR/.golangci-lint"
before_script:
- mkdir -p .go .golangci-lint
cache:
paths:
- ".go/pkg/mod/"
- ".golangci-lint/"
".documentation":
stage: documentation
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
check_docs_update:
extends: ".documentation"
script:
- git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME && git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
&& git checkout $CI_COMMIT_SHA
- make gen-docs
- |-
git status
if [[ $(git add -A --dry-run) ]]; then
echo '✖ ERROR: Documentation changes detected!';
echo '✖ These changes require a documentation update. To regenerate the docs, read https://gitlab.com/gitlab-org/cli/-/tree/main/docs#generating-the-docs.';
exit 1;
else
echo '✔ No documentation updates detected.';
exit 0;
fi
check_docs_markdown:
image: registry.gitlab.com/gitlab-org/gitlab-docs/lint-markdown:alpine-3.16-vale-2.20.1-markdownlint-0.32.2
extends: ".documentation"
script:
- vale --minAlertLevel error docs README.md
- markdownlint --config .markdownlint.yml 'docs/**/*.md' README.md
lint_commit:
stage: test
image: node:16-slim
script:
- apt-get update && apt-get install -y git
- git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME && git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
&& git checkout $CI_COMMIT_SHA
- cd scripts/commit-lint && npm ci
- node lint.js
rules:
- if: $CI_MERGE_REQUEST_IID && $CI_PROJECT_VISIBILITY == "public"
when: always
lint:
extends: ".go-cache"
image: registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-1.50-alpine
stage: test
script:
- golangci-lint --version
- "[ -e .golangci.yml ] || cp /golangci/.golangci.yml ."
- golangci-lint run --out-format colored-line-number:stdout,code-climate:gl-code-quality-report.json
artifacts:
reports:
codequality: gl-code-quality-report.json
paths:
- gl-code-quality-report.json
code_navigation:
stage: test
image: golang:latest
allow_failure: true
script:
- go install github.com/sourcegraph/lsif-go/cmd/lsif-go@latest
- lsif-go
artifacts:
reports:
lsif: dump.lsif
run_tests:
stage: test
extends: ".go-cache"
parallel:
matrix:
- GO_VERSION:
- '1.18'
- '1.19'
- '1.20'
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- chmod 600 ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
script:
- GITLAB_TOKEN=$GITLAB_TOKEN_TEST make test
after_script:
- echo -e "\e[0Ksection_start:`date +%s`:coverage[collapsed=true]\r\e[0KRunning
coverage report"
- make coverage
- echo -e "\e[0Ksection_end:`date +%s`:coverage\r\e[0K"
coverage: "/^total:\\t+\\(statements\\)\\t+\\d+\\.\\d+%$/"
artifacts:
reports:
junit: coverage.xml
".release":
stage: release
image: docker:stable
services:
- docker:dind
variables:
GIT_DEPTH: 0
needs:
- windows_installer
dependencies:
- windows_installer
release_test:
extends: ".release"
rules:
- if: "$CI_COMMIT_TAG"
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
script: |
docker run --rm --privileged \
-v $PWD:/go/src/gitlab.com/gitlab-org/cli \
-w /go/src/gitlab.com/gitlab-org/cli \
-v /var/run/docker.sock:/var/run/docker.sock \
goreleaser/goreleaser release --snapshot
build_windows:
stage: test
extends: ".go-cache"
script:
- GOOS=windows GOARCH=amd64 make build
- mv bin/glab bin/glab.exe
artifacts:
paths:
- bin/glab.exe
expire_in: 30 days
windows_installer:
stage: release
image:
name: amake/innosetup
entrypoint:
- ''
script:
- mv scripts/setup_windows.iss .
- iscc "setup_windows.iss" -DVersion=${CI_COMMIT_TAG//v}
artifacts:
paths:
- bin/*
expire_in: 30 days
dependencies:
- build_windows
needs:
- build_windows
release:
extends: ".release"
rules:
- if: "$CI_COMMIT_TAG"
script: |
docker run --rm --privileged \
-v $PWD:/go/src/gitlab.com/gitlab-org/cli \
-w /go/src/gitlab.com/gitlab-org/cli \
-v /var/run/docker.sock:/var/run/docker.sock \
-e GITLAB_TOKEN=$GITLAB_TOKEN_RELEASE \
--entrypoint "" \
goreleaser/goreleaser \
bash -c "
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
docker login -u $DOCKER_IO_USER -p $DOCKER_IO_PASSWORD
goreleaser release
"
homebrew-release:
image: homebrew/ubuntu22.04:latest
stage: release
rules:
- if: "$CI_COMMIT_TAG"
script:
- touch ~/.gitconfig
- git config --global user.email "$GITHUB_EMAIL"
- git config --global user.name "$GITHUB_NAME"
- curl "$CI_PROJECT_URL/-/archive/$CI_COMMIT_TAG/$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz"
--output "$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz"
- brew bump-formula-pr glab --no-browse --url="$CI_PROJECT_URL/-/archive/$CI_COMMIT_TAG/$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz"
--sha256="$(sha256sum $CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz | cut -d ' ' -f 1)"
secret_detection:
dependencies: []