-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
244 lines (223 loc) · 6.74 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
variables:
PACKAGE_NAME: sensmetry.sysml-2ls
EXTENSION_NAME: $PACKAGE_NAME-${CI_COMMIT_SHORT_SHA}
EXTENSION_PATH: $CI_PROJECT_DIR/$EXTENSION_NAME.vsix
SERVER_FILENAME: syside-languageserver.js
SERVER_ZIPNAME: syside-languageserver.zip
SERVER_DIST_PATH: packages/syside-vscode/dist/node
SERVER_PATH: $CI_PROJECT_DIR/$SERVER_DIST_PATH/language-server/main.js
SERVER_LICENSE: $CI_PROJECT_DIR/$SERVER_DIST_PATH/LICENSE
default:
image: node:19.2
before_script:
- corepack enable
- corepack prepare pnpm@latest-9 --activate
- pnpm config set store-dir .pnpm-store
- pnpm install --ignore-scripts
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
stages:
- build
- test
- deploy
- publish
build:
stage: build
script:
- pnpm run lint
- pnpm run build
artifacts:
# seems like gitlab doesn't pass untracked artifacts to the next stage by
# default, use a short expiration time since they should only be available
# for the next stage
untracked: true
expire_in: 5 mins
exclude:
- node_modules/**/*
- packages/**/node_modules/**/*
- .pnpm-store/**/*
code_navigation:
allow_failure: true # recommended
script:
- npm install -g @sourcegraph/scip-typescript
- scip-typescript index --pnpm-workspaces
- env
TAG="v0.4.0"
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed -e 's/x86_64/amd64/')"
bash -c 'curl -L "https://github.com/sourcegraph/scip/releases/download/$TAG/scip-$OS-$ARCH.tar.gz"' | tar xzf - scip
- ./scip convert
artifacts:
reports:
lsif: dump.lsif
test:
stage: test
coverage: /Lines\s*:\s*(\d+.?\d*)%/
script:
- pnpm run test:ci
artifacts:
paths:
- coverage/
when: always
reports:
junit:
- junit.xml
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
validate:
stage: test
script:
- pnpm run prepare-validation
- pnpm run run-validation
.apt_install_package: &apt_install_package |
apt-get update -qq
apt-get install -y --no-install-recommends zip
.package_artefacts: &package_artefacts |
pnpm run vscode:package -o $EXTENSION_PATH
cp $SERVER_PATH $SERVER_FILENAME
zip $SERVER_ZIPNAME -j $SERVER_FILENAME $SERVER_LICENSE
.package-template:
stage: deploy
script:
- *apt_install_package
- *package_artefacts
artifacts:
paths:
- $SERVER_ZIPNAME
- $EXTENSION_PATH
name: $EXTENSION_NAME
expire_in: 1 mos
package:production:
extends: .package-template
rules:
# do not run on tags
- if: $VERSION
when: never
# only on pushes to main branch
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
environment: production
package:development:
extends: .package-template
rules:
# do not run on tags
- if: $VERSION || $CI_PIPELINE_SOURCE == 'merge_request_event'
when: never
# only on pushes to other branches (i.e. MRs)
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
environment: development
pages:
stage: deploy
before_script: []
needs:
- job: test
artifacts: true
script:
- mkdir .public
- cp -r coverage/* .public
- mv .public public
artifacts:
paths:
- public
only:
- main
# =======================================================================
# Jobs for release
# =======================================================================
.on-release-template:
rules:
- if: $VERSION && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
environment: release
variables:
EXTENSION_NAME: $PACKAGE_NAME-$VERSION
EXTENSION_FILENAME: $EXTENSION_NAME.vsix
EXTENSION_RELPATH: $EXTENSION_FILENAME
EXTENSION_PATH: $CI_PROJECT_DIR/$EXTENSION_FILENAME
package:release:
stage: deploy
extends: .on-release-template
script:
- >
if [ $(git tag -l "$VERSION") ]; then
echo "$VERSION tag already exists, bailing out"
exit 1
fi
- *apt_install_package
# add GH and GL remotes and check that we can access them
- git remote add github_origin https://github-ci-token:${GH_ACCESS_TOKEN}@github.com/sensmetry/sysml-2ls.git
- git ls-remote -q github_origin
- git remote add gitlab_origin https://gitlab-ci-token:${ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git
- git ls-remote -q gitlab_origin
- echo "Preparing for $VERSION release"
# update version fields
- pnpm run --silent prepare-release $VERSION -o release.description
# setup bot
- git config user.email "${GITLAB_USER_EMAIL}"
- git config user.name "${GITLAB_USER_NAME}"
# commit version changes
- git add --all
- git commit -m "Release $VERSION"
- git tag ${VERSION}
# package the extension
- *package_artefacts
- echo PACKAGE_JOB_ID=$CI_JOB_ID >> release.env
# push to github mirror first before gitlab can push automatically and this fails
# prevent triggering pipeline again with -o ci.skip
- git push github_origin HEAD:main -o ci.skip
- git push gitlab_origin HEAD:main -o ci.skip
# push tags as the last command
- git push github_origin HEAD:main --tags -o ci.skip
- git push gitlab_origin HEAD:main --tags -o ci.skip
artifacts:
paths:
- $SERVER_ZIPNAME
- $EXTENSION_PATH
- release.description
name: $EXTENSION_NAME
# release builds never expire
expire_in: never
reports:
dotenv: release.env
.publish-template:
stage: publish
extends: .on-release-template
needs:
- job: package:release
artifacts: true
publish:release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
extends: .publish-template
variables:
ARTIFACTS_ROOT_URL: ${CI_SERVER_PROTOCOL}://${CI_SERVER_HOST}/${CI_PROJECT_PATH}/-/jobs/${PACKAGE_JOB_ID}/artifacts/raw
before_script: []
# cache is not needed, not running TS
cache:
script:
- echo "Releasing $VERSION"
release:
# See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: "$VERSION"
description: ./release.description
assets:
links:
- name: $EXTENSION_FILENAME
url: $ARTIFACTS_ROOT_URL/$EXTENSION_RELPATH
- name: $SERVER_FILENAME
url: $ARTIFACTS_ROOT_URL/$SERVER_FILENAME
publish:github:
extends: .publish-template
script:
- echo "Creating and uploading release artifacts to GitHub mirror for version $VERSION"
- node ./scripts/gh-release.mjs --pat ${GH_ACCESS_TOKEN} --tag ${VERSION} --notes ./release.description -a ${EXTENSION_FILENAME}=${EXTENSION_PATH} -a ${SERVER_FILENAME}
publish:vscode:
extends: .publish-template
script:
- pnpm run vscode:publish --packagePath $EXTENSION_PATH
publish:ovsx:
extends: .publish-template
script:
- pnpm run ovsx:publish --packagePath $EXTENSION_PATH