Skip to content

Commit 2e094e9

Browse files
committed
Add save-qlt-cache, bundle-codeql-packs, run-qlt-unit-tests actions
Companion actions to the extended install-qlt: save-qlt-cache persists its cache-dir/cache-primary-key outputs, bundle-codeql-packs wraps `codeql pack bundle` for a data-driven list of packs, and run-qlt-unit-tests wraps `qlt test run execute-unit-tests`/`validate-unit-tests` for a single language.
1 parent 8a46b66 commit 2e094e9

3 files changed

Lines changed: 124 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Bundle CodeQL packs
2+
description: |
3+
Bundles a set of CodeQL query packs via `codeql pack bundle`, reusing the cache
4+
directory populated by the `install-qlt` action. This wraps the CLI directly rather than
5+
a `qlt pack` subcommand, since QLT's own pack-publication CLI surface wasn't verified
6+
when this action was written; it can be swapped for a native `qlt pack bundle` call
7+
once that's confirmed.
8+
inputs:
9+
codeql-bin:
10+
description: Path to the `codeql` binary, e.g. the `codeql-bin` output of `install-qlt`.
11+
required: true
12+
13+
cache-dir:
14+
description: The cache directory to pass as `--common-caches`, e.g. the `cache-dir` output of `install-qlt`.
15+
required: true
16+
17+
packs:
18+
description: |
19+
One `<output-file>.tgz <pack-src-path>` pair per line, e.g.:
20+
common-cpp-coding-standards.tgz cpp/common/src
21+
common-c-coding-standards.tgz c/common/src
22+
required: true
23+
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Bundle packs
28+
shell: bash
29+
env:
30+
CODEQL_BIN: ${{ inputs.codeql-bin }}
31+
CACHE_DIR: ${{ inputs.cache-dir }}
32+
PACKS: ${{ inputs.packs }}
33+
run: |
34+
while read -r output pack_path; do
35+
[ -z "$output" ] && continue
36+
echo "::debug::Bundling $pack_path -> $output"
37+
"$CODEQL_BIN" pack bundle --common-caches="$CACHE_DIR" --output="$output" "$pack_path"
38+
done <<< "$PACKS"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Run and validate CodeQL unit tests via QLT
2+
description: |
3+
Runs the repository's unit tests for a given language via `qlt test run
4+
execute-unit-tests`, then validates the results via `qlt test run
5+
validate-unit-tests`, failing the step if any test failed.
6+
7+
Replaces a hand-rolled `codeql test run` slicing script plus a separate
8+
results-validation job with QLT's own test-running/validation subcommands.
9+
Unverified: whether QLT's runner supports the same degree of parallelism/RAM
10+
tuning as the `--slice`/`--ram` flags used by the script it replaces.
11+
inputs:
12+
language:
13+
description: The language to run tests for, e.g. `cpp` or `c`.
14+
required: true
15+
16+
num-threads:
17+
description: Number of threads to use for the test runner.
18+
required: false
19+
default: "8"
20+
21+
work-dir:
22+
description: Where to place intermediate execution output files.
23+
required: false
24+
default: ${{ runner.temp }}
25+
26+
base:
27+
description: The base path to find the query repository.
28+
required: false
29+
default: ${{ github.workspace }}
30+
31+
codeql-args:
32+
description: Extra arguments to pass through to CodeQL.
33+
required: false
34+
default: ""
35+
36+
outputs:
37+
results-directory:
38+
description: The directory containing the raw test execution results.
39+
value: ${{ inputs.work-dir }}
40+
41+
runs:
42+
using: composite
43+
steps:
44+
- name: Execute unit tests
45+
shell: bash
46+
run: |
47+
qlt test run execute-unit-tests \
48+
--num-threads "${{ inputs.num-threads }}" \
49+
--language "${{ inputs.language }}" \
50+
--runner-os "${{ runner.os }}" \
51+
--work-dir "${{ inputs.work-dir }}" \
52+
--base "${{ inputs.base }}" \
53+
--automation-type actions \
54+
${{ inputs.codeql-args != '' && format('--codeql-args "{0}"', inputs.codeql-args) || '' }}
55+
56+
- name: Validate unit test results
57+
shell: bash
58+
run: |
59+
# Deliberately omit --pretty-print: per QLT's own docs, that mode does not
60+
# exit with a failure code on test failures, which we need for CI gating.
61+
qlt test run validate-unit-tests \
62+
--results-directory "${{ inputs.work-dir }}" \
63+
--base "${{ inputs.base }}" \
64+
--automation-type actions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Save QLT cache
2+
description: |
3+
Persists the cache directory populated by the `install-qlt` action (downloaded bundle and
4+
compiled query artifacts) so subsequent runs can reuse it. Call this at the end of the job,
5+
typically with `if: always()` so the cache is saved even if the test run failed.
6+
inputs:
7+
cache-dir:
8+
description: The cache directory output by the `install-qlt` action.
9+
required: true
10+
11+
cache-primary-key:
12+
description: The cache-primary-key output by the `install-qlt` action.
13+
required: true
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Save QLT cache
19+
uses: actions/cache/save@v6
20+
with:
21+
path: ${{ inputs.cache-dir }}
22+
key: ${{ inputs.cache-primary-key }}

0 commit comments

Comments
 (0)