Repository navigation
Deploy workflows: preflight the settings load before replacing the site - #1465
Merged
Merged
Conversation
Adds a step between `docker compose build` and `up -d` in both deploy workflows that imports makeabilitylab.settings in a throwaway container (--no-deps, real mounts/env/user). A config.ini that the 2.35.3 guard rejects now fails the job with the reason in the log and leaves the running container alone, instead of a green deploy and a 502. Tested locally against the built image: valid config exits 0; a config without SECRET_KEY exits 1 with the ImproperlyConfigured message; a missing config path exits 1. Part of #1460. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ocs; bypass From an independent review of this branch: - configparser errors quote the offending line/value, and the preflight prints to a public Actions log. config.ini is now read only through a guarded read and safe_config_get(), which re-raise ImproperlyConfigured with the error type only (`from None`). Covers SECRET_KEY, ALLOWED_HOSTS and the optional [Postgres] credentials. 3 new tests. - The step runs scripts/preflight_settings.py instead of a bare import: it prints the exception type, the message only for ImproperlyConfigured, and never a traceback. - Docs/comments no longer claim the site simply "stays up": the old container keeps running but on the new checkout. - SKIP_DEPLOY_PREFLIGHT repository variable bypasses the step without a commit. - Docs: deploys are GitHub Actions workflows, not webhooks/deploy emails. Verified in a container against five configs (valid, no key, bare % in key, no section header, bad % in Postgres password): correct exit codes, no config text in any output. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Part of #1460. Follow-up to #1464.
What changed
Both deploy workflows get one step between
docker compose build websiteanddocker compose up -d:It loads the Django settings in a throwaway container using the host's real
config.inimount, environment and container user. Since 2.35.3, settings refuse to load on test/prod without a readableconfig.inithat setsSECRET_KEYandALLOWED_HOSTS. Before this change that refusal was invisible:up -dreturns before the app boots, so the job went green and the site answered 502/503. Now a bad config fails the job at this step with the reason in the Actions log.--no-depskeeps it from starting or touching the database.config.iniis ever printed.configparserquotes the bad line or value in its own errors, sosettings.pynow reads the file only through a guarded read andsafe_config_get(), which report the error type alone. The script prints no tracebacks.SKIP_DEPLOY_PREFLIGHTtotrueskips the step without a commit, in case the step itself ever misfires.What a failure means
The running container is not replaced and normally keeps answering. It is, however, already running on top of the new checkout (
/codeis bind-mounted), so it can go down at its next worker respawn or restart. Fix the config or revert promptly.Verification
Run in a container against the project image:
SECRET_KEY+ALLOWED_HOSTSPREFLIGHT OKSECRET_KEY%in the key[Django]header%in a[Postgres]passwordThe first three were also run through
docker compose runitself under a separate project. Not verifiable before merge: the step on the CSE self-hosted runners. PR CI does not run the deploy workflows, so the first real run is the -test deploy when this merges.Review
An independent review (Opus 5.5, claude-opus-5-5) led to the second commit: the value-safe config reads and script, corrected failure-mode wording, the bypass variable, and doc updates. Left as follow-ups: widening the preflight to
django.setup(), and making a missingCONFIG_PATHa compose error instead of an auto-created directory.No version bump: no change in site behaviour.
🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2