Skip to content

Fix deploy-wasm CI trigger condition #577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 39 additions & 12 deletions .github/workflows/deploy-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ on:
workflow_dispatch:
branches:
- master
repository_dispatch: # listening to rv32emu-prebuilt events
types: [deploy_wasm]

jobs:
wasm-deploy:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
if: github.event.pull_request.merged == true ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand All @@ -22,12 +26,20 @@ jobs:
uses: tj-actions/changed-files@v45
with:
files: |
assets/html/index.html
assets/js/pre.js
assets/wasm/html/index.html
assets/wasm/js/pre.js
build/*.elf
tools/gen-elf-list-js.py
# 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
- name: install emcc
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch'}}
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch' }}
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
Expand All @@ -38,29 +50,42 @@ jobs:
source ./emsdk_env.sh
echo "$PATH" >> $GITHUB_PATH
shell: bash
- name: fetch artifact
run: |
make artifact
# Hack Cloudflare 403 Forbidden on GitHub Runner for Doom artifact download
wget --header="User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0" \
--header="Referer: https://www.doomworld.com/" \
--header="Accept-Language: en-US,en;q=0.9" \
-O build/shareware_doom_iwad.zip \
"https://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip"
unzip -d build/ build/shareware_doom_iwad.zip
- name: build with emcc and move application files to /tmp
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch'}}
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch' }}
run: |
make CC=emcc ENABLE_GDBSTUB=0 ENABLE_SDL=1
make CC=emcc ENABLE_SDL=1
mkdir /tmp/rv32emu-demo
mv assets/html/index.html /tmp/rv32emu-demo
mv assets/js/coi-serviceworker.min.js /tmp/rv32emu-demo
mv assets/wasm/html/index.html /tmp/rv32emu-demo
mv assets/wasm/js/coi-serviceworker.min.js /tmp/rv32emu-demo
mv build/elf_list.js /tmp/rv32emu-demo
mv build/rv32emu.js /tmp/rv32emu-demo
mv build/rv32emu.wasm /tmp/rv32emu-demo
mv build/rv32emu.worker.js /tmp/rv32emu-demo
ls -al /tmp/rv32emu-demo
- name: Check out the rv32emu-demo repo
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch'}}
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch' }}
uses: actions/checkout@v4
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
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch'}}
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch' }}
run: |
mv /tmp/rv32emu-demo/index.html .
mv /tmp/rv32emu-demo/coi-serviceworker.min.js .
Expand All @@ -70,15 +95,17 @@ jobs:
mv /tmp/rv32emu-demo/rv32emu.worker.js .
- name: Commit files
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch'}}
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch' }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add --all
git commit -m "Add changes"
- name: Push changes
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch'}}
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch' }}
uses: ad-m/github-push-action@master
with:
repository: sysprog21/rv32emu-demo
Expand Down
243 changes: 0 additions & 243 deletions assets/html/index.html

This file was deleted.

2 changes: 0 additions & 2 deletions assets/js/coi-serviceworker.min.js

This file was deleted.

9 changes: 0 additions & 9 deletions assets/js/pre.js

This file was deleted.

17 changes: 13 additions & 4 deletions mk/wasm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ WEB_JS_RESOURCES := $(ASSETS)/js
EXPORTED_FUNCS := _main,_indirect_rv_halt
DEMO_DIR := demo
WEB_FILES := $(BIN).js \
$(BIN).wasm \
$(BIN).worker.js \
$(BIN).wasm \
$(BIN).worker.js \
$(OUT)/elf_list.js

ifeq ("$(CC_IS_EMCC)", "1")
Expand All @@ -29,10 +29,19 @@ CFLAGS_emcc += -sINITIAL_MEMORY=2GB \
-s"EXPORTED_FUNCTIONS=$(EXPORTED_FUNCS)" \
-sSTACK_SIZE=4MB \
-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency \
--embed-file build@/ \
--embed-file build/jit-bf.elf@/jit-bf.elf \
--embed-file build/coro.elf@/coro.elf \
--embed-file build/fibonacci.elf@/fibonacci.elf \
--embed-file build/hello.elf@/hello.elf \
--embed-file build/ieee754.elf@/ieee754.elf \
--embed-file build/perfcount.elf@/perfcount.elf \
--embed-file build/readelf.elf@/readelf.elf \
--embed-file build/smolnes.elf@/smolnes.elf \
--embed-file build/riscv32@/riscv32 \
--embed-file build/DOOM1.WAD@/DOOM1.WAD \
--embed-file build/id1/pak0.pak@/id1/pak0.pak \
--embed-file build/timidity@/etc/timidity \
-DMEM_SIZE=0x40000000 \
-DMEM_SIZE=0x60000000 \
-DCYCLE_PER_STEP=2000000 \
--pre-js $(WEB_JS_RESOURCES)/pre.js \
-O3 \
Expand Down
1 change: 1 addition & 0 deletions src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ void rv_step(void *arg)
if (rv_has_halted(rv)) {
emscripten_cancel_main_loop();
rv_delete(rv); /* clean up and reuse memory */
rv_log_info("RISC-V emulator is destroyed");
}
#endif
}
Expand Down
1 change: 0 additions & 1 deletion src/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ void rv_run(riscv_t *rv)
attr->data.user.elf_program
#endif
);
attr->cycle_per_step = 100000000;

if (!(attr->run_flag & (RV_RUN_TRACE | RV_RUN_GDBSTUB))) {
#ifdef __EMSCRIPTEN__
Expand Down
33 changes: 28 additions & 5 deletions tools/gen-elf-list-js.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,55 @@

import os

def list_files(d):

def list_files(d, ignore_list=None):
if ignore_list is None:
ignore_list = []
try:
if d == "build":
files = [f for f in os.listdir(d) if (os.path.isfile(os.path.join(d, f)) and f.endswith('.elf'))]
files = [
f
for f in os.listdir(d)
if os.path.isfile(os.path.join(d, f))
and f.endswith(".elf")
and not any(f.endswith(ign) or f.startswith(ign) for ign in ignore_list)
]
else:
parent_dir = os.path.dirname(d)
files = [
os.path.relpath(os.path.join(d, f), start=parent_dir)
for f in os.listdir(d)
if os.path.isfile(os.path.join(d, f))
and not any(
f.endswith(ign) or os.path.join(d, f).endswith(ign)
for ign in ignore_list
)
]
return files
except FileNotFoundError:
print(f"Directory {directory} not found.")
print(f"Directory {d} not found.")
return []


elf_exec_dirs = ["build", "build/riscv32"]
msg_less_ignore_files = [
"cc.elf",
"chacha20.elf",
"riscv32/lena",
"riscv32/puzzle",
"riscv32/line",
"riscv32/captcha",
] # List of files to ignore
elf_exec_list = []

for d in elf_exec_dirs:
files = list_files(d)
files = list_files(d, ignore_list=msg_less_ignore_files)
elf_exec_list.extend(files)
#print(elf_exec_list)


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


gen_elf_list_js()
Loading