From 80da55b938b8696e750d341a80b76efbbfa0c75b Mon Sep 17 00:00:00 2001 From: Weiming Liao Date: Fri, 4 Dec 2026 14:35:58 +0800 Subject: [PATCH] [ci] desktop: reuse installed smoke checks for PRs and releases ## summary - Run the same macOS and Windows installer checks against relevant PR changes and release tags. Wait for both verified packages before attaching them to the draft release. - Update the installed smoke journey to enter Canvas through Welcome, check the current dock side, and exercise incremental trace reads. Refs: #273 --- .github/workflows/desktop-installers.yml | 162 +++++++++++++++++++ .github/workflows/desktop-release.yml | 195 ++--------------------- .github/workflows/release-checks.yml | 9 +- apps/desktop/scripts/smoke-window.mjs | 55 +++++-- apps/desktop/scripts/smoke.mjs | 12 +- docs/development/ci-failures.md | 4 +- docs/development/desktop.md | 8 +- docs/development/desktop.zh-CN.md | 8 +- docs/development/lessons.md | 6 + docs/development/release.md | 2 +- docs/development/validation.md | 2 + scripts/ci/select_checks.py | 25 ++- scripts/ci/summarize_checks.py | 35 ++-- tests/test_ci_scope.py | 44 ++++- tests/test_ci_summary.py | 40 +++-- 15 files changed, 372 insertions(+), 235 deletions(-) create mode 100644 .github/workflows/desktop-installers.yml diff --git a/.github/workflows/desktop-installers.yml b/.github/workflows/desktop-installers.yml new file mode 100644 index 000000000..84c4698db --- /dev/null +++ b/.github/workflows/desktop-installers.yml @@ -0,0 +1,162 @@ +name: Desktop installer checks + +on: + workflow_call: + inputs: + release-tag: + description: Existing release tag. Omit to test the caller's commit. + type: string + default: '' + +permissions: + contents: read + +env: + RELEASE_TAG: ${{ inputs.release-tag }} + +jobs: + macos: + runs-on: macos-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + ref: ${{ inputs.release-tag && format('refs/tags/{0}', inputs.release-tag) || github.sha }} + persist-credentials: false + - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 + with: + node-version-file: .nvmrc + - name: Check release version and architecture + run: | + version=$(node -p 'require("./apps/desktop/package.json").version') + if [[ -n "$RELEASE_TAG" && "$RELEASE_TAG" != "v$version" ]] && + ! [[ "$GITHUB_REPOSITORY" != "ThinkFlowLab/OpenDirector" && + "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-desktop-test\.[0-9]+$ && + "${RELEASE_TAG%-desktop-test.*}" = "v$version" ]]; then + echo "::error::Expected a release tag matching v$version" + exit 1 + fi + echo "DESKTOP_VERSION=$version" >> "$GITHUB_ENV" + test "$(uname -m)" = arm64 + - name: Prepare build tools + run: | + brew install uv + media="$RUNNER_TEMP/desktop-media" + mkdir -p "$media" + for tool in ffmpeg ffprobe; do + curl --fail --silent --show-error --location --retry 3 \ + "https://github.com/descriptinc/ffmpeg-ffprobe-static/releases/download/b6.1.2-rc.1/${tool}-darwin-arm64" \ + --output "$media/$tool" + chmod +x "$media/$tool" + "$media/$tool" -version + done + echo "OPENDIRECTOR_FFMPEG_DIR=$media" >> "$GITHUB_ENV" + - name: Build desktop application + env: + CSC_IDENTITY_AUTO_DISCOVERY: 'false' + run: | + npm ci --prefix apps/desktop + npm run prepare:runtime --prefix apps/desktop + npm run pack --prefix apps/desktop + app="apps/desktop/build/mac-arm64/OpenDirector.app" + codesign --force --deep --sign - "$app" + codesign --verify --deep --strict "$app" + - name: Build and smoke-test DMG + run: | + mount="$RUNNER_TEMP/desktop-mount" + installer="$PWD/apps/desktop/installer/macos" + mkdir -p "$mount" release-assets + dmg="OpenDirector-v${DESKTOP_VERSION}-mac-arm64-adhoc.dmg" + uv tool run --from 'dmgbuild==2.0.0' dmgbuild \ + -s "$installer/dmg-settings.py" \ + -D "app=$PWD/apps/desktop/build/mac-arm64/OpenDirector.app" \ + -D "background=$installer/background.png" \ + OpenDirector "release-assets/$dmg" + hdiutil attach "release-assets/$dmg" -readonly -nobrowse -mountpoint "$mount" + trap 'hdiutil detach "$mount"' EXIT + test -s "$mount/.DS_Store" + test -s "$mount/.background.tiff" + test "$(readlink "$mount/Applications")" = /Applications + installed=$(mktemp -d "$RUNNER_TEMP/desktop-install.XXXXXX")/OpenDirector.app + ditto "$mount/OpenDirector.app" "$installed" + codesign --verify --deep --strict "$installed" + node apps/desktop/scripts/smoke.mjs "$installed/Contents/MacOS/OpenDirector" + codesign --verify --deep --strict "$installed" + cd release-assets + shasum -a 256 "$dmg" > "${dmg}.sha256" + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: desktop-dmg + path: release-assets/ + compression-level: 0 + if-no-files-found: error + + windows: + runs-on: windows-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + ref: ${{ inputs.release-tag && format('refs/tags/{0}', inputs.release-tag) || github.sha }} + persist-credentials: false + - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 + with: + node-version-file: .nvmrc + - name: Check release version and architecture + run: | + $version = node -p 'require("./apps/desktop/package.json").version' + $tagPattern = '^v' + [regex]::Escape($version) + '$' + if ($env:GITHUB_REPOSITORY -ne 'ThinkFlowLab/OpenDirector') { + $tagPattern = '^v' + [regex]::Escape($version) + '(-desktop-test\.[0-9]+)?$' + } + if (($env:RELEASE_TAG -and $env:RELEASE_TAG -cnotmatch $tagPattern) -or (node -p process.arch) -ne 'x64') { + throw 'Expected a matching release tag and Windows x64' + } + "DESKTOP_VERSION=$version" >> $env:GITHUB_ENV + - name: Prepare build tools + run: | + choco install uv --yes --no-progress + if ($LASTEXITCODE -ne 0) { throw 'uv installation failed' } + $media = Join-Path $env:RUNNER_TEMP 'desktop-media' + New-Item -ItemType Directory -Path $media | Out-Null + foreach ($tool in 'ffmpeg', 'ffprobe') { + curl.exe --fail --silent --show-error --location --retry 3 ` + "https://github.com/descriptinc/ffmpeg-ffprobe-static/releases/download/b6.1.2-rc.1/${tool}-win32-x64" ` + --output (Join-Path $media "$tool.exe") + if ($LASTEXITCODE -ne 0) { throw "Failed to download $tool" } + } + "OPENDIRECTOR_FFMPEG_DIR=$media" >> $env:GITHUB_ENV + - name: Build Windows installer + env: + CSC_IDENTITY_AUTO_DISCOVERY: 'false' + run: | + npm ci --prefix apps/desktop + if ($LASTEXITCODE -ne 0) { throw 'Desktop dependency installation failed' } + npm run prepare:runtime --prefix apps/desktop + if ($LASTEXITCODE -ne 0) { throw 'Runtime preparation failed' } + npm run pack:windows --prefix apps/desktop + if ($LASTEXITCODE -ne 0) { throw 'Windows packaging failed' } + - name: Smoke-test installed application + run: | + $name = "OpenDirector-v$env:DESKTOP_VERSION-win-x64-unsigned.exe" + $installer = Get-Item "apps/desktop/build/$name" + $install = Join-Path $env:RUNNER_TEMP 'OpenDirector' + $setup = Start-Process -FilePath $installer.FullName -ArgumentList "/S /D=$install" -Wait -PassThru + if ($setup.ExitCode -ne 0) { throw "Installer failed: $($setup.ExitCode)" } + node apps/desktop/scripts/smoke.mjs (Join-Path $install 'OpenDirector.exe') + if ($LASTEXITCODE -ne 0) { throw 'Installed application smoke test failed' } + $uninstaller = Get-Item (Join-Path $install 'Uninstall OpenDirector.exe') + $removal = Start-Process -FilePath $uninstaller.FullName -ArgumentList '/S' -Wait -PassThru + if ($removal.ExitCode -ne 0 -or (Test-Path (Join-Path $install 'OpenDirector.exe'))) { + throw 'Uninstall failed' + } + New-Item -ItemType Directory -Path release-assets | Out-Null + Copy-Item $installer.FullName release-assets + $hash = (Get-FileHash -Algorithm SHA256 $installer.FullName).Hash.ToLowerInvariant() + [IO.File]::WriteAllText((Join-Path (Get-Location) "release-assets/$name.sha256"), "$hash $name`n") + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: desktop-windows + path: release-assets/ + compression-level: 0 + if-no-files-found: error diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml index 98075b68d..5fa70300f 100644 --- a/.github/workflows/desktop-release.yml +++ b/.github/workflows/desktop-release.yml @@ -21,171 +21,13 @@ env: RELEASE_TAG: ${{ inputs.tag || github.ref_name }} jobs: - macos: - runs-on: macos-latest - timeout-minutes: 45 - steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - with: - ref: refs/tags/${{ env.RELEASE_TAG }} - persist-credentials: false - - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 - with: - node-version-file: .nvmrc - - name: Check release version and architecture - run: | - version=$(node -p 'require("./apps/desktop/package.json").version') - if [[ "$GITHUB_REPOSITORY" == "ThinkFlowLab/OpenDirector" ]]; then - test "$RELEASE_TAG" = "v$version" - else - [[ "$RELEASE_TAG" = "v$version" || "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-desktop-test\.[0-9]+$ && "${RELEASE_TAG%-desktop-test.*}" = "v$version" ]] - fi - echo "DESKTOP_VERSION=$version" >> "$GITHUB_ENV" - test "$(uname -m)" = arm64 - - name: Prepare build tools - run: | - brew install uv - media="$RUNNER_TEMP/desktop-media" - mkdir -p "$media" - for tool in ffmpeg ffprobe; do - curl --fail --silent --show-error --location --retry 3 \ - "https://github.com/descriptinc/ffmpeg-ffprobe-static/releases/download/b6.1.2-rc.1/${tool}-darwin-arm64" \ - --output "$media/$tool" - chmod +x "$media/$tool" - "$media/$tool" -version - done - echo "OPENDIRECTOR_FFMPEG_DIR=$media" >> "$GITHUB_ENV" - - name: Build desktop application - env: - CSC_IDENTITY_AUTO_DISCOVERY: 'false' - run: | - npm ci --prefix apps/desktop - npm run prepare:runtime --prefix apps/desktop - npm run pack --prefix apps/desktop - app="apps/desktop/build/mac-arm64/OpenDirector.app" - codesign --force --deep --sign - "$app" - codesign --verify --deep --strict "$app" - - name: Build and smoke-test DMG - run: | - mount="$RUNNER_TEMP/desktop-mount" - installer="$PWD/apps/desktop/installer/macos" - mkdir -p "$mount" release-assets - dmg="OpenDirector-v${DESKTOP_VERSION}-mac-arm64-adhoc.dmg" - uv tool run --from 'dmgbuild==2.0.0' dmgbuild \ - -s "$installer/dmg-settings.py" \ - -D "app=$PWD/apps/desktop/build/mac-arm64/OpenDirector.app" \ - -D "background=$installer/background.png" \ - OpenDirector "release-assets/$dmg" - hdiutil attach "release-assets/$dmg" -readonly -nobrowse -mountpoint "$mount" - trap 'hdiutil detach "$mount"' EXIT - test -s "$mount/.DS_Store" - test -s "$mount/.background.tiff" - test "$(readlink "$mount/Applications")" = /Applications - installed=$(mktemp -d "$RUNNER_TEMP/desktop-install.XXXXXX")/OpenDirector.app - ditto "$mount/OpenDirector.app" "$installed" - codesign --verify --deep --strict "$installed" - node apps/desktop/scripts/smoke.mjs "$installed/Contents/MacOS/OpenDirector" - codesign --verify --deep --strict "$installed" - cd release-assets - shasum -a 256 "$dmg" > "${dmg}.sha256" - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: desktop-dmg - path: release-assets/ - compression-level: 0 - if-no-files-found: error - - windows: - runs-on: windows-latest - timeout-minutes: 45 - steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - with: - ref: refs/tags/${{ env.RELEASE_TAG }} - persist-credentials: false - - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 - with: - node-version-file: .nvmrc - - name: Check release version and architecture - run: | - $version = node -p 'require("./apps/desktop/package.json").version' - $tagPattern = '^v' + [regex]::Escape($version) + '$' - if ($env:GITHUB_REPOSITORY -ne 'ThinkFlowLab/OpenDirector') { - $tagPattern = '^v' + [regex]::Escape($version) + '(-desktop-test\.[0-9]+)?$' - } - if ($env:RELEASE_TAG -cnotmatch $tagPattern -or (node -p process.arch) -ne 'x64') { - throw 'Expected a matching release tag and Windows x64' - } - "DESKTOP_VERSION=$version" >> $env:GITHUB_ENV - - name: Prepare build tools - run: | - choco install uv --yes --no-progress - if ($LASTEXITCODE -ne 0) { throw 'uv installation failed' } - $media = Join-Path $env:RUNNER_TEMP 'desktop-media' - New-Item -ItemType Directory -Path $media | Out-Null - foreach ($tool in 'ffmpeg', 'ffprobe') { - curl.exe --fail --silent --show-error --location --retry 3 ` - "https://github.com/descriptinc/ffmpeg-ffprobe-static/releases/download/b6.1.2-rc.1/${tool}-win32-x64" ` - --output (Join-Path $media "$tool.exe") - if ($LASTEXITCODE -ne 0) { throw "Failed to download $tool" } - } - "OPENDIRECTOR_FFMPEG_DIR=$media" >> $env:GITHUB_ENV - - name: Build Windows installer - env: - CSC_IDENTITY_AUTO_DISCOVERY: 'false' - run: | - npm ci --prefix apps/desktop - if ($LASTEXITCODE -ne 0) { throw 'Desktop dependency installation failed' } - npm run prepare:runtime --prefix apps/desktop - if ($LASTEXITCODE -ne 0) { throw 'Runtime preparation failed' } - npm run pack:windows --prefix apps/desktop - if ($LASTEXITCODE -ne 0) { throw 'Windows packaging failed' } - - name: Smoke-test installed application - run: | - $name = "OpenDirector-v$env:DESKTOP_VERSION-win-x64-unsigned.exe" - $installer = Get-Item "apps/desktop/build/$name" - $install = Join-Path $env:RUNNER_TEMP 'OpenDirector' - $setup = Start-Process -FilePath $installer.FullName -ArgumentList "/S /D=$install" -Wait -PassThru - if ($setup.ExitCode -ne 0) { throw "Installer failed: $($setup.ExitCode)" } - node apps/desktop/scripts/smoke.mjs (Join-Path $install 'OpenDirector.exe') - if ($LASTEXITCODE -ne 0) { throw 'Installed application smoke test failed' } - $uninstaller = Get-Item (Join-Path $install 'Uninstall OpenDirector.exe') - $removal = Start-Process -FilePath $uninstaller.FullName -ArgumentList '/S' -Wait -PassThru - if ($removal.ExitCode -ne 0 -or (Test-Path (Join-Path $install 'OpenDirector.exe'))) { - throw 'Uninstall failed' - } - New-Item -ItemType Directory -Path release-assets | Out-Null - Copy-Item $installer.FullName release-assets - $hash = (Get-FileHash -Algorithm SHA256 $installer.FullName).Hash.ToLowerInvariant() - [IO.File]::WriteAllText((Join-Path (Get-Location) "release-assets/$name.sha256"), "$hash $name`n") - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: desktop-windows - path: release-assets/ - compression-level: 0 - if-no-files-found: error + installers: + uses: ./.github/workflows/desktop-installers.yml + with: + release-tag: ${{ inputs.tag || github.ref_name }} - prepare-release: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Find or create draft release - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - run: | - set -euo pipefail - draft=$(gh api --paginate "repos/$GH_REPO/releases" \ - --jq ".[] | select(.tag_name == \"$RELEASE_TAG\") | .draft") - case "$draft" in - true) ;; - '') gh release create "$RELEASE_TAG" --verify-tag --draft --generate-notes ;; - *) echo "::error::Release $RELEASE_TAG is already published"; exit 1 ;; - esac - - release-macos: - needs: [prepare-release, macos] + attach-installers: + needs: installers runs-on: ubuntu-latest permissions: contents: write @@ -194,24 +36,21 @@ jobs: with: name: desktop-dmg path: release-assets - - name: Attach verified installer to draft release - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - run: gh release upload "$RELEASE_TAG" release-assets/* --clobber - - release-windows: - needs: [prepare-release, windows] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: name: desktop-windows path: release-assets - - name: Attach verified installer to draft release + - name: Attach both verified installers to the draft release env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} - run: gh release upload "$RELEASE_TAG" release-assets/* --clobber + run: | + set -euo pipefail + draft=$(gh api --paginate "repos/$GH_REPO/releases" | + jq -r --arg tag "$RELEASE_TAG" '.[] | select(.tag_name == $tag) | .draft') + case "$draft" in + true) ;; + '') gh release create "$RELEASE_TAG" --verify-tag --draft --generate-notes ;; + *) echo "::error::Release $RELEASE_TAG is already published"; exit 1 ;; + esac + gh release upload "$RELEASE_TAG" release-assets/* --clobber diff --git a/.github/workflows/release-checks.yml b/.github/workflows/release-checks.yml index 67d162bbf..65cb8d8cb 100644 --- a/.github/workflows/release-checks.yml +++ b/.github/workflows/release-checks.yml @@ -26,6 +26,7 @@ jobs: timeout-minutes: 10 outputs: run-heavy: ${{ steps.scope.outputs.run-heavy }} + run-desktop: ${{ steps.scope.outputs.run-desktop }} scope-reason: ${{ steps.scope.outputs.scope-reason }} changed-files: ${{ steps.scope.outputs.changed-files }} steps: @@ -59,8 +60,14 @@ jobs: env: PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} MERGE_GROUP_BASE_SHA: ${{ github.event.merge_group.base_sha }} + PUSH_BASE_SHA: ${{ github.event.before }} run: python scripts/ci/select_checks.py + desktop: + needs: static + if: ${{ !cancelled() && ((needs.static.result == 'success' && needs.static.outputs.run-desktop != 'false') || (!inputs.static-checks && needs.static.result == 'skipped')) }} + uses: ./.github/workflows/desktop-installers.yml + python: needs: static if: ${{ !cancelled() && ((needs.static.result == 'success' && needs.static.outputs.run-heavy != 'false') || (!inputs.static-checks && needs.static.result == 'skipped')) }} @@ -324,7 +331,7 @@ jobs: # cancelled or unexpectedly skipped lanes, including static-gate failures. checks: if: always() - needs: [static, python, frontend, browser] + needs: [static, python, frontend, browser, desktop] runs-on: ubuntu-22.04 timeout-minutes: 5 steps: diff --git a/apps/desktop/scripts/smoke-window.mjs b/apps/desktop/scripts/smoke-window.mjs index 7c7b479ff..e0a6ceaf2 100644 --- a/apps/desktop/scripts/smoke-window.mjs +++ b/apps/desktop/scripts/smoke-window.mjs @@ -293,18 +293,21 @@ async function completeWelcome(window) { ['.cw-welcome-intro .cw-welcome-primary', null, 'Welcome did not offer Get started'], ['.cw-welcome-connection-options > button:last-child', null, 'Welcome did not offer an existing harness'], ['.cw-welcome-options > button', 'OpenCode', 'Bundled OpenCode was not available in Welcome'], + ['.cw-welcome-mode-canvas', null, 'Welcome did not offer Canvas mode after connecting OpenCode'], ]) { await waitFor(() => webContents.executeJavaScript(`(() => { const label = ${JSON.stringify(label)}; const buttons = document.querySelectorAll(${JSON.stringify(`dialog.cw-welcome[open] ${selector}`)}); - const button = [...buttons].find(item => !item.disabled && (!label || item.querySelector('strong')?.textContent === label)); + const button = [...buttons].find(item => !item.matches(':disabled') && (!label || item.querySelector('strong')?.textContent === label)); if (!button) return false; button.click(); return true; })()`), error); } const input = 'dialog.cw-welcome[open] input[type="file"]'; - await waitFor(() => webContents.executeJavaScript(`!!document.querySelector(${JSON.stringify(input)})`), 'Welcome did not reach the task chooser'); + await waitFor(() => webContents.executeJavaScript( + '!!document.querySelector(\'dialog.cw-welcome[open] button[aria-labelledby$="-import"]:enabled\')', + ), 'Welcome did not enable Import media in Canvas mode'); const debuggerSession = webContents.debugger; debuggerSession.attach(); try { @@ -410,10 +413,15 @@ async function smokeTraceWindows(window, projectId) { const editor = ".cw-assistant-composer [contenteditable=true]"; await waitFor(() => evaluate(`document.querySelector(${JSON.stringify(editor)})?.checkVisibility()`), 'Assistant composer did not open'); await waitFor(() => evaluate(`(() => { + const workspace = document.querySelector('.cw-workspace'); const chat = document.querySelector('#canvas-assistant').getBoundingClientRect(); const canvas = document.querySelector('.cw-canvas-region').getBoundingClientRect(); - const sidebar = document.querySelector('.cw-workspace[data-desktop-sidebar=open] .od-project-sidebar'); - return chat.left >= (sidebar?.getBoundingClientRect().right ?? 0) && chat.right <= canvas.left; + const sidebar = workspace.dataset.desktopSidebar === 'open' ? workspace.querySelector('.od-project-sidebar') : null; + const sidebarRight = sidebar?.getBoundingClientRect().right ?? 0; + const tolerance = 2; + if (sidebarRight > Math.min(chat.left, canvas.left) + tolerance) return false; + if (workspace.dataset.chatDock === 'left') return chat.right <= canvas.left + tolerance; + return workspace.dataset.chatDock === 'right' && canvas.right <= chat.left + tolerance; })()`), 'The project sidebar, conversation and canvas overlap'); await evaluate(`document.querySelector(${JSON.stringify(editor)}).focus()`); await window.webContents.insertText('Draft before opening trace'); @@ -427,17 +435,34 @@ async function smokeTraceWindows(window, projectId) { const first = live ? 'Live trace begins' : 'Historical trace'; writeFileSync(file, event(first)); const query = new URLSearchParams({ traceProject: projectId, turn, runtime: 'opencode', ...(live ? { live: '1' } : {}) }); - await evaluate(`window.open('/?${query}', '_blank', 'noopener,noreferrer'); undefined`); - const child = await waitFor(() => BrowserWindow.getAllWindows().find(item => - item.getParentWindow() === window && item.webContents.getURL().includes(turn)), 'Desktop trace did not open in its own window'); - const contains = text => child.webContents.executeJavaScript( - `document.querySelector('.cw-trace-page')?.innerText.includes(${JSON.stringify(text)})`); - await waitFor(() => contains(first), 'Trace window did not read the stored trace'); - appendFileSync(file, event('Trace file updated')); - if (live) await waitFor(() => contains('Trace file updated'), 'Live trace did not refresh'); - else if (await contains('Trace file updated')) throw new Error('Historical trace unexpectedly refreshed'); - child.close(); - await waitFor(() => child.isDestroyed(), 'Trace window did not close'); + const { webRequest } = window.webContents.session; + if (live) { + const prefix = `opendirector://app/api/creation/projects/${projectId}/assistant/traces/${turn}/`; + webRequest.onHeadersReceived({ urls: [''] }, (details, done) => { + if (!details.url.startsWith(prefix) || !new URL(details.url).searchParams.has('cursor')) { + done({}); + return; + } + const headers = Object.fromEntries(Object.entries(details.responseHeaders ?? {}) + .filter(([name]) => name.toLowerCase() !== 'x-trace-running')); + done({ responseHeaders: { ...headers, 'X-Trace-Running': ['1'] } }); + }); + } + try { + await evaluate(`window.open('/?${query}', '_blank', 'noopener,noreferrer'); undefined`); + const child = await waitFor(() => BrowserWindow.getAllWindows().find(item => + item.getParentWindow() === window && item.webContents.getURL().includes(turn)), 'Desktop trace did not open in its own window'); + const contains = text => child.webContents.executeJavaScript( + `document.querySelector('.cw-trace-page')?.innerText.includes(${JSON.stringify(text)})`); + await waitFor(() => contains(first), 'Trace window did not read the stored trace'); + appendFileSync(file, event('Trace file updated')); + if (live) await waitFor(() => contains('Trace file updated'), 'Live trace did not refresh'); + else if (await contains('Trace file updated')) throw new Error('Historical trace unexpectedly refreshed'); + child.close(); + await waitFor(() => child.isDestroyed(), 'Trace window did not close'); + } finally { + if (live) webRequest.onHeadersReceived(null); + } if (!(await draft())?.includes('Draft before opening trace')) throw new Error('Closing the trace lost the assistant draft'); } window.focus(); diff --git a/apps/desktop/scripts/smoke.mjs b/apps/desktop/scripts/smoke.mjs index 34bae00ff..3caa182d3 100644 --- a/apps/desktop/scripts/smoke.mjs +++ b/apps/desktop/scripts/smoke.mjs @@ -16,13 +16,21 @@ let largeVideo; try { const runtime = resolve(dirname(binary), process.platform === 'darwin' ? '../Resources/runtime' : 'resources/runtime'); const { python } = JSON.parse(await readFile(join(runtime, 'manifest.json'), 'utf8')); + const pythonBinary = join(runtime, python); // Give the isolated smoke process a real installed harness for the welcome flow. - const harnessBin = execFileSync(join(runtime, python), ['-I', '-B', '-X', 'utf8', '-c', + const harnessBin = execFileSync(pythonBinary, ['-I', '-B', '-X', 'utf8', '-c', 'from opendirector.installation import BUNDLED; print(BUNDLED / "bin")'], { encoding: 'utf8' }).trim(); await access(join(harnessBin, process.platform === 'win32' ? 'opencode.exe' : 'opencode')); await access(join(runtime, 'bin/LICENSE.three.txt')); - execFileSync(join(runtime, python), ['-I', '-B', '-X', 'utf8', '-c', + execFileSync(pythonBinary, ['-I', '-B', '-X', 'utf8', '-c', 'from opendirector.installation import web_root; w = web_root() / "assets/motion-templates"; assert (w / "three.min.js").is_file() and "three.js authors" in (w / "LICENSE").read_text(encoding="utf-8")'], { encoding: 'utf8' }); + execFileSync(pythonBinary, ['-I', '-B', '-X', 'utf8', '-c', [ + 'from pathlib import Path', + 'from opendirector.infrastructure.model_configs import ModelConfigs', + 'import sys', + 'ModelConfigs(Path(sys.argv[1])).save("image", "http://127.0.0.1:1/v1", "desktop-smoke-image", "",', + ' connection_type="self_hosted", protocol="openai", auth_mode="none", capability_auto_check=False)', + ].join('\n'), join(directory, 'workspace')]); const video = process.platform === 'win32' ? await createLargeVideo(join(directory, 'large-video.mp4')) : null; diff --git a/docs/development/ci-failures.md b/docs/development/ci-failures.md index fed313f01..1f12b5cf6 100644 --- a/docs/development/ci-failures.md +++ b/docs/development/ci-failures.md @@ -31,8 +31,8 @@ The OpenCode hang tracked as #162 is unrelated and was not verified here. - 先确认失败是否可复现于同一 SHA:对比该 commit 在同一分支上的近期运行结果;一个失败随后在同 SHA 上转绿,属于偶发信号,不属于该 PR 的回归。 - Python 套件失败时查看 nightly flake triage 的分类:`flaky`(失败子集重跑通过)与 `fail`(重跑仍失败)含义不同;watchlist 用例的 3 次连跑结果给出波动率。 -- Release checks 先运行静态门禁,再并行运行 Python、前端/打包和三个浏览器旅程;测试线失败不取消其余测试线。最终 checks 汇总必须全部成功,只有明确关闭的 static 可 skipped。静态失败造成的下游 skipped 不是通过,判别时同时查看 static、各测试线和最终汇总。 -- Release checks runs the static gate first, followed by independent Python, frontend/package and three browser journeys. The final checks aggregate rejects failures, cancellations and unexpected skips; only an explicitly disabled static lane may be skipped. +- Release checks 先运行静态门禁,再并行运行 Python、前端/打包、浏览器旅程和桌面安装检查。测试线失败不取消其他测试线。最终汇总允许按变更范围跳过的检查和明确关闭的静态检查。判别时同时查看静态检查、各测试线和最终汇总。 +- Release checks runs the static gate first, followed by independent Python, frontend/package, browser and desktop installer checks. The aggregate accepts skips justified by the change scope or an explicitly disabled static gate. Check the static result, individual jobs and aggregate when diagnosing a failure. ## 已知时序敏感模式(2026-11 观测) diff --git a/docs/development/desktop.md b/docs/development/desktop.md index 263597304..497d2ccbe 100644 --- a/docs/development/desktop.md +++ b/docs/development/desktop.md @@ -18,7 +18,9 @@ node apps/desktop/scripts/smoke.mjs /absolute/path/to/packaged/OpenDirector The runtime preparation builds the Python wheel using the existing build backend, including Web assets, skills and the actual OpenCode executable. It installs the wheel and dependencies into a private standalone Python distribution, validates CLI help and both media binaries, and records the target in `runtime/manifest.json`. It never modifies system Python. Supply media binaries with their redistribution licenses for the target; system package-manager binaries with external shared-library dependencies are not portable. -The smoke check launches the actual packaged executable with isolated temporary data, opens the canvas, drops local MP4, PNG, and WAV files and verifies their assets and nodes persist across launches, checks authenticated health and project queries, verifies renderer isolation and both locales, hides the window without stopping the Host, and reopens the same project after quitting. It makes no provider calls. It does not establish Agent-assisted creation, export quality, signing, or support on an untested platform. +The smoke check launches the packaged executable with isolated temporary data. It connects the bundled OpenCode, chooses Canvas mode, and imports a WAV through Welcome with a local media model configuration that needs no provider calls. It also drops local MP4, PNG, and WAV files, verifies the saved assets and nodes after reopening, checks authenticated API calls, renderer isolation and both locales, and hides the window while the Host stays running. + +The live trace fixture supplies the running flag for its own synthetic turn. The trace window reads incremental data from the packaged Host and renders the appended trace record. ## Terminal command @@ -32,4 +34,6 @@ Before release, run the complete clean-machine acceptance in #363 on each declar ## Release packages -The desktop release workflow builds an Apple Silicon DMG with an ad-hoc signed App and an unsigned Windows x64 NSIS installer. Each platform uploads its installer and SHA-256 file to the shared draft release after its native checks pass. The macOS job verifies the installed App signature before and after the smoke test. +[Desktop installer checks](../../.github/workflows/desktop-installers.yml) build and install an Apple Silicon DMG with an ad-hoc signed App and an unsigned Windows x64 NSIS installer. macOS verifies the installed App signature before and after the smoke test. Windows also tests silent uninstall. + +[Release checks](../../.github/workflows/release-checks.yml) include both installer jobs when a PR, merge group or push changes packaging inputs, shared app code or the smoke fixtures. A failed installer job fails the aggregate check. CI stores the installers and checksums as workflow artifacts. [Desktop release](../../.github/workflows/desktop-release.yml) runs the same jobs at the release tag and attaches both verified packages and their SHA-256 files to the draft. Publish the draft after this workflow succeeds. diff --git a/docs/development/desktop.zh-CN.md b/docs/development/desktop.zh-CN.md index e4efab4ac..18f372d6e 100644 --- a/docs/development/desktop.zh-CN.md +++ b/docs/development/desktop.zh-CN.md @@ -18,7 +18,9 @@ node apps/desktop/scripts/smoke.mjs /absolute/path/to/packaged/OpenDirector 运行时准备复用现有构建后端生成 Python wheel,包含前端、技能和实际 OpenCode 可执行文件;将 wheel 和依赖安装到私有独立 Python,验证 CLI 帮助及两个媒体程序,并将平台写入 `runtime/manifest.json`。不会修改系统 Python。提供对应平台可分发的媒体程序及许可证;依赖包管理器外部动态库的系统二进制不能直接作为便携运行时。 -冒烟检查使用临时数据目录启动实际打包程序,进入画布,拖入本地 MP4、PNG 和 WAV 文件并确认重启后素材和节点仍在,检查鉴权健康接口和工程查询,验证渲染隔离及中英文切换,隐藏窗口并确认 Host 保留,退出后重开同一工程,不调用模型服务。该检查不代表已完成 Agent 辅助创作、导出质量、签名或未测试平台的验收。 +冒烟检查使用临时数据目录启动打包程序,连接内置 OpenCode,选择画布模式,并通过欢迎页导入 WAV。测试使用无需调用模型服务的本地媒体模型配置。随后拖入本地 MP4、PNG 和 WAV 文件,重开工程确认素材和节点已保存,检查 API 鉴权、渲染隔离和中英文切换,并确认隐藏窗口后 Host 仍在运行。 + +实时轨迹用例为合成的测试轮次提供运行标志。轨迹窗口从打包的 Host 增量读取数据并显示追加的轨迹记录。 ## 终端命令 @@ -32,4 +34,6 @@ node apps/desktop/scripts/smoke.mjs /absolute/path/to/packaged/OpenDirector ## 发布安装包 -桌面发布工作流构建 Apple Silicon DMG 和未签名的 Windows x64 NSIS 安装包。DMG 内的 App 使用 ad-hoc 签名。每个平台通过原生验证后,将安装包和 SHA-256 校验文件上传到同一个草稿 Release。macOS 任务在冒烟测试前后校验已安装 App 的签名。 +[桌面安装检查](../../.github/workflows/desktop-installers.yml)构建并安装两个平台的产物。Apple Silicon DMG 内的 App 使用 ad-hoc 签名,macOS 任务在冒烟测试前后均验证已安装 App 的签名。Windows x64 NSIS 安装包为未签名版本,Windows 任务也测试静默卸载。 + +PR、合并组合或 push 改动打包输入、共用应用代码或冒烟测试素材时,[Release checks](../../.github/workflows/release-checks.yml)会运行两端安装检查,任一失败都会导致汇总检查失败。CI 将安装包和校验文件保存为工作流产物。[桌面发布](../../.github/workflows/desktop-release.yml)在发布 tag 上复用相同检查,将两端验证通过的安装包及 SHA-256 校验文件上传到草稿 Release。工作流成功后再公开草稿。 diff --git a/docs/development/lessons.md b/docs/development/lessons.md index c25a1fbc3..d8857fee7 100644 --- a/docs/development/lessons.md +++ b/docs/development/lessons.md @@ -12,6 +12,12 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u - **Evidence:** The [CI layer assessment](ci-layer-assessment.md) found three Linux/Windows ID differences from interpreter paths in runtime-readiness parameters and dynamically encoded PNG bytes in BigModel image parameters, despite unchanged test sources and parameter counts. - **Check:** Preserve raw identities and environment metadata; use comparable same-platform samples for exact conservation checks. When changing those parameterizations, prefer explicit semantic IDs over generated bytes or executable paths. Do not silently normalize distinct IDs and claim that coverage was preserved. +## Desktop onboarding changes affect the installed smoke test + +- **Trigger:** Changing the Welcome flow or cutting a desktop release. +- **Evidence:** [Desktop release v0.1.7](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/47198531313) failed on both platforms after the Welcome flow added a workspace mode choice. The same run found an already published Release before installers could be attached. +- **Check:** Run the same installer workflow for PRs that change packaged inputs and for the tagged release. Complete the actual Welcome steps and verify the imported media after reopening. Keep the GitHub Release in draft until both platform installers and checksums are attached. + ## Model capabilities and requests can diverge - **Trigger:** Creating a generation node, configuring model capabilities, or constructing a provider request. diff --git a/docs/development/release.md b/docs/development/release.md index 140afa9f3..3e519ff34 100644 --- a/docs/development/release.md +++ b/docs/development/release.md @@ -14,7 +14,7 @@ Public tags are `vMAJOR.MINOR.PATCH`. Keep a single public stream. Do not add Ca A published tag is immutable and points at one `main` commit: the commit after the version-bump pull request merges. Do not retag. Do not create a floating `latest` git tag. -Ship a GitHub Release with the tag. Notes are English and list the merges since the previous tag. +Pushing the tag starts [Desktop release](../../.github/workflows/desktop-release.yml). Wait for it to attach both verified installers and their checksums to the draft, then publish the GitHub Release. Notes are English and list the merges since the previous tag. ## When to cut diff --git a/docs/development/validation.md b/docs/development/validation.md index c62a5dea9..75e79f85d 100644 --- a/docs/development/validation.md +++ b/docs/development/validation.md @@ -357,6 +357,8 @@ The table records current execution before cutover, including main reruns and ni L1–L4 的自动检查不调用付费模型、不依赖真实服务;真实凭证与真实模型的验收属于需要明确授权的范围,不纳入本体系的自动执行。建议性结论与阻断性结论的边界见下节;已知失败模式的解读见 [CI 失败模式](ci-failures.md)。 +桌面安装检查也纳入 Release checks 汇总。PR、合并组合和 main push 按打包输入的变更范围运行,nightly gate-parity 完整运行。macOS 和 Windows 从各自安装包启动,流程与 tag 发布共用。 / The Release checks aggregate also includes installed desktop smoke tests. PRs, merge groups, and main pushes select the jobs by packaging inputs, while nightly gate parity runs both platforms. The tag release uses the same workflow. [桌面验证 / Desktop validation](desktop.zh-CN.md) + ### 发布决策与 lane 政策 - 切换前,候选 `v0.1.x` 仍须通过当前 gate-parity 发布门槛。队列完成验证并强制生效后,发布依据切换为与准确 main 内容对应的成功队列证据;nightly 不作为替代门槛,也不自动打 tag 或触发发布。/ Before cutover, candidate `v0.1.x` releases retain the current gate-parity bar. After queue validation and enforcement, release decisions use successful queue evidence proven to match exact main content; nightly is not a substitute gate and never automatically tags or publishes. diff --git a/scripts/ci/select_checks.py b/scripts/ci/select_checks.py index 8f546f30d..e7af994f4 100644 --- a/scripts/ci/select_checks.py +++ b/scripts/ci/select_checks.py @@ -9,6 +9,17 @@ ROOT_DOCUMENTS = {'README.md', 'README.zh-CN.md', 'CONTRIBUTING.md', 'CHANGELOG.md'} DOCUMENT_SUFFIXES = {'.md', '.png', '.jpg', '.jpeg', '.gif', '.webp'} +DESKTOP_INPUT_DIRS = ( + 'apps/', 'packages/', 'src/', 'public/', 'scripts/', '.github/actions/', + 'tests/fixtures/timeline-text/', +) +DESKTOP_INPUT_FILES = { + '.github/workflows/ci.yml', '.github/workflows/release-checks.yml', + '.github/workflows/desktop-release.yml', '.github/workflows/desktop-installers.yml', + '.nvmrc', '.npmrc', 'MANIFEST.in', 'build_backend.py', 'index.html', + 'package.json', 'package-lock.json', 'pyproject.toml', 'requirements.txt', + 'setup.py', 'vite.config.ts', 'tsconfig.json', +} REASONS = { 'docs_only': 'Documentation only; heavy checks skipped / 纯文档,跳过重检查', 'non_documentation': 'Code, configuration or other inputs changed / 代码、配置或其他输入有变更', @@ -57,8 +68,9 @@ def changed_paths(event, base, *, head=None, repository=None): def select(event, base, *, head=None, repository=None): - result = {'run-heavy': 'true', 'scope-reason': 'event_requires_full', 'changed-files': '0'} - if event not in {'pull_request', 'merge_group'}: + result = {'run-heavy': 'true', 'run-desktop': 'true', + 'scope-reason': 'event_requires_full', 'changed-files': '0'} + if event not in {'pull_request', 'merge_group', 'push'}: return result result['scope-reason'] = 'comparison_unavailable' paths = changed_paths(event, base, head=head, repository=repository) @@ -67,10 +79,13 @@ def select(event, base, *, head=None, repository=None): result['changed-files'] = str(len(paths)) if not paths: result['scope-reason'] = 'empty_diff' - elif all(documentation(path) for path in paths): - result.update({'run-heavy': 'false', 'scope-reason': 'docs_only'}) else: - result['scope-reason'] = 'non_documentation' + if not any(path.startswith(DESKTOP_INPUT_DIRS) or path in DESKTOP_INPUT_FILES for path in paths): + result['run-desktop'] = 'false' + if event != 'push' and all(documentation(path) for path in paths): + result.update({'run-heavy': 'false', 'scope-reason': 'docs_only'}) + else: + result['scope-reason'] = 'event_requires_full' if event == 'push' else 'non_documentation' return result diff --git a/scripts/ci/summarize_checks.py b/scripts/ci/summarize_checks.py index 52707ce96..2daa4db0d 100644 --- a/scripts/ci/summarize_checks.py +++ b/scripts/ci/summarize_checks.py @@ -9,39 +9,52 @@ def main(): static_enabled = json.loads(os.environ['STATIC_ENABLED']) if not isinstance(static_enabled, bool): raise SystemExit('STATIC_ENABLED must be a JSON boolean') - expected = {'static', 'python', 'frontend', 'browser'} + expected = {'static', 'python', 'frontend', 'browser', 'desktop'} if set(results) != expected: raise SystemExit('Missing or unexpected release-check lanes') scope = results['static'].get('outputs', {}) heavy = scope.get('run-heavy', '') - if heavy not in {'', 'true', 'false'}: + desktop = scope.get('run-desktop', '') + if any(decision not in {'', 'true', 'false'} for decision in (heavy, desktop)): raise SystemExit('Invalid check-scope decision / 检查范围判定无效') docs_only = heavy == 'false' + skip_desktop = desktop == 'false' + event = os.environ.get('GITHUB_EVENT_NAME') + comparable = (static_enabled and results['static']['result'] == 'success' + and str(scope.get('changed-files', '')).isdigit() + and int(scope['changed-files']) > 0) if docs_only and not ( - static_enabled and results['static']['result'] == 'success' - and os.environ.get('GITHUB_EVENT_NAME') in {'pull_request', 'merge_group'} + comparable and event in {'pull_request', 'merge_group'} and scope.get('scope-reason') == 'docs_only' - and str(scope.get('changed-files', '')).isdigit() - and int(scope['changed-files']) > 0 ): raise SystemExit('Unproven documentation-only skip / 无法证明纯文档跳过依据') + if skip_desktop and not ( + comparable and ( + (event in {'pull_request', 'merge_group'} and scope.get('scope-reason') in {'docs_only', 'non_documentation'}) + or (event == 'push' and scope.get('scope-reason') == 'event_requires_full') + ) + ): + raise SystemExit('Unproven desktop skip / 无法证明桌面安装检查的跳过依据') rows = [] failed = [] for name in sorted(expected): result = results[name]['result'] allowed = {'success'} - if docs_only and name != 'static': + if (name == 'desktop' and skip_desktop) or (docs_only and name not in {'static', 'desktop'}): allowed = {'skipped'} if name == 'static' and not static_enabled: allowed.add('skipped') rows.append(f'| {name} | {result} |') if result not in allowed: failed.append(name) + summary = 'Full checks required / 需要完整检查' + if docs_only: + summary = ('Documentation-only PR / merge group: static passed; heavy checks intentionally skipped. / ' + '纯文档 PR / 合并组合:静态通过,按明确范围跳过重检查。') + elif skip_desktop: + summary = 'Desktop installers skipped by path scope. / 按变更范围跳过桌面安装检查。' report = '\n'.join([ - '## Release checks / 发布检查', '', - ('Documentation-only PR / merge group: static passed; heavy checks intentionally skipped. / ' - '纯文档 PR / 合并组合:静态通过,按明确范围跳过重检查。' if docs_only - else 'Full checks required / 需要完整检查'), + '## Release checks / 发布检查', '', summary, 'Scope / 范围: ' + str(scope.get('scope-reason', 'full')) + '; changed paths / 变更路径数: ' + str(scope.get('changed-files', 'unknown')), '', '| Lane / 检查线 | Result / 结果 |', '| --- | --- |', *rows, '', diff --git a/tests/test_ci_scope.py b/tests/test_ci_scope.py index 3f4ed0acd..e774db83c 100644 --- a/tests/test_ci_scope.py +++ b/tests/test_ci_scope.py @@ -69,6 +69,24 @@ def test_only_allowlisted_nonempty_documentation_can_skip(repository, names, doc assert int(decision['changed-files']) == len(names) +@pytest.mark.parametrize('name,run_desktop', [ + ('src/canvas/WelcomeScreen.tsx', 'true'), + ('apps/desktop/scripts/smoke-window.mjs', 'true'), + ('packages/core/src/opendirector/installation.py', 'true'), + ('tests/fixtures/timeline-text/audio-b.wav', 'true'), + ('.github/workflows/desktop-installers.yml', 'true'), + ('docs/development/desktop.md', 'false'), + ('tests/browser/first_run.mjs', 'false'), +]) +@pytest.mark.parametrize('event', ['pull_request', 'merge_group', 'push']) +def test_desktop_check_follows_packaged_inputs(repository, name, run_desktop, event): + repo, base = repository + commit(repo, name) + commit(repo, 'docs/latest.md') + decision = scope.select(event, base, head=git(repo, 'rev-parse', 'HEAD'), repository=repo) + assert decision['run-desktop'] == run_desktop + + def test_whole_pr_not_only_last_commit(repository): repo, base = repository commit(repo, 'src/app.py') @@ -119,12 +137,15 @@ def test_missing_or_invalid_comparison_falls_back_to_full(repository, base): commit(repo, 'docs/guide.md') decision = scope.select('pull_request', base, repository=repo) assert decision['run-heavy'] == 'true' + assert decision['run-desktop'] == 'true' assert decision['scope-reason'] == 'comparison_unavailable' def test_empty_diff_does_not_authorize_skip(repository): repo, base = repository - assert scope.select('pull_request', base, repository=repo)['scope-reason'] == 'empty_diff' + decision = scope.select('pull_request', base, repository=repo) + assert decision['scope-reason'] == 'empty_diff' + assert decision['run-desktop'] == 'true' @pytest.mark.parametrize('failure', [OSError('git unavailable'), subprocess.TimeoutExpired('git', 30)]) @@ -156,7 +177,7 @@ def test_real_selector_outputs_drive_real_aggregate(repository, tmp_path, event) decision = dict(line.split('=', 1) for line in output.read_text(encoding='utf-8').splitlines()) assert decision == json.loads(selected.stdout) results = {'static': {'result': 'success', 'outputs': decision}, - **{lane: {'result': 'skipped'} for lane in ['python', 'frontend', 'browser']}} + **{lane: {'result': 'skipped'} for lane in ['python', 'frontend', 'browser', 'desktop']}} aggregated = subprocess.run([sys.executable, str(ROOT / 'scripts/ci/summarize_checks.py')], env={**env, 'CHECK_RESULTS': json.dumps(results), 'STATIC_ENABLED': 'true'}, capture_output=True, text=True, encoding='utf-8') @@ -278,10 +299,25 @@ def test_workflow_wires_every_heavy_lane_to_successful_static_scope(): jobs = yaml.safe_load((ROOT / '.github/workflows/release-checks.yml').read_text(encoding='utf-8'))['jobs'] assert jobs['static']['steps'][-1]['id'] == 'scope' assert jobs['static']['steps'][-1]['run'] == 'python scripts/ci/select_checks.py' - assert set(jobs['static']['outputs']) == {'run-heavy', 'scope-reason', 'changed-files'} + assert set(jobs['static']['outputs']) == {'run-heavy', 'run-desktop', 'scope-reason', 'changed-files'} for lane in ['python', 'frontend', 'browser']: assert jobs[lane]['needs'] == 'static' assert "needs.static.result == 'success' && needs.static.outputs.run-heavy != 'false'" in jobs[lane]['if'] assert "!inputs.static-checks && needs.static.result == 'skipped'" in jobs[lane]['if'] assert jobs['checks']['if'] == 'always()' - assert set(jobs['checks']['needs']) == {'static', 'python', 'frontend', 'browser'} + assert set(jobs['checks']['needs']) == {'static', 'python', 'frontend', 'browser', 'desktop'} + + +def test_ci_and_release_share_read_only_installer_checks(): + def workflow(name): + return yaml.safe_load((ROOT / f'.github/workflows/{name}.yml').read_text(encoding='utf-8')) + + desktop = workflow('release-checks')['jobs']['desktop'] + assert desktop['needs'] == 'static' + assert "needs.static.outputs.run-desktop != 'false'" in desktop['if'] + assert '!inputs.static-checks' in desktop['if'] + assert desktop['uses'] == workflow('desktop-release')['jobs']['installers']['uses'] + installers = workflow('desktop-installers') + assert installers['permissions'] == {'contents': 'read'} + assert set(installers['jobs']) == {'macos', 'windows'} + assert workflow('desktop-release')['jobs']['attach-installers']['needs'] == 'installers' diff --git a/tests/test_ci_summary.py b/tests/test_ci_summary.py index 501a1b6b1..9f699a5e7 100644 --- a/tests/test_ci_summary.py +++ b/tests/test_ci_summary.py @@ -10,6 +10,7 @@ pytestmark = [pytest.mark.cpu, pytest.mark.ready] SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/ci/summarize_checks.py' +LANES = ['static', 'python', 'frontend', 'browser', 'desktop'] def run_summary(tmp_path, statuses, enabled=True, *, scope=None, event='pull_request'): @@ -28,16 +29,15 @@ def run_summary(tmp_path, statuses, enabled=True, *, scope=None, event='pull_req def test_success_writes_summary(tmp_path): - result, summary = run_summary(tmp_path, dict.fromkeys( - ['static', 'python', 'frontend', 'browser'], 'success')) + result, summary = run_summary(tmp_path, dict.fromkeys(LANES, 'success')) assert result.returncode == 0, result.stderr assert '| browser | success |' in summary.read_text(encoding='utf-8') -@pytest.mark.parametrize('lane', ['static', 'python', 'frontend', 'browser']) +@pytest.mark.parametrize('lane', LANES) @pytest.mark.parametrize('status', ['failure', 'cancelled', 'skipped']) def test_unsuccessful_required_lane_blocks_merge(tmp_path, lane, status): - statuses = dict.fromkeys(['static', 'python', 'frontend', 'browser'], 'success') + statuses = dict.fromkeys(LANES, 'success') statuses[lane] = status result, _ = run_summary(tmp_path, statuses) assert result.returncode != 0 @@ -47,7 +47,7 @@ def test_unsuccessful_required_lane_blocks_merge(tmp_path, lane, status): def test_static_failure_and_skipped_test_jobs_do_not_pass(tmp_path): result, _ = run_summary(tmp_path, { 'static': 'failure', 'python': 'skipped', - 'frontend': 'skipped', 'browser': 'skipped', + 'frontend': 'skipped', 'browser': 'skipped', 'desktop': 'skipped', }) assert result.returncode != 0 @@ -55,21 +55,21 @@ def test_static_failure_and_skipped_test_jobs_do_not_pass(tmp_path): def test_intentionally_disabled_static_lane_is_allowed(tmp_path): result, _ = run_summary(tmp_path, { 'static': 'skipped', 'python': 'success', - 'frontend': 'success', 'browser': 'success', + 'frontend': 'success', 'browser': 'success', 'desktop': 'success', }, enabled=False) assert result.returncode == 0, result.stderr -@pytest.mark.parametrize('missing', ['static', 'python', 'frontend', 'browser']) +@pytest.mark.parametrize('missing', LANES) def test_missing_receipt_fails_closed(tmp_path, missing): - statuses = dict.fromkeys(['static', 'python', 'frontend', 'browser'], 'success') + statuses = dict.fromkeys(LANES, 'success') del statuses[missing] result, _ = run_summary(tmp_path, statuses) assert result.returncode != 0 -DOC_SCOPE = {'run-heavy': 'false', 'scope-reason': 'docs_only', 'changed-files': '2'} -DOC_RESULTS = {'static': 'success', 'python': 'skipped', 'frontend': 'skipped', 'browser': 'skipped'} +DOC_SCOPE = {'run-heavy': 'false', 'run-desktop': 'false', 'scope-reason': 'docs_only', 'changed-files': '2'} +DOC_RESULTS = {**dict.fromkeys(LANES, 'skipped'), 'static': 'success'} @pytest.mark.parametrize('event', ['pull_request', 'merge_group']) @@ -81,7 +81,7 @@ def test_proven_docs_only_skip_succeeds_and_reports_reason(tmp_path, event): assert '| browser | skipped |' in text -@pytest.mark.parametrize('lane', ['static', 'python', 'frontend', 'browser']) +@pytest.mark.parametrize('lane', LANES) @pytest.mark.parametrize('status', ['failure', 'cancelled']) @pytest.mark.parametrize('event', ['pull_request', 'merge_group']) def test_docs_only_never_hides_failed_or_cancelled_jobs(tmp_path, lane, status, event): @@ -110,9 +110,25 @@ def test_disabled_static_cannot_authorize_heavy_skip(tmp_path): assert result.returncode != 0 -@pytest.mark.parametrize('missing', ['static', 'python', 'frontend', 'browser']) +@pytest.mark.parametrize('missing', LANES) def test_docs_only_still_requires_every_lane_receipt(tmp_path, missing): statuses = dict(DOC_RESULTS) del statuses[missing] result, _ = run_summary(tmp_path, statuses, scope=DOC_SCOPE if missing != 'static' else None) assert result.returncode != 0 + + +@pytest.mark.parametrize('event,reason', [ + ('pull_request', 'non_documentation'), + ('merge_group', 'non_documentation'), + ('push', 'event_requires_full'), +]) +@pytest.mark.parametrize('status', ['skipped', 'failure', 'cancelled']) +def test_only_proven_desktop_skip_can_pass(tmp_path, event, reason, status): + statuses = {**dict.fromkeys(LANES, 'success'), 'desktop': status} + scope = {'run-heavy': 'true', 'run-desktop': 'false', 'scope-reason': reason, 'changed-files': '2'} + result, _ = run_summary(tmp_path, statuses, scope=scope, event=event) + assert (result.returncode == 0) == (status == 'skipped') + + unproven, _ = run_summary(tmp_path, statuses, scope={**scope, 'changed-files': '0'}, event=event) + assert unproven.returncode != 0