Repository navigation
[improve][ci] Start CodeQL without waiting for the unit tests - #27344
Merged
Merged
Conversation
The CodeQL job analyzes with build-mode: none, so it reads the sources and uses neither the build outputs nor the test results. Waiting for every unit test job made its 13-18 min start after the slowest one, at the end of every master run and of every PR run that changes Java main code. It now starts after Preconditions; its condition is unchanged.
codelipenghui
approved these changes
Nov 4, 2026
codelipenghui
left a comment
Contributor
There was a problem hiding this comment.
Code Review approval for commit 04bc2df.
Summary:
No actionable findings identified within the reviewed scope.
The approach is sound: CodeQL can run independently after Preconditions, while the final CI gate continues to enforce test results. Extra runner consumption and potentially later aggregate failure reporting are documented tradeoffs. Recommend approval; live validation of the new scheduling remains outstanding.
lhotari
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Run CodeQL Analysishasneeds: ['preconditions', 'unit-tests'], so it starts when the last unit-test job ends, thenruns for 6–18 min (a median of 12 on PRs last week). It runs on master runs and on PRs to master that change
src/main/java, and on those it is usually the last job:Times are from the run's first job. Test-only PRs skip CodeQL, which is why their runs end sooner. Over the 110 PR runs
of 27 Oct – 3 Nov where CodeQL ran in the first attempt, starting it after Preconditions would have ended them a median
8.1 min sooner (p25 3.2, p75 13.7). 18 of them would have ended at the same time, because another job ended last.
The job uses nothing from the unit tests. Since #25932 it analyzes with
build-mode: none: it reads the sources andruns Gradle only to resolve dependencies, without the build job's outputs or the tests' results. The wait came with
#22132 (Feb 2024), when the job ran its own Maven build and the other secondary jobs were held back the same way:
macos-buildand
owasp-dep-checkwaited for the integration tests. The Gradle migration (#25398) already movedmacos-buildtostart after the build job.
Modifications
codeqljob needs onlypreconditions, with a comment saying why. Itsifis unchanged, so it still runs onlyon master runs and on PRs to master that change
**/src/main/java/**/*.java.Nothing depends on the order.
Pulsar CI checks completed, the only required check on master, listscodeqlandunit-testsin its ownneedsand still requires the unit tests to succeed and CodeQL to succeed or be skipped. TheSARIF upload goes to code scanning for the run's ref and reads no other job's output.
Trade-off
From the 374 PR runs of 27 Oct – 3 Nov, 250 of them on PRs that CodeQL applies to:
attempt failed in the unit tests (28) or the build (2) and wasn't re-run to a pass, so CodeQL never ran. Running it
there would have cost 351 runner-minutes for the week: 20 % more than CodeQL used (1,788), and 0.24 % of the
145,457 runner-minutes of all jobs in these runs.
it again. Before, 10 re-runs of failed unit test jobs ran CodeQL after their tests, a median 8.8 min more each.
integration or system test job failed and the unit tests passed, the run stayed open until CodeQL ended.
unit tests; the number of jobs is the same. In the three runs above, the most jobs running at once (when the
integration and system matrices overlap the unit tests) would go from 31, 28 and 25 to 32, 29 and 25.
Pulsar CI checks completedreports once CodeQL ends, up to ~10 min later. The failed buildjob shows right away.
it takes master's newest, as the build job does. Its Gradle step only resolves dependencies (1.0–1.8 min).
The alternative is
needs: ['preconditions', 'build-and-license-check']. It skips CodeQL when the build fails, but thebuild failed in only 2 of those first attempts, so it would have saved 23 of the 351 runner-minutes. In exchange,
CodeQL starts 8–13 min later and has less room before the last test job: over the 110 runs, it would end at least
7.6 min (median 30.5) before it, against 17.4 (median 42.5) when it starts after Preconditions. Neither would make
CodeQL the last job today. But it runs for up to 18 min plus queueing, and the slowest unit test jobs are getting
shorter, so after the build it would soon be last again. That's why this PR starts it after Preconditions.
Verifying this change
Make sure that the change passes the CI checks.
actionlintreports the same 17 findings before and after the change, all shellcheck notes on other jobs' scripts.This PR changes no
src/main/javafile, so its own run skips CodeQL. The first scheduled master run after it shouldstart CodeQL right after Preconditions and end before the last test job.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes