Repository navigation
Deploy PR previews to Cloud Run, like seating and sections - #23
Open
pancakereport wants to merge 3 commits into
Open
pancakereport wants to merge 3 commits into
pancakereport wants to merge 3 commits into
Conversation
- Dockerfile: build the frontend with `flask build` (production serves oh_queue/static/public as it is, and it isn't committed), run one non-root gunicorn worker with threads, add a /health check, and only migrate with RUN_MIGRATIONS=true instead of on every start. - Connect to Cloud SQL as the service account the app runs as (IAM database auth, CLOUD_SQL_INSTANCE/DB_USER/DB_NAME), so no database password is stored; Alembic uses the app's engine and takes an advisory lock. - Refuse requests with an explanation while the database doesn't match the migrations, as on a preview whose PR adds a migration (from sections). - PR preview workflow, from seating's and sections'. - Remove entrypoint.sh and the unused Heroku buildpacks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The default compute service account has Editor on the project, so letting the deployer act as it would give every PR branch Editor on staging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
==========================================
+ Coverage 72.66% 73.41% +0.74%
==========================================
Files 10 11 +1
Lines 1394 1452 +58
Branches 198 207 +9
==========================================
+ Hits 1013 1066 +53
- Misses 323 327 +4
- Partials 58 59 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🚀 Staging Preview Deployed! |
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.
Deploys each pull request as a preview on the staging project, the way seating and sections do, and gets the image ready for Cloud Run.
Changes
flask buildin a build stage that has Node. In production the app servesoh_queue/static/public/common.jsandstyle.cssas they are, and they aren't committed, so the old image had no JavaScript./health.RUN_MIGRATIONS=true.entrypoint.shran them on every start, which would have let a preview migrate the shared staging database.CLOUD_SQL_INSTANCE,DB_USER,DB_NAME), like sections, so no database password is stored.DATABASE_URLstill works locally and in CI. Alembic now uses the app's engine so migrations connect the same way, and takes an advisory lock so instances starting together don't migrate at once.oh_queue/schema_check.py, from sections): while the database's migration doesn't match the code's, pages, API calls and/healthreturn 503 with an explanation. On a preview whose PR adds a migration, it says to merge the PR. On a preview behind staging, it says to mergemain. Seedocs/migrations.md. The course page reloads on a 503 from its API, as it already did on 403 and 404, so an open page shows the explanation too..github/workflows/pr-staging.yml: seating's hardened version (pinned actions, per-job permissions, no previews for fork or Dependabot PRs) with sections' concurrency group. Runs asoh-appwith theoh-*secrets, and builds asoh-build.entrypoint.shand the unused Heroku.buildpacks.Before previews work
oh-buildservice account with onlyroles/run.builder, and the deployer may act only asoh-buildandoh-app. Sections' deployer instead acts as the default compute service account, which has Editor on the project.ohdatabase is at8f4b2d6f0c1a, before the migrations from Remove the monorepo's common package and Slack notifications #5, Remove appointments #6 and Serve every bCourses course from one site, with seating's routes #22, so previews show the "adds a database migration" message until it's upgraded.Testing
pytest(112 passed, including new tests for the schema check,/healthand the Cloud SQL settings) andflake8.ENV=prod. Before migrations,/healthreturned 503 with the preview message. Afterflask initdb,/health, the landing page and/static/public/common.jsreturned 200. Gunicorn ran as PID 1 under theappuser, and Docker reported the container healthy.🤖 Generated with Claude Code