-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (117 loc) · 4.74 KB
/
Copy pathwasm-demo.yml
File metadata and controls
131 lines (117 loc) · 4.74 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
name: WASM Demo
# Builds the self-contained WebAssembly bank GUI (examples/bank/gui_wasm) and
# publishes it to GitHub Pages under /demo/, alongside the Doxygen docs at the
# site root. Single-threaded Qt-for-WASM ⇒ no SharedArrayBuffer ⇒ no COOP/COEP
# headers ⇒ plain Pages hosting works.
on:
push:
branches:
- master
paths:
- 'examples/bank/**'
- 'include/morph/**'
- '.github/workflows/wasm-demo.yml'
pull_request:
branches:
- master
paths:
- 'examples/bank/**'
- 'include/morph/**'
- '.github/workflows/wasm-demo.yml'
concurrency:
group: wasm-demo-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
env:
QT_VERSION: 6.8.3
EMSDK_VERSION: 3.1.56 # the emscripten Qt 6.8 was built against
jobs:
build-wasm:
name: Build & deploy WASM demo
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install build tools
run: |
sudo apt-get update -q
sudo apt-get install -y ninja-build
# aqtinstall gives a matched host + wasm Qt pair (same cmake glue), so no
# host/target version skew.
- name: Install Qt (host desktop)
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
host: linux
target: desktop
arch: linux_gcc_64
dir: ${{ runner.temp }}/qt
# Qt 6.7+ ships WebAssembly under host=all_os / target=wasm (not
# linux/desktop). The matching host desktop Qt above provides the tools.
- name: Install Qt (wasm, single-threaded)
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
host: all_os
target: wasm
arch: wasm_singlethread
dir: ${{ runner.temp }}/qt
- name: Set up emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ env.EMSDK_VERSION }}
actions-cache-folder: emsdk-cache
- name: Configure
run: |
export EM_CACHE="$PWD/.emcache"
mkdir -p "$EM_CACHE"
HOST=${{ runner.temp }}/qt/Qt/${{ env.QT_VERSION }}/gcc_64
WASM=${{ runner.temp }}/qt/Qt/${{ env.QT_VERSION }}/wasm_singlethread
# The all_os/wasm package extracts its scripts without the exec bit.
chmod +x "$WASM"/bin/* || true
# MinSizeRel: no CMAKE_BUILD_TYPE was ever set here, so every prior
# run configured an unoptimized debug-equivalent build -- Emscripten
# without -Os/dead-code-elimination produces a .wasm north of
# GitHub's 100 MB Pages/repo file-size limit (108.29 MB, confirmed
# from a real failed deploy), which the "Deploy to GitHub Pages"
# step below has been silently failing on for every push since this
# workflow was introduced. This is a demo bundle shipped to end
# users over the network, not a local dev build, so MinSizeRel (not
# Release) is the right target -- payload size matters more than
# runtime speed here.
"$WASM/bin/qt-cmake" -S . -B build-wasm -G Ninja \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DQT_HOST_PATH="$HOST" \
-DMORPH_BUILD_EXAMPLES=ON -DMORPH_BUILD_BANK_EXAMPLE=ON \
-DMORPH_BUILD_BANK_GUI=ON -DMORPH_BUILD_TESTS=OFF
- name: Build
run: |
export EM_CACHE="$PWD/.emcache"
cmake --build build-wasm --target bank_gui_wasm
- name: Stage bundle
run: |
mkdir -p site
BIN=build-wasm/examples/bank/gui_wasm
cp "$BIN"/bank_gui_wasm.js "$BIN"/bank_gui_wasm.wasm "$BIN"/qtloader.js site/
# GitHub rejects any single file over 100 MB on push (confirmed:
# bank_gui_wasm.wasm hit 108.29 MB before this workflow set
# CMAKE_BUILD_TYPE, silently breaking every gh-pages deploy since
# this workflow was introduced). Fail fast here, in the build log,
# rather than lose that signal in the deploy step's git-push error.
ls -la site/
WASM_BYTES=$(stat -c%s site/bank_gui_wasm.wasm)
echo "bank_gui_wasm.wasm: $WASM_BYTES bytes"
if [ "$WASM_BYTES" -gt 104857600 ]; then
echo "::error::bank_gui_wasm.wasm is $WASM_BYTES bytes, over GitHub's 100 MB push limit"
exit 1
fi
# Serve the Qt loader page as the directory index.
cp "$BIN"/bank_gui_wasm.html site/index.html
- name: Deploy to GitHub Pages (/demo)
if: github.ref == 'refs/heads/master'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
target-folder: demo
clean: false # leave the Doxygen docs at the site root untouched