-
Notifications
You must be signed in to change notification settings - Fork 152
226 lines (220 loc) · 8.67 KB
/
Copy pathdeploy-wasm.yml
File metadata and controls
226 lines (220 loc) · 8.67 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
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
name: WebAssembly
on:
pull_request_target:
branches:
- master
types:
- closed
workflow_dispatch:
repository_dispatch: # listening to rv32emu-prebuilt events
types: [deploy_user_wasm, deploy_system_wasm]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false # Don't cancel deployments
permissions:
contents: read
jobs:
# Resolve both file sets once, so each deploy job carries a single condition
# instead of repeating it on every step.
# Only the merge path needs a file diff. On workflow_dispatch and
# repository_dispatch there is no base commit to diff against, and
# changed-files errors out; those events deploy unconditionally anyway.
detect-file-changes:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-24.04
outputs:
system: ${{ steps.system.outputs.any_modified }}
user: ${{ steps.user.outputs.any_modified }}
steps:
- name: Check out the repo
uses: actions/checkout@v7
- name: Verify if the system emulation files have been modified
id: system
uses: tj-actions/changed-files@v47
with:
files: |
assets/wasm/html/system.html
assets/wasm/js/system-pre.js
src/em_runtime.c
# Build system configuration
mk/kconfig.mk
mk/wasm.mk
configs/wasm_defconfig
tools/detect-env.py
# Helper scripts the deploy job runs
.ci/wasm-build.sh
.ci/fetch-artifacts.sh
.ci/emsdk-warm-cache.sh
# rootfs overlay tooling (S99automount auto-mounts /dev/vda)
tools/cpio-inject.py
tools/rootfs-automount.sh
# Files below may have a potential performance impact (reference from benchmark.yml)
src/devices/*.c
src/system.c
src/riscv.c
src/decode.c
src/emulate.c
src/rv32_template.c
src/rv32_constopt.c
- name: Verify if the user emulation files have been modified
id: user
uses: tj-actions/changed-files@v47
with:
files: |
assets/wasm/html/user.html
# Landing page is committed at the repo root by the user job
assets/wasm/html/demo-index.html
assets/wasm/js/user-pre.js
build/*.elf
tools/gen-elf-list-js.py
src/em_runtime.c
# Build system configuration
mk/kconfig.mk
mk/wasm.mk
configs/wasm_defconfig
tools/detect-env.py
# Helper scripts the deploy job runs
.ci/wasm-build.sh
.ci/fetch-artifacts.sh
.ci/emsdk-warm-cache.sh
# Files below may have a potential performance impact (reference from benchmark.yml)
src/riscv.c
src/decode.c
src/emulate.c
src/rv32_template.c
src/rv32_constopt.c
wasm-system-deploy:
needs: [detect-file-changes]
# !cancelled() keeps this reachable when detect-file-changes is skipped (a
# dispatch event) or fails. Without a status function the default rule
# skips every dependent job, which would silently cancel a deploy that was
# asked for explicitly.
if: >
!cancelled() && (
(github.event.pull_request.merged == true && needs.detect-file-changes.outputs.system == 'true') ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm')
)
timeout-minutes: 60
runs-on: ubuntu-24.04
# GH_TOKEN authenticates the parse-time fetch-releases-tag call in
# mk/artifact.mk so the GitHub API request escapes the 60 req/hr
# anonymous (IP-shared) limit and stops flaking when several merges land
# back-to-back.
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v7
with:
submodules: 'true'
- name: Install dependencies
run: .ci/apt-install.sh curl device-tree-compiler
# Pinned to the emsdk tag: newer Emscripten releases tightened the
# port-cache lock and broke "make -j" builds here.
- name: Set up emsdk
uses: mymindstorm/setup-emsdk@v16
with:
version: 3.1.51
actions-cache-folder: 'emsdk-cache'
- name: Fetch artifact
run: .ci/fetch-artifacts.sh linux-image
- name: Warm emscripten port cache
run: .ci/emsdk-warm-cache.sh
- name: Build system emulation demo
run: .ci/wasm-build.sh system
- name: Check out the rv32emu-demo repo
uses: actions/checkout@v7
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
repository: sysprog21/rv32emu-demo
- name: Create local changes
run: |
mkdir -p system
mv /tmp/rv32emu-system-demo/* ./system/
- name: Commit files
id: commit
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add system/
if git diff --cached --quiet; then
echo "committed=false" >> $GITHUB_OUTPUT
else
git commit -m "Add changes to system emulation"
echo "committed=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.commit.outputs.committed == 'true'
uses: ad-m/github-push-action@v1.3.0
with:
repository: sysprog21/rv32emu-demo
github_token: ${{ secrets.RV32EMU_DEMO_TOKEN }}
branch: main
wasm-user-deploy:
# Sequential with the system job: both push to the same demo repository.
# "skipped" is not a failure here, a merge may touch only one of the two.
needs: [detect-file-changes, wasm-system-deploy]
if: >
!cancelled() && needs.wasm-system-deploy.result != 'failure' && (
(github.event.pull_request.merged == true && needs.detect-file-changes.outputs.user == 'true') ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm')
)
timeout-minutes: 60
runs-on: ubuntu-24.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v7
with:
submodules: 'true'
- name: Install dependencies
run: .ci/apt-install.sh curl device-tree-compiler
- name: Set up emsdk
uses: mymindstorm/setup-emsdk@v16
with:
version: 3.1.51
actions-cache-folder: 'emsdk-cache'
- name: Fetch artifact
run: .ci/fetch-artifacts.sh elf doom
- name: Warm emscripten port cache
run: .ci/emsdk-warm-cache.sh
- name: Build user emulation demo
run: .ci/wasm-build.sh user
- name: Check out the rv32emu-demo repo
uses: actions/checkout@v7
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
repository: sysprog21/rv32emu-demo
- name: Create local changes
run: |
# Migration: earlier deploys placed user-mode assets at the repo
# root. Drop the stale copies so the layout stays consistent
# (landing page at /, user mode at /user/, system at /system/).
rm -f navigation.html coi-serviceworker.min.js xterm.min.js \
xterm.min.css elf_list.js rv32emu.js rv32emu.wasm \
rv32emu.worker.js
mkdir -p user
mv /tmp/rv32emu-demo/landing.html ./index.html
mv /tmp/rv32emu-demo/* ./user/
- name: Commit files
id: commit
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add --all
if git diff --cached --quiet; then
echo "committed=false" >> $GITHUB_OUTPUT
else
git commit -m "Add changes to user emulation"
echo "committed=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.commit.outputs.committed == 'true'
uses: ad-m/github-push-action@v1.3.0
with:
repository: sysprog21/rv32emu-demo
github_token: ${{ secrets.RV32EMU_DEMO_TOKEN }}
branch: main