A full-featured download manager.
ci: parallelize validation and scope native package builds (#2481)
Dr_rOot2e08cb4159c7
diff --git a/.github/ci-package-targets.json b/.github/ci-package-targets.jsonnew file mode 100644index 00000000..8dff8faa--- /dev/null+++ b/.github/ci-package-targets.json@@ -0,0 +1,62 @@+[+ {+ "target": "darwin-arm64",+ "os": "macos-26",+ "platform": "darwin",+ "arch": "arm64",+ "rust_target": "aarch64-apple-darwin",+ "electron_builder_args": "--mac --arm64",+ "resources_dir": "release/mac-arm64/Motrix.app/Contents/Resources",+ "app_path": "release/mac-arm64/Motrix.app"+ },+ {+ "target": "darwin-x64",+ "os": "macos-26-intel",+ "platform": "darwin",+ "arch": "x64",+ "rust_target": "x86_64-apple-darwin",+ "electron_builder_args": "--mac --x64",+ "resources_dir": "release/mac/Motrix.app/Contents/Resources",+ "app_path": "release/mac/Motrix.app"+ },+ {+ "target": "linux-x64",+ "os": "ubuntu-22.04",+ "platform": "linux",+ "arch": "x64",+ "rust_target": "x86_64-unknown-linux-musl",+ "electron_builder_args": "--linux --x64",+ "resources_dir": "release/linux-unpacked/resources",+ "app_path": "release/linux-unpacked"+ },+ {+ "target": "linux-arm64",+ "os": "ubuntu-22.04-arm",+ "platform": "linux",+ "arch": "arm64",+ "rust_target": "aarch64-unknown-linux-musl",+ "electron_builder_args": "--linux --arm64",+ "resources_dir": "release/linux-arm64-unpacked/resources",+ "app_path": "release/linux-arm64-unpacked"+ },+ {+ "target": "win32-x64",+ "os": "windows-2025",+ "platform": "win32",+ "arch": "x64",+ "rust_target": "x86_64-pc-windows-msvc",+ "electron_builder_args": "--win dir --x64",+ "resources_dir": "release/win-unpacked/resources",+ "app_path": "release/win-unpacked"+ },+ {+ "target": "win32-arm64",+ "os": "windows-11-arm",+ "platform": "win32",+ "arch": "arm64",+ "rust_target": "aarch64-pc-windows-msvc",+ "electron_builder_args": "--win dir --arm64",+ "resources_dir": "release/win-arm64-unpacked/resources",+ "app_path": "release/win-arm64-unpacked"+ }+]diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex ace1913e..2431a36f 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1,12 +1,6 @@-# Motrix Turbo — General CI-#-# Validates plugin manifest schema parity (host façade of the published-# @motrix/plugin-manifest-schema), lint, type-check, unit tests, and the-# standalone Rust native-messaging host.-#-# Security note: this workflow does not consume any GitHub event payload-# (issue titles, PR bodies, commit messages) in run: steps, so there is-# no injection surface.+# Complete tests on every PR; presentation-only changes use three native+# desktop targets. Main, nightly and manual runs validate all six targets and+# both distribution formats. The stable `ci` job checks every selected result.name: CI@@ -15,16 +9,40 @@ on:branches: [main]pull_request:branches: [main]+ merge_group:+ schedule:+ - cron: '17 3 * * *'+ workflow_dispatch:permissions:contents: readconcurrency:- group: ci-${{ github.workflow }}-${{ github.ref }}+ group: ci-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}cancel-in-progress: truejobs:- ci:+ plan:+ name: Select validation scope+ runs-on: ubuntu-24.04+ timeout-minutes: 5+ outputs:+ profile: ${{ steps.plan.outputs.profile }}+ package_matrix: ${{ steps.plan.outputs.package_matrix }}+ distributions: ${{ steps.plan.outputs.distributions }}+ installers: ${{ steps.plan.outputs.installers }}+ filesystems: ${{ steps.plan.outputs.filesystems }}+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ fetch-depth: 0+ - name: Select checks from the complete Git diff+ id: plan+ run: node scripts/ci-plan.mjs++ quality:+ name: Static checksruns-on: ubuntu-latesttimeout-minutes: 20steps:@@ -60,7 +78,7 @@ jobs:run: pnpm run check:schema-parity- name: Third-party notice contract- # The verifier tests run once in the full suite below.+ # The verifier tests run once in the root test shards.run: node scripts/generate-third-party-notices.mjs --check- name: File naming conventions@@ -80,23 +98,122 @@ jobs:- name: Type-check (root)run: pnpm exec tsc --noEmit- - name: Install torrent conformance browsers- run: pnpm exec playwright install --with-deps chromium firefox webkit-- - name: Torrent conformance on HTTP without WebCrypto- run: pnpm test:browser:torrent-- name: Native host JavaScript tooling testsrun: >-node --testpackages/native-host/build.test.mjspackages/native-host/package-flatpak-companion.test.mjs- - name: Tests (root)- # Run each test once, including the embedded Electron Node proxy probe.- run: pnpm test+ tests:+ name: Tests / ${{ matrix.shard }} of 4+ runs-on: ubuntu-24.04+ timeout-minutes: 15+ strategy:+ fail-fast: false+ matrix:+ shard: [1, 2, 3, 4]+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0+ with:+ version: 12.16.1+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0+ with:+ node-version: 24+ cache: pnpm+ - name: Install dependencies+ run: pnpm install --frozen-lockfile+ env:+ MOTRIX_SKIP_ELECTRON_REBUILD: '1'+ MOTRIX_SKIP_ENGINE_FETCH: '1'+ - name: Ensure Electron runtime payload+ run: node node_modules/electron/install.js+ - name: Setup Rust for native test fixtures+ uses: dtolnay/rust-toolchain@686976e191b89faba57d3206551f0f330d8cb249 # stable+ with:+ toolchain: 1.94.1+ - name: Prepare native filesystem test fixture+ # These suites inspect binary availability during collection. Preparing+ # it here removes their former dependency on another test's beforeAll.+ run: |+ cargo build --manifest-path packages/finalize-fs/Cargo.toml --locked+ test -x packages/finalize-fs/target/debug/motrix-finalize-fs+ - name: Run complete test partition+ # pnpm test preserves the Node ABI pretest hook. No changed-file filter+ # or relaxed isolation: every root test belongs to exactly one shard.+ run: >-+ pnpm test --shard=${{ matrix.shard }}/4+ --reporter=default --reporter=json+ --outputFile=output/ci/reports/shard-${{ matrix.shard }}.jsonenv:MOTRIX_REQUIRE_ELECTRON_PROXY_TEST: '1'+ - name: Upload test partition report+ if: ${{ !cancelled() }}+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: root-tests-${{ matrix.shard }}+ path: output/ci/reports/shard-${{ matrix.shard }}.json+ if-no-files-found: error+ overwrite: true+ retention-days: 7++ test-reports:+ name: Verify complete test coverage+ needs: tests+ runs-on: ubuntu-24.04+ timeout-minutes: 5+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0+ with:+ version: 12.16.1+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0+ with:+ node-version: 24+ cache: pnpm+ - name: Install dependencies+ run: pnpm install --frozen-lockfile+ env:+ MOTRIX_SKIP_ELECTRON_REBUILD: '1'+ MOTRIX_SKIP_ENGINE_FETCH: '1'+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2+ with:+ pattern: root-tests-*+ path: output/ci/reports+ merge-multiple: true+ - name: Check every discovered test file ran exactly once+ run: |+ pnpm exec vitest list --filesOnly --json=output/ci/test-files.json+ node scripts/verify-ci-test-reports.mjs++ torrent-browser:+ name: Torrent / Chromium, Firefox, WebKit+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0+ with:+ version: 12.16.1+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0+ with:+ node-version: 24+ cache: pnpm+ - name: Install dependencies+ run: pnpm install --frozen-lockfile+ env:+ MOTRIX_SKIP_ELECTRON_REBUILD: '1'+ MOTRIX_SKIP_ENGINE_FETCH: '1'+ - name: Install torrent conformance browsers+ run: pnpm exec playwright install --with-deps chromium firefox webkit+ - name: Torrent conformance on HTTP without WebCrypto+ run: pnpm test:browser:torrentserver-runtime:name: Server runtime / ${{ matrix.target }}@@ -198,6 +315,7 @@ jobs:cargo test --manifest-path packages/native-host/Cargo.toml --all-targets --all-features --lockedpackage-targets:+ needs: planname: Package smoke / ${{ matrix.target }}runs-on: ${{ matrix.os }}timeout-minutes: 45@@ -211,56 +329,7 @@ jobs:MACOSX_DEPLOYMENT_TARGET: ${{ matrix.platform == 'darwin' && '13.0' || '' }}strategy:fail-fast: false- matrix:- include:- - target: darwin-arm64- os: macos-26- platform: darwin- arch: arm64- rust_target: aarch64-apple-darwin- electron_builder_args: --mac --arm64- resources_dir: release/mac-arm64/Motrix.app/Contents/Resources- app_path: release/mac-arm64/Motrix.app- - target: darwin-x64- os: macos-26-intel- platform: darwin- arch: x64- rust_target: x86_64-apple-darwin- electron_builder_args: --mac --x64- resources_dir: release/mac/Motrix.app/Contents/Resources- app_path: release/mac/Motrix.app- - target: linux-x64- os: ubuntu-22.04- platform: linux- arch: x64- rust_target: x86_64-unknown-linux-musl- electron_builder_args: --linux --x64- resources_dir: release/linux-unpacked/resources- app_path: release/linux-unpacked- - target: linux-arm64- os: ubuntu-22.04-arm- platform: linux- arch: arm64- rust_target: aarch64-unknown-linux-musl- electron_builder_args: --linux --arm64- resources_dir: release/linux-arm64-unpacked/resources- app_path: release/linux-arm64-unpacked- - target: win32-x64- os: windows-2025- platform: win32- arch: x64- rust_target: x86_64-pc-windows-msvc- electron_builder_args: --win nsis zip --x64- resources_dir: release/win-unpacked/resources- app_path: release/win-unpacked- - target: win32-arm64- os: windows-11-arm- platform: win32- arch: arm64- rust_target: aarch64-pc-windows-msvc- electron_builder_args: --win nsis zip --arm64- resources_dir: release/win-arm64-unpacked/resources- app_path: release/win-arm64-unpacked+ matrix: ${{ fromJSON(needs.plan.outputs.package_matrix) }}steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:@@ -282,6 +351,32 @@ jobs:toolchain: 1.94.1targets: ${{ matrix.rust_target }}+ - name: Cache native compilation+ uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5+ with:+ path: |+ ~/.cargo/registry+ ~/.cargo/git+ packages/native-host/target+ packages/finalize-fs/target+ key: native-v1-${{ runner.os }}-${{ runner.arch }}-${{ matrix.rust_target }}-1.94.1-${{ hashFiles('.cargo/**', 'packages/*/Cargo.lock', 'packages/*/Cargo.toml') }}-${{ hashFiles('packages/native-host/src/**', 'packages/finalize-fs/src/**') }}+ restore-keys: |+ native-v1-${{ runner.os }}-${{ runner.arch }}-${{ matrix.rust_target }}-1.94.1-${{ hashFiles('.cargo/**', 'packages/*/Cargo.lock', 'packages/*/Cargo.toml') }}-++ - name: Identify Swift toolchain+ if: matrix.platform == 'darwin'+ id: swift+ run: echo "version=$(xcrun swift --version | shasum -a 256 | cut -d ' ' -f 1)" >> "$GITHUB_OUTPUT"++ - name: Cache Safari helper compilation+ if: matrix.platform == 'darwin'+ uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5+ with:+ path: packages/safari-bootstrap/.build+ key: safari-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.swift.outputs.version }}-1.94.1-${{ hashFiles('.cargo/**', 'packages/native-host/Cargo.*', 'packages/native-host/src/**', 'packages/native-host/include/**', 'packages/safari-bootstrap/Package.swift', 'packages/safari-bootstrap/Package.resolved', 'packages/safari-bootstrap/Sources/**', 'packages/safari-bootstrap/Tests/**', 'packages/safari-bootstrap/Native/**', 'packages/safari-bootstrap/Executables/**', 'packages/safari-bootstrap/configuration.json', 'packages/safari-bootstrap/build.mjs') }}+ restore-keys: |+ safari-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.swift.outputs.version }}-1.94.1-+# Every matrix entry uses a runner with the same native architecture as# rust_target. Tests therefore execute the target binary directly; no# Rosetta, QEMU, Wine, or compile-only result is presented as a test.@@ -389,6 +484,16 @@ jobs:--dir--publish never+ # Explicit archive targets override --dir in electron-builder. Keep them+ # out of ordinary smoke builds; full validation also exercises installers.+ - name: Build Windows installers+ if: matrix.platform == 'win32' && needs.plan.outputs.installers == 'true'+ env:+ CSC_IDENTITY_AUTO_DISCOVERY: 'false'+ run: >-+ pnpm exec electron-builder --win nsis zip --${{ matrix.arch }}+ --prepackaged "${{ matrix.app_path }}" --publish never+- name: Install Arch packaging toolsif: matrix.platform == 'linux'run: |@@ -521,3 +626,63 @@ jobs:path: release/size-reports/${{ matrix.target }}*.jsonif-no-files-found: errorretention-days: 14++ flatpak:+ needs: plan+ if: needs.plan.outputs.distributions == 'true'+ uses: ./.github/workflows/flatpak.yml++ snap:+ needs: plan+ if: needs.plan.outputs.distributions == 'true'+ uses: ./.github/workflows/snap.yml++ finalize-filesystems:+ needs: plan+ if: needs.plan.outputs.filesystems == 'true'+ uses: ./.github/workflows/finalize-filesystems.yml++ finalize-nfs:+ needs: plan+ if: needs.plan.outputs.filesystems == 'true'+ uses: ./.github/workflows/finalize-nfs.yml++ finalize-smb:+ needs: plan+ if: needs.plan.outputs.filesystems == 'true'+ uses: ./.github/workflows/finalize-smb.yml++ finalize-exfat:+ needs: plan+ if: needs.plan.outputs.filesystems == 'true'+ uses: ./.github/workflows/finalize-exfat.yml++ ci:+ name: ci+ if: ${{ always() }}+ needs:+ - plan+ - quality+ - tests+ - test-reports+ - torrent-browser+ - server-runtime+ - rust-quality+ - safari-native-host+ - package-targets+ - flatpak+ - snap+ - finalize-filesystems+ - finalize-nfs+ - finalize-smb+ - finalize-exfat+ runs-on: ubuntu-24.04+ timeout-minutes: 5+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ - name: Require success from every selected check+ env:+ CI_NEEDS: ${{ toJSON(needs) }}+ run: node scripts/ci-gate.mjsdiff --git a/.github/workflows/finalize-exfat.yml b/.github/workflows/finalize-exfat.ymlindex 1dc5870a..7426a918 100644--- a/.github/workflows/finalize-exfat.yml+++ b/.github/workflows/finalize-exfat.yml@@ -1,29 +1,14 @@name: Finalize macOS exFATon:- pull_request:- branches: [main]- paths:- - 'packages/finalize-fs/**'- - 'src/core/plugin/finalize/**'- - 'src/core/session/*finalize*'- - 'src/core/task/task-recovery-service*'- - '.github/workflows/finalize-exfat.yml'- push:- branches: [main]- paths:- - 'packages/finalize-fs/**'- - 'src/core/plugin/finalize/**'- - 'src/core/session/*finalize*'- - 'src/core/task/task-recovery-service*'- - '.github/workflows/finalize-exfat.yml'+ workflow_call:workflow_dispatch:permissions:contents: readconcurrency:- group: finalize-exfat-${{ github.ref }}+ group: finalize-exfat-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}cancel-in-progress: truejobs:diff --git a/.github/workflows/finalize-filesystems.yml b/.github/workflows/finalize-filesystems.ymlindex c31bc64e..29f6bf2b 100644--- a/.github/workflows/finalize-filesystems.yml+++ b/.github/workflows/finalize-filesystems.yml@@ -1,29 +1,14 @@name: Finalize Linux filesystemson:- pull_request:- branches: [main]- paths:- - 'packages/finalize-fs/**'- - 'src/core/plugin/finalize/**'- - 'src/core/session/*finalize*'- - '.github/scripts/finalize-filesystems.sh'- - '.github/workflows/finalize-filesystems.yml'- push:- branches: [main]- paths:- - 'packages/finalize-fs/**'- - 'src/core/plugin/finalize/**'- - 'src/core/session/*finalize*'- - '.github/scripts/finalize-filesystems.sh'- - '.github/workflows/finalize-filesystems.yml'+ workflow_call:workflow_dispatch:permissions:contents: readconcurrency:- group: finalize-filesystems-${{ github.ref }}+ group: finalize-filesystems-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}cancel-in-progress: truejobs:diff --git a/.github/workflows/finalize-nfs.yml b/.github/workflows/finalize-nfs.ymlindex 951af83a..9f123931 100644--- a/.github/workflows/finalize-nfs.yml+++ b/.github/workflows/finalize-nfs.yml@@ -1,27 +1,14 @@name: Finalize NFSon:- pull_request:- branches: [main]- paths:- - 'packages/finalize-fs/**'- - 'src/core/plugin/finalize/**'- - 'src/core/session/*finalize*'- - '.github/workflows/finalize-nfs.yml'- push:- branches: [main]- paths:- - 'packages/finalize-fs/**'- - 'src/core/plugin/finalize/**'- - 'src/core/session/*finalize*'- - '.github/workflows/finalize-nfs.yml'+ workflow_call:workflow_dispatch:permissions:contents: readconcurrency:- group: finalize-nfs-${{ github.ref }}+ group: finalize-nfs-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}cancel-in-progress: truejobs:diff --git a/.github/workflows/finalize-smb.yml b/.github/workflows/finalize-smb.ymlindex 076aa266..ad2b30c4 100644--- a/.github/workflows/finalize-smb.yml+++ b/.github/workflows/finalize-smb.yml@@ -1,27 +1,14 @@name: Finalize SMBon:- pull_request:- branches: [main]- paths:- - 'packages/finalize-fs/**'- - 'src/core/plugin/finalize/**'- - 'src/core/session/*finalize*'- - '.github/workflows/finalize-smb.yml'- push:- branches: [main]- paths:- - 'packages/finalize-fs/**'- - 'src/core/plugin/finalize/**'- - 'src/core/session/*finalize*'- - '.github/workflows/finalize-smb.yml'+ workflow_call:workflow_dispatch:permissions:contents: readconcurrency:- group: finalize-smb-${{ github.ref }}+ group: finalize-smb-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}cancel-in-progress: truejobs:diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.ymlindex 896d8f4c..1075aab5 100644--- a/.github/workflows/flatpak.yml+++ b/.github/workflows/flatpak.yml@@ -7,66 +7,20 @@name: Flatpakon:- pull_request:- paths:- - '.npmrc'- - '.cargo/**'- - '.github/workflows/flatpak.yml'- - 'build/**'- - 'extra/**'- - 'flatpak/**'- - 'packages/native-host/**'- - 'packages/finalize-fs/**'- - 'public/**'- - 'scripts/**'- - 'src/**'- - 'tests/**'- - 'THIRD_PARTY_LICENSES/**'- - 'THIRD_PARTY_NOTICES.md'- - 'THIRD_PARTY_NOTICES.zh-CN.md'- - 'electron-builder.json'- - 'package.json'- - 'pnpm-lock.yaml'- - 'pnpm-workspace.yaml'- - 'tsconfig*.json'- - 'vite*.config.ts'- push:- branches: [main]- paths:- - '.npmrc'- - '.cargo/**'- - '.github/workflows/flatpak.yml'- - 'build/**'- - 'extra/**'- - 'flatpak/**'- - 'packages/native-host/**'- - 'packages/finalize-fs/**'- - 'public/**'- - 'scripts/**'- - 'src/**'- - 'tests/**'- - 'THIRD_PARTY_LICENSES/**'- - 'THIRD_PARTY_NOTICES.md'- - 'THIRD_PARTY_NOTICES.zh-CN.md'- - 'electron-builder.json'- - 'package.json'- - 'pnpm-lock.yaml'- - 'pnpm-workspace.yaml'- - 'tsconfig*.json'- - 'vite*.config.ts'workflow_dispatch:workflow_call:inputs:release-version:description: Expected package version from the release preflight- required: true+ required: false+ default: ''type: stringpermissions:contents: readconcurrency:- group: flatpak-${{ github.workflow }}-${{ github.ref }}+ group: flatpak-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}cancel-in-progress: ${{ inputs.release-version == '' }}jobs:diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.ymlindex 522e6ea5..6365402c 100644--- a/.github/workflows/snap.yml+++ b/.github/workflows/snap.yml@@ -12,31 +12,7 @@name: Snapon:- pull_request:- branches: [main]- paths:- - '.cargo/**'- - '.github/workflows/ci.yml'- - '.github/workflows/snap.yml'- - 'build/256x256.png'- - 'build/snap/**'- - 'electron-builder.json'- - 'extra/aria2.conf'- - 'extra/tray/**'- - 'package.json'- - 'pnpm-lock.yaml'- - 'packages/native-host/**'- - 'packages/finalize-fs/**'- - 'resources/**'- - 'scripts/**'- - 'src/**'- - 'THIRD_PARTY_LICENSES/**'- - 'THIRD_PARTY_NOTICES.md'- - 'THIRD_PARTY_NOTICES.zh-CN.md'- - 'tests/scripts/snap*.test.ts'- - 'tests/scripts/workflow-*.test.ts'- - 'tsconfig*.json'- - 'vite.*.ts'+ workflow_call:push:tags:- 'v*'@@ -57,7 +33,7 @@ concurrency:group: >-${{(- github.event_name == 'push'+ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))|| (github.event_name == 'workflow_dispatch'&& inputs.publish_edge == true@@ -68,7 +44,7 @@ concurrency:}}cancel-in-progress: >-${{- github.event_name != 'push'+ !startsWith(github.ref, 'refs/tags/v')&& inputs.publish_edge != true}}@@ -93,7 +69,7 @@ jobs:# pretending to be a protected release-tag event.RELEASE_EVENT_NAME: >-${{- github.event_name == 'push'+ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')&& 'push'|| 'workflow_dispatch'}}@@ -105,7 +81,7 @@ jobs:--github-output "$GITHUB_OUTPUT"- name: Verify tag commit is on main- if: github.event_name == 'push'+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')shell: bashrun: |set -euo pipefaildiff --git a/.gitignore b/.gitignoreindex f7568050..1fcf9880 100644--- a/.gitignore+++ b/.gitignore@@ -159,6 +159,7 @@ graphify-out/*/.playwright/*!/.playwright/cli.config.json/output/playwright/+/output/ci/# Legacy artifact locations (keep old local evidence ignored)/e2e/test-results/e2e/playwright-reportdiff --git a/scripts/ci-gate.mjs b/scripts/ci-gate.mjsnew file mode 100644index 00000000..c977f678--- /dev/null+++ b/scripts/ci-gate.mjs@@ -0,0 +1,57 @@+import { pathToFileURL } from 'node:url'++export const ALWAYS_REQUIRED = [+ 'plan',+ 'quality',+ 'tests',+ 'test-reports',+ 'torrent-browser',+ 'server-runtime',+ 'rust-quality',+ 'safari-native-host',+ 'package-targets',+]+export const CONDITIONAL_JOBS = {+ snap: 'distributions',+ flatpak: 'distributions',+ 'finalize-filesystems': 'filesystems',+ 'finalize-nfs': 'filesystems',+ 'finalize-smb': 'filesystems',+ 'finalize-exfat': 'filesystems',+}++export function validateCiResults(needs) {+ const plan = needs.plan?.outputs+ if (+ !['ui', 'full'].includes(plan?.profile) ||+ !['true', 'false'].includes(plan?.filesystems) ||+ plan?.distributions !== String(plan?.profile === 'full')+ ) {+ throw new Error('Missing or invalid CI plan')+ }+ const expected = new Set([+ ...ALWAYS_REQUIRED,+ ...Object.keys(CONDITIONAL_JOBS),+ ])+ for (const name of Object.keys(needs)) {+ if (!expected.has(name)) throw new Error(`Unaccounted CI job: ${name}`)+ }+ for (const name of expected) {+ const required =+ ALWAYS_REQUIRED.includes(name) || plan[CONDITIONAL_JOBS[name]] === 'true'+ const result = needs[name]?.result+ if (result !== (required ? 'success' : 'skipped')) {+ throw new Error(+ `${name}: expected ${required ? 'success' : 'skipped'}, got ${result}`+ )+ }+ }+}++if (+ process.argv[1] &&+ import.meta.url === pathToFileURL(process.argv[1]).href+) {+ validateCiResults(JSON.parse(process.env.CI_NEEDS))+ console.log('All selected checks passed.')+}diff --git a/scripts/ci-plan.mjs b/scripts/ci-plan.mjsnew file mode 100644index 00000000..2fe7eb13--- /dev/null+++ b/scripts/ci-plan.mjs@@ -0,0 +1,114 @@+import { execFileSync } from 'node:child_process'+import { appendFileSync, readFileSync } from 'node:fs'+import { pathToFileURL } from 'node:url'++export const PACKAGE_TARGETS = JSON.parse(+ readFileSync(new URL('../.github/ci-package-targets.json', import.meta.url))+)+const UI_TARGETS = new Set(['linux-x64', 'win32-x64', 'darwin-arm64'])++// Only presentation files qualify for the reduced platform matrix. Transport,+// shared contracts, dependencies, build inputs and unknown paths stay full.+export function isPresentationPath(file) {+ return (+ /^src\/renderer\/(components|routes|layouts)\/.+\.(tsx?|css)$/.test(file) ||+ /^src\/shared\/locales\/[^/]+\.json$/.test(file)+ )+}++function isCompanionUnitTest(file) {+ return (+ /^src\/(core|shared|main|server)\/.+\.test\.tsx?$/.test(file) &&+ !/(\.integration\.|\.win32\.|\.darwin\.|\/finalize\/|\/session\/|task-recovery-service)/.test(+ file+ )+ )+}++export function createCiPlan(eventName, files) {+ const ui =+ eventName === 'pull_request' &&+ Array.isArray(files) &&+ files.length > 0 &&+ files.some(isPresentationPath) &&+ files.every((file) => isPresentationPath(file) || isCompanionUnitTest(file))+ const full = !ui+ const filesystems =+ !Array.isArray(files) ||+ files.length === 0 ||+ ['schedule', 'workflow_dispatch', 'merge_group'].includes(eventName) ||+ files.some(+ (file) =>+ !isCompanionUnitTest(file) &&+ /^(packages\/finalize-fs\/|src\/core\/|src\/shared\/(?!locales\/)|\.github\/|\.cargo\/|scripts\/|tests\/|package\.json$|pnpm-(lock\.yaml|workspace\.yaml)$|vitest.*\.ts$)/.test(+ file+ )+ )+ return {+ profile: ui ? 'ui' : 'full',+ distributions: full,+ installers: full,+ filesystems,+ package_matrix: {+ include: PACKAGE_TARGETS.filter(+ (target) => full || UI_TARGETS.has(target.target)+ ),+ },+ }+}++export function changedFiles(eventName, event, cwd = process.cwd()) {+ const base =+ eventName === 'pull_request' ? event.pull_request?.base?.sha : event.before+ const head =+ eventName === 'pull_request' ? event.pull_request?.head?.sha : event.after+ if (![base, head].every((sha) => /^[a-f0-9]{40}$/.test(sha ?? ''))) {+ throw new Error('Missing comparison revisions')+ }+ const git = (args) =>+ execFileSync('git', args, {+ cwd,+ encoding: 'utf8',+ maxBuffer: 16 * 1024 ** 2,+ })+ const start =+ eventName === 'pull_request' ? git(['merge-base', base, head]).trim() : base+ // Disable rename detection so moving a core file into a UI directory still+ // includes the deleted core path. NUL delimiters preserve unusual filenames.+ return git(['diff', '--name-only', '--no-renames', '-z', start, head, '--'])+ .split('\0')+ .filter(Boolean)+}++function main() {+ let files+ try {+ const event = JSON.parse(+ readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')+ )+ files = changedFiles(process.env.GITHUB_EVENT_NAME, event)+ } catch {+ console.log('Comparison unavailable; selecting complete validation.')+ }+ const plan = createCiPlan(process.env.GITHUB_EVENT_NAME, files)+ for (const [key, value] of Object.entries(plan)) {+ appendFileSync(+ process.env.GITHUB_OUTPUT,+ `${key}=${typeof value === 'object' ? JSON.stringify(value) : value}\n`+ )+ }+ appendFileSync(+ process.env.GITHUB_STEP_SUMMARY,+ `CI profile: **${plan.profile}**\n\n` ++ `Desktop targets: ${plan.package_matrix.include.map((t) => t.target).join(', ')}\n\n` ++ `Snap/Flatpak: ${plan.distributions}; filesystem suites: ${plan.filesystems}.\n` ++ 'All profiles run the complete root test suite and three torrent browsers.\n'+ )+}++if (+ process.argv[1] &&+ import.meta.url === pathToFileURL(process.argv[1]).href+) {+ main()+}diff --git a/scripts/verify-ci-test-reports.mjs b/scripts/verify-ci-test-reports.mjsnew file mode 100644index 00000000..6eef92a4--- /dev/null+++ b/scripts/verify-ci-test-reports.mjs@@ -0,0 +1,88 @@+import { appendFileSync, readdirSync, readFileSync } from 'node:fs'+import path from 'node:path'+import { pathToFileURL } from 'node:url'++export const NATIVE_FIXTURE_SUITES = [+ 'src/core/plugin/finalize/native-artifact-operations.integration.test.ts',+ 'src/core/plugin/finalize/finalize-nfs-recovery.integration.test.ts',+ 'src/core/plugin/finalize/finalize-smb-recovery.integration.test.ts',+ 'src/core/plugin/finalize/finalize-adversarial.integration.test.ts',+ 'src/core/task/bt-storage.integration.test.ts',+]++export function verifyNativeFixtures(reports) {+ const results = reports.flatMap((report) => report.testResults)+ for (const file of NATIVE_FIXTURE_SUITES) {+ const suite = results.find((result) => result.name.endsWith(`/${file}`))+ if (+ !suite?.assertionResults?.length ||+ suite.assertionResults.some((test) => test.status !== 'passed')+ ) {+ throw new Error(`Native fixture tests did not all execute: ${file}`)+ }+ }+}++export function verifyTestReports(expected, reports) {+ const wanted = new Set(expected.map((entry) => entry.file))+ if (wanted.size === 0 || wanted.size !== expected.length) {+ throw new Error('Empty or duplicate test discovery')+ }+ const seen = new Set()+ let tests = 0+ let skipped = 0+ for (const report of reports) {+ if (+ report.success !== true ||+ report.numFailedTests !== 0 ||+ report.numFailedTestSuites !== 0 ||+ !Array.isArray(report.testResults) ||+ report.testResults.length === 0+ ) {+ throw new Error('Failed or empty test shard')+ }+ for (const result of report.testResults) {+ if (!wanted.has(result.name))+ throw new Error(`Unexpected test file: ${result.name}`)+ if (seen.has(result.name))+ throw new Error(`Duplicate test file: ${result.name}`)+ seen.add(result.name)+ }+ tests += report.numTotalTests+ skipped += report.numPendingTests + report.numTodoTests+ }+ const missing = [...wanted].filter((file) => !seen.has(file))+ if (missing.length)+ throw new Error(`Missing test files: ${missing.join(', ')}`)+ return { files: seen.size, tests, skipped }+}++function main() {+ const directory = 'output/ci/reports'+ const names = readdirSync(directory).sort()+ const shards = [1, 2, 3, 4].map((index) => `shard-${index}.json`)+ if (JSON.stringify(names) !== JSON.stringify(shards)) {+ throw new Error('Expected exactly four shard reports')+ }+ const readJson = (file) => JSON.parse(readFileSync(file, 'utf8'))+ const reports = names.map((name) => readJson(path.join(directory, name)))+ const result = verifyTestReports(+ readJson('output/ci/test-files.json'),+ reports+ )+ // CI shards run on Linux, where all these native publication tests apply.+ // Keep local report inspection usable on other operating systems.+ if (process.env.GITHUB_ACTIONS === 'true') verifyNativeFixtures(reports)+ const summary = `Verified ${result.files} test files exactly once across four shards; ${result.tests} tests (${result.skipped} skipped/todo).\n`+ console.log(summary)+ if (process.env.GITHUB_STEP_SUMMARY) {+ appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary)+ }+}++if (+ process.argv[1] &&+ import.meta.url === pathToFileURL(process.argv[1]).href+) {+ main()+}diff --git a/tests/scripts/ci-validation.test.ts b/tests/scripts/ci-validation.test.tsnew file mode 100644index 00000000..d0a68a21--- /dev/null+++ b/tests/scripts/ci-validation.test.ts@@ -0,0 +1,399 @@+import { execFileSync } from 'node:child_process'+import {+ mkdirSync,+ mkdtempSync,+ readFileSync,+ rmSync,+ writeFileSync,+} from 'node:fs'+import { createRequire } from 'node:module'+import { tmpdir } from 'node:os'+import path from 'node:path'+import { load } from 'js-yaml'+import { describe, expect, it } from 'vitest'+// @ts-expect-error -- CI script has no declaration file+import {+ ALWAYS_REQUIRED,+ CONDITIONAL_JOBS,+ validateCiResults,+} from '../../scripts/ci-gate.mjs'+// @ts-expect-error -- CI script has no declaration file+import {+ changedFiles,+ createCiPlan,+ PACKAGE_TARGETS,+} from '../../scripts/ci-plan.mjs'+// @ts-expect-error -- CI script has no declaration file+import {+ NATIVE_FIXTURE_SUITES,+ verifyNativeFixtures,+ verifyTestReports,+} from '../../scripts/verify-ci-test-reports.mjs'++const require = createRequire(import.meta.url)+const workflow = load(readFileSync('.github/workflows/ci.yml', 'utf8')) as any+const uiFiles = [+ 'src/renderer/routes/downloads/task-list.tsx',+ 'src/shared/locales/zh-CN.json',+]++describe('CI scope selection', () => {+ it('keeps companion unit tests in the complete root suite without expanding a UI matrix', () => {+ expect(+ createCiPlan('pull_request', [+ ...uiFiles,+ 'src/core/plugin/commands/wire.test.ts',+ ])+ ).toMatchObject({ profile: 'ui', filesystems: false })+ expect(+ createCiPlan('pull_request', ['src/core/plugin/commands/wire.test.ts'])+ .profile+ ).toBe('full')+ for (const file of [+ 'src/core/engine/aria2/engine.integration.test.ts',+ 'src/core/plugin/finalize/finalize.test.ts',+ 'src/main/os.win32.test.ts',+ ]) {+ expect(createCiPlan('pull_request', [...uiFiles, file]).profile).toBe(+ 'full'+ )+ }+ })+ it('keeps three native OS targets for presentation-only PRs', () => {+ const plan = createCiPlan('pull_request', uiFiles)+ expect(plan).toMatchObject({+ profile: 'ui',+ distributions: false,+ installers: false,+ filesystems: false,+ })+ expect(+ plan.package_matrix.include.map((entry: any) => entry.target).sort()+ ).toEqual(['darwin-arm64', 'linux-x64', 'win32-x64'])+ })++ it.each([+ 'src/renderer/lib/transport.ts',+ 'src/preload/index.ts',+ 'src/core/task/task-manager.ts',+ 'src/server/index.ts',+ 'src/shared/protocol/commands.ts',+ 'src/main/index.ts',+ 'packages/native-host/src/main.rs',+ 'packages/finalize-fs/src/main.rs',+ 'packages/safari-bootstrap/Native/NativeBootstrapResolver.swift',+ 'package.json',+ 'pnpm-lock.yaml',+ 'pnpm-workspace.yaml',+ 'electron-builder.json',+ '.cargo/config.toml',+ 'Dockerfile',+ 'flatpak/app.motrix.native.yml',+ 'build/snap/snapcraft.yaml',+ '.github/workflows/ci.yml',+ '.github/ci-package-targets.json',+ 'scripts/ci-plan.mjs',+ 'tests/scripts/ci-validation.test.ts',+ 'new-unknown-input',+ 'src/renderer/components/unusual\nname.tsx',+ ])('uses the complete matrix for %s, including mixed UI PRs', (file) => {+ const plan = createCiPlan('pull_request', [...uiFiles, file])+ expect(plan).toMatchObject({+ profile: 'full',+ distributions: true,+ installers: true,+ })+ expect(plan.package_matrix.include).toEqual(PACKAGE_TARGETS)+ expect(plan.package_matrix.include).toHaveLength(6)+ })++ it.each(['push', 'schedule', 'workflow_dispatch', 'merge_group', 'unknown'])(+ 'keeps full validation for %s events',+ (event) => {+ expect(createCiPlan(event, uiFiles).profile).toBe('full')+ }+ )++ it.each([undefined, []])(+ 'falls back to full validation when comparison is unavailable',+ (files) => {+ expect(createCiPlan('pull_request', files)).toMatchObject({+ profile: 'full',+ filesystems: true,+ })+ }+ )++ it.each([+ 'packages/finalize-fs/src/main.rs',+ 'src/core/task/task-recovery-service.ts',+ 'pnpm-lock.yaml',+ 'scripts/ci-plan.mjs',+ ])('includes actual filesystem tests for %s', (file) => {+ expect(createCiPlan('pull_request', [file]).filesystems).toBe(true)+ })++ it('uses a merge-base diff, preserves deleted rename sources and has no API file limit', () => {+ const cwd = mkdtempSync(path.join(tmpdir(), 'motrix-ci-diff-'))+ const git = (...args: string[]) =>+ execFileSync('git', args, {+ cwd,+ encoding: 'utf8',+ stdio: ['ignore', 'pipe', 'pipe'],+ }).trim()+ const put = (file: string) => {+ mkdirSync(path.dirname(path.join(cwd, file)), { recursive: true })+ writeFileSync(path.join(cwd, file), file)+ }+ const commit = () => {+ git('add', '.')+ git('commit', '-m', 'fixture')+ return git('rev-parse', 'HEAD')+ }+ try {+ git('init', '-b', 'main')+ git('config', 'user.email', '[email protected]')+ git('config', 'user.name', 'Test')+ git('config', 'core.fsmonitor', 'false')+ git('config', 'gc.auto', '0')+ git('config', 'maintenance.auto', 'false')+ put('src/core/old.ts')+ commit()+ git('checkout', '-b', 'feature')+ mkdirSync(path.join(cwd, 'src/renderer/components'), { recursive: true })+ git('mv', 'src/core/old.ts', 'src/renderer/components/moved.ts')+ for (let index = 0; index < 3100; index++)+ put(`src/renderer/components/${index}.tsx`)+ put('src/renderer/components/space name.tsx')+ const head = commit()+ git('checkout', 'main')+ put('unrelated-main-change')+ const base = commit()+ const files = changedFiles(+ 'pull_request',+ { pull_request: { base: { sha: base }, head: { sha: head } } },+ cwd+ )+ expect(files).toHaveLength(3103)+ expect(files).toContain('src/core/old.ts')+ expect(files).toContain('src/renderer/components/moved.ts')+ expect(files).toContain('src/renderer/components/space name.tsx')+ expect(files).not.toContain('unrelated-main-change')+ expect(createCiPlan('pull_request', files).profile).toBe('full')+ expect(+ changedFiles('push', { before: head, after: base }, cwd)+ ).toContain('unrelated-main-change')+ expect(() =>+ changedFiles(+ 'pull_request',+ { pull_request: { base: { sha: '--help' }, head: { sha: head } } },+ cwd+ )+ ).toThrow()+ } finally {+ rmSync(cwd, { recursive: true, force: true, maxRetries: 3 })+ }+ }, 15_000)+})++function successfulNeeds(profile: 'ui' | 'full') {+ const outputs = {+ profile,+ distributions: String(profile === 'full'),+ filesystems: String(profile === 'full'),+ }+ const needs: Record<string, any> = Object.fromEntries(+ ALWAYS_REQUIRED.map((name: string) => [name, { result: 'success' }])+ )+ needs.plan.outputs = outputs+ for (const [name, flag] of Object.entries(CONDITIONAL_JOBS)) {+ needs[name] = {+ result:+ outputs[flag as keyof typeof outputs] === 'true'+ ? 'success'+ : 'skipped',+ }+ }+ return needs+}++describe('required CI gate', () => {+ it.each(['ui', 'full'] as const)('accepts a complete %s run', (profile) => {+ expect(() => validateCiResults(successfulNeeds(profile))).not.toThrow()+ })++ it.each(['failure', 'cancelled', 'skipped', undefined])(+ 'rejects every selected job with result %s',+ (result) => {+ for (const name of [+ ...ALWAYS_REQUIRED,+ ...Object.keys(CONDITIONAL_JOBS),+ ]) {+ const needs = successfulNeeds('full')+ needs[name].result = result+ expect(() => validateCiResults(needs), name).toThrow()+ }+ }+ )++ it('rejects missing jobs, unknown jobs and invalid planning outputs', () => {+ const needs = successfulNeeds('ui')+ delete needs.snap+ expect(() => validateCiResults(needs)).toThrow(/snap/)+ expect(() =>+ validateCiResults({+ ...successfulNeeds('full'),+ extra: { result: 'failure' },+ })+ ).toThrow(/Unaccounted/)+ const invalid = successfulNeeds('full')+ invalid.plan.outputs.distributions = 'false'+ expect(() => validateCiResults(invalid)).toThrow(/plan/)+ })++ it('accounts for every workflow job and runs even after failures', () => {+ const jobs = [...ALWAYS_REQUIRED, ...Object.keys(CONDITIONAL_JOBS)].sort()+ expect(+ Object.keys(workflow.jobs)+ .filter((name) => name !== 'ci')+ .sort()+ ).toEqual(jobs)+ expect([...workflow.jobs.ci.needs].sort()).toEqual(jobs)+ expect(workflow.jobs.ci.name).toBe('ci')+ expect(workflow.jobs.ci.if).toBe(`\${{ always() }}`)+ expect(workflow.on).toHaveProperty('schedule')+ expect(workflow.on).toHaveProperty('merge_group')+ expect(workflow.on.pull_request).not.toHaveProperty('paths')+ expect(workflow.on.pull_request).not.toHaveProperty('paths-ignore')+ for (const [name, flag] of Object.entries(CONDITIONAL_JOBS)) {+ expect(workflow.jobs[name]).toMatchObject({+ needs: 'plan',+ if: `needs.plan.outputs.${flag} == 'true'`,+ uses: `./.github/workflows/${name}.yml`,+ })+ const child = load(+ readFileSync(`.github/workflows/${name}.yml`, 'utf8')+ ) as any+ expect(child.on).toHaveProperty('workflow_call')+ expect(child.on).not.toHaveProperty('pull_request')+ }+ })+})++const report = (names: string[]) => ({+ success: true,+ numFailedTests: 0,+ numFailedTestSuites: 0,+ numTotalTests: names.length,+ numPendingTests: 0,+ numTodoTests: 0,+ testResults: names.map((name) => ({ name })),+})+describe('test partition completeness', () => {+ it('rejects native suites that silently skipped because a fixture was missing', () => {+ const reports = [+ {+ testResults: NATIVE_FIXTURE_SUITES.map((file: string) => ({+ name: `/repo/${file}`,+ assertionResults: [{ status: 'passed' }],+ })),+ },+ ]+ expect(() => verifyNativeFixtures(reports)).not.toThrow()+ for (const suite of reports[0]!.testResults) {+ suite.assertionResults[0].status = 'pending'+ expect(() => verifyNativeFixtures(reports)).toThrow(/did not all execute/)+ suite.assertionResults[0].status = 'passed'+ }+ expect(() => verifyNativeFixtures([])).toThrow(/did not all execute/)+ })+ const files = ['a', 'b', 'c', 'd'].map((file) => ({ file }))+ it('accepts the union of all discovered files exactly once', () => {+ expect(+ verifyTestReports(+ files,+ files.map(({ file }) => report([file]))+ )+ ).toEqual({ files: 4, tests: 4, skipped: 0 })+ })+ it('rejects omitted, duplicated, extra and failed test results', () => {+ expect(() => verifyTestReports(files, [report(['a', 'b', 'c'])])).toThrow(+ /Missing/+ )+ expect(() =>+ verifyTestReports(files, [report(['a', 'b', 'c', 'd']), report(['a'])])+ ).toThrow(/Duplicate/)+ expect(() =>+ verifyTestReports(files, [report(['a', 'b', 'c', 'd', 'e'])])+ ).toThrow(/Unexpected/)+ expect(() =>+ verifyTestReports(files, [+ { ...report(['a', 'b', 'c', 'd']), success: false },+ ])+ ).toThrow(/Failed/)+ expect(() => verifyTestReports([], [])).toThrow(/Empty/)+ })+ it('runs four complete partitions with ABI hooks and an independent discovery check', () => {+ const tests = workflow.jobs.tests+ expect(tests.strategy.matrix.shard).toEqual([1, 2, 3, 4])+ expect(tests.strategy['fail-fast']).toBe(false)+ const step = tests.steps.find(+ (step: any) => step.name === 'Run complete test partition'+ )+ expect(step.run).toContain(`pnpm test --shard=\${{ matrix.shard }}/4`)+ expect(step.run).not.toMatch(/--changed|--no-isolate|--passWithNoTests/)+ expect(step.env.MOTRIX_REQUIRE_ELECTRON_PROXY_TEST).toBe('1')+ const fixtureIndex = tests.steps.findIndex(+ (step: any) => step.name === 'Prepare native filesystem test fixture'+ )+ expect(fixtureIndex).toBeGreaterThan(0)+ expect(fixtureIndex).toBeLessThan(tests.steps.indexOf(step))+ expect(tests.steps[fixtureIndex].run).toContain(+ 'cargo build --manifest-path packages/finalize-fs/Cargo.toml --locked'+ )+ expect(+ tests.steps.find(+ (step: any) => step.name === 'Upload test partition report'+ ).with.overwrite+ ).toBe(true)+ expect(workflow.jobs['test-reports'].needs).toBe('tests')+ expect(workflow.jobs['torrent-browser']).not.toHaveProperty('needs')+ expect(+ workflow.jobs['torrent-browser'].steps.some((step: any) =>+ step.run?.includes('chromium firefox webkit')+ )+ ).toBe(true)+ })+})++describe('Windows directory smoke', () => {+ it('resolves only the dir target using the real electron-builder CLI parser', () => {+ const {+ configureBuildCommand,+ normalizeOptions,+ } = require('electron-builder/out/builder')+ for (const target of PACKAGE_TARGETS.filter(+ (entry: any) => entry.platform === 'win32'+ )) {+ const args = [+ ...target.electron_builder_args.split(' '),+ '--dir',+ '--publish',+ 'never',+ ]+ const parsed = configureBuildCommand(+ require('yargs/yargs')(args)+ ).parseSync()+ const normalized = normalizeOptions(parsed)+ const types = [...normalized.targets.values()]+ .flatMap((arch: any) => [...arch.values()])+ .flat()+ expect(types).toEqual(['dir'])+ }+ const installers = workflow.jobs['package-targets'].steps.find(+ (step: any) => step.name === 'Build Windows installers'+ )+ expect(installers.if).toContain("needs.plan.outputs.installers == 'true'")+ expect(installers.run).toContain('--prepackaged')+ })+})diff --git a/tests/scripts/workflow-flatpak-release.test.ts b/tests/scripts/workflow-flatpak-release.test.tsindex b51434f9..8994bb15 100644--- a/tests/scripts/workflow-flatpak-release.test.ts+++ b/tests/scripts/workflow-flatpak-release.test.ts@@ -38,7 +38,8 @@ describe('Flatpak release gate', () => {inputs: {'release-version': {description: expect.any(String),- required: true,+ required: false,+ default: '',type: 'string',},},diff --git a/tests/scripts/workflow-release-matrix.test.ts b/tests/scripts/workflow-release-matrix.test.tsindex 9cbee63c..6e58e2bc 100644--- a/tests/scripts/workflow-release-matrix.test.ts+++ b/tests/scripts/workflow-release-matrix.test.ts@@ -59,6 +59,13 @@ const ELECTRON_BUILDER_CUSTOM_DIR_ENVIRONMENT_VARIABLES = ['ELECTRON_BUILDER_BINARIES_CUSTOM_DIR',] as constconst EXPECTED_ACTION_PINS = new Map([+ [+ 'actions/cache',+ {+ sha: 'caa296126883cff596d87d8935842f9db880ef25',+ comment: 'v5',+ },+ ],['actions/checkout',{@@ -3124,7 +3131,19 @@ function targetMatrix(workflow: LooseRecord): {if (job.strategy === undefined) return []const strategy = asRecord(job.strategy, `${jobName} strategy`)if (strategy.matrix === undefined) return []- const matrix = asRecord(strategy.matrix, `${jobName} matrix`)+ const matrix =+ workflow === ciWorkflow && jobName === 'package-targets'+ ? (() => {+ expect(strategy.matrix).toBe(+ `\${{ fromJSON(needs.plan.outputs.package_matrix) }}`+ )+ return {+ include: JSON.parse(+ readFileSync('.github/ci-package-targets.json', 'utf8')+ ),+ }+ })()+ : asRecord(strategy.matrix, `${jobName} matrix`)if (!Array.isArray(matrix.include)) return []const entries = matrix.include.map((entry) =>asRecord(entry, `${jobName} matrix entry`)diff --git a/tests/scripts/workflow-snap.test.ts b/tests/scripts/workflow-snap.test.tsindex 0f60d764..9378df06 100644--- a/tests/scripts/workflow-snap.test.ts+++ b/tests/scripts/workflow-snap.test.ts@@ -62,20 +62,10 @@ describe('Snap build workflow contract', () => {expect(stringField(build, 'runs-on')).toContain('matrix.os')})- it('rebuilds Snap PRs when every packaged release input changes', () => {+ it('lets the CI planner schedule PR builds without duplicate triggers', () => {const triggers = asRecord(snapWorkflow.on, 'Snap triggers')- const pullRequest = asRecord(triggers.pull_request, 'pull request trigger')- const paths = arrayField(pullRequest, 'paths')-- expect(paths).toEqual(- expect.arrayContaining([- '.cargo/**',- 'scripts/**',- 'THIRD_PARTY_LICENSES/**',- 'THIRD_PARTY_NOTICES.md',- 'THIRD_PARTY_NOTICES.zh-CN.md',- ])- )+ expect(triggers).toHaveProperty('workflow_call')+ expect(triggers).not.toHaveProperty('pull_request')})it('builds an unpacked app and never lets electron-builder publish', () => {@@ -182,7 +172,7 @@ describe('Snap build workflow contract', () => {expect(asRecord(triggers.push, 'push trigger')).toEqual({tags: ['v*'],})- expect(triggers).toHaveProperty('pull_request')+ expect(triggers).toHaveProperty('workflow_call')const manual = asRecord(triggers.workflow_dispatch,'workflow dispatch trigger'