Skip to content

Version-consistency CI gate, SECRET_KEY production guard, and small cleanups#15

Merged
lewisjared merged 6 commits into
mainfrom
feat/version-consistency-and-deploy-guards
Jul 1, 2026
Merged

Version-consistency CI gate, SECRET_KEY production guard, and small cleanups#15
lewisjared merged 6 commits into
mainfrom
feat/version-consistency-and-deploy-guards

Conversation

@lewisjared

@lewisjared lewisjared commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Three small, independent hardening changes for the AFT deployment repo, one per commit.

  • Version-consistency CI gate — component pins live in five files (pyproject.toml, versions.toml, helm/Chart.yaml, helm/values.yaml, docker/docker-compose.yaml) and were synced by hand. A new tests/test_version_consistency.py asserts they agree and runs in the fast lint job, so drift fails the build. Also reconciles a pre-existing mismatch: the ref-app frontend image (v0.3.0 in Helm, v0.2.3 in Docker, untracked in the manifest) is now tracked under [frontend] and set to v0.3.0 everywhere.
  • SECRET_KEY production guard — the chart shipped ENVIRONMENT: production with SECRET_KEY: changethis. A new ref.validateApiSecret helper aborts the render when production has an empty or placeholder key; the default is hardened to empty. Production-only; real overrides, api.enabled: false, and non-prod are untouched.
  • Cleanups — un-mark the fast test_provider_discovery as slow so it runs by default; fix the stale README Helm install version (0.1.00.2.2).

Verification (combined branch): ruff check/format pass; pytest -m "not slow" green (11 passed); 10 consistency assertions pass; helm lint passes and the render fails on defaults. Each change adds a changelog fragment.

Note: the Docker frontend bump to v0.3.0 wasn't exercised against climate-ref:v0.14.3 on the full docker stack — worth a local bash scripts/smoke-test.sh first.

Summary by CodeRabbit

  • New Features

    • Added checks to keep component versions aligned across the app, chart, and deployment configs.
    • Added a frontend version pin to support consistent releases.
  • Bug Fixes

    • Improved Helm validation so production deployments require a real secret key.
    • Updated CI validation to pass a placeholder secret during chart linting.
  • Documentation

    • Updated installation and changelog notes to reflect the latest Helm chart version.

Add tests/test_version_consistency.py: eight tests that parse
pyproject.toml, versions.toml, helm/Chart.yaml, helm/values.yaml
and docker/docker-compose.yaml and assert all component version pins
agree. Two frontend image-comparison tests are skipped pending
reconciliation of the helm (v0.3.0) vs docker (v0.2.3) frontend
version drift.

Also:
- Add [frontend] table to versions.toml to start tracking the
  climate-ref-frontend image version (set to 0.3.0, matching Helm).
- Wire the new test into the CI lint job so version drift becomes
  a hard build failure.
- Add changelog fragment.
Align the docker-compose ref-app image tag up to v0.3.0 to match the
Helm chart (api.image.tag) and versions.toml [frontend]. With the drift
resolved, enable the two previously-skipped frontend image-comparison
tests and drop the now-unused pytest import.
Add a ref.validateApiSecret helper that calls fail when
api.env.ENVIRONMENT=production and api.env.SECRET_KEY is empty or the
'changethis' placeholder. The helper is invoked at the top of
templates/api/secret.yaml so the guard fires whenever the API Secret
would be rendered.

Default api.env.SECRET_KEY in values.yaml is changed from 'changethis'
to '' (empty string), which the guard also rejects in production.

The helm-lint CI step is updated to pass --set api.env.SECRET_KEY=lint-not-a-real-secret
so the workflow remains green.
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e010a873-1689-4d89-b336-3b9889986f4e

📥 Commits

Reviewing files that changed from the base of the PR and between 46b9f4c and a94d140.

📒 Files selected for processing (13)
  • .github/workflows/ci.yml
  • README.md
  • changelog/15.docs.md
  • changelog/15.fix.md
  • changelog/15.improvement.md
  • changelog/15.trivial.md
  • docker/docker-compose.yaml
  • helm/templates/_helpers.tpl
  • helm/templates/api/secret.yaml
  • helm/values.yaml
  • tests/integration/test_cmip7_aft.py
  • tests/test_version_consistency.py
  • versions.toml
💤 Files with no reviewable changes (1)
  • tests/integration/test_cmip7_aft.py

📝 Walkthrough

Walkthrough

This PR adds a CI-enforced test suite verifying version consistency across pyproject.toml, versions.toml, Helm chart files, and docker-compose.yaml; introduces a Helm helper that blocks production rendering when SECRET_KEY is unset or placeholder; pins the frontend version; and applies minor documentation, CI, and test-marker updates.

Changes

Version Consistency Test Suite

Layer / File(s) Summary
Frontend version pinning
versions.toml, docker/docker-compose.yaml
Adds a [frontend] section pinning climate-ref-frontend to 0.3.0 and bumps the ref-app image tag to v0.3.0.
Version consistency test module
tests/test_version_consistency.py
New test suite asserting core package, Helm chart, worker/API, Docker image, and frontend versions stay consistent across config files.
CI wiring
.github/workflows/ci.yml
Adds a "Version consistency" pytest step to the lint job and passes a dummy SECRET_KEY to helm lint.

Helm Production Secret Guard

Layer / File(s) Summary
validateApiSecret helper and wiring
helm/templates/_helpers.tpl, helm/values.yaml, helm/templates/api/secret.yaml
New ref.validateApiSecret helper fails rendering when ENVIRONMENT=production and SECRET_KEY is empty or changethis; default SECRET_KEY value changed to empty string; helper invoked from the Secret template.

Housekeeping and Changelog

Layer / File(s) Summary
Test marker, README version, changelogs
tests/integration/test_cmip7_aft.py, README.md, changelog/15.docs.md, changelog/15.fix.md, changelog/15.improvement.md, changelog/15.trivial.md
Removes @pytest.mark.slow from test_provider_discovery, bumps README Helm install version to 0.2.2, and adds changelog entries.

Sequence Diagram(s)

sequenceDiagram
    participant CI as CI Lint Job
    participant TestSuite as test_version_consistency.py
    participant Files as Config Files (pyproject.toml, versions.toml, Chart.yaml, values.yaml, docker-compose.yaml)
    participant Helm as Helm Render

    CI->>TestSuite: run pytest test_version_consistency.py
    TestSuite->>Files: read pinned versions
    Files-->>TestSuite: version values
    TestSuite-->>CI: pass/fail assertion

    CI->>Helm: helm lint --set api.env.SECRET_KEY=lint-not-a-real-secret
    Helm->>Helm: ref.validateApiSecret check (ENVIRONMENT, SECRET_KEY)
    Helm-->>CI: render success or fail
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly covers the main changes: version-consistency CI, the SECRET_KEY production guard, and minor cleanups.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/version-consistency-and-deploy-guards

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

Rename the +slug.type.md fragments to the repo's <PR>.<type>.md convention so towncrier links them to #15, and split the combined trivial fragment so the README fix renders under Improved Documentation.
@lewisjared lewisjared merged commit 2600752 into main Jul 1, 2026
10 checks passed
@lewisjared lewisjared deleted the feat/version-consistency-and-deploy-guards branch July 1, 2026 11:50
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