Skip to content

Commit 672e253

Browse files
Support splitting of DB creation and query execution
1 parent 7726ece commit 672e253

12 files changed

Lines changed: 178 additions & 67 deletions

File tree

.github/workflows/pr-checks.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ jobs:
119119
with:
120120
config-file: ".github/codeql/codeql-config-packaging.yml"
121121
languages: javascript
122-
# TODO: this can be removed when cli v2.5.6 is released and available in the tool cache
123-
tools: https://github.com/dsp-testing/aeisenberg-codeql-action-packaging/releases/download/codeql-bundle-20210615/codeql-bundle-linux64.tar.gz
124-
122+
tools: latest
125123
- name: Build code
126124
shell: bash
127125
run: ./build.sh
@@ -234,6 +232,54 @@ jobs:
234232
exit 1
235233
fi
236234
235+
# Tests a split workflow where database construction and query execution happen in different steps
236+
test-split-workflow:
237+
needs: [check-js, check-node-modules]
238+
runs-on: ubuntu-latest
239+
240+
steps:
241+
- uses: actions/checkout@v2
242+
- name: Move codeql-action
243+
shell: bash
244+
run: |
245+
mkdir ../action
246+
mv * .github ../action/
247+
mv ../action/tests/multi-language-repo/{*,.github} .
248+
mv ../action/.github/workflows .github
249+
- uses: ./../action/init
250+
with:
251+
config-file: ".github/codeql/codeql-config-packaging3.yml"
252+
packs: +dsp-testing/codeql-pack1@0.0.4
253+
languages: javascript
254+
# TODO: this can be removed when cli v2.5.6 is released and available in the tool cache
255+
tools: https://github.com/dsp-testing/aeisenberg-codeql-action-packaging/releases/download/codeql-bundle-20210615/codeql-bundle-linux64.tar.gz
256+
257+
- name: Build code
258+
shell: bash
259+
run: ./build.sh
260+
- uses: ./../action/analyze
261+
with:
262+
skip-queries: true
263+
env:
264+
TEST_MODE: true
265+
- uses: ./../action/analyze
266+
with:
267+
output: "${{ runner.temp }}/results"
268+
env:
269+
TEST_MODE: true
270+
- name: Assert Results
271+
run: |
272+
cd "$RUNNER_TEMP/results"
273+
# We should have 3 hits from these rules
274+
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
275+
276+
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
277+
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
278+
echo "Found matching rules '$RULES'"
279+
if [ "$RULES" != "$EXPECTED_RULES" ]; then
280+
echo "Did not match expected rules '$EXPECTED_RULES'."
281+
exit 1
282+
fi
237283
238284
# Identify the CodeQL tool versions to integration test against.
239285
check-codeql-versions:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## [UNRELEASED]
44

55
- Fix `RUNNER_TEMP environment variable must be set` when using runner.
6+
- The `analyze` step now supports a `skip-queries` option to merely build the CodeQL database without analyzing.
7+
68
## 1.0.3 - 23 Jun 2021
79

810
No user facing changes.

analyze/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ inputs:
2424
description: Specify whether or not to add code snippets to the output sarif file.
2525
required: false
2626
default: "false"
27+
skip-queries:
28+
description: If this option is set, the CodeQL database will be built but no queries will be run on it. Thus, no results will be produced.
29+
required: false
30+
default: "false"
2731
threads:
2832
description: The number of threads to be used by CodeQL.
2933
required: false

lib/analyze-action.js

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

lib/analyze-action.js.map

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

lib/analyze.js

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

0 commit comments

Comments
 (0)