forked from quick-lint/quick-lint-js
-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (216 loc) · 10.7 KB
/
build-static.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
# Copyright (C) 2020 Matthew Glazar
# See end of file for extended copyright information.
name: build static
on:
push:
pull_request:
types: [opened, synchronize]
jobs:
build:
name: ${{ matrix.toolchain.name }}
strategy:
fail-fast: false
matrix:
toolchain:
- {runs_on: macos-10.15, name: "macOS", archive_name: "macos", archive_extension: ".tar.gz", CC: /usr/local/opt/llvm/bin/clang, CXX: /usr/local/opt/llvm/bin/clang++, CFLAGS: "-isystem /usr/local/opt/llvm/include -isystem /usr/local/opt/llvm/include/c++/v1 -mmacosx-version-min=10.9 -D_LIBCPP_DISABLE_AVAILABILITY", LDFLAGS: "-L/usr/local/opt/llvm/lib -mlinker-version=278 -nostdlib++ /usr/local/opt/llvm/lib/libc++.a /usr/local/opt/llvm/lib/libc++abi.a"}
- {runs_on: ubuntu-latest, name: "Linux", archive_name: "linux", archive_extension: ".tar.gz", CC: gcc-8, CXX: g++-8, LDFLAGS: "-static-libgcc -static-libstdc++"}
- {runs_on: windows-latest, name: "Windows", archive_name: "windows", archive_extension: ".zip", CMAKE_FLAGS: "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded"}
runs-on: ${{ matrix.toolchain.runs_on }}
container: ${{ fromJSON('["", "ghcr.io/quick-lint/quick-lint-js-github-builder:v1"]')[matrix.toolchain.runs_on == 'ubuntu-latest'] }}
env:
CMAKE_BUILD_TYPE: ${{ matrix.toolchain.CMAKE_BUILD_TYPE }}
CMAKE_CXX_COMPILER: ${{ matrix.toolchain.CXX }}
CMAKE_CXX_FLAGS: ${{ matrix.toolchain.CFLAGS }}
CMAKE_C_COMPILER: ${{ matrix.toolchain.CC }}
CMAKE_C_FLAGS: ${{ matrix.toolchain.CFLAGS }}
CMAKE_EXE_LINKER_FLAGS: ${{ matrix.toolchain.LDFLAGS }}
CMAKE_EXTRA_FLAGS: ${{ matrix.toolchain.CMAKE_FLAGS }}
CMAKE_SHARED_LINKER_FLAGS: ${{ matrix.toolchain.LDFLAGS }}
QLJS_COLLECT_COPYRIGHT_NO_WARNINGS: 1
steps:
- name: checkout
uses: actions/checkout@v2
- name: configure
run: |
env | grep '^CMAKE\|^QUICK_LINT_JS' | sort
cmake ${CMAKE_C_COMPILER+-DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}"} ${CMAKE_CXX_COMPILER+-DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}"} -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DBUILD_TESTING=NO -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS}" -DCMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS}" ${CMAKE_EXTRA_FLAGS} -S . -B build
shell: bash
- name: build
run: cmake --build build --config Release --target quick-lint-js quick-lint-js-licenses
- name: install
run: cmake --install build --prefix usr
- name: bundle build into .tar.gz
if: ${{ matrix.toolchain.archive_extension == '.tar.gz' }}
run: |
mv usr /tmp/quick-lint-js
tar czf ${{ matrix.toolchain.archive_name }}${{ matrix.toolchain.archive_extension }} -C /tmp/ quick-lint-js
- name: bundle build into .zip
if: ${{ matrix.toolchain.archive_extension == '.zip' }}
uses: papeloto/action-zip@v1
with:
dest: ${{ matrix.toolchain.archive_name }}${{ matrix.toolchain.archive_extension }}
files: usr/
recursive: true
- name: upload build to workflow
uses: actions/upload-artifact@v2
with:
if-no-files-found: error
name: quick-lint-js-${{ matrix.toolchain.archive_name }}-${{ github.sha }}
path: ${{ matrix.toolchain.archive_name }}${{ matrix.toolchain.archive_extension }}
- name: upload build to long-term storage
if: ${{ github.event_name == 'push' }}
uses: quick-lint/sftp-upload@master
with:
host: ${{ secrets.artifacts_host }}
local-file-globs: ${{ matrix.toolchain.archive_name }}${{ matrix.toolchain.archive_extension }}
private-key: ${{ secrets.artifacts_key }}
remote-directory: ${{ secrets.artifacts_root }}/builds/${{ github.sha }}/manual/
user: ${{ secrets.artifacts_user }}
test:
name: test on ${{ matrix.os.name }}
needs: build
strategy:
fail-fast: false
matrix:
os:
- {runs_on: windows-latest, name: "Windows", archive_name: "windows", exe_file: "bin/quick-lint-js.exe"}
- {runs_on: macos-10.15, name: "macOS 10.15", archive_name: "macos", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "archlinux:base", name: "Arch Linux", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "centos:centos7", name: "CentOS 7", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "centos:centos8", name: "CentOS 8", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "debian:buster", name: "Debian 10 Buster", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "debian:jessie", name: "Debian 8 Jessie", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "debian:stretch", name: "Debian 9 Stretch", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "fedora:31", name: "Fedora 31", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "fedora:32", name: "Fedora 32", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "ubuntu:16.04", name: "Ubuntu 16.04 LTS Xenial", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "ubuntu:18.04", name: "Ubuntu 18.04 LTS Bionic", archive_name: "linux", exe_file: "bin/quick-lint-js"}
- {runs_on: ubuntu-latest, docker_container: "ubuntu:20.04", name: "Ubuntu 20.04 LTS Focal", archive_name: "linux", exe_file: "bin/quick-lint-js"}
runs-on: ${{ matrix.os.runs_on }}
container: ${{ matrix.os.docker_container }}
steps:
- name: OS information
run: |
exec 2>&1
set -x
cat /etc/lsb-release || :
cat /etc/os-release || :
cat /etc/system-release || :
sw_vers || :
systeminfo || :
uname -a || :
shell: bash
- uses: actions/download-artifact@v2
with:
name: quick-lint-js-${{ matrix.os.archive_name }}-${{ github.sha }}
- name: unpack .zip build
if: ${{ matrix.os.archive_name == 'windows' }}
run: Expand-Archive -LiteralPath ${{ matrix.os.archive_name }}.zip -DestinationPath quick-lint-js
shell: powershell
- name: unpack .tar.gz build
if: ${{ matrix.os.archive_name != 'windows' }}
run: tar xf ${{ matrix.os.archive_name }}.tar.gz
- name: test
run: DYLD_BIND_AT_LAUNCH=1 LD_BIND_NOW=1 quick-lint-js/${{ matrix.os.exe_file }} --version
shell: bash
package-npm:
name: npm package
needs: [build, test]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: quick-lint-js-linux-${{ github.sha }}
path: ./
- uses: actions/download-artifact@v2
with:
name: quick-lint-js-macos-${{ github.sha }}
path: ./
- uses: actions/download-artifact@v2
with:
name: quick-lint-js-windows-${{ github.sha }}
path: ./
- name: extract downloaded archives
run: |
set -x
tar xf linux.tar.gz
mv quick-lint-js dist/npm/linux
tar xf macos.tar.gz
mv quick-lint-js dist/npm/macos
mkdir dist/npm/windows
unzip windows.zip -d dist/npm/windows/
- name: package
run: npm pack ./dist/npm
- name: upload package to workflow
uses: actions/upload-artifact@v2
with:
if-no-files-found: error
name: quick-lint-js-npm-${{ github.sha }}
path: quick-lint-js-*.tgz
- name: upload package to long-term storage
if: ${{ github.event_name == 'push' }}
uses: quick-lint/sftp-upload@master
with:
host: ${{ secrets.artifacts_host }}
local-file-globs: quick-lint-js-*.tgz
private-key: ${{ secrets.artifacts_key }}
remote-directory: ${{ secrets.artifacts_root }}/builds/${{ github.sha }}/npm/
user: ${{ secrets.artifacts_user }}
test-npm-package:
name: test npm package on ${{ matrix.os.name }} with ${{ matrix.manager.name }}
needs: package-npm
strategy:
fail-fast: false
matrix:
os:
- {runs_on: windows-latest, name: "Windows", test_cmd: true}
- {runs_on: macos-10.15, name: "macOS 10.15"}
- {runs_on: ubuntu-latest, name: "Ubuntu", global_install_command_prefix: "sudo"}
manager:
- {name: "npm", install_command: "npm install", global: false}
- {name: "npm (--global)", install_command: "npm install --global --unsafe-perm", global: true}
- {name: "Yarn", install_command: "yarn add", global: false}
runs-on: ${{ matrix.os.runs_on }}
steps:
- uses: actions/download-artifact@v2
with:
name: quick-lint-js-npm-${{ github.sha }}
- name: install globally
if: ${{ matrix.manager.global }}
run: ${{ matrix.os.global_install_command_prefix }} ${{ matrix.manager.install_command }} ./quick-lint-js-*.tgz
shell: bash
- name: test globally
if: ${{ matrix.manager.global }}
run: quick-lint-js --version
- name: install locally
if: ${{ !matrix.manager.global }}
run: |
echo '{}' >package.json
${{ matrix.manager.install_command }} ./quick-lint-js-*.tgz
shell: bash
- name: test locally
if: ${{ !matrix.manager.global }}
run: ./node_modules/.bin/quick-lint-js --version
shell: bash
- name: test locally (.cmd)
if: ${{ !matrix.manager.global && matrix.os.test_cmd }}
run: node_modules/.bin/quick-lint-js.cmd --version
# 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/>.