ci(codeql): force a clean recompile every run#41
Merged
Conversation
CodeQL was failing with "could not process any code written in Java/Kotlin" on PRs that touched no Java source — the README PR (#40) and the release-cut commit (#39, which only edits CHANGELOG.md). Diagnosis: gradle/actions/setup-gradle@v6 restores the build cache on every run. README- and CHANGELOG-only changes leave every input to the JavaCompile task identical, so Gradle reports the `classes` task as UP-TO-DATE and runs zero `javac` invocations. CodeQL's Java tracer wraps `javac`; no invocations means no extracted classes, which surfaces as the empty-database error at the analyze step. Confirmed by the run-duration pattern in `gh run list --workflow=codeql.yml`: - failing runs (#39 release-cut, #40 README) finished in ~1 min - successful runs (#35-#38 feature PRs that touched src/) took ~2 min The minute of "missing" wall-clock is exactly the javac step that didn't run. Fix: `--no-build-cache clean classes` forces a recompile every CodeQL invocation. Drops a `clean` task ahead of `classes` to guarantee no UP-TO-DATE skip, and `--no-build-cache` is belt-and-braces against the setup-gradle action's cache restore. Slightly slower CodeQL runs (~30s more on cold compile) but the analyze step gets real javac output to extract from.
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.
Summary
CodeQL was failing with "could not process any code written in Java/Kotlin" on PRs that touched no Java source — the README PR (#40) and the release-cut commit on `main` (#39, which only edits `CHANGELOG.md`).
Diagnosis
`gradle/actions/setup-gradle@v6` restores the build cache on every run. README- and CHANGELOG-only changes leave every input to the `JavaCompile` task identical, so Gradle reports the `classes` task as `UP-TO-DATE` and runs zero `javac` invocations. CodeQL's Java tracer wraps `javac`; no invocations means no extracted classes, which surfaces as the empty-database error at the analyze step.
Confirmed by the run-duration pattern in `gh run list --workflow=codeql.yml --limit=5`:
The minute of "missing" wall-clock on the failing runs is exactly the `javac` step that didn't execute. (The release-cut PR branch succeeded only because it was the first run after the previous javac compile shifted enough inputs.)
Fix
```yaml
name: Compile (drives CodeQL extraction)
run: ./gradlew --no-daemon --no-build-cache clean classes
```
`clean` forces a recompile every run.
`--no-build-cache` belt-and-braces against the setup-gradle action's cache restore.
Trade: ~30s slower CodeQL runs on cold compile. The analyze step gets real `javac` output to extract from, which is the actual job.
After merge
The README PR #40 will pass CodeQL on its next push (or after a no-op rebase). Same for any future README/CHANGELOG/workflow-only PRs.