Repository navigation
170 lines (160 loc) · 7.23 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
170 lines (160 loc) · 7.23 KB
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
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["dev"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
# Bumping Emscripten means editing this and the matching line in wasm-ci.yml;
# a workflow-level env cannot reach across files. The two deploy workflows at
# least move together.
env:
EMSDK_VERSION: 4.0.19
jobs:
# This should be synced to the "wasm" job in test-deploy-docs.yml
wasm:
name: Build WASM artifact
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
# Restoring the artifact is what keeps a docs-only change off the
# Emscripten toolchain entirely. The key covers everything the binding
# links -- the set wasm-ci.yml filters on, `**/CMakeLists.txt` included,
# kept deliberately broad so the two cannot drift apart -- plus two things
# that shape the artifact without being linked into it: build-scripts/cmake,
# which decides the compile flags, and both deploy workflows.
#
# Both files rather than just this one: the keys have to be identical for
# a pull request to restore what the branch build already compiled.
- name: Cache WASM artifact
id: wasm-cache
uses: actions/cache@v6
with:
path: build-wasm/tools/wasm
key: >-
openzl-wasm-${{runner.os}}-emsdk${{env.EMSDK_VERSION}}-${{hashFiles(
'tools/wasm/**', 'tools/training/**', 'tools/io/**',
'tools/logger/**', 'cli/utils/profile_graphs.*',
'custom_parsers/**', 'cpp/**', 'src/**', 'include/**',
'**/CMakeLists.txt', 'build-scripts/cmake/**',
'.github/workflows/deploy-docs.yml',
'.github/workflows/test-deploy-docs.yml')}}
- name: Set up Emscripten
if: steps.wasm-cache.outputs.cache-hit != 'true'
uses: emscripten-core/setup-emsdk@v16
with:
version: ${{env.EMSDK_VERSION}}
actions-cache-folder: emsdk-cache
- name: Configure
if: steps.wasm-cache.outputs.cache-hit != 'true'
# The build type only reaches the libraries the binding links, since
# tools/wasm/CMakeLists.txt pins the artifact itself to -O3. Release
# rather than MinSizeRel: the playground exists to report MB/s, and -Os
# costs about 14% of compression throughput.
run: emcmake cmake -DOPENZL_BUILD_WASM=ON -DCMAKE_BUILD_TYPE=Release -B build-wasm
- name: Build
if: steps.wasm-cache.outputs.cache-hit != 'true'
run: cmake --build build-wasm --target openzl_wasm -j$(getconf _NPROCESSORS_ONLN)
# Release inherits `-g` from build-scripts/cmake/OpenZLCompilerUnix.cmake,
# which is 40 of the 45 MB it produces. Worth stripping for that alone,
# but the DWARF is also load-bearing: emcc skips binaryen's post-link pass
# when debug info has to survive, and on this workload that pass costs
# about a quarter of the compression throughput. So the module is built
# with debug info, kept out of that pass, and stripped afterwards.
#
# It follows that removing that `-g` upstream would quietly cost the
# deployed tool 25%, with nothing here to notice -- so
# tools/wasm/CMakeLists.txt states `-g` on the target rather than
# inheriting it, and this step is what undoes it again.
- name: Strip debug info
if: steps.wasm-cache.outputs.cache-hit != 'true'
run: emstrip --strip-debug build-wasm/tools/wasm/openzl.wasm
- name: Upload WASM artifact
uses: actions/upload-artifact@v7
with:
name: openzl-wasm
path: |
build-wasm/tools/wasm/openzl.js
build-wasm/tools/wasm/openzl.wasm
# Otherwise a build that produced nothing uploads nothing and passes,
# and the run fails a job later where the download comes up empty.
if-no-files-found: error
retention-days: 1
# This should be synced to the "build" step in test-deploy-docs.yml
build:
needs: wasm
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
submodules: recursive
- name: Set up Node
uses: actions/setup-node@v7
with:
node-version: lts/*
cache: 'yarn'
cache-dependency-path: ${{github.workspace}}/tools/web/yarn.lock
# Next to wasm_api.js, which is the only place it is needed: that module
# imports the glue relatively and locates the binary with
# `new URL('./openzl.wasm', import.meta.url)`, which Vite resolves at
# build time and re-emits under assets/ with a content hash.
- name: Download WASM artifact
uses: actions/download-artifact@v7
with:
name: openzl-wasm
path: ${{github.workspace}}/tools/wasm/js
- name: Install yarn dependencies
working-directory: ${{github.workspace}}/tools/web
run: yarn --frozen-lockfile
- name: Build web tools
working-directory: ${{github.workspace}}/tools/web
run: yarn build
- name: Setup Pages
uses: actions/configure-pages@v6
- name: Setup mkdocs environment
run: |
sudo apt-get update
sudo apt-get install doxygen clang-format
pip install mkdocs-material==9.5.50 mkdocstrings==0.27.0 mkdocs==1.6.1 mkdocstrings-python==1.13.0
- name: build
run: |
./doc/mkdocs/github_pages_build_script.py
# Cross-origin isolation, and so the module itself, rests on Vite having
# rewritten this src against the tool's base. Nothing else would catch it
# regressing: the page renders fine, and only fails when a run starts.
- name: Check the isolation worker is referenced under the tool's base
run: grep -q '"/tools/playground/cross-origin-isolation-sw.js"' doc/mkdocs/build/tools/playground/index.html
# Without the artifact, the playground's vite.config.ts leaves the module
# for the browser to fetch, so the build passes and the page only fails
# once a run starts. Both halves of it have to be in the site.
- name: Check the WASM module is in the playground build
run: ls doc/mkdocs/build/tools/playground/assets/openzl-*.js doc/mkdocs/build/tools/playground/assets/openzl-*.wasm
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: './doc/mkdocs/build/'
include-hidden-files: true
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5