72 lines
1.8 KiB
YAML
72 lines
1.8 KiB
YAML
name: Build & Test WASM
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Clone kobopatch source
|
|
run: |
|
|
cd kobopatch-wasm
|
|
./setup.sh
|
|
|
|
- name: Run native tests
|
|
run: |
|
|
cd kobopatch-wasm/kobopatch-src
|
|
go test ./...
|
|
|
|
- name: Build WASM binary
|
|
run: |
|
|
cd kobopatch-wasm
|
|
./build.sh
|
|
test -f kobopatch.wasm || { echo "ERROR: kobopatch.wasm not found after build"; exit 1; }
|
|
|
|
- name: Run WASM tests
|
|
run: |
|
|
cd kobopatch-wasm/kobopatch-src
|
|
GOROOT="$(go env GOROOT)"
|
|
if [ -f "$GOROOT/lib/wasm/go_js_wasm_exec" ]; then
|
|
EXEC="$GOROOT/lib/wasm/go_js_wasm_exec"
|
|
else
|
|
EXEC="$GOROOT/misc/wasm/go_js_wasm_exec"
|
|
fi
|
|
GOOS=js GOARCH=wasm go test -exec="$EXEC" ./...
|
|
|
|
- name: Check if integration test is needed
|
|
id: check-wasm
|
|
run: |
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
echo "run=true" >> "$GITHUB_OUTPUT"
|
|
elif git diff --name-only HEAD~1 HEAD | grep -q '^kobopatch-wasm/'; then
|
|
echo "run=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "run=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Full integration test
|
|
if: steps.check-wasm.outputs.run == 'true' && env.GITEA_ACTIONS != 'true'
|
|
run: |
|
|
cd kobopatch-wasm
|
|
./test-integration.sh
|