From ed476d12d364c2f36fc371061598bd3b2c769554 Mon Sep 17 00:00:00 2001 From: Mauro Baluda Date: Wed, 26 Aug 2026 22:22:08 +0200 Subject: [PATCH 1/6] Upgrade CodeQL caching and dependencies installation Updated CodeQL workflow to use caching --- .github/workflows/codeql_unit_tests.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/codeql_unit_tests.yml b/.github/workflows/codeql_unit_tests.yml index 23d6972a1..400fe8d2b 100644 --- a/.github/workflows/codeql_unit_tests.yml +++ b/.github/workflows/codeql_unit_tests.yml @@ -17,7 +17,6 @@ on: - "rc/**" jobs: - prepare-unit-test-matrix: name: Prepare CodeQL unit test matrix runs-on: ubuntu-22.04 @@ -58,16 +57,15 @@ jobs: run: pip install -r scripts/requirements.txt - 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 - # An explicit key for restoring and saving the cache - key: codeql-home-${{matrix.os}}-${{matrix.codeql_cli}}-${{matrix.codeql_standard_library}} + path: ~/.codeql + key: ${{ runner.os }}-codeql-cache-${{ matrix.language }}-${{ matrix.codeql_cli }}-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-codeql-cache-${{ matrix.language }}-${{ matrix.codeql_cli }} + ${{ runner.os }}-codeql-cache-${{ matrix.language }} - name: Install CodeQL - if: steps.cache-codeql.outputs.cache-hit != 'true' uses: ./.github/actions/install-codeql with: codeql-cli-version: ${{ matrix.codeql_cli }} @@ -83,8 +81,7 @@ jobs: - 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 --threads 0 ${{ matrix.language }} - name: Run test suites id: run-test-suites From 5905fe79f4b0284456260507e53722a3818244d6 Mon Sep 17 00:00:00 2001 From: Mauro Baluda Date: Wed, 26 Aug 2026 22:37:25 +0200 Subject: [PATCH 2/6] Refactor CodeQL caching in workflow Updated caching strategy for CodeQL to use a new path and key format. --- .github/workflows/codeql_unit_tests.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql_unit_tests.yml b/.github/workflows/codeql_unit_tests.yml index 400fe8d2b..dc1069ab1 100644 --- a/.github/workflows/codeql_unit_tests.yml +++ b/.github/workflows/codeql_unit_tests.yml @@ -57,15 +57,16 @@ jobs: run: pip install -r scripts/requirements.txt - name: Cache CodeQL + id: cache-codeql uses: actions/cache@v6 with: - path: ~/.codeql - key: ${{ runner.os }}-codeql-cache-${{ matrix.language }}-${{ matrix.codeql_cli }}-${{ github.run_id }} - restore-keys: | - ${{ runner.os }}-codeql-cache-${{ matrix.language }}-${{ matrix.codeql_cli }} - ${{ runner.os }}-codeql-cache-${{ matrix.language }} + # A list of files, directories, and wildcard patterns to cache and restore + path: ${{github.workspace}}/codeql_home + # An explicit key for restoring and saving the cache + key: codeql-home-${{matrix.os}}-${{matrix.codeql_cli}}-${{matrix.codeql_standard_library}} - name: Install CodeQL + if: steps.cache-codeql.outputs.cache-hit != 'true' uses: ./.github/actions/install-codeql with: codeql-cli-version: ${{ matrix.codeql_cli }} @@ -73,6 +74,13 @@ jobs: codeql-home: ${{ github.workspace }}/codeql_home add-to-path: false + - name: Cache codeql compilation + uses: actions/cache@v6 + with: + path: ~/.codeql + key: ${{ runner.os }}-codeql-compilation-${{ github.run_id }} + restore-keys: ${{ runner.os }}-codeql-compilation + - name: Install CodeQL packs uses: ./.github/actions/install-codeql-packs with: From 17c43f33961bbad9d4df849a57d0623fac9a3f2f Mon Sep 17 00:00:00 2001 From: Mauro Baluda Date: Thu, 27 Aug 2026 00:47:42 +0200 Subject: [PATCH 3/6] Rename cache step for clarity --- .github/workflows/codeql_unit_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql_unit_tests.yml b/.github/workflows/codeql_unit_tests.yml index dc1069ab1..ca9f59efb 100644 --- a/.github/workflows/codeql_unit_tests.yml +++ b/.github/workflows/codeql_unit_tests.yml @@ -74,7 +74,7 @@ jobs: codeql-home: ${{ github.workspace }}/codeql_home add-to-path: false - - name: Cache codeql compilation + - name: Cache queries compilation uses: actions/cache@v6 with: path: ~/.codeql From 7263a98e2c847f752161ca6a2e43f009cd3de911 Mon Sep 17 00:00:00 2001 From: Mauro Baluda Date: Thu, 27 Aug 2026 01:10:18 +0200 Subject: [PATCH 4/6] Static caching path --- .github/workflows/codeql_unit_tests.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql_unit_tests.yml b/.github/workflows/codeql_unit_tests.yml index ca9f59efb..21f2061a9 100644 --- a/.github/workflows/codeql_unit_tests.yml +++ b/.github/workflows/codeql_unit_tests.yml @@ -77,7 +77,7 @@ jobs: - name: Cache queries compilation uses: actions/cache@v6 with: - path: ~/.codeql + path: ${{ github.workspace }}/codeql_cache key: ${{ runner.os }}-codeql-compilation-${{ github.run_id }} restore-keys: ${{ runner.os }}-codeql-compilation @@ -89,7 +89,10 @@ jobs: - 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 @@ -140,7 +143,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() From 1b01c6c0ce91b2f319a9754f0ffbfb64ecc83ebd Mon Sep 17 00:00:00 2001 From: Mauro Baluda Date: Thu, 27 Aug 2026 01:26:59 +0200 Subject: [PATCH 5/6] Add common caches support --- .github/actions/install-codeql-packs/action.yml | 9 ++++++++- .github/workflows/codeql_unit_tests.yml | 1 + scripts/install-packs.py | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/actions/install-codeql-packs/action.yml b/.github/actions/install-codeql-packs/action.yml index 2e6d5f1a2..3a60e47bb 100644 --- a/.github/actions/install-codeql-packs/action.yml +++ b/.github/actions/install-codeql-packs/action.yml @@ -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`. @@ -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 }}" diff --git a/.github/workflows/codeql_unit_tests.yml b/.github/workflows/codeql_unit_tests.yml index 21f2061a9..93bac6f96 100644 --- a/.github/workflows/codeql_unit_tests.yml +++ b/.github/workflows/codeql_unit_tests.yml @@ -85,6 +85,7 @@ jobs: 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 diff --git a/scripts/install-packs.py b/scripts/install-packs.py index ab45c3281..f9a703e1d 100644 --- a/scripts/install-packs.py +++ b/scripts/install-packs.py @@ -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 @@ -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) From d74deb3a9f66f0ece55cde69a0aeb762bbb63fa1 Mon Sep 17 00:00:00 2001 From: Mauro Baluda Date: Thu, 27 Aug 2026 02:03:53 +0200 Subject: [PATCH 6/6] Enhance CodeQL caching key to include language, CLI, and standard library --- .github/workflows/codeql_unit_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql_unit_tests.yml b/.github/workflows/codeql_unit_tests.yml index 93bac6f96..eea96cbd8 100644 --- a/.github/workflows/codeql_unit_tests.yml +++ b/.github/workflows/codeql_unit_tests.yml @@ -78,8 +78,8 @@ jobs: uses: actions/cache@v6 with: path: ${{ github.workspace }}/codeql_cache - key: ${{ runner.os }}-codeql-compilation-${{ github.run_id }} - restore-keys: ${{ runner.os }}-codeql-compilation + 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