Skip to content

Commit fb48112

Browse files
committed
Bundle action using esbuild
Remove node_modules from repository to reduce cost to download repository. Because node_modules is no longer included: * If `npm` isn't available (e.g. in a container), install it * Run `npm install` before performing various tasks Change pr-checks to not be particularly picky about the generated content because it will differ between different versions as everything is bundled together.
1 parent 5ac2ddd commit fb48112

File tree

18,887 files changed

+3125
-4740773
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

18,887 files changed

+3125
-4740773
lines changed

.github/actions/prepare-test/action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ outputs:
1919
runs:
2020
using: composite
2121
steps:
22+
- name: npm install
23+
shell: bash
24+
run: |
25+
if command -v npm >/dev/null 2>/dev/null; then
26+
npm ci
27+
fi
2228
- name: Move codeql-action
2329
shell: bash
2430
run: |

.github/actions/update-bundle/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ runs:
88
shell: bash
99
run: npm install -g ts-node
1010

11+
- name: Install
12+
shell: bash
13+
run: npm ci
14+
1115
- name: Run update script
1216
working-directory: ${{ github.action_path }}
1317
shell: bash

.github/workflows/pr-checks.yml

+19
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- name: Checkout
2727
uses: actions/checkout@v4
2828

29+
- name: Install
30+
run: npm install
31+
2932
- name: Lint
3033
id: lint
3134
run: npm run-script lint-ci
@@ -52,6 +55,16 @@ jobs:
5255
# `npm install` on Linux.
5356
npm install
5457
58+
(
59+
echo '*/*-action.js';
60+
echo '*/*-action-post.js'
61+
) >> .gitignore
62+
for action in $(
63+
find * -mindepth 1 -maxdepth 1 -type f -name action.yml
64+
); do
65+
git rm -f "$(dirname "$action")"/*-action*.js
66+
done
67+
5568
if [ ! -z "$(git status --porcelain)" ]; then
5669
git config --global user.email "[email protected]"
5770
git config --global user.name "github-actions[bot]"
@@ -112,6 +125,12 @@ jobs:
112125

113126
steps:
114127
- uses: actions/checkout@v4
128+
- name: npm install
129+
run: |
130+
npm ci
131+
- name: Build
132+
run: |
133+
npm run build
115134
- name: npm test
116135
run: |
117136
# Run any commands referenced in package.json using Bash, otherwise

.gitignore

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# Ignore for example failing-tests.json from AVA
2-
node_modules/.cache/
1+
# actions are bundled to make this repository lightweight for consumers
2+
node_modules/
3+
# lib is generated by tsc
4+
lib
35
# Java build files
46
.gradle/
57
*.class
@@ -8,4 +10,4 @@ node_modules/.cache/
810
# eslint sarif report
911
eslint.sarif
1012
# for local incremental compilation
11-
tsconfig.tsbuildinfo
13+
tsconfig.tsbuildinfo

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Note that the only difference between `v2` and `v3` of the CodeQL Action is the
77
## [UNRELEASED]
88

99
- The CodeQL Action now downloads bundles compressed using Zstandard on GitHub Enterprise Server when using Linux or macOS runners. This speeds up the installation of the CodeQL tools. This feature is already available to GitHub.com users. [#2573](https://github.com/github/codeql-action/pull/2573)
10+
- The CodeQL Action no longer includes node_modules. This should drammatically decrease the download size/increase download speed for `uses: github/codeql-action@...`.
1011

1112
## 3.27.0 - 22 Oct 2024
1213

CONTRIBUTING.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,15 @@ Before you start, ensure that you have a recent version of node (16 or higher) i
1717

1818
### Common tasks
1919

20-
* Transpile the TypeScript to JavaScript: `npm run build`. Note that the JavaScript files are committed to git.
21-
* Run tests: `npm run test`. You’ll need to ensure that the JavaScript files are up-to-date first by running the command above.
22-
* Run the linter: `npm run lint`.
20+
* Set up node: `npm ci`
21+
* Transpile the TypeScript to JavaScript: `npm run build`. Note that the bundled action files are committed to git.
22+
* Run tests: `npm run test`. You’ll need to ensure that the `node_modules` are available andJavaScript files are up-to-date first by running the commands above.
23+
* Run the linter: `npm run lint` (requires the first command).
2324

2425
This project also includes configuration to run tests from VSCode (with support for breakpoints) - open the test file you wish to run and choose "Debug AVA test file" from the Run menu in the Run panel.
2526

2627
You may want to run `tsc --watch` from the command line or inside of vscode in order to ensure build artifacts are up to date as you are working.
2728

28-
### Checking in compiled artifacts and `node_modules`
29-
30-
Because CodeQL Action users consume the code directly from this repository, and there can be no build step during an GitHub Actions run, this repository contains all compiled artifacts and node modules. There is a PR check that will fail if any of the compiled artifacts are not up to date. Compiled artifacts are stored in the `lib/` directory. For all day-to-day development purposes, this folder can be ignored.
31-
32-
Only run `npm install` if you are explicitly changing the set of dependencies in `package.json`. The `node_modules` directory should be up to date when you check out, but if for some reason, there is an inconsistency use `npm ci && npm run removeNPMAbsolutePaths` to ensure the directory is in a state consistent with the `package-lock.json`. Note that due to a macOS-specific dependency, this command should be run on a macOS machine. There is a PR check to ensure the consistency of the `node_modules` directory.
33-
3429
### Running the action
3530

3631
To see the effect of your changes and to test them, push your changes in a branch and then look at the [Actions output](https://github.com/github/codeql-action/actions) for that branch. You can also exercise the code locally by running the automated tests.

analyze/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,5 @@ outputs:
9292
description: The ID of the uploaded SARIF file.
9393
runs:
9494
using: node20
95-
main: "../lib/analyze-action.js"
96-
post: "../lib/analyze-action-post.js"
95+
main: "analyze-action.js"
96+
post: "analyze-action-post.js"

analyze/analyze-action-post.js

+379
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

analyze/analyze-action.js

+230
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

autobuild/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ inputs:
1616
required: false
1717
runs:
1818
using: node20
19-
main: '../lib/autobuild-action.js'
19+
main: 'autobuild-action.js'

autobuild/autobuild-action.js

+180
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export default [
3131
"tests/**/*",
3232
"eslint.config.mjs",
3333
".github/**/*",
34+
"*/*-action.js",
35+
"*/*-action-post.js",
3436
],
3537
},
3638
...fixupConfigRules(

init/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,5 @@ outputs:
147147
description: The version of the CodeQL binary used for analysis
148148
runs:
149149
using: node20
150-
main: '../lib/init-action.js'
151-
post: '../lib/init-action-post.js'
150+
main: 'init-action.js'
151+
post: 'init-action-post.js'

init/init-action-post.js

+379
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

init/init-action.js

+187
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)