Skip to content

Commit fd1ce48

Browse files
committed
CI: Update for deploying user-wasm and system-wasm
This commit updates the CI to deploy both user and system WebAssembly demos to the rv32emu-demo repository, resulting in the following file structure: . |-- coi-serviceworker.min.js |-- elf_list.js |-- index.html |-- rv32emu.js |-- rv32emu.wasm |-- rv32emu.worker.js |-- system |-- coi-serviceworker.min.js |-- index.html |-- rv32emu.js |-- rv32emu.wasm |-- rv32emu.worker.js The top-level files serve the user-space demo, while the system/ subdirectory hosts the system emulation demo. This structure allows both pages to coexist and be navigated independently in the same deployment. Improvements: - The release artifacts in the rv32emu-prebuilt repository include either a user-space executable (e.g., RISC-V ELF binaries) or a Linux image for system emulation. To distinguish between these two types of releases and trigger only the necessary deployment workflow, two separate dispatch event types are introduced: - deploy_user_wasm for user-space emulation WebAssembly deployment. - deploy_system_wasm for system emulation WebAssembly deployment. - Add needs and always() to ensure proper sequencing and execution of dependent jobs when both targets are deployed. - Change the source of the shareware Doom artifact: Downloading directly from the original site often results in 403 Forbidden errors on GitHub runners recently. The artifact is now hosted in our own repository (rv32emu-prebuilt) for more reliable access. Error: Resolving www.doomworld.com (www.doomworld.com)... 172.67.171.63, 104.21.29.17, 2606:4700:3037::ac43:ab3f, ... Connecting to www.doomworld.com (www.doomworld.com)|172.67.171.63|:443... connected. HTTP request sent, awaiting response... 403 Forbidden
1 parent 4a27f5d commit fd1ce48

File tree

2 files changed

+114
-34
lines changed

2 files changed

+114
-34
lines changed

.github/workflows/deploy-wasm.yml

Lines changed: 110 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,107 @@ on:
1010
branches:
1111
- master
1212
repository_dispatch: # listening to rv32emu-prebuilt events
13-
types: [deploy_wasm]
13+
types: [deploy_user_wasm, deploy_system_wasm]
1414

1515
jobs:
16-
wasm-deploy:
16+
wasm-system-deploy:
1717
if: github.event.pull_request.merged == true ||
1818
github.event_name == 'workflow_dispatch' ||
19-
github.event_name == 'repository_dispatch'
19+
github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm'
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check out the repo
23+
uses: actions/checkout@v4
24+
- name: install-dependencies
25+
run: |
26+
sudo apt-get update -q=2
27+
sudo apt-get install -q=2 device-tree-compiler
28+
- name: Verify if the JS or HTML files has been modified
29+
id: changed-files
30+
uses: tj-actions/changed-files@v46
31+
with:
32+
files: |
33+
assets/wasm/html/system.html
34+
assets/wasm/js/system-pre.js
35+
# Files below may have a potential performance impact (reference from benchmark.yml)
36+
src/devices/*.c
37+
src/system.c
38+
src/riscv.c
39+
src/decode.c
40+
src/emulate.c
41+
src/rv32_template.c
42+
src/rv32_constopt.c
43+
- name: install emcc
44+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
45+
github.event_name == 'workflow_dispatch' ||
46+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
47+
run: |
48+
git clone https://github.com/emscripten-core/emsdk -b 3.1.51
49+
cd emsdk
50+
./emsdk install latest
51+
./emsdk activate latest
52+
source ./emsdk_env.sh
53+
echo "$PATH" >> $GITHUB_PATH
54+
shell: bash
55+
- name: fetch artifact
56+
run: |
57+
make artifact
58+
# get from rv32emu-prebuilt
59+
wget -O build/shareware_doom_iwad.zip "https://raw.githubusercontent.com/sysprog21/rv32emu-prebuilt/doom-artifact/shareware_doom_iwad.zip"
60+
unzip -d build/ build/shareware_doom_iwad.zip
61+
- name: build with emcc and move application files to /tmp
62+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
63+
github.event_name == 'workflow_dispatch' ||
64+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
65+
run: |
66+
make CC=emcc ENABLE_SYSTEM=1 ENABLE_SDL=1 INITRD_SIZE=32 -j
67+
mkdir /tmp/rv32emu-system-demo
68+
mv assets/wasm/html/system.html /tmp/rv32emu-system-demo/index.html
69+
mv assets/wasm/js/coi-serviceworker.min.js /tmp/rv32emu-system-demo
70+
mv build/rv32emu.js /tmp/rv32emu-system-demo
71+
mv build/rv32emu.wasm /tmp/rv32emu-system-demo
72+
mv build/rv32emu.worker.js /tmp/rv32emu-system-demo
73+
ls -al /tmp/rv32emu-system-demo
74+
- name: Check out the rv32emu-system-demo repo
75+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
76+
github.event_name == 'workflow_dispatch' ||
77+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
78+
uses: actions/checkout@v4
79+
with:
80+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
81+
repository: sysprog21/rv32emu-demo
82+
- name: Create local changes
83+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
84+
github.event_name == 'workflow_dispatch' ||
85+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
86+
run: |
87+
mkdir -p system
88+
mv /tmp/rv32emu-system-demo/index.html ./system
89+
mv /tmp/rv32emu-system-demo/coi-serviceworker.min.js ./system
90+
mv /tmp/rv32emu-system-demo/rv32emu.js ./system
91+
mv /tmp/rv32emu-system-demo/rv32emu.wasm ./system
92+
mv /tmp/rv32emu-system-demo/rv32emu.worker.js ./system
93+
- name: Commit files
94+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
95+
github.event_name == 'workflow_dispatch' ||
96+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
97+
run: |
98+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
99+
git config --local user.name "github-actions[bot]"
100+
git add system/
101+
git commit -m "Add changes to system emulation"
102+
- name: Push changes
103+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
104+
github.event_name == 'workflow_dispatch' ||
105+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
106+
uses: ad-m/github-push-action@master
107+
with:
108+
repository: sysprog21/rv32emu-demo
109+
github_token: ${{ secrets.RV32EMU_DEMO_TOKEN }}
110+
branch: main
111+
wasm-user-deploy:
112+
needs: wasm-system-deploy # run jobs sequentially since two jobs operate on same reposity: rv32emu-demo
113+
if: always() # ensures wasm-user-deploy runs regardless of the outcome or condition of wasm-system-deploy
20114
runs-on: ubuntu-latest
21115
steps:
22116
- name: Check out the repo
@@ -26,8 +120,8 @@ jobs:
26120
uses: tj-actions/changed-files@v46
27121
with:
28122
files: |
29-
assets/wasm/html/index.html
30-
assets/wasm/js/pre.js
123+
assets/wasm/html/user.html
124+
assets/wasm/js/user-pre.js
31125
build/*.elf
32126
tools/gen-elf-list-js.py
33127
# Files below may have a potential performance impact (reference from benchmark.yml)
@@ -39,12 +133,10 @@ jobs:
39133
- name: install emcc
40134
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
41135
github.event_name == 'workflow_dispatch' ||
42-
github.event_name == 'repository_dispatch' }}
136+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
43137
run: |
44-
git clone https://github.com/emscripten-core/emsdk.git
138+
git clone https://github.com/emscripten-core/emsdk -b 3.1.51
45139
cd emsdk
46-
git pull
47-
git checkout 3.1.51
48140
./emsdk install latest
49141
./emsdk activate latest
50142
source ./emsdk_env.sh
@@ -53,21 +145,17 @@ jobs:
53145
- name: fetch artifact
54146
run: |
55147
make artifact
56-
# Hack Cloudflare 403 Forbidden on GitHub Runner for Doom artifact download
57-
wget --header="User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0" \
58-
--header="Referer: https://www.doomworld.com/" \
59-
--header="Accept-Language: en-US,en;q=0.9" \
60-
-O build/shareware_doom_iwad.zip \
61-
"https://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip"
148+
# get from rv32emu-prebuilt
149+
wget -O build/shareware_doom_iwad.zip "https://raw.githubusercontent.com/sysprog21/rv32emu-prebuilt/doom-artifact/shareware_doom_iwad.zip"
62150
unzip -d build/ build/shareware_doom_iwad.zip
63151
- name: build with emcc and move application files to /tmp
64152
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
65153
github.event_name == 'workflow_dispatch' ||
66-
github.event_name == 'repository_dispatch' }}
154+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
67155
run: |
68156
make CC=emcc ENABLE_SDL=1
69157
mkdir /tmp/rv32emu-demo
70-
mv assets/wasm/html/index.html /tmp/rv32emu-demo
158+
mv assets/wasm/html/user.html /tmp/rv32emu-demo/index.html
71159
mv assets/wasm/js/coi-serviceworker.min.js /tmp/rv32emu-demo
72160
mv build/elf_list.js /tmp/rv32emu-demo
73161
mv build/rv32emu.js /tmp/rv32emu-demo
@@ -77,15 +165,15 @@ jobs:
77165
- name: Check out the rv32emu-demo repo
78166
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
79167
github.event_name == 'workflow_dispatch' ||
80-
github.event_name == 'repository_dispatch' }}
168+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
81169
uses: actions/checkout@v4
82170
with:
83171
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
84172
repository: sysprog21/rv32emu-demo
85173
- name: Create local changes
86174
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
87175
github.event_name == 'workflow_dispatch' ||
88-
github.event_name == 'repository_dispatch' }}
176+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
89177
run: |
90178
mv /tmp/rv32emu-demo/index.html .
91179
mv /tmp/rv32emu-demo/coi-serviceworker.min.js .
@@ -96,16 +184,16 @@ jobs:
96184
- name: Commit files
97185
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
98186
github.event_name == 'workflow_dispatch' ||
99-
github.event_name == 'repository_dispatch' }}
187+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
100188
run: |
101189
git config --local user.email "github-actions[bot]@users.noreply.github.com"
102190
git config --local user.name "github-actions[bot]"
103191
git add --all
104-
git commit -m "Add changes"
192+
git commit -m "Add changes to user emulation"
105193
- name: Push changes
106194
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
107195
github.event_name == 'workflow_dispatch' ||
108-
github.event_name == 'repository_dispatch' }}
196+
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
109197
uses: ad-m/github-push-action@master
110198
with:
111199
repository: sysprog21/rv32emu-demo

.github/workflows/main.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,8 @@ jobs:
8080
make artifact
8181
make ENABLE_SYSTEM=1 artifact
8282
make ENABLE_ARCH_TEST=1 artifact
83-
# Hack Cloudflare 403 Forbidden on GitHub Runner for Doom artifact download
84-
wget --header="User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0" \
85-
--header="Referer: https://www.doomworld.com/" \
86-
--header="Accept-Language: en-US,en;q=0.9" \
87-
-O build/shareware_doom_iwad.zip \
88-
"https://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip"
83+
# get from rv32emu-prebuilt
84+
wget -O build/shareware_doom_iwad.zip "https://raw.githubusercontent.com/sysprog21/rv32emu-prebuilt/doom-artifact/shareware_doom_iwad.zip"
8985
unzip -d build/ build/shareware_doom_iwad.zip
9086
if: ${{ always() }}
9187
- name: default build using emcc
@@ -394,12 +390,8 @@ jobs:
394390
| head -n 1 \
395391
| sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
396392
make LATEST_RELEASE=$LATEST_RELEASE ENABLE_ARCH_TEST=1 artifact
397-
# Hack Cloudflare 403 Forbidden on GitHub Runner for Doom artifact download
398-
wget --header="User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15" \
399-
--header="Referer: https://www.doomworld.com/" \
400-
--header="Accept-Language: en-US,en;q=0.9" \
401-
-O build/shareware_doom_iwad.zip \
402-
"https://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip"
393+
# get from rv32emu-prebuilt
394+
wget -O build/shareware_doom_iwad.zip "https://raw.githubusercontent.com/sysprog21/rv32emu-prebuilt/doom-artifact/shareware_doom_iwad.zip"
403395
unzip -d build/ build/shareware_doom_iwad.zip
404396
if: ${{ always() }}
405397
- name: default build using emcc

0 commit comments

Comments
 (0)