Skip to content

ci(codeql): force a clean recompile every run#41

Merged
trendvidia merged 2 commits into
mainfrom
fix-codeql-clean-build
May 12, 2026
Merged

ci(codeql): force a clean recompile every run#41
trendvidia merged 2 commits into
mainfrom
fix-codeql-clean-build

Conversation

@trendvidia

Copy link
Copy Markdown
Owner

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`:

Run Result Duration Touched src/?
#40 README ❌ failure 1m10s no
#39 release-cut on main ❌ failure 1m6s no
#39 release-cut PR branch ✅ success 2m0s no
#38 TableReader main ✅ success 1m53s yes
#38 TableReader PR branch ✅ success 1m53s yes

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.

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.
@trendvidia trendvidia merged commit e62d505 into main May 12, 2026
3 checks passed
@trendvidia trendvidia deleted the fix-codeql-clean-build branch May 12, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant