Skip to content

Commit 1e88221

Browse files
committed
CI: Deploy wasm-user and wasm-system
Since the wasm build targets are now divided into user and system, it is reasonable to separate the CI deployment into two flavors: user and system.
1 parent ec4005d commit 1e88221

File tree

2 files changed

+228
-0
lines changed

2 files changed

+228
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: WebAssembly System
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- master
7+
types:
8+
- closed
9+
workflow_dispatch:
10+
branches:
11+
- master
12+
repository_dispatch: # listening to rv32emu-prebuilt events
13+
types: [deploy_wasm]
14+
15+
jobs:
16+
wasm-system-deploy:
17+
if: github.event.pull_request.merged == true ||
18+
github.event_name == 'workflow_dispatch' ||
19+
github.event_name == 'repository_dispatch'
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 libsdl2-dev libsdl2-mixer-dev 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' }}
47+
run: |
48+
git clone https://github.com/emscripten-core/emsdk.git
49+
cd emsdk
50+
git pull
51+
git checkout 3.1.51
52+
./emsdk install latest
53+
./emsdk activate latest
54+
source ./emsdk_env.sh
55+
echo "$PATH" >> $GITHUB_PATH
56+
shell: bash
57+
- name: fetch artifact
58+
run: |
59+
make artifact
60+
# Hack Cloudflare 403 Forbidden on GitHub Runner for Doom artifact download
61+
wget --header="User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0" \
62+
--header="Referer: https://www.doomworld.com/" \
63+
--header="Accept-Language: en-US,en;q=0.9" \
64+
-O build/shareware_doom_iwad.zip \
65+
"https://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip"
66+
unzip -d build/ build/shareware_doom_iwad.zip
67+
- name: build with emcc and move application files to /tmp
68+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
69+
github.event_name == 'workflow_dispatch' ||
70+
github.event_name == 'repository_dispatch' }}
71+
run: |
72+
make CC=emcc ENABLE_SYSTEM=1 ENABLE_SDL=1 INITRD_SIZE=32 -j
73+
mkdir /tmp/rv32emu-demo-system
74+
mv assets/wasm/html/system.html /tmp/rv32emu-demo-system/index.html
75+
mv assets/wasm/js/coi-serviceworker.min.js /tmp/rv32emu-demo-system
76+
mv build/rv32emu.js /tmp/rv32emu-demo-system
77+
mv build/rv32emu.wasm /tmp/rv32emu-demo-system
78+
mv build/rv32emu.worker.js /tmp/rv32emu-demo-system
79+
ls -al /tmp/rv32emu-demo-system
80+
- name: Check out the rv32emu-demo-system repo
81+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
82+
github.event_name == 'workflow_dispatch' ||
83+
github.event_name == 'repository_dispatch' }}
84+
uses: actions/checkout@v4
85+
with:
86+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
87+
repository: ChinYikMing/rv32emu-demo-system
88+
- name: Create local changes
89+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
90+
github.event_name == 'workflow_dispatch' ||
91+
github.event_name == 'repository_dispatch' }}
92+
run: |
93+
mv /tmp/rv32emu-demo-system/index.html .
94+
mv /tmp/rv32emu-demo-system/coi-serviceworker.min.js .
95+
mv /tmp/rv32emu-demo-system/rv32emu.js .
96+
mv /tmp/rv32emu-demo-system/rv32emu.wasm .
97+
mv /tmp/rv32emu-demo-system/rv32emu.worker.js .
98+
- name: Commit files
99+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
100+
github.event_name == 'workflow_dispatch' ||
101+
github.event_name == 'repository_dispatch' }}
102+
run: |
103+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
104+
git config --local user.name "github-actions[bot]"
105+
git add --all
106+
git commit -m "Add changes"
107+
- name: Push changes
108+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
109+
github.event_name == 'workflow_dispatch' ||
110+
github.event_name == 'repository_dispatch' }}
111+
uses: ad-m/github-push-action@master
112+
with:
113+
repository: ChinYikMing/rv32emu-demo-system
114+
github_token: ${{ secrets.RV32EMU_DEMO_SYSTEM_TOKEN }}
115+
branch: main
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: WebAssembly
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- master
7+
types:
8+
- closed
9+
workflow_dispatch:
10+
branches:
11+
- master
12+
repository_dispatch: # listening to rv32emu-prebuilt events
13+
types: [deploy_wasm]
14+
15+
jobs:
16+
wasm-deploy:
17+
if: github.event.pull_request.merged == true ||
18+
github.event_name == 'workflow_dispatch' ||
19+
github.event_name == 'repository_dispatch'
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check out the repo
23+
uses: actions/checkout@v4
24+
- name: Verify if the JS or HTML or ELF executable files has been modified
25+
id: changed-files
26+
uses: tj-actions/changed-files@v46
27+
with:
28+
files: |
29+
assets/wasm/html/user.html
30+
assets/wasm/js/user-pre.js
31+
build/*.elf
32+
tools/gen-elf-list-js.py
33+
# Files below may have a potential performance impact (reference from benchmark.yml)
34+
src/riscv.c
35+
src/decode.c
36+
src/emulate.c
37+
src/rv32_template.c
38+
src/rv32_constopt.c
39+
- name: install emcc
40+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
41+
github.event_name == 'workflow_dispatch' ||
42+
github.event_name == 'repository_dispatch' }}
43+
run: |
44+
git clone https://github.com/emscripten-core/emsdk.git
45+
cd emsdk
46+
git pull
47+
git checkout 3.1.51
48+
./emsdk install latest
49+
./emsdk activate latest
50+
source ./emsdk_env.sh
51+
echo "$PATH" >> $GITHUB_PATH
52+
shell: bash
53+
- name: fetch artifact
54+
run: |
55+
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"
62+
unzip -d build/ build/shareware_doom_iwad.zip
63+
- name: build with emcc and move application files to /tmp
64+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
65+
github.event_name == 'workflow_dispatch' ||
66+
github.event_name == 'repository_dispatch' }}
67+
run: |
68+
make CC=emcc ENABLE_SDL=1
69+
mkdir /tmp/rv32emu-demo
70+
mv assets/wasm/html/user.html /tmp/rv32emu-demo/index.html
71+
mv assets/wasm/js/coi-serviceworker.min.js /tmp/rv32emu-demo
72+
mv build/elf_list.js /tmp/rv32emu-demo
73+
mv build/rv32emu.js /tmp/rv32emu-demo
74+
mv build/rv32emu.wasm /tmp/rv32emu-demo
75+
mv build/rv32emu.worker.js /tmp/rv32emu-demo
76+
ls -al /tmp/rv32emu-demo
77+
- name: Check out the rv32emu-demo repo
78+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
79+
github.event_name == 'workflow_dispatch' ||
80+
github.event_name == 'repository_dispatch' }}
81+
uses: actions/checkout@v4
82+
with:
83+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
84+
repository: ChinYikMing/rv32emu-demo
85+
- name: Create local changes
86+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
87+
github.event_name == 'workflow_dispatch' ||
88+
github.event_name == 'repository_dispatch' }}
89+
run: |
90+
mv /tmp/rv32emu-demo/index.html .
91+
mv /tmp/rv32emu-demo/coi-serviceworker.min.js .
92+
mv /tmp/rv32emu-demo/elf_list.js .
93+
mv /tmp/rv32emu-demo/rv32emu.js .
94+
mv /tmp/rv32emu-demo/rv32emu.wasm .
95+
mv /tmp/rv32emu-demo/rv32emu.worker.js .
96+
- name: Commit files
97+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
98+
github.event_name == 'workflow_dispatch' ||
99+
github.event_name == 'repository_dispatch' }}
100+
run: |
101+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
102+
git config --local user.name "github-actions[bot]"
103+
git add --all
104+
git commit -m "Add changes"
105+
- name: Push changes
106+
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
107+
github.event_name == 'workflow_dispatch' ||
108+
github.event_name == 'repository_dispatch' }}
109+
uses: ad-m/github-push-action@master
110+
with:
111+
repository: ChinYikMing/rv32emu-demo
112+
github_token: ${{ secrets.RV32EMU_DEMO_TOKEN }}
113+
branch: main

0 commit comments

Comments
 (0)