Skip to content

Commit e08aa2b

Browse files
committed
CI: Add WebAssembly and GitHub Pages deployment
- Add wasm-build job with Emscripten 4.0.3 and artifact caching - Add deploy-pages job for GitHub Pages deployment on main branch - Add .ci/build-wasm.sh for WASM build and deployment preparation - Add configs/wasm_defconfig for WebAssembly build configuration - Fix shell script formatting (shfmt compliance) - Fix ASan test linking by detecting CONFIG_SANITIZERS in headless tests - Make wasm-install target fail explicitly when artifacts are missing
1 parent eda118f commit e08aa2b

File tree

9 files changed

+459
-313
lines changed

9 files changed

+459
-313
lines changed

.ci/build-wasm.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
# Build WebAssembly version and prepare deployment artifacts
4+
# Usage: .ci/build-wasm.sh [build|deploy-prep]
5+
6+
set -euo pipefail
7+
8+
source "$(dirname "$0")/common.sh"
9+
10+
MODE="${1:-build}"
11+
12+
case "$MODE" in
13+
build)
14+
# Bootstrap Kconfig tools first
15+
make defconfig
16+
17+
# Apply WASM configuration using proper Kconfig flow
18+
python3 tools/kconfig/defconfig.py --kconfig configs/Kconfig configs/wasm_defconfig
19+
python3 tools/kconfig/genconfig.py --header-path src/iui_config.h configs/Kconfig
20+
21+
# Build with full Emscripten toolchain
22+
CC=emcc AR=emar RANLIB=emranlib make $PARALLEL
23+
print_success "WebAssembly build complete"
24+
;;
25+
deploy-prep)
26+
# Prepare deployment artifacts
27+
mkdir -p deploy
28+
cp assets/web/index.html deploy/
29+
cp assets/web/iui-wasm.js deploy/
30+
31+
# Copy generated files (may be in assets/web or root)
32+
if [ -f assets/web/libiui_example.js ]; then
33+
cp assets/web/libiui_example.js deploy/
34+
cp assets/web/libiui_example.wasm deploy/
35+
elif [ -f libiui_example.js ]; then
36+
cp libiui_example.js deploy/
37+
cp libiui_example.wasm deploy/
38+
else
39+
print_error "WASM artifacts not found - build may have failed"
40+
exit 1
41+
fi
42+
43+
ls -la deploy/
44+
print_success "Deployment artifacts prepared"
45+
;;
46+
*)
47+
print_error "Unknown mode: $MODE"
48+
echo "Usage: $0 [build|deploy-prep]"
49+
exit 1
50+
;;
51+
esac

.ci/check-format.sh

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,75 +15,75 @@ PY_FORMAT_EXIT=0
1515
# Use git ls-files to exclude submodules and untracked files
1616
C_SOURCES=()
1717
while IFS= read -r file; do
18-
[ -n "$file" ] && C_SOURCES+=("$file")
18+
[ -n "$file" ] && C_SOURCES+=("$file")
1919
done < <(git ls-files -- 'include/*.h' 'src/*.c' 'src/*.h' 'ports/*.c' 'ports/*.h' 'tests/*.c' 'tests/*.h')
2020

2121
if [ ${#C_SOURCES[@]} -gt 0 ]; then
22-
if command -v clang-format-20 >/dev/null 2>&1; then
23-
echo "Checking C files with clang-format-20..."
24-
clang-format-20 -n --Werror "${C_SOURCES[@]}"
25-
C_FORMAT_EXIT=$?
26-
elif command -v clang-format >/dev/null 2>&1; then
27-
echo "Checking C files with clang-format..."
28-
clang-format -n --Werror "${C_SOURCES[@]}"
29-
C_FORMAT_EXIT=$?
30-
else
31-
if [ "$REQUIRE_TOOLS" = "true" ]; then
32-
echo "ERROR: clang-format not found (required in CI)" >&2
33-
C_FORMAT_EXIT=1
34-
else
35-
echo "Skipping C format check: clang-format not found" >&2
36-
fi
37-
fi
22+
if command -v clang-format-20 > /dev/null 2>&1; then
23+
echo "Checking C files with clang-format-20..."
24+
clang-format-20 -n --Werror "${C_SOURCES[@]}"
25+
C_FORMAT_EXIT=$?
26+
elif command -v clang-format > /dev/null 2>&1; then
27+
echo "Checking C files with clang-format..."
28+
clang-format -n --Werror "${C_SOURCES[@]}"
29+
C_FORMAT_EXIT=$?
30+
else
31+
if [ "$REQUIRE_TOOLS" = "true" ]; then
32+
echo "ERROR: clang-format not found (required in CI)" >&2
33+
C_FORMAT_EXIT=1
34+
else
35+
echo "Skipping C format check: clang-format not found" >&2
36+
fi
37+
fi
3838
fi
3939

4040
SH_SOURCES=()
4141
while IFS= read -r file; do
42-
[ -n "$file" ] && SH_SOURCES+=("$file")
42+
[ -n "$file" ] && SH_SOURCES+=("$file")
4343
done < <(git ls-files -- '*.sh' '.ci/*.sh' 'scripts/*.sh')
4444

4545
if [ ${#SH_SOURCES[@]} -gt 0 ]; then
46-
if command -v shfmt >/dev/null 2>&1; then
47-
echo "Checking shell scripts..."
48-
MISMATCHED_SH=$(shfmt -l "${SH_SOURCES[@]}")
49-
if [ -n "$MISMATCHED_SH" ]; then
50-
echo "The following shell scripts are not formatted correctly:"
51-
printf '%s\n' "$MISMATCHED_SH"
52-
shfmt -d "${SH_SOURCES[@]}"
53-
SH_FORMAT_EXIT=1
54-
fi
55-
else
56-
if [ "$REQUIRE_TOOLS" = "true" ]; then
57-
echo "ERROR: shfmt not found (required in CI)" >&2
58-
SH_FORMAT_EXIT=1
59-
else
60-
echo "Skipping shell script format check: shfmt not found" >&2
61-
fi
62-
fi
46+
if command -v shfmt > /dev/null 2>&1; then
47+
echo "Checking shell scripts..."
48+
MISMATCHED_SH=$(shfmt -l "${SH_SOURCES[@]}")
49+
if [ -n "$MISMATCHED_SH" ]; then
50+
echo "The following shell scripts are not formatted correctly:"
51+
printf '%s\n' "$MISMATCHED_SH"
52+
shfmt -d "${SH_SOURCES[@]}"
53+
SH_FORMAT_EXIT=1
54+
fi
55+
else
56+
if [ "$REQUIRE_TOOLS" = "true" ]; then
57+
echo "ERROR: shfmt not found (required in CI)" >&2
58+
SH_FORMAT_EXIT=1
59+
else
60+
echo "Skipping shell script format check: shfmt not found" >&2
61+
fi
62+
fi
6363
fi
6464

6565
PY_SOURCES=()
6666
while IFS= read -r file; do
67-
[ -n "$file" ] && PY_SOURCES+=("$file")
67+
[ -n "$file" ] && PY_SOURCES+=("$file")
6868
done < <(git ls-files -- 'scripts/*.py')
6969

7070
if [ ${#PY_SOURCES[@]} -gt 0 ]; then
71-
if command -v black >/dev/null 2>&1; then
72-
echo "Checking Python files..."
73-
black --check --diff "${PY_SOURCES[@]}"
74-
PY_FORMAT_EXIT=$?
75-
else
76-
if [ "$REQUIRE_TOOLS" = "true" ]; then
77-
echo "ERROR: black not found (required in CI)" >&2
78-
PY_FORMAT_EXIT=1
79-
else
80-
echo "Skipping Python format check: black not found" >&2
81-
fi
82-
fi
71+
if command -v black > /dev/null 2>&1; then
72+
echo "Checking Python files..."
73+
black --check --diff "${PY_SOURCES[@]}"
74+
PY_FORMAT_EXIT=$?
75+
else
76+
if [ "$REQUIRE_TOOLS" = "true" ]; then
77+
echo "ERROR: black not found (required in CI)" >&2
78+
PY_FORMAT_EXIT=1
79+
else
80+
echo "Skipping Python format check: black not found" >&2
81+
fi
82+
fi
8383
fi
8484

8585
# Use logical OR to avoid exit code overflow (codes are mod 256)
8686
if [ $C_FORMAT_EXIT -ne 0 ] || [ $SH_FORMAT_EXIT -ne 0 ] || [ $PY_FORMAT_EXIT -ne 0 ]; then
87-
exit 1
87+
exit 1
8888
fi
8989
exit 0

.ci/check-newline.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ show=0
99
# Excludes: externals/ (third-party code with own style), binary files
1010
# Reference: https://medium.com/@alexey.inkin/how-to-force-newline-at-end-of-files-and-why-you-should-do-it-fdf76d1d090e
1111
while IFS= read -rd '' f; do
12-
# Skip externals directory (third-party code)
13-
case "$f" in
14-
externals/*) continue ;;
15-
esac
12+
# Skip externals directory (third-party code)
13+
case "$f" in
14+
externals/*) continue ;;
15+
esac
1616

17-
# Skip empty files (e.g., __init__.py markers)
18-
[ -s "$f" ] || continue
17+
# Skip empty files (e.g., __init__.py markers)
18+
[ -s "$f" ] || continue
1919

20-
if file --mime-encoding "$f" | grep -qv binary; then
21-
tail -c1 <"$f" | read -r _ || show=1
22-
if [ $show -eq 1 ]; then
23-
echo "Warning: No newline at end of file $f"
24-
ret=1
25-
show=0
26-
fi
27-
fi
20+
if file --mime-encoding "$f" | grep -qv binary; then
21+
tail -c1 < "$f" | read -r _ || show=1
22+
if [ $show -eq 1 ]; then
23+
echo "Warning: No newline at end of file $f"
24+
ret=1
25+
show=0
26+
fi
27+
fi
2828
done < <(git ls-files -z)
2929

3030
exit $ret

0 commit comments

Comments
 (0)