-
-
Notifications
You must be signed in to change notification settings - Fork 29
285 lines (221 loc) · 10.1 KB
/
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# Copyright (C) 2019-2021 Julian Valentin, LTeX Development Community
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
name: "CI"
on:
push:
branches:
- "*"
tags:
- "*"
pull_request:
branches:
- "develop"
workflow_dispatch:
jobs:
buildForVsCode:
name: "CI - Build for VS Code Job"
runs-on: "${{ matrix.os }}"
strategy:
matrix:
os:
- "ubuntu-20.04"
- "macos-11.0"
- "windows-2019"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2"
- name: "Set up Node.js"
uses: "actions/setup-node@v1"
with:
node-version: "16.11.0"
- name: "Install Node.js Dependencies"
run: "npm install && npm install -g vsce@1.100.1"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "3.9.0"
- name: "Install Python Dependencies"
run: "python -u -m pip install --upgrade pip && pip install semver==2.13.0"
- name: "Start X Virtual Frame Buffer"
if: "${{ startsWith(matrix.os, 'ubuntu-') }}"
run: "echo \"DISPLAY=:99.0\" >> $GITHUB_ENV && Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &"
- name: "Build Package with vsce"
run: "vsce package"
- name: "Run ESLint"
run: "npm run lint"
- name: "Run Mocha Tests (Linux)"
if: "${{ startsWith(matrix.os, 'ubuntu-') }}"
env:
LTEX_GITHUB_OAUTH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# to suppress "async hook stack has become corrupted" errors
# (https://github.com/microsoft/vscode/issues/85601)
NODE_OPTIONS: "--no-force-async-hooks-checks"
run: "npm run test"
- name: "Run Mocha Tests (Windows)"
if: "${{ startsWith(matrix.os, 'windows-') }}"
env:
LTEX_GITHUB_OAUTH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# to suppress "async hook stack has become corrupted" errors
# (https://github.com/microsoft/vscode/issues/85601)
NODE_OPTIONS: "--no-force-async-hooks-checks"
# otherwise, git clean fails to remove lib/ with "Invalid argument" errors
run: "npm run test -- --fast"
buildForCocNvim:
name: "CI - Build for coc.nvim Job"
runs-on: "ubuntu-20.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2"
- name: "Set up Node.js"
uses: "actions/setup-node@v1"
with:
node-version: "16.11.0"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "3.9.0"
- name: "Install Python Dependencies"
run: "python -u -m pip install --upgrade pip && pip install semver==2.13.0"
- name: "Patch for coc.nvim Target"
run: "python -u tools/patchForTarget.py --target coc.nvim"
- name: "Install Node.js Dependencies"
run: "npm install"
- name: "Compile and Package"
run: "npm run coc.nvim:prepublish"
- name: "Run ESLint"
run: "npm run lint"
validate:
name: "CI - Validate Job"
runs-on: "ubuntu-20.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "3.9.0"
- name: "Install Python Dependencies"
run: "python -u -m pip install --upgrade pip && pip install jsonschema==3.2.0 xmlschema==1.6.4"
- name: "Validate changelog.xml"
run: "python -u -c 'import xmlschema; xmlschema.XMLSchema(\"schemas/changes-1.0.0.xsd\").validate(\"changelog.xml\")'"
- name: "Validate JSON files"
run: "python -u tools/validateJsonFiles.py"
analyzeCodeQl:
name: "CI - CodeQL Job"
runs-on: "ubuntu-20.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2"
- name: "Initialize CodeQL"
uses: "github/codeql-action/init@v1"
with:
languages: "javascript,python"
- name: "Autobuild"
uses: "github/codeql-action/autobuild@v1"
- name: "Perform CodeQL Analysis"
uses: "github/codeql-action/analyze@v1"
deployForVsCode:
name: "CI - Deploy for VS Code Job"
if: "${{ startsWith(github.ref, 'refs/tags/') }}"
needs:
- "buildForVsCode"
- "buildForCocNvim"
- "validate"
- "analyzeCodeQl"
runs-on: "ubuntu-20.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2"
- name: "Set up Node.js"
uses: "actions/setup-node@v1"
with:
node-version: "16.11.0"
- name: "Install Node.js Dependencies"
run: "npm install && npm install -g vsce@1.100.1 ovsx@0.2.1"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "3.9.0"
- name: "Install Python Dependencies"
run: "python -u -m pip install --upgrade pip && pip install semver==2.13.0"
- name: "Set VSCODE_LTEX_VERSION"
run: "echo \"VSCODE_LTEX_VERSION=$(python -u -c \"import json; print(json.load(open('package.json', 'r'))['version'], end='')\")\" >> $GITHUB_ENV"
- name: "Check VSCODE_LTEX_VERSION"
run: "if [[ -z \"$VSCODE_LTEX_VERSION\" ]]; then echo 'Error: VSCODE_LTEX_VERSION not set!'; (exit 1); fi; echo \"VSCODE_LTEX_VERSION set to '$VSCODE_LTEX_VERSION'\""
- name: "Set VSCODE_LTEX_IS_PRERELEASE"
run: "if [[ -z \"$VSCODE_LTEX_VERSION\" ]]; then echo 'Error: VSCODE_LTEX_VERSION not set!'; (exit 1); fi; echo \"VSCODE_LTEX_IS_PRERELEASE=$(python -u -c \"import semver; print('true' if semver.VersionInfo.parse('$VSCODE_LTEX_VERSION').prerelease is not None else 'false', end='')\")\" >> $GITHUB_ENV"
- name: "Check VSCODE_LTEX_IS_PRERELEASE"
run: "if [[ -z \"$VSCODE_LTEX_IS_PRERELEASE\" ]]; then echo 'Error: VSCODE_LTEX_IS_PRERELEASE not set!'; (exit 1); fi; echo \"VSCODE_LTEX_IS_PRERELEASE set to '$VSCODE_LTEX_IS_PRERELEASE'\""
- name: "Set VSCODE_LTEX_CHANGELOG"
run: "if [ \"$VSCODE_LTEX_IS_PRERELEASE\" = \"false\" ]; then echo \"VSCODE_LTEX_CHANGELOG<<EOF\" >> $GITHUB_ENV; python -u tools/convertChangelog.py --xml-file changelog.xml --version latest >> $GITHUB_ENV; echo \"EOF\" >> $GITHUB_ENV; else echo \"VSCODE_LTEX_CHANGELOG=This is a pre-release. Use at your own risk.\" >> $GITHUB_ENV; fi"
- name: "Build Package with vsce"
run: "vsce package"
- name: "Build Offline Packages"
env:
LTEX_GITHUB_OAUTH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: "python -u tools/createOfflinePackages.py"
- name: "Create GitHub Release"
uses: "softprops/action-gh-release@v0.1.8"
with:
token: "${{ secrets.VSCODE_LTEX_CREATE_GITHUB_RELEASE_TOKEN }}"
prerelease: "${{ env.VSCODE_LTEX_IS_PRERELEASE }}"
body: "${{ env.VSCODE_LTEX_CHANGELOG }}"
files: "vscode-ltex-${{ env.VSCODE_LTEX_VERSION }}.vsix\nvscode-ltex-${{ env.VSCODE_LTEX_VERSION }}-offline-linux-x64.vsix\nvscode-ltex-${{ env.VSCODE_LTEX_VERSION }}-offline-mac-x64.vsix\nvscode-ltex-${{ env.VSCODE_LTEX_VERSION }}-offline-windows-x64.vsix"
- name: "Publish Package on VS Marketplace"
if: "${{ env.VSCODE_LTEX_IS_PRERELEASE == 'false' }}"
env:
VSCODE_LTEX_VSCE_TOKEN: "${{ secrets.VSCODE_LTEX_VSCE_TOKEN }}"
run: "vsce publish -p \"$VSCODE_LTEX_VSCE_TOKEN\""
- name: "Publish Package on Open VSX"
if: "${{ env.VSCODE_LTEX_IS_PRERELEASE == 'false' }}"
env:
VSCODE_LTEX_OVSX_TOKEN: "${{ secrets.VSCODE_LTEX_OVSX_TOKEN }}"
run: "ovsx publish -p \"$VSCODE_LTEX_OVSX_TOKEN\""
deployForCocNvim:
name: "CI - Deploy for coc.nvim Job"
if: "${{ startsWith(github.ref, 'refs/tags/') }}"
needs:
- "buildForVsCode"
- "buildForCocNvim"
- "validate"
- "analyzeCodeQl"
runs-on: "ubuntu-20.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2"
- name: "Set up Node.js"
uses: "actions/setup-node@v1"
with:
node-version: "16.11.0"
registry-url: "https://registry.npmjs.org"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "3.9.0"
- name: "Install Python Dependencies"
run: "python -u -m pip install --upgrade pip && pip install semver==2.13.0"
- name: "Patch for coc.nvim Target"
run: "python -u tools/patchForTarget.py --target coc.nvim"
- name: "Install Node.js Dependencies"
run: "npm install"
- name: "Set VSCODE_LTEX_VERSION"
run: "echo \"VSCODE_LTEX_VERSION=$(python -u -c \"import json; print(json.load(open('package.json', 'r'))['version'], end='')\")\" >> $GITHUB_ENV"
- name: "Check VSCODE_LTEX_VERSION"
run: "if [[ -z \"$VSCODE_LTEX_VERSION\" ]]; then echo 'Error: VSCODE_LTEX_VERSION not set!'; (exit 1); fi; echo \"VSCODE_LTEX_VERSION set to '$VSCODE_LTEX_VERSION'\""
- name: "Set VSCODE_LTEX_IS_PRERELEASE"
run: "if [[ -z \"$VSCODE_LTEX_VERSION\" ]]; then echo 'Error: VSCODE_LTEX_VERSION not set!'; (exit 1); fi; echo \"VSCODE_LTEX_IS_PRERELEASE=$(python -u -c \"import semver; print('true' if semver.VersionInfo.parse('$VSCODE_LTEX_VERSION').prerelease is not None else 'false', end='')\")\" >> $GITHUB_ENV"
- name: "Check VSCODE_LTEX_IS_PRERELEASE"
run: "if [[ -z \"$VSCODE_LTEX_IS_PRERELEASE\" ]]; then echo 'Error: VSCODE_LTEX_IS_PRERELEASE not set!'; (exit 1); fi; echo \"VSCODE_LTEX_IS_PRERELEASE set to '$VSCODE_LTEX_IS_PRERELEASE'\""
- name: "Compile and Package"
run: "npm run coc.nvim:prepublish"
- name: "Publish on npm (Dry Run)"
if: "${{ env.VSCODE_LTEX_IS_PRERELEASE == 'true' }}"
run: "npm publish --dry-run"
- name: "Publish on npm"
if: "${{ env.VSCODE_LTEX_IS_PRERELEASE == 'false' }}"
env:
NODE_AUTH_TOKEN: "${{ secrets.VSCODE_LTEX_NPM_TOKEN }}"
run: "npm publish"