GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||
GeezerVison is showing github.com — Improve esbuild metadata usage by mbg · Pull Request #3808 · github/codeql-action Conversation
|
| File | Description |
|---|---|
pr-checks/sync-checks.ts |
Reuses shared API client constants and shared --token CLI parsing config. |
pr-checks/config.ts |
Adds a baseline metadata file path constant used by the comparison script. |
pr-checks/bundle-metadata.ts |
Adds baseline download + unzip + comparison logic for bundle metadata. |
pr-checks/api-client.ts |
Centralizes CODEQL_ACTION_REPO and shared token option config for PR-check scripts. |
package.json |
Removes bundle-metadata script invocation from npm run build. |
.github/workflows/pr-checks.yml |
Uploads meta.json as an artifact for later baseline comparison. |
pr-checks/bundle-metadata.ts:149
filesInBaseline.difference(filesInCurrent) relies on Set.prototype.difference, which is not available in Node 20 and will throw at runtime for anyone running this script under the repo’s minimum-supported Node version. Consider computing the set difference manually (or using a small helper) to avoid depending on these newer Set methods. const filesInBaseline = new Set(Object.keys(baselineMetadata.outputs));
const filesInCurrent = new Set(Object.keys(metadata.outputs));
const filesNotPresent = filesInBaseline.difference(filesInCurrent);
if (filesNotPresent.size > 0) {
console.info(`Found ${filesNotPresent.size} file(s) which were removed:`);
for (const removedFile of filesNotPresent) {
console.info(` - ${removedFile}`);
}
}
pr-checks/bundle-metadata.ts:115
-d "." (current working directory), but the script then asserts that BASELINE_BUNDLE_METADATA_FILE (based on __dirname/PR_CHECKS_DIR) exists. If the script is invoked from the repo root (e.g. npx tsx ./pr-checks/bundle-metadata.ts), the extracted meta.json will land in the repo root and this check will fail. Use an explicit extraction directory (e.g. PR_CHECKS_DIR or a temp dir) and write/read the archive and extracted file using absolute paths so the script doesn’t depend on the caller’s CWD. const archivePath = `${expectedArtifactName}.zip`;
await fs.writeFile(archivePath, Buffer.from(downloadInfo.data));
console.info(`Extracting zip file: ${archivePath}`);
await exec.exec("unzip", ["-o", archivePath, "-d", "."]);
// We no longer need the archive after unzipping it.
await fs.rm(archivePath);
// Check that we have the expected file.
try {
await fs.stat(BASELINE_BUNDLE_METADATA_FILE);
} catch (err) {
throw new Error(
`Expected '${BASELINE_BUNDLE_METADATA_FILE}' to have been extracted, but it does not exist: ${err}`,
);
}
pr-checks/bundle-metadata.ts:107
unzip -o directly into the working directory. This can overwrite local files and exposes you to zip-slip/path traversal risks if the artifact contents are ever attacker-controlled (e.g. comparing against an untrusted branch). Extract into a dedicated temporary directory and only read the expected meta.json from that directory (and consider validating the extracted path) to reduce the blast radius. console.info(`Extracting zip file: ${archivePath}`);
await exec.exec("unzip", ["-o", archivePath, "-d", "."]);
// We no longer need the archive after unzipping it.
await fs.rm(archivePath);
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of highlighting changes that will affect how long it takes for clients to download the CodeQL Action. However my understanding is that clients will download the entire contents of the repository, especially now that the Actions packaging experiment has been discontinued. By measuring just the size of the compiled artifacts I think we risk missing other changes that would slow down clients.
I would encourage us to try to measure and optimise for the client Action download time as best as possible, perhaps by having a PR check that finds out the change in the size of the entire contents of the repo?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
That's not necessarily the primary/sole motivation. Analysing the bundle metadata can also help us understand whether/when we end up bundling things that don't have to be bundled and that might lead to unnecessary (or unnecessarily large) bundle changes.
We could do that separately from this, or think again about whether we can find a way to tag an optimised version of the repo that only contains the bundles. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Analysing the bundle metadata can also help us understand whether/when we end up bundling things that don't have to be bundled and that might lead to unnecessary (or unnecessarily large) bundle changes.
Is there a reason that we'd care about that other than it taking longer to download the Action? If not, then I think it makes more sense from a complexity point of view to just measure the size of the repo.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Diff sizes / potential merge conflicts is one. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing this for now, since we merged #3884. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.