1
0
Files
kobopatch-webui/.github/workflows/build.yml

154 lines
4.2 KiB
YAML

name: Build and test project
on:
push:
branches: [main, develop, electron]
tags: ['v*']
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: Install jq
run: sudo apt-get install -y jq
- 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-e2e
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "run=true" >> "$GITHUB_OUTPUT"
elif git diff --name-only HEAD~1 HEAD | grep -qE '^(kobopatch-wasm/|web/|tests/|nickelmenu/|koreader/|readerly/)'; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "run=false" >> "$GITHUB_OUTPUT"
fi
- name: Download test firmware
if: steps.check-e2e.outputs.run == 'true' && env.GITEA_ACTIONS != 'true'
run: |
mkdir -p tests/cached_assets
echo "Downloading firmware..."
curl -fL --progress-bar -o tests/cached_assets/kobo-update-4.45.23646.zip \
https://ereaderfiles.kobo.com/firmwares/kobo13/Mar2026/kobo-update-4.45.23646.zip
- name: Full integration test (WASM)
if: steps.check-e2e.outputs.run == 'true' && env.GITEA_ACTIONS != 'true'
run: kobopatch-wasm/test-integration.sh
- name: Set up NickelMenu assets
if: steps.check-e2e.outputs.run == 'true' && env.GITEA_ACTIONS != 'true'
run: nickelmenu/setup.sh
- name: Set up KOReader assets
if: steps.check-e2e.outputs.run == 'true' && env.GITEA_ACTIONS != 'true'
run: koreader/setup.sh
- name: Set up Readerly assets
if: steps.check-e2e.outputs.run == 'true' && env.GITEA_ACTIONS != 'true'
run: readerly/setup.sh
- name: Full integration test (Playwright)
if: steps.check-e2e.outputs.run == 'true' && env.GITEA_ACTIONS != 'true'
run: |
cd tests/e2e
./run-e2e.sh
build-electron:
needs: build-and-test
if: always() && needs.build-and-test.result == 'success'
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Build WASM binary
run: |
cd kobopatch-wasm
./setup.sh
./build.sh
- name: Set up NickelMenu assets
run: nickelmenu/setup.sh
- name: Set up KOReader assets
run: koreader/setup.sh
- name: Set up Readerly assets
run: readerly/setup.sh
- name: Build frontend
run: |
cd web
npm install
npm run build
- name: Build Electron app
run: |
cd electron
npm install
npm run build:${{ matrix.platform }}
- name: Upload Electron artifact
uses: actions/upload-artifact@v4
with:
name: electron-${{ matrix.platform }}
path: |
electron/release/*.AppImage
electron/release/*.dmg
electron/release/*.zip
electron/release/*.exe
if-no-files-found: warn