ci: add smoke-gated quality checks to the main pipeline

Replaced test.yml with ci.yml, added a built-app smoke runner in scripts/smoke-web-app.js, and inserted a release preflight so tags run the same core checks before packaging.
This commit is contained in:
plebeius
2026-03-08 12:41:52 +08:00
parent 4e3cc06a81
commit e46c7dd169
3 changed files with 418 additions and 43 deletions
@@ -1,15 +1,138 @@
name: Test Builds
name: CI
on:
push:
branches: [ development, master ]
branches: [development, master]
pull_request:
branches: [ development, master ]
branches: [development, master]
workflow_dispatch:
env:
HUSKY: '0'
permissions:
contents: read
jobs:
test-linux:
name: Test Linux (Ubuntu)
quality:
name: Quality + Smoke
runs-on: ubuntu-22.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js v22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
- name: Install dependencies
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --frozen-lockfile --ignore-engines --network-timeout 100000 --network-concurrency 1 && break
sleep 5
[ "$i" = "3" ] && exit 1
done
- name: Run Vitest
run: yarn test --run
- name: Collect coverage
run: yarn test:coverage
- name: Lint
run: yarn lint
- name: Type check
run: yarn type-check
- name: Build React app
run: yarn build
env:
CI: ''
- name: Build preload script
run: yarn build:preload
- name: Verify build outputs
run: |
ls -la build/ || exit 1
ls -la build/electron/preload.cjs || exit 1
ls -la build/index.html || exit 1
- name: Verify forge config
run: node -e "import('./forge.config.js').then(c => console.log('Config loaded, makers:', c.default.makers?.length || 0)).catch(e => { console.error(e); process.exit(1); })"
- name: Run React Doctor
run: yarn doctor
- name: Install Chromium for smoke tests
run: npx playwright install --with-deps chromium
- name: Smoke test built web app
run: node scripts/smoke-web-app.js --start-preview
- name: Upload coverage summary
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-summary
path: coverage/coverage-summary.json
if-no-files-found: warn
android-build:
name: Android Build
runs-on: ubuntu-22.04
needs: quality
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Setup Node.js v22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
- name: Install dependencies
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --frozen-lockfile --ignore-engines --network-timeout 100000 --network-concurrency 1 && break
sleep 5
[ "$i" = "3" ] && exit 1
done
- name: Build React app
run: yarn build
env:
CI: ''
- name: Sync Capacitor Android project
run: npx cap sync android
- name: Run Android unit tests and assemble debug APK
run: cd android && ./gradlew testDebugUnitTest assembleDebug --stacktrace
package-linux:
name: Package Linux (Ubuntu)
runs-on: ubuntu-22.04
needs: quality
steps:
- uses: actions/checkout@v4
with:
@@ -37,49 +160,38 @@ jobs:
[ "$i" = "3" ] && exit 1
done
- name: Build React App
- name: Build React app
run: yarn build
env:
CI: ''
- name: Build Preload Script
- name: Build preload script
run: yarn build:preload
- name: Verify build outputs
run: |
echo "=== Checking build/ directory ==="
ls -la build/ || exit 1
echo "=== Checking build/electron/preload.cjs ==="
ls -la build/electron/preload.cjs || exit 1
echo "=== Checking build/index.html ==="
ls -la build/index.html || exit 1
- name: Verify forge config
run: |
echo "=== forge.config.js exists ==="
ls -la forge.config.js
echo "=== Validating forge config can be loaded ==="
node -e "import('./forge.config.js').then(c => console.log('Config loaded, makers:', c.default.makers?.length || 0)).catch(e => { console.error(e); process.exit(1); })"
- name: Package Electron App
- name: Package Electron app
timeout-minutes: 30
run: |
set -o pipefail
yarn electron-forge package 2>&1 | tee forge-output.log
echo "=== Checking out/ directory ==="
ls -la out/
- name: Verify Executable
- name: Verify executable
run: |
ls -la out/
EXE=$(node scripts/find-forge-executable.js)
echo "Found executable: $EXE"
# Verify the file exists and is executable
test -f "$EXE" && test -x "$EXE" && echo "✓ Executable is valid"
test -f "$EXE" && test -x "$EXE" && echo "Executable is valid"
test-mac-intel:
name: Test Mac (Intel)
package-mac-intel:
name: Package Mac (Intel)
runs-on: macos-15-intel
needs: quality
steps:
- uses: actions/checkout@v4
with:
@@ -110,12 +222,12 @@ jobs:
[ "$i" = "3" ] && exit 1
done
- name: Build React App
- name: Build React app
run: yarn build
env:
CI: ''
- name: Build Preload Script
- name: Build preload script
run: yarn build:preload
- name: Verify build outputs
@@ -124,23 +236,24 @@ jobs:
ls -la build/electron/preload.cjs || exit 1
ls -la build/index.html || exit 1
- name: Package Electron App
- name: Package Electron app
timeout-minutes: 30
run: |
set -o pipefail
yarn electron-forge package 2>&1 | tee forge-output.log
ls -la out/
- name: Verify Executable
- name: Verify executable
run: |
ls -la out/
EXE=$(node scripts/find-forge-executable.js)
echo "Found executable: $EXE"
test -f "$EXE" && test -x "$EXE" && echo "✓ Executable is valid"
test -f "$EXE" && test -x "$EXE" && echo "Executable is valid"
test-mac-arm:
name: Test Mac (Apple Silicon)
package-mac-arm:
name: Package Mac (Apple Silicon)
runs-on: macos-latest
needs: quality
steps:
- uses: actions/checkout@v4
with:
@@ -171,12 +284,12 @@ jobs:
[ "$i" = "3" ] && exit 1
done
- name: Build React App
- name: Build React app
run: yarn build
env:
CI: ''
- name: Build Preload Script
- name: Build preload script
run: yarn build:preload
- name: Verify build outputs
@@ -185,23 +298,24 @@ jobs:
ls -la build/electron/preload.cjs || exit 1
ls -la build/index.html || exit 1
- name: Package Electron App
- name: Package Electron app
timeout-minutes: 30
run: |
set -o pipefail
yarn electron-forge package 2>&1 | tee forge-output.log
ls -la out/
- name: Verify Executable
- name: Verify executable
run: |
ls -la out/
EXE=$(node scripts/find-forge-executable.js)
echo "Found executable: $EXE"
test -f "$EXE" && test -x "$EXE" && echo "✓ Executable is valid"
test -f "$EXE" && test -x "$EXE" && echo "Executable is valid"
test-windows:
name: Test Windows
package-windows:
name: Package Windows
runs-on: windows-2022
needs: quality
steps:
- uses: actions/checkout@v4
with:
@@ -230,13 +344,13 @@ jobs:
[ "$i" = "3" ] && exit 1
done
- name: Build React App
- name: Build React app
shell: bash
run: yarn build
env:
CI: ''
- name: Build Preload Script
- name: Build preload script
shell: bash
run: yarn build:preload
@@ -247,7 +361,7 @@ jobs:
ls -la build/electron/preload.cjs || exit 1
ls -la build/index.html || exit 1
- name: Package Electron App
- name: Package Electron app
shell: bash
timeout-minutes: 30
run: |
@@ -255,10 +369,10 @@ jobs:
yarn electron-forge package 2>&1 | tee forge-output.log
ls -la out/
- name: Verify Executable
- name: Verify executable
shell: bash
run: |
ls -la out/
EXE=$(node scripts/find-forge-executable.js)
echo "Found executable: $EXE"
test -f "$EXE" && test -x "$EXE" && echo "✓ Executable is valid"
test -f "$EXE" && test -x "$EXE" && echo "Executable is valid"
+40
View File
@@ -13,12 +13,49 @@ env:
HUSKY: '0'
jobs:
preflight:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js v22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
- name: Install dependencies
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --frozen-lockfile --ignore-engines --network-timeout 100000 --network-concurrency 1 && break
sleep 5
[ "$i" = "3" ] && exit 1
done
- name: Run Vitest
run: yarn test --run
- name: Lint
run: yarn lint
- name: Type check
run: yarn type-check
- name: Build React app
run: CI='' NODE_ENV=production yarn build
- name: Run React Doctor
run: yarn doctor
- name: Install Chromium for smoke tests
run: npx playwright install --with-deps chromium
- name: Smoke test built web app
run: node scripts/smoke-web-app.js --start-preview
linux:
strategy:
fail-fast: false
matrix:
arch: [x64, arm64]
runs-on: ubuntu-22.04
needs: preflight
permissions:
contents: write
steps:
@@ -85,6 +122,7 @@ jobs:
- runner: macos-latest # Apple Silicon arm64
arch: arm64
runs-on: ${{ matrix.runner }}
needs: preflight
permissions:
contents: write
steps:
@@ -154,6 +192,7 @@ jobs:
windows:
runs-on: windows-2022
needs: preflight
permissions:
contents: write
steps:
@@ -195,6 +234,7 @@ jobs:
android:
runs-on: ubuntu-22.04
needs: preflight
permissions:
contents: write
steps: