Files
5chan/.github/workflows/ci.yml
T
Tommaso CasaburiandGitHub a67c66de0d perf(electron): speed up Windows packaging with ASAR (#1190)
* perf(electron): package Windows app with ASAR

* fix(electron): use portable ASAR unpack glob

* fix(electron): unpack native modules from ASAR
2026-08-01 12:50:23 +02:00

518 lines
15 KiB
YAML

name: CI
on:
push:
branches: [development, master]
pull_request:
branches: [development, master]
workflow_dispatch:
permissions:
contents: read
jobs:
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
- run: corepack enable
- name: Install dependencies
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --immutable && break
sleep 5
[ "$i" = "3" ] && exit 1
done
- name: Run Vitest
run: yarn test --run
- name: Collect coverage
run: yarn test:coverage
- name: Write coverage badge payload
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: node scripts/write-coverage-badge.mjs
- name: Upload coverage badge
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v4
with:
name: coverage-badge
path: badges/coverage.json
if-no-files-found: error
- 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: 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
publish-coverage-badge:
name: Publish Badges
runs-on: ubuntu-22.04
needs: quality
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
env:
COVERAGE_PAGES_ARTIFACT: coverage-pages-${{ github.run_attempt }}
steps:
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
- name: Download coverage badge
uses: actions/download-artifact@v4
with:
name: coverage-badge
path: ${{ runner.temp }}/coverage-badge
- name: Check published coverage badge
id: published-badge
env:
BADGE_SOURCE_PATH: ${{ runner.temp }}/coverage-badge/coverage.json
PUBLISHED_BADGE_PATH: ${{ runner.temp }}/published-coverage.json
run: |
if curl -fsSL --retry 3 --retry-delay 5 "https://bitsocialnet.github.io/5chan/badges/coverage.json" -o "${PUBLISHED_BADGE_PATH}" &&
cmp -s "${BADGE_SOURCE_PATH}" "${PUBLISHED_BADGE_PATH}"; then
echo "changed=false" >> "${GITHUB_OUTPUT}"
echo "Coverage badge is already up to date."
else
echo "changed=true" >> "${GITHUB_OUTPUT}"
fi
- name: Prepare Pages artifact
if: steps.published-badge.outputs.changed == 'true'
env:
BADGE_SOURCE_PATH: ${{ runner.temp }}/coverage-badge/coverage.json
PAGES_OUTPUT_PATH: ${{ runner.temp }}/github-pages
run: |
mkdir -p "${PAGES_OUTPUT_PATH}/badges"
cp "${BADGE_SOURCE_PATH}" "${PAGES_OUTPUT_PATH}/badges/coverage.json"
touch "${PAGES_OUTPUT_PATH}/.nojekyll"
- name: Upload Pages artifact
if: steps.published-badge.outputs.changed == 'true'
uses: actions/upload-pages-artifact@v4
with:
name: ${{ env.COVERAGE_PAGES_ARTIFACT }}
path: ${{ runner.temp }}/github-pages
- name: Deploy badge site
if: steps.published-badge.outputs.changed == 'true'
id: deployment
continue-on-error: true
uses: actions/deploy-pages@v4
with:
artifact_name: ${{ env.COVERAGE_PAGES_ARTIFACT }}
- name: Wait before badge deploy retry
if: steps.published-badge.outputs.changed == 'true' && steps.deployment.outcome == 'failure'
run: sleep 60
- name: Retry badge site deploy
if: steps.published-badge.outputs.changed == 'true' && steps.deployment.outcome == 'failure'
id: deployment_retry
continue-on-error: true
uses: actions/deploy-pages@v4
with:
artifact_name: ${{ env.COVERAGE_PAGES_ARTIFACT }}
- name: Report badge deploy failure
if: steps.published-badge.outputs.changed == 'true' && steps.deployment.outcome == 'failure' && steps.deployment_retry.outcome != 'success'
run: |
echo "::warning::Coverage badge artifact was generated, but GitHub Pages rejected the badge deployment. App CI remains green because badge publishing is advisory."
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
- run: corepack enable
- name: Install dependencies
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --immutable && 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 APKs
run: cd android && ./gradlew testGithubDebugUnitTest testFdroidDebugUnitTest assembleGithubDebug assembleFdroidDebug --stacktrace
package-linux:
name: Package Linux (Ubuntu)
runs-on: ubuntu-22.04
needs: quality
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js v22
uses: actions/setup-node@v4
with:
node-version: 22
- run: corepack enable
- name: Cache electron binaries
uses: actions/cache@v4
with:
path: ~/.cache/electron
key: ${{ runner.os }}-electron-v2-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-electron-v2-
- name: Install dependencies
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --immutable && break
sleep 5
[ "$i" = "3" ] && exit 1
done
- 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: Rebuild and verify Electron native modules
timeout-minutes: 10
run: yarn electron:prepare-package
- 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
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"
package-mac-intel:
name: Package Mac (Intel)
runs-on: macos-15-intel
needs: quality
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js v22
uses: actions/setup-node@v4
with:
node-version: 22
- run: corepack enable
- name: Install setuptools for native modules
run: pip3 install --break-system-packages setuptools || pip3 install --user setuptools || true
- name: Cache electron binaries
uses: actions/cache@v4
with:
path: ~/Library/Caches/electron
key: ${{ runner.os }}-electron-v2-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-electron-v2-
- name: Install dependencies
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --immutable && break
sleep 5
[ "$i" = "3" ] && exit 1
done
- 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: Rebuild and verify Electron native modules
timeout-minutes: 10
run: yarn electron:prepare-package
- 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
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"
package-mac-arm:
name: Package Mac (Apple Silicon)
runs-on: macos-latest
needs: quality
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js v22
uses: actions/setup-node@v4
with:
node-version: 22
- run: corepack enable
- name: Install setuptools for native modules
run: pip3 install --break-system-packages setuptools || pip3 install --user setuptools || true
- name: Cache electron binaries
uses: actions/cache@v4
with:
path: ~/Library/Caches/electron
key: ${{ runner.os }}-electron-v2-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-electron-v2-
- name: Install dependencies
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --immutable && break
sleep 5
[ "$i" = "3" ] && exit 1
done
- 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: Rebuild and verify Electron native modules
timeout-minutes: 10
run: yarn electron:prepare-package
- 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
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"
package-windows:
name: Package Windows
runs-on: windows-2022
needs: quality
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js v22
uses: actions/setup-node@v4
with:
node-version: 22
- run: corepack enable
- name: Resolve Yarn cache path
id: yarn-cache
shell: bash
run: echo "dir=$(corepack yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
- name: Cache Yarn package tarballs
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('yarn.lock', 'package.json', '.yarnrc.yml') }}
restore-keys: ${{ runner.os }}-yarn-v1-
- name: Cache electron binaries
uses: actions/cache@v4
with:
path: ~/AppData/Local/electron/Cache
key: ${{ runner.os }}-electron-v2-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-electron-v2-
- name: Install dependencies
shell: bash
run: |
for i in 1 2 3; do
echo "yarn install attempt $i"
yarn install --immutable && break
sleep 5
[ "$i" = "3" ] && exit 1
done
- name: Build React app
shell: bash
run: yarn build
env:
CI: ''
- name: Build preload script
shell: bash
run: yarn build:preload
- name: Verify build outputs
shell: bash
run: |
ls -la build/ || exit 1
ls -la build/electron/preload.cjs || exit 1
ls -la build/index.html || exit 1
- name: Rebuild and verify Electron native modules
shell: bash
timeout-minutes: 10
run: yarn electron:prepare-package
- name: Make Electron installer
shell: bash
timeout-minutes: 30
run: |
set -o pipefail
yarn electron-forge make --platform=win32 --arch=x64 2>&1 | tee forge-output.log
ls -la out/make/
- name: Verify ASAR runtime files
shell: bash
run: |
APP_ASAR=$(find out -path '*/resources/app.asar' | head -n 1)
KUBO_EXE=$(find out -path '*/resources/app.asar.unpacked/bin/win/ipfs.exe' | head -n 1)
SQLITE_MODULE=$(find out -path '*/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node' | head -n 1)
DATACHANNEL_MODULE=$(find out -path '*/resources/app.asar.unpacked/node_modules/node-datachannel/build/Release/node_datachannel.node' | head -n 1)
echo "Found ASAR: $APP_ASAR"
echo "Found Kubo: $KUBO_EXE"
echo "Found SQLite module: $SQLITE_MODULE"
echo "Found data channel module: $DATACHANNEL_MODULE"
test -f "$APP_ASAR"
test -f "$KUBO_EXE"
test -f "$SQLITE_MODULE"
test -f "$DATACHANNEL_MODULE"
"$KUBO_EXE" version
- name: Verify Squirrel installer
shell: bash
run: |
SETUP_EXE=$(find out/make -iname '*setup*.exe' | head -n 1)
echo "Found installer: $SETUP_EXE"
test -n "$SETUP_EXE" && test -f "$SETUP_EXE" && echo "Installer is valid"
- 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"