forked from quick-lint/quick-lint-js
-
Notifications
You must be signed in to change notification settings - Fork 1
269 lines (245 loc) · 12.9 KB
/
build-and-test-plugin-vscode.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
# Copyright (C) 2020 Matthew Glazar
# See end of file for extended copyright information.
name: build and test VS Code extension
on:
push:
pull_request:
types: [opened, synchronize]
jobs:
build:
name: build ${{ matrix.os.name }}
strategy:
fail-fast: false
matrix:
os:
- {runs_on: macos-12, name: "macOS x86_64", platform_arch: "darwin-x64", test: true, CC: /usr/local/opt/llvm@15/bin/clang, CXX: /usr/local/opt/llvm@15/bin/clang++, CFLAGS: "-isystem /usr/local/opt/llvm@15/include -isystem /usr/local/opt/llvm@15/include/c++/v1 -mmacosx-version-min=10.9 -D_LIBCPP_DISABLE_AVAILABILITY", LDFLAGS: "-L/usr/local/opt/llvm@15/lib -mlinker-version=278 -nostdlib++ /usr/local/opt/llvm@15/lib/c++/libc++.a /usr/local/opt/llvm@15/lib/c++/libc++abi.a", CMAKE_FLAGS: "-G Ninja", homebrew_packages: "ninja"}
- {runs_on: stracle-macos-aarch64, name: "macOS AArch64", platform_arch: "darwin-arm64", test: true, CFLAGS: "-mmacosx-version-min=11.0", CMAKE_FLAGS: "-G Ninja"}
- {runs_on: ubuntu-latest, name: "Linux x86_64", platform_arch: "linux-x64", test: false, docker_container: "ghcr.io/quick-lint/quick-lint-js-github-baseline-builder:v1", LDFLAGS: "-static-libgcc -static-libstdc++", CMAKE_FLAGS: "-G Ninja"}
- {runs_on: ubuntu-latest, name: "Linux ARM", platform_arch: "linux-arm", test: false, docker_container: "ghcr.io/quick-lint/quick-lint-js-github-cross-builder:v3", cross_compiling: true, CMAKE_FLAGS: "-DCMAKE_TOOLCHAIN_FILE=.github/toolchain-linux-armhf.cmake -G Ninja", LDFLAGS: "-static-libgcc -static-libstdc++"}
- {runs_on: ubuntu-latest, name: "Linux AArch64", platform_arch: "linux-arm64", test: false, docker_container: "ghcr.io/quick-lint/quick-lint-js-github-cross-builder:v3", cross_compiling: true, CMAKE_FLAGS: "-DCMAKE_TOOLCHAIN_FILE=.github/toolchain-linux-aarch64.cmake -G Ninja", LDFLAGS: "-static-libgcc -static-libstdc++"}
- {runs_on: windows-2022, name: "Windows x86", platform_arch: "win32-ia32", test: true, CC: "c:/msys64/mingw32/bin/gcc.exe", CXX: "c:/msys64/mingw32/bin/g++.exe", CMAKE_FLAGS: "-G Ninja", chocolatey_packages: "ninja", msys2_packages: "mingw-w64-i686-gcc ninja", LDFLAGS: "-static"}
- {runs_on: windows-2022, name: "Windows x64", platform_arch: "win32-x64", test: true, CC: "c:/msys64/ucrt64/bin/gcc.exe", CXX: "c:/msys64/ucrt64/bin/g++.exe", CMAKE_FLAGS: "-G Ninja", chocolatey_packages: "ninja", msys2_packages: "mingw-w64-ucrt-x86_64-gcc ninja", LDFLAGS: "-static"}
- {runs_on: ubuntu-latest, name: "Windows ARM", platform_arch: "win32-arm", test: false, docker_container: "ghcr.io/quick-lint/quick-lint-js-github-mingw-builder:v3", cross_compiling: true, CMAKE_FLAGS: "-DCMAKE_TOOLCHAIN_FILE=.github/toolchain-mingw-armv7.cmake -G Ninja", LDFLAGS: "-static"}
- {runs_on: ubuntu-latest, name: "Windows ARM64", platform_arch: "win32-arm64", test: false, docker_container: "ghcr.io/quick-lint/quick-lint-js-github-mingw-builder:v3", cross_compiling: true, CMAKE_FLAGS: "-DCMAKE_TOOLCHAIN_FILE=.github/toolchain-mingw-aarch64.cmake -G Ninja", LDFLAGS: "-static"}
runs-on: ${{ matrix.os.runs_on }}
container: ${{ matrix.os.docker_container }}
env:
CMAKE_CXX_COMPILER: ${{ matrix.os.CXX }}
CMAKE_CXX_FLAGS: ${{ matrix.os.CFLAGS }}
CMAKE_C_COMPILER: ${{ matrix.os.CC }}
CMAKE_C_FLAGS: ${{ matrix.os.CFLAGS }}
CMAKE_EXE_LINKER_FLAGS: ${{ matrix.os.LDFLAGS }}
CMAKE_EXTRA_FLAGS: ${{ matrix.os.CMAKE_FLAGS }}
CMAKE_SHARED_LINKER_FLAGS: ${{ matrix.os.LDFLAGS }}
QLJS_COLLECT_COPYRIGHT_NO_WARNINGS: 1
steps:
- name: checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: update $PATH
if: ${{ matrix.os.msys2_packages }}
run: |
# For DLLs needed by GCC:
echo "c:/msys64/mingw32/bin" >>"${GITHUB_PATH}"
echo "c:/msys64/ucrt64/bin" >>"${GITHUB_PATH}"
shell: bash
- name: install dependencies (Chocolatey)
if: ${{ matrix.os.chocolatey_packages }}
run: choco install --yes ${{ matrix.os.chocolatey_packages }}
shell: powershell
- name: install dependencies (Homebrew)
if: ${{ matrix.os.homebrew_packages }}
run: brew install ${{ matrix.os.homebrew_packages }}
- name: install dependencies (MSYS2)
if: ${{ matrix.os.msys2_packages }}
run: c:/msys64/usr/bin/pacman.exe --sync --noconfirm ${{ matrix.os.msys2_packages }}
- name: build tools for cross compilation
if: ${{ matrix.os.cross_compiling }}
run: |
unset CC CXX
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF -S . -B build-tools -G Ninja
cmake --build build-tools --config Debug --target quick-lint-js-build-tools
- name: C++ configure
shell: "python3 {0}"
run: |
import os
import shlex
import subprocess
def var(name):
return os.environ.get(name, '')
command = [
"cmake",
"-DCMAKE_BUILD_TYPE=Release",
"-DBUILD_TESTING=NO",
"-DQUICK_LINT_JS_ENABLE_VSCODE=YES",
"-DCMAKE_POSITION_INDEPENDENT_CODE=YES",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=YES",
"-S", ".", "-B", "build",
f"-DCMAKE_C_FLAGS={var('CMAKE_C_FLAGS')}",
f"-DCMAKE_CXX_FLAGS={var('CMAKE_CXX_FLAGS')}",
f"-DCMAKE_EXE_LINKER_FLAGS={var('CMAKE_EXE_LINKER_FLAGS')}",
f"-DCMAKE_SHARED_LINKER_FLAGS={var('CMAKE_SHARED_LINKER_FLAGS')}",
]
c_compiler = var('CMAKE_C_COMPILER')
if c_compiler: command.append(f"-DCMAKE_C_COMPILER={c_compiler}")
cxx_compiler = var('CMAKE_CXX_COMPILER')
if cxx_compiler: command.append(f"-DCMAKE_CXX_COMPILER={cxx_compiler}")
if "${{ matrix.os.cross_compiling }}":
command.append(f"-DQUICK_LINT_JS_USE_BUILD_TOOLS={os.getcwd()}/build-tools")
command.extend(var('CMAKE_EXTRA_FLAGS').split())
print(" ".join(shlex.quote(arg) for arg in command), flush=True)
result = subprocess.run(command)
exit(result.returncode)
- name: C++ build
run: cmake --build build --config Release --target quick-lint-js-vscode-node quick-lint-js-vscode-node-licenses
- name: C++ install
run: cmake --install build --component vscode-node --prefix plugin/vscode --strip
- name: upload build to workflow
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
if-no-files-found: error
name: vscode-dist-${{ matrix.os.platform_arch }}
path: plugin/vscode/dist/
test:
name: test ${{ matrix.os.name }}
needs: build
strategy:
fail-fast: false
matrix:
os:
- {runs_on: macos-12, name: "macOS x86_64", platform_arch: "darwin-x64"}
- {runs_on: stracle-macos-aarch64, name: "macOS AArch64", platform_arch: "darwin-arm64"}
# FIXME(strager): For some reason, tests fail with the a Docker
# container.
- {runs_on: ubuntu-latest, name: "Linux x86_64", platform_arch: "linux-x64", xvfb: true}
- {runs_on: windows-2022, name: "Windows x86", platform_arch: "win32-ia32"}
- {runs_on: windows-2022, name: "Windows x64", platform_arch: "win32-x64"}
# TODO(strager): Also test Linux x86 32-bit.
# TODO(strager): Also test Linux ARM (32-bit and 64-bit).
# TODO(strager): Also test Windows ARM (32-bit and 64-bit).
runs-on: ${{ matrix.os.runs_on }}
container: ${{ matrix.os.docker_container }}
steps:
- name: checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-linux-x64
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-darwin-arm64
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-darwin-x64
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-win32-ia32
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-win32-x64
path: ./plugin/vscode/dist/
- name: configure
run: cd plugin/vscode && yarn
- name: test
shell: bash
run: |
run_xvfb=${{ fromJSON('[0, 1]')[matrix.os.xvfb] }}
if [ "${run_xvfb}" -ne 0 ]; then
DISPLAY=:1
export DISPLAY
type Xvfb # Ensure Xvfb is installed.
Xvfb "${DISPLAY}" -screen 0 1024x768x24 &
sleep 0.1 # Wait for Xvfb to start.
printf 'Started Xvfb\n' >&2
fi
cd plugin/vscode
yarn test --target ${{ matrix.os.platform_arch }}
if [ "${run_xvfb}" -ne 0 ]; then
kill %1
wait || :
fi
vsix:
name: VS Code .vsix
needs: build
runs-on: ubuntu-latest
# TODO(strager): Use a stable Docker image.
env:
QLJS_COLLECT_COPYRIGHT_NO_WARNINGS: 1
steps:
- name: checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-linux-x64
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-linux-arm
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-linux-arm64
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-darwin-arm64
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-darwin-x64
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-win32-ia32
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-win32-x64
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-win32-arm
path: ./plugin/vscode/dist/
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: vscode-dist-win32-arm64
path: ./plugin/vscode/dist/
- name: configure
run: cd plugin/vscode && yarn
- name: create extension
run: cd plugin/vscode && ./node_modules/.bin/vsce package --baseImagesUrl https://raw.githubusercontent.com/quick-lint/quick-lint-js/master/plugin/vscode/
- name: upload build to workflow
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
if-no-files-found: error
name: plugin-vscode-${{ github.sha }}
path: plugin/vscode/*.vsix
- name: upload build to long-term storage
if: ${{ github.event_name == 'push' && github.repository_owner == 'quick-lint' != null }}
uses: quick-lint/sftp-upload@1fa54164d4bdd081207a6e54ec143d8dda3a7fb8 # v3
with:
host: ${{ secrets.artifacts_host }}
local-file-globs: plugin/vscode/*.vsix
private-key: ${{ secrets.artifacts_key }}
remote-directory: ${{ secrets.artifacts_root }}/builds/${{ github.sha }}/vscode/
user: ${{ secrets.artifacts_user }}
# quick-lint-js finds bugs in JavaScript programs.
# Copyright (C) 2020 Matthew Glazar
#
# This file is part of quick-lint-js.
#
# quick-lint-js is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# quick-lint-js is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>.