Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/actions/install-codeql-packs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ inputs:
The path to the CodeQL CLI directory.
required: false

common_caches:
description: |
The path to the CodeQL common caches directory.
required: false

mode:
description: |
The `--mode` option to `codeql pack install`.
Expand All @@ -22,4 +27,6 @@ runs:
CODEQL_CLI: ${{ inputs.cli_path }}
run: |
PATH=$PATH:$CODEQL_CLI
python scripts/install-packs.py --mode ${{ inputs.mode }}
python scripts/install-packs.py \
--mode ${{ inputs.mode }} \
--common-caches "${{ inputs.common_caches }}"
19 changes: 14 additions & 5 deletions .github/workflows/codeql_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ on:
- "rc/**"

jobs:

prepare-unit-test-matrix:
name: Prepare CodeQL unit test matrix
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -59,7 +58,7 @@ jobs:

- name: Cache CodeQL
id: cache-codeql
uses: actions/cache@v5
uses: actions/cache@v6
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ${{github.workspace}}/codeql_home
Expand All @@ -75,16 +74,26 @@ jobs:
codeql-home: ${{ github.workspace }}/codeql_home
add-to-path: false

- name: Cache queries compilation
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/codeql_cache
key: ${{ runner.os }}-codeql-compilation-${{ matrix.language }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}-${{ github.run_id }}
restore-keys: ${{ runner.os }}-codeql-compilation-${{ matrix.language }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}

- name: Install CodeQL packs
uses: ./.github/actions/install-codeql-packs
with:
cli_path: ${{ github.workspace }}/codeql_home/codeql
common_caches: ${{ github.workspace }}/codeql_cache

- name: Pre-Compile Queries
id: pre-compile-queries
run: |
${{ github.workspace }}/codeql_home/codeql/codeql query compile --threads 0 ${{ matrix.language }}

${{ github.workspace }}/codeql_home/codeql/codeql query compile \
--common-caches=${{ github.workspace }}/codeql_cache \
--threads 0 \
${{ matrix.language }}

- name: Run test suites
id: run-test-suites
Expand Down Expand Up @@ -135,7 +144,7 @@ jobs:
os.makedirs(os.path.dirname(test_report_path), exist_ok=True)
test_report_file = open(test_report_path, 'w')
files_to_close.append(test_report_file)
procs.append(subprocess.Popen([codeql_bin, "test", "run", "--failing-exitcode=122", f"--slice={slice}/{num_slices}", "--ram=2048", "--format=json", *test_roots], stdout=test_report_file, stderr=subprocess.PIPE))
procs.append(subprocess.Popen([codeql_bin, "test", "run", "--common-caches=${{ github.workspace }}/codeql_cache", "--failing-exitcode=122", f"--slice={slice}/{num_slices}", "--ram=2048", "--format=json", *test_roots], stdout=test_report_file, stderr=subprocess.PIPE))

for p in procs:
_, err = p.communicate()
Expand Down
3 changes: 3 additions & 0 deletions scripts/install-packs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
parser = argparse.ArgumentParser(description="Install CodeQL library pack dependencies.")
parser.add_argument('--mode', required=False, choices=['use-lock', 'update', 'verify', 'no-lock'], default="use-lock", help="Installation mode, identical to the `--mode` argument to `codeql pack install`")
parser.add_argument('--codeql', required=False, default='codeql', help="Path to the `codeql` executable.")
parser.add_argument('--common-caches', required=False, help="Path to the CodeQL common caches directory.")
args = parser.parse_args()

# Find the root of the repo
Expand All @@ -19,5 +20,7 @@
pack_path = os.path.join(root, pack)
# Run `codeql pack install` to install dependencies.
command = [args.codeql, 'pack', 'install', '--allow-prerelease', '--mode', args.mode, pack_path]
if args.common_caches:
command.insert(3, f'--common-caches={args.common_caches}')
print(f'Running `{" ".join(command)}`')
subprocess.check_call(command)
Loading