diff --git a/CHANGELOG.md b/CHANGELOG.md index eb7df16..27e11ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ All notable changes to this project are documented here, following ## [Unreleased] +## [0.3.3] - 2026-11-04 + +### Fixed + +- **CodeQL keeps its compiled queries between runs.** Its cache defaulted to + `~/.codeql`, which is `/tmp` in the image and discarded with the container, + so every run compiled the whole query suite again. `--common-caches` now + points at `/cache/codeql-common` on the cache volume. Measured on trentina + (same image, same limits as the hook): analysis 132s cold, 46s warm; the + whole check 166s to 92s. Compiling had been 1m32s to 3m13s of every push. + ## [0.3.2] - 2026-11-04 ### Fixed diff --git a/Containerfile b/Containerfile index 9a29780..7a27d2c 100644 --- a/Containerfile +++ b/Containerfile @@ -44,7 +44,7 @@ LABEL description="Every CrunchTools Python SDLC check in one image: ruff, mypy, LABEL org.opencontainers.image.source="https://github.com/crunchtools/python-sdlc" LABEL org.opencontainers.image.description="Every CrunchTools Python SDLC check in one image." LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later" -LABEL version="0.3.2" +LABEL version="0.3.3" # What the image carries, readable without starting anything. `sdlc versions` # prints these and a consuming repo's CI pins them. diff --git a/IMAGE_TAG b/IMAGE_TAG index d15723f..1c09c74 100644 --- a/IMAGE_TAG +++ b/IMAGE_TAG @@ -1 +1 @@ -0.3.2 +0.3.3 diff --git a/README.md b/README.md index efd609a..f3498b7 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ default_install_hook_types: [pre-commit, pre-push] repos: - repo: https://github.com/crunchtools/python-sdlc - rev: v0.3.2 + rev: v0.3.3 hooks: - id: sdlc-commit - id: sdlc-push diff --git a/pyproject.toml b/pyproject.toml index 5e3d918..334bf4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ [project] name = "python-sdlc" -version = "0.3.2" +version = "0.3.3" description = "One container image and one script for every CrunchTools Python SDLC check" requires-python = ">=3.14" license = "AGPL-3.0-or-later" diff --git a/sdlc b/sdlc index 9d37060..c73be34 100755 --- a/sdlc +++ b/sdlc @@ -894,6 +894,14 @@ def t_codeql(s: dict) -> int: if config != default_config and not (REPO / config).is_file(): cannot(f"codeql config {config} does not exist") db = CACHE / "codeql" / project_name() + # Compiled query plans, kept between runs. CodeQL's default is ~/.codeql, + # which is /tmp in this image and gone when the container exits, so every + # run compiled all of security-extended again: 1m32s-3m13s of trentina's + # analysis, against 46s for the whole analysis on a warm cache. Shared by + # every repo on the volume, which is the point -- the standard packs are the + # same bytes everywhere -- and keyed by CodeQL on each query's own hash, so + # a changed query recompiles and nothing stale is reused. + caches = CACHE / "codeql-common" sarif = Path("/tmp/codeql-results.sarif") shutil.rmtree(db, ignore_errors=True) # An unwritable cache is a 2, not a traceback and not a 1. The same bug in @@ -901,6 +909,7 @@ def t_codeql(s: dict) -> int: # that claimed a finding. try: db.parent.mkdir(parents=True, exist_ok=True) + caches.mkdir(parents=True, exist_ok=True) except OSError as exc: cannot(f"cannot create the CodeQL database directory {db.parent}: {exc}") @@ -912,6 +921,7 @@ def t_codeql(s: dict) -> int: "--language=python", "--source-root=.", "--overwrite", + f"--common-caches={caches}", ] analyze = [ "codeql", @@ -921,6 +931,7 @@ def t_codeql(s: dict) -> int: "--format=sarif-latest", f"--output={sarif}", f"--threads={os.environ.get('SDLC_JOBS', '0')}", + f"--common-caches={caches}", ] # `--codescanning-config` is NOT a CLI flag in 2.27.4, on either subcommand.