Skip to content

Commit 4293754

Browse files
authored
Merge pull request github#738 from github/cklin/extractor-ram-threads-options
Add RAM and threads options to init action
2 parents 2905689 + 70b730e commit 4293754

25 files changed

+631
-58
lines changed

.github/workflows/__extractor-ram-threads.yml

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/pr-checks.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,42 @@ jobs:
393393
# Deliberately don't use TEST_MODE here. This is specifically testing
394394
# the compatibility with the API.
395395
runner/dist/codeql-runner-linux upload --sarif-file src/testdata/empty-sarif.sarif --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
396+
397+
runner-extractor-ram-threads-options:
398+
name: Runner ubuntu extractor RAM and threads options
399+
needs: [check-js, check-node-modules]
400+
runs-on: ubuntu-latest
401+
402+
steps:
403+
- uses: actions/checkout@v2
404+
405+
- name: Build runner
406+
run: |
407+
cd runner
408+
npm install
409+
npm run build-runner
410+
411+
- name: Run init
412+
run: |
413+
runner/dist/codeql-runner-linux init --ram=230 --threads=1 --repository $GITHUB_REPOSITORY --languages java --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
414+
415+
- name: Assert Results
416+
shell: bash
417+
run: |
418+
. ./codeql-runner/codeql-env.sh
419+
if [ "${CODEQL_RAM}" != "230" ]; then
420+
echo "CODEQL_RAM is '${CODEQL_RAM}' instead of 230"
421+
exit 1
422+
fi
423+
if [ "${CODEQL_EXTRACTOR_JAVA_RAM}" != "230" ]; then
424+
echo "CODEQL_EXTRACTOR_JAVA_RAM is '${CODEQL_EXTRACTOR_JAVA_RAM}' instead of 230"
425+
exit 1
426+
fi
427+
if [ "${CODEQL_THREADS}" != "1" ]; then
428+
echo "CODEQL_THREADS is '${CODEQL_THREADS}' instead of 1"
429+
exit 1
430+
fi
431+
if [ "${CODEQL_EXTRACTOR_JAVA_THREADS}" != "1" ]; then
432+
echo "CODEQL_EXTRACTOR_JAVA_THREADS is '${CODEQL_EXTRACTOR_JAVA_THREADS}' instead of 1"
433+
exit 1
434+
fi

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## [UNRELEASED]
44

5-
No user facing changes.
5+
- The `init` step of the Action now supports `ram` and `threads` inputs to limit resource use of CodeQL extractors. These inputs also serve as defaults to the subsequent `analyze` step, which finalizes the database and executes queries. [#738](https://github.com/github/codeql-action/pull/738)
66

77
## 1.0.21 - 28 Oct 2021
88

analyze/action.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ inputs:
1818
required: false
1919
default: "brutal"
2020
ram:
21-
description: Override the amount of memory in MB to be used by CodeQL. By default, almost all the memory of the machine is used.
21+
description: >-
22+
The amount of memory in MB that can be used by CodeQL for database finalization and query execution.
23+
By default, this action will use the same amount of memory as previously set in the "init" action.
24+
If the "init" action also does not have an explicit "ram" input, this action will use most of the
25+
memory available in the system (which for GitHub-hosted runners is 6GB for Linux, 5.5GB for Windows,
26+
and 13GB for macOS).
2227
required: false
2328
add-snippets:
2429
description: Specify whether or not to add code snippets to the output sarif file.
@@ -29,7 +34,12 @@ inputs:
2934
required: false
3035
default: "false"
3136
threads:
32-
description: The number of threads to be used by CodeQL.
37+
description: >-
38+
The number of threads that can be used by CodeQL for database finalization and query execution.
39+
By default, this action will use the same number of threads as previously set in the "init" action.
40+
If the "init" action also does not have an explicit "threads" input, this action will use all the
41+
hardware threads available in the system (which for GitHub-hosted runners is 2 for Linux and Windows
42+
and 3 for macOS).
3343
required: false
3444
checkout_path:
3545
description: "The path at which the analyzed repository was checked out. Used to relativize any absolute paths in the uploaded SARIF file."

init/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ inputs:
4141
source-root:
4242
description: Path of the root source code directory, relative to $GITHUB_WORKSPACE.
4343
required: false
44+
ram:
45+
description: >-
46+
The amount of memory in MB that can be used by CodeQL extractors.
47+
By default, CodeQL extractors will use most of the memory available in the system
48+
(which for GitHub-hosted runners is 6GB for Linux, 5.5GB for Windows, and 13GB for macOS).
49+
This input also sets the amount of memory that can later be used by the "analyze" action.
50+
required: false
51+
threads:
52+
description: >-
53+
The number of threads that can be used by CodeQL extractors.
54+
By default, CodeQL extractors will use all the hardware threads available in the system
55+
(which for GitHub-hosted runners is 2 for Linux and Windows and 3 for macOS).
56+
This input also sets the number of threads that can later be used by the "analyze" action.
57+
required: false
4458
outputs:
4559
codeql-path:
4660
description: The path of the CodeQL binary used for analysis

lib/analyze-action-env.test.js

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action-env.test.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action-input.test.js

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action-input.test.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)