-
Notifications
You must be signed in to change notification settings - Fork 308
ci(windows): gate packaged sandbox lifecycle evidence #3558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
liugddx
wants to merge
3
commits into
apache:main
Choose a base branch
from
liugddx:ci/windows-sandbox-lifecycle-gate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { existsSync, readFileSync } from 'node:fs'; | ||
| import { extname, join, relative, resolve, sep } from 'node:path'; | ||
| import { build } from 'esbuild'; | ||
| import { parse as parseYaml } from 'yaml'; | ||
|
|
||
| const defaultRepoRoot = resolve(import.meta.dirname, '..'); | ||
| const sourceExtensions = ['.ts', '.tsx', '.mts', '.cts', '.js', '.mjs', '.cjs', '.json']; | ||
|
|
||
| export const windowsPackageSourceEntrypoints = [ | ||
| 'packages/runtime/src/filesystem-worker/index.ts', | ||
| 'packages/runtime/src/filesystem-worker/worker-entry.ts', | ||
| 'packages/runtime/src/sandbox/index.ts', | ||
| ]; | ||
|
|
||
| export async function collectWindowsPackageSourceClosure(repoRoot = defaultRepoRoot) { | ||
| const workspaces = loadWorkspacePackages(repoRoot); | ||
| const result = await build({ | ||
| absWorkingDir: repoRoot, | ||
| bundle: true, | ||
| entryPoints: windowsPackageSourceEntrypoints, | ||
| format: 'esm', | ||
| logLevel: 'silent', | ||
| metafile: true, | ||
| outdir: 'windows-package-source-closure', | ||
| packages: 'external', | ||
| platform: 'node', | ||
| plugins: [workspaceSourcePlugin(repoRoot, workspaces)], | ||
| treeShaking: false, | ||
| write: false, | ||
| }); | ||
| return Object.keys(result.metafile.inputs) | ||
| .map(normalize) | ||
| .filter((path) => path.startsWith('packages/')) | ||
| .sort(); | ||
| } | ||
|
|
||
| export function readWindowsReleasePathPatterns(repoRoot = defaultRepoRoot) { | ||
| const workflowPath = join(repoRoot, '.github', 'workflows', 'release-windows-check.yml'); | ||
| const workflow = parseYaml(readFileSync(workflowPath, 'utf8')); | ||
| const paths = workflow?.on?.pull_request?.paths; | ||
| if (!Array.isArray(paths) || !paths.every((path) => typeof path === 'string')) { | ||
| throw new Error('Release Windows check must declare pull_request.paths as strings.'); | ||
| } | ||
| return paths; | ||
| } | ||
|
|
||
| export function windowsReleasePatternCoversSource(path, pattern) { | ||
| if (path === pattern) return true; | ||
| return pattern.endsWith('/**') && path.startsWith(pattern.slice(0, -2)); | ||
| } | ||
|
|
||
| function workspaceSourcePlugin(repoRoot, workspaces) { | ||
| return { | ||
| name: 'maka-workspace-source', | ||
| setup(esbuild) { | ||
| esbuild.onResolve({ filter: /^@maka\// }, ({ path: specifier }) => { | ||
| const workspace = [...workspaces.values()].find( | ||
| ({ name }) => specifier === name || specifier.startsWith(`${name}/`), | ||
| ); | ||
| if (!workspace) return undefined; | ||
| const subpath = | ||
| specifier === workspace.name ? '.' : `.${specifier.slice(workspace.name.length)}`; | ||
| const exported = exportTarget(workspace.manifest.exports?.[subpath]); | ||
| const candidate = exported | ||
| ? resolve(workspace.directory, exported.replace(/^\.\/dist\//u, './src/')) | ||
| : resolve(workspace.directory, 'src', specifier.slice(workspace.name.length + 1)); | ||
| return { path: resolveSourceCandidate(candidate, repoRoot, specifier) }; | ||
| }); | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function resolveSourceCandidate(candidate, repoRoot, specifier) { | ||
| const extension = extname(candidate); | ||
| const candidates = [candidate]; | ||
| if (['.js', '.mjs', '.cjs'].includes(extension)) { | ||
| const stem = candidate.slice(0, -extension.length); | ||
| candidates.push(...sourceExtensions.map((sourceExtension) => `${stem}${sourceExtension}`)); | ||
| } else if (!extension) { | ||
| candidates.push(...sourceExtensions.map((sourceExtension) => `${candidate}${sourceExtension}`)); | ||
| candidates.push( | ||
| ...sourceExtensions.map((sourceExtension) => join(candidate, `index${sourceExtension}`)), | ||
| ); | ||
| } | ||
| const resolved = candidates.find((path) => existsSync(path)); | ||
| if (!resolved || !normalize(relative(repoRoot, resolved)).startsWith('packages/')) { | ||
| throw new Error( | ||
| `Unable to resolve local Windows package import ${specifier} from ${candidate}`, | ||
| ); | ||
| } | ||
| return resolved; | ||
| } | ||
|
|
||
| function exportTarget(value) { | ||
| if (typeof value === 'string') return value; | ||
| if (!value || typeof value !== 'object') return undefined; | ||
| for (const condition of ['types', 'import', 'default']) { | ||
| const target = exportTarget(value[condition]); | ||
| if (target) return target; | ||
| } | ||
| return undefined; | ||
| } | ||
|
|
||
| function loadWorkspacePackages(repoRoot) { | ||
| const rootManifest = JSON.parse(readFileSync(join(repoRoot, 'package.json'), 'utf8')); | ||
| const result = new Map(); | ||
| for (const workspacePath of rootManifest.workspaces ?? []) { | ||
| const directory = resolve(repoRoot, workspacePath); | ||
| const manifest = JSON.parse(readFileSync(join(directory, 'package.json'), 'utf8')); | ||
| result.set(manifest.name, { directory, manifest, name: manifest.name }); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| function normalize(path) { | ||
| return path.split(sep).join('/'); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] This gate does not arm on changes to the workflow it exists to protect.
Anchoring here because the relevant line is outside this PR's diff — the allowlist entry for this workflow itself is at line 90 of the file.
The allowlist correctly includes this workflow itself at line 90, but omits
.github/workflows/release.yml— andrelease.yml:190-228is wherenpm run package:windows-x64,npm run verify:windows-x64, and the installer-lifecycle, autoupdate, and rollback verifications are actually invoked.Concretely: a future PR that touches only
release.ymlcan delete, reorder, or condition away any of those Windows verification steps, and this lane stays skipped. CI's Linux release-contract selection does not execute the Windows artifact or lifecycle path, so nothing else catches it either. The regression reaches main with no packaged-Windows evidence — which is the exact failure mode described in this file's own header comment.Worth noting the asymmetry as its own argument: the list already guards against edits to this file, so the principle that release wiring must re-arm the gate is one the file already accepts.
release.ymlis the more important half of that wiring.Minimal fix: add
.github/workflows/release.ymlto this allowlist, and assert the relationship in the path-filter contract test so it cannot silently drift out again.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed at exact head
f65dc9d154cf1e57d211ad7aad1dedcffc33da33..github/workflows/release.ymlpath torelease-windows-check.yml. This is the workflow that invokes the Windows package, release verification, installer upgrade/uninstall, autoupdate, and rollback steps.the packaged Windows gate triggers on release orchestration changestoscripts/ci-test-plan.test.mjs, so the relationship cannot silently drift..github/workflows/**glob, no release workflow behavior change, and no Runtime/broker changes.Fresh exact-head evidence is green:
The original source-closure finding and this control-plane trigger finding are now both covered. Please re-review this exact head.