Open
Conversation
- `package.json` is bundled by `esbuild` because we depend on it in `actions-util.ts` - That is so we can access the `version` property - We now use `build.mjs` to define a constant for it instead - We also set this constant in `ava.setup.mjs` for tests - This reduces the size of the generated `.js` files and avoids changing them entirely in some cases
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the build and test setup so the bundled JavaScript no longer embeds the full package.json just to access the action version. Instead, the version is injected at build/test time via a __CODEQL_ACTION_VERSION__ constant.
Changes:
- Replace
require("../package.json")usage insrc/actions-util.tswith a build-defined__CODEQL_ACTION_VERSION__constant. - Update
build.mjsto readpackage.jsonand pass the version into esbuild viadefine. - Add AVA config/setup files to preload the version constant for unit tests, and remove the old AVA config block from
package.json.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/actions-util.ts | Uses __CODEQL_ACTION_VERSION__ instead of requiring package.json at runtime. |
| build.mjs | Loads package.json during build and injects the version via esbuild define. |
| ava.setup.mjs | Preloads a global version value for tests. |
| ava.config.mjs | Moves AVA configuration from package.json into a config file and preloads ava.setup.mjs. |
| eslint.config.mjs | Ignores the new AVA config/setup files (and other non-linted paths). |
| package.json | Removes embedded AVA configuration (now in ava.config.mjs). |
| lib/analyze-action.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/analyze-action-post.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/autobuild-action.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/init-action.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/init-action-post.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/resolve-environment-action.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/setup-codeql-action.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/start-proxy-action.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/start-proxy-action-post.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/upload-lib.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/upload-sarif-action.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
| lib/upload-sarif-action-post.js | Generated bundle updated to inline the version constant and omit bundling root package.json. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, we bundle the entire contents of
package.jsonin our generated JavaScript files. This is because we depend on the"version"property inactions-util.ts.This PR changes this so that we load
package.jsoninbuild.mjs, retrieve theversion, and use it to define a constant named__CODEQL_ACTION_VERSION__that's available to the bundled code instead. Therefore, we no longer depend onpackage.json, andesbuildomits it.To allow the tests to continue functioning (which don't go through the build process first), an equivalent change for
avanow runsava.setup.mjsbefore tests which also loadspackage.jsonand sets__CODEQL_ACTION_VERSION__to theversionvalue.Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, Code Quality, ...).Products:
analysis-kinds: code-scanning.analysis-kinds: code-quality.upload-sarifaction.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist