Skip to content

Commit 6928f8c

Browse files
authored
Merge pull request #577 from ChinYikMing/ci-fix-deploy-wasm
Fix deploy-wasm CI trigger condition
2 parents 7a77bf8 + c429166 commit 6928f8c

File tree

8 files changed

+81
-276
lines changed

8 files changed

+81
-276
lines changed

.github/workflows/deploy-wasm.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ on:
99
workflow_dispatch:
1010
branches:
1111
- master
12+
repository_dispatch: # listening to rv32emu-prebuilt events
13+
types: [deploy_wasm]
1214

1315
jobs:
1416
wasm-deploy:
15-
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
17+
if: github.event.pull_request.merged == true ||
18+
github.event_name == 'workflow_dispatch' ||
19+
github.event_name == 'repository_dispatch'
1620
runs-on: ubuntu-latest
1721
steps:
1822
- name: Check out the repo
@@ -22,12 +26,20 @@ jobs:
2226
uses: tj-actions/changed-files@v45
2327
with:
2428
files: |
25-
assets/html/index.html
26-
assets/js/pre.js
29+
assets/wasm/html/index.html
30+
assets/wasm/js/pre.js
2731
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
2839
- name: install emcc
2940
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
30-
github.event_name == 'workflow_dispatch'}}
41+
github.event_name == 'workflow_dispatch' ||
42+
github.event_name == 'repository_dispatch' }}
3143
run: |
3244
git clone https://github.com/emscripten-core/emsdk.git
3345
cd emsdk
@@ -38,29 +50,42 @@ jobs:
3850
source ./emsdk_env.sh
3951
echo "$PATH" >> $GITHUB_PATH
4052
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
4163
- name: build with emcc and move application files to /tmp
4264
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
43-
github.event_name == 'workflow_dispatch'}}
65+
github.event_name == 'workflow_dispatch' ||
66+
github.event_name == 'repository_dispatch' }}
4467
run: |
45-
make CC=emcc ENABLE_GDBSTUB=0 ENABLE_SDL=1
68+
make CC=emcc ENABLE_SDL=1
4669
mkdir /tmp/rv32emu-demo
47-
mv assets/html/index.html /tmp/rv32emu-demo
48-
mv assets/js/coi-serviceworker.min.js /tmp/rv32emu-demo
70+
mv assets/wasm/html/index.html /tmp/rv32emu-demo
71+
mv assets/wasm/js/coi-serviceworker.min.js /tmp/rv32emu-demo
4972
mv build/elf_list.js /tmp/rv32emu-demo
5073
mv build/rv32emu.js /tmp/rv32emu-demo
5174
mv build/rv32emu.wasm /tmp/rv32emu-demo
5275
mv build/rv32emu.worker.js /tmp/rv32emu-demo
5376
ls -al /tmp/rv32emu-demo
5477
- name: Check out the rv32emu-demo repo
5578
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
56-
github.event_name == 'workflow_dispatch'}}
79+
github.event_name == 'workflow_dispatch' ||
80+
github.event_name == 'repository_dispatch' }}
5781
uses: actions/checkout@v4
5882
with:
5983
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
6084
repository: sysprog21/rv32emu-demo
6185
- name: Create local changes
6286
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
63-
github.event_name == 'workflow_dispatch'}}
87+
github.event_name == 'workflow_dispatch' ||
88+
github.event_name == 'repository_dispatch' }}
6489
run: |
6590
mv /tmp/rv32emu-demo/index.html .
6691
mv /tmp/rv32emu-demo/coi-serviceworker.min.js .
@@ -70,15 +95,17 @@ jobs:
7095
mv /tmp/rv32emu-demo/rv32emu.worker.js .
7196
- name: Commit files
7297
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
73-
github.event_name == 'workflow_dispatch'}}
98+
github.event_name == 'workflow_dispatch' ||
99+
github.event_name == 'repository_dispatch' }}
74100
run: |
75101
git config --local user.email "github-actions[bot]@users.noreply.github.com"
76102
git config --local user.name "github-actions[bot]"
77103
git add --all
78104
git commit -m "Add changes"
79105
- name: Push changes
80106
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
81-
github.event_name == 'workflow_dispatch'}}
107+
github.event_name == 'workflow_dispatch' ||
108+
github.event_name == 'repository_dispatch' }}
82109
uses: ad-m/github-push-action@master
83110
with:
84111
repository: sysprog21/rv32emu-demo

assets/html/index.html

Lines changed: 0 additions & 243 deletions
This file was deleted.

assets/js/coi-serviceworker.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

assets/js/pre.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

mk/wasm.mk

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ WEB_JS_RESOURCES := $(ASSETS)/js
66
EXPORTED_FUNCS := _main,_indirect_rv_halt
77
DEMO_DIR := demo
88
WEB_FILES := $(BIN).js \
9-
$(BIN).wasm \
10-
$(BIN).worker.js \
9+
$(BIN).wasm \
10+
$(BIN).worker.js \
1111
$(OUT)/elf_list.js
1212

1313
ifeq ("$(CC_IS_EMCC)", "1")
@@ -29,10 +29,19 @@ CFLAGS_emcc += -sINITIAL_MEMORY=2GB \
2929
-s"EXPORTED_FUNCTIONS=$(EXPORTED_FUNCS)" \
3030
-sSTACK_SIZE=4MB \
3131
-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency \
32-
--embed-file build@/ \
32+
--embed-file build/jit-bf.elf@/jit-bf.elf \
33+
--embed-file build/coro.elf@/coro.elf \
34+
--embed-file build/fibonacci.elf@/fibonacci.elf \
35+
--embed-file build/hello.elf@/hello.elf \
36+
--embed-file build/ieee754.elf@/ieee754.elf \
37+
--embed-file build/perfcount.elf@/perfcount.elf \
38+
--embed-file build/readelf.elf@/readelf.elf \
39+
--embed-file build/smolnes.elf@/smolnes.elf \
3340
--embed-file build/riscv32@/riscv32 \
41+
--embed-file build/DOOM1.WAD@/DOOM1.WAD \
42+
--embed-file build/id1/pak0.pak@/id1/pak0.pak \
3443
--embed-file build/timidity@/etc/timidity \
35-
-DMEM_SIZE=0x40000000 \
44+
-DMEM_SIZE=0x60000000 \
3645
-DCYCLE_PER_STEP=2000000 \
3746
--pre-js $(WEB_JS_RESOURCES)/pre.js \
3847
-O3 \

src/emulate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ void rv_step(void *arg)
11751175
if (rv_has_halted(rv)) {
11761176
emscripten_cancel_main_loop();
11771177
rv_delete(rv); /* clean up and reuse memory */
1178+
rv_log_info("RISC-V emulator is destroyed");
11781179
}
11791180
#endif
11801181
}

src/riscv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ void rv_run(riscv_t *rv)
615615
attr->data.user.elf_program
616616
#endif
617617
);
618-
attr->cycle_per_step = 100000000;
619618

620619
if (!(attr->run_flag & (RV_RUN_TRACE | RV_RUN_GDBSTUB))) {
621620
#ifdef __EMSCRIPTEN__

tools/gen-elf-list-js.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,55 @@
22

33
import os
44

5-
def list_files(d):
5+
6+
def list_files(d, ignore_list=None):
7+
if ignore_list is None:
8+
ignore_list = []
69
try:
710
if d == "build":
8-
files = [f for f in os.listdir(d) if (os.path.isfile(os.path.join(d, f)) and f.endswith('.elf'))]
11+
files = [
12+
f
13+
for f in os.listdir(d)
14+
if os.path.isfile(os.path.join(d, f))
15+
and f.endswith(".elf")
16+
and not any(f.endswith(ign) or f.startswith(ign) for ign in ignore_list)
17+
]
918
else:
1019
parent_dir = os.path.dirname(d)
1120
files = [
1221
os.path.relpath(os.path.join(d, f), start=parent_dir)
1322
for f in os.listdir(d)
1423
if os.path.isfile(os.path.join(d, f))
24+
and not any(
25+
f.endswith(ign) or os.path.join(d, f).endswith(ign)
26+
for ign in ignore_list
27+
)
1528
]
1629
return files
1730
except FileNotFoundError:
18-
print(f"Directory {directory} not found.")
31+
print(f"Directory {d} not found.")
1932
return []
2033

34+
2135
elf_exec_dirs = ["build", "build/riscv32"]
36+
msg_less_ignore_files = [
37+
"cc.elf",
38+
"chacha20.elf",
39+
"riscv32/lena",
40+
"riscv32/puzzle",
41+
"riscv32/line",
42+
"riscv32/captcha",
43+
] # List of files to ignore
2244
elf_exec_list = []
2345

2446
for d in elf_exec_dirs:
25-
files = list_files(d)
47+
files = list_files(d, ignore_list=msg_less_ignore_files)
2648
elf_exec_list.extend(files)
27-
#print(elf_exec_list)
49+
2850

2951
def gen_elf_list_js():
3052
js_code = f"const elfFiles = {elf_exec_list};\n"
3153
print(js_code)
3254

55+
3356
gen_elf_list_js()

0 commit comments

Comments
 (0)