Skip to content

ci: Use build-mode none for CodeQL C/C++ scanning - #6900

Closed
sakirr05 wants to merge 1 commit into
OSGeo:mainfrom
sakirr05:ci/codeql-build-mode-none
Closed

sakirr05 wants to merge 1 commit into
OSGeo:mainfrom
sakirr05:ci/codeql-build-mode-none

Conversation

@sakirr05

Copy link
Copy Markdown
Contributor

Motivation

CodeQL C/C++ scanning can now be performed without builds (GA as of Oct 2025). The current setup uses a build step, runs only on Linux, and analyzes ~3.01k out of ~3.35k C files (~340 files missing). This change improves coverage by scanning all source files without requiring a build.

See: #6529

What Changed

  • Added build-mode: none for C/C++ language in CodeQL init step
  • Removed build step and related setup (installation directory, LD_LIBRARY_PATH, MAKEFLAGS, build script execution)
  • Kept dependency installation to ensure system headers are available for analysis
  • Python and Actions scanning remain unchanged

Why This Approach

  1. Better Coverage: Scans all ~3.35k C source files instead of only compiled files
  2. Faster CI: Removes time-consuming build step for CodeQL analysis
  3. Simpler: Reduces workflow complexity
  4. Safe: Headers are still available via dependency installation

Trade-offs

  • Generated code won't be scanned: Flex/bison generated files (4 files in lib/db/sqlp and raster/r.mapcalc) are in build directories, not source. This is acceptable as they're generated code.
  • Slightly less accurate for complex macros: Acceptable given that headers are available and custom macros are in header files.

Validation

  • ✅ YAML syntax validated
  • ✅ Workflow structure verified
  • ✅ No breaking changes to Python/Actions scanning
  • ✅ All pre-commit hooks passed

How to Verify

After merge, check the CodeQL status page:

  • Should show ~3.35k C files analyzed (up from ~3.01k)
  • CodeQL job should complete faster (no build step)
  • Existing alerts should remain; new files may introduce new alerts

References

Addresses #6529

Switch CodeQL C/C++ analysis to build-mode: none to improve file coverage
from ~3.01k to all ~3.35k C files in the repository. This leverages
GitHub's generally available no-build scanning for C/C++ (announced
Oct 2025).

Changes:
- Add build-mode: none for c-cpp language in CodeQL init step
- Remove build step and related setup (no longer needed)
- Keep dependency installation to ensure headers are available
- Python and Actions scanning unchanged

Trade-offs:
- Generated code (flex/bison in build directories) won't be scanned
- Slightly less accurate for complex macro-heavy code (acceptable given
  header availability)

This addresses issue OSGeo#6529.
@echoix

echoix commented Jan 15, 2026

Copy link
Copy Markdown
Member

For reference, that is what I tried a couple months ago: echoix#569

@github-actions github-actions Bot added the CI Continuous integration label Jan 15, 2026
@sakirr05
sakirr05 marked this pull request as ready for review January 15, 2026 15:58
@sakirr05 sakirr05 closed this Jan 15, 2026
@sakirr05
sakirr05 deleted the ci/codeql-build-mode-none branch January 16, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants