forked from google/neuroglancer
-
Notifications
You must be signed in to change notification settings - Fork 0
300 lines (293 loc) · 10.1 KB
/
build.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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: Build
on:
push:
branches:
- master
tags:
- v**
pull_request:
jobs:
client:
strategy:
matrix:
os:
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
# Need full history to determine version number.
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
cache-dependency-path: |
package-lock.json
examples/**/package-lock.json
- run: npm install
- run: npm run format:fix
- name: Check for dirty working directory
run: git diff --exit-code
- run: npm run lint:check
- name: Typecheck with TypeScript
run: npm run typecheck
- name: Build client bundles
run: |
build_info="{'tag':'$(git describe --always --tags)', 'url':'https://github.com/google/neuroglancer/commit/$(git rev-parse HEAD)', 'timestamp':'$(date)'}"
npm run build -- --no-typecheck --no-lint --define NEUROGLANCER_BUILD_INFO="${build_info}"
echo $build_info > ./dist/client/version.json
shell: bash
- name: Build Python client bundles
run: npm run build-python -- --no-typecheck --no-lint
- run: npm run build-package
- run: npm publish --dry-run
working-directory: dist/package
- uses: ./.github/actions/setup-firefox
- name: Run JavaScript tests (including WebGL)
run: npm test
if: ${{ runner.os != 'macOS' }}
- name: Run JavaScript tests (excluding WebGL)
run: npm test -- --project node
if: ${{ runner.os == 'macOS' }}
- name: Run JavaScript benchmarks
run: npm run benchmark
- name: Upload NPM package as artifact
uses: actions/upload-artifact@v4
with:
name: npm-package
path: dist/package
if: ${{ runner.os == 'Linux' }}
- name: Upload client as artifact
uses: actions/upload-artifact@v4
with:
name: client
path: dist/client
if: ${{ runner.os == 'Linux' }}
# Builds Python package and runs Python tests
#
# On ubuntu-latest, this also runs browser-based tests. On Mac OS and
# Windows, this only runs tests that do not require a browser, since a working
# headless WebGL2 implementation is not available on Github actions.
python-tests:
strategy:
matrix:
python-version:
- "3.9"
- "3.12"
os:
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
# Need full history to determine version number.
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Uncomment the action below for an interactive shell
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Install Python packaging/test tools
run: pip install --upgrade pip tox nox wheel numpy -r python/requirements-test.txt
- uses: ./.github/actions/setup-firefox
- run: nox -s lint format mypy
- name: Check for dirty working directory
run: git diff --exit-code
- name: Test with tox
run: tox -e ${{ fromJSON('["skip-browser-tests","firefox-xvfb"]')[runner.os == 'Linux'] }}
# Verify that editable install works
- name: Install in editable form
run: pip install -e . --config-settings editable_mode=strict
- name: Run Python tests against editable install (excluding WebGL)
working-directory: python/tests
run: pytest -vv --skip-browser-tests
python-build-package:
strategy:
matrix:
include:
- os: "ubuntu-latest"
cibw_build: "*"
wheel_identifier: "linux"
- os: "windows-latest"
cibw_build: "*"
wheel_identifier: "windows"
- os: "macos-14"
cibw_build: "*_x86_64"
wheel_identifier: "macos_x86_64"
- os: "macos-14"
cibw_build: "*_arm64"
wheel_identifier: "macos_arm64"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
# Need full history to determine version number.
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> "$GITHUB_OUTPUT"
- run: npm install
- run: |
build_info="{'tag':'$(git describe --always --tags)', 'url':'https://github.com/google/neuroglancer/commit/$(git rev-parse HEAD)', 'timestamp':'$(date)'}"
npm run build-python -- --no-typecheck --no-lint --define NEUROGLANCER_BUILD_INFO="${build_info}"
shell: bash
- name: Check for dirty working directory
run: git diff --exit-code
- name: Install setuptools
run: pip install setuptools
- name: Build Python source distribution (sdist)
run: python setup.py sdist --format gztar
if: ${{ runner.os == 'Linux' }}
- name: Install cibuildwheel
run: pip install cibuildwheel
- name: Build Python wheels
run: bash -xve ./python/build_tools/cibuildwheel.sh
env:
# On Linux, share pip cache with manylinux docker containers
CIBW_ENVIRONMENT_LINUX: PIP_CACHE_DIR=/host${{ steps.pip-cache.outputs.dir }}
CIBW_BEFORE_ALL_LINUX: /project/python/build_tools/cibuildwheel_linux_cache_setup.sh /host${{ steps.pip-cache.outputs.dir }}
CIBW_BUILD: ${{ matrix.cibw_build }}
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v4
with:
name: python-wheels-${{ matrix.wheel_identifier }}
path: |
dist/*.whl
dist/*.tar.gz
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@b1de5da23ed0a6d14e0aeee8ed52fdd87af2363c # v2.0.2
with:
macos-skip-brew-update: "true"
- name: Install nox
run: pip install nox
- name: Build docs
run: nox -s docs
- name: Upload docs as artifact
uses: actions/upload-artifact@v4
with:
name: docs
path: |
dist/docs
publish-package:
# Only publish package on push to tag or default branch.
if: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') }}
runs-on: ubuntu-latest
needs:
- "client"
- "python-build-package"
- "docs"
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: "https://registry.npmjs.org"
- uses: actions/download-artifact@v4
with:
pattern: python-wheels-*
path: dist
merge-multiple: true
- uses: actions/download-artifact@v4
with:
name: npm-package
path: npm-package
# - name: Publish to PyPI (test server)
# uses: pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
# with:
# user: __token__
# password: ${{ secrets.pypi_test_token }}
- name: Publish to PyPI (main server)
uses: pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
with:
user: __token__
password: ${{ secrets.pypi_token }}
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Publish to NPM registry
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: npm publish
working-directory: npm-package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Download dist/client after publishing to PyPI, because PyPI publish
# action fails if dist/client directory is present.
- uses: actions/download-artifact@v4
with:
name: client
path: dist/client
- name: Publish client to Firebase hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
firebaseServiceAccount: "${{ secrets.FIREBASE_HOSTING_SERVICE_ACCOUNT_KEY }}"
projectId: neuroglancer-demo
channelId: live
target: app
# Download dist/docs after publishing to PyPI, because PyPI publish
# action fails if dist/docs directory is present.
- uses: actions/download-artifact@v4
with:
name: docs
path: dist/docs
- name: Publish docs to Firebase hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
firebaseServiceAccount: "${{ secrets.FIREBASE_HOSTING_SERVICE_ACCOUNT_KEY }}"
projectId: neuroglancer-demo
channelId: live
target: docs
ngauth:
strategy:
matrix:
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: ngauth_server/go.mod
cache-dependency-path: ngauth_server/go.sum
- run: go build .
working-directory: ngauth_server
wasm:
# Ensures that .wasm files are reproducible.
strategy:
matrix:
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: ./src/mesh/draco/build.sh
- run: ./src/sliceview/compresso/build.sh
- run: ./src/sliceview/png/build.sh
# Check that there are no differences.
- run: git diff --exit-code