Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/keep-warm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: keep-warm

# Keeps the live demo awake from 08:00 to midnight IST: the free Render service
# sleeps after 15 idle minutes. It is left to sleep overnight on purpose, since
# only a boot resets the demo (docs/infra/DEPLOYMENT.md §0), so each morning
# starts fresh. An anonymous GET of the login page, never a sign-in: a sign-in
# writes an audit entry, and the reset only runs once nothing was audited for
# 10 minutes.

on:
schedule:
# Cron is UTC; IST is UTC+5:30. Every 5 minutes, because GitHub can start a
# scheduled run late and 10 minutes would leave no margin before the sleep.
- cron: '30-55/5 2 * * *' # 08:00-08:25 IST
- cron: '*/5 3-17 * * *' # 08:30-23:25 IST
- cron: '0-25/5 18 * * *' # 23:30-23:55 IST
workflow_dispatch:

permissions: {}

concurrency:
group: keep-warm
cancel-in-progress: true

jobs:
ping:
name: ping the live demo
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
# A cold boot takes about 2.5 minutes; the request itself is what wakes
# it, so a timeout here still leaves it booting. Only the status is kept.
- run: curl -fsS -o /dev/null --max-time 180 -w '%{http_code}\n' https://labops.onrender.com/login
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ worked.
**Live demo: [labops.onrender.com](https://labops.onrender.com)**

- Sign in as `demo`. The password is shared with the project submission.
- It runs on a free plan that sleeps after 15 minutes without a visit, so the
first visit can take a few minutes to wake up. After that, pages load in well
under a second.
- It runs on a free plan, kept awake from 08:00 to midnight India time and
asleep overnight. A visit while it sleeps can take a few minutes to wake it.
After that, pages load in well under a second.
- Every wake-up starts a fresh demo. If an incident is already resolved when you
arrive, someone used it recently; it will be fresh after the next sleep.
arrive, someone used it earlier today; it will be fresh the next morning.

> **Everything here is simulated.** The labs, their failures and the fixes are
> generated by the project itself. It connects to no real cloud or lab
Expand Down
5 changes: 3 additions & 2 deletions docs/GAPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ platform. The *action* would not.
the API, the worker and the web app as three processes in one Render free
service, with Redis on Render Key Value and PostgreSQL on Neon. Any process
exiting restarts all three; there is no second instance and no failover.
- **It sleeps after 15 minutes without a request**, worker included. The first
visit after that waits for a cold boot (about 2.5 minutes, measured locally
- **It sleeps after 15 minutes without a request**, worker included, except
from 08:00 to midnight IST, when `keep-warm.yml` pings it. The first
visit after a sleep waits for a cold boot (about 2.5 minutes, measured locally
under the same 0.1 CPU cap, not on the host).
- **The demo resets when idle.** A boot after 10 idle minutes (every wake from
sleep) drops and reseeds the demo database (`DEMO_RESET_ON_BOOT`), so
Expand Down
14 changes: 11 additions & 3 deletions docs/infra/DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ memory figures below were measured locally under the same caps, not on the host.

- **It sleeps after 15 minutes without a request**, worker included. Locally,
capped at 0.1 CPU, a boot took about 2.5 minutes to serve the login page
(migrate, seed, then Next.js alone about 45 s). Warm it before showing it.
(migrate, seed, then Next.js alone about 45 s).
- **It is kept awake from 08:00 to midnight IST.** `.github/workflows/keep-warm.yml`
GETs `/login` every 5 minutes in that window and lets it sleep overnight, so
each morning boots a fresh demo. Never a sign-in: that writes an audit entry,
which would stop the idle reset. About 480 of the 750 free hours a month, and
Neon's compute stays awake too, since the worker queries it on a timer.
GitHub can start a scheduled run late, so an occasional sleep in the window is
possible; a failed ping fails the run, and GitHub emails about it. Two
visitors on the same day share one demo.
- **512 MB and 0.1 CPU** for three Node processes. Measured locally under the
same caps: about 145 MB for the whole container, through a full incident
journey. Each heap is capped anyway (`API_HEAP_MB`, `WORKER_HEAP_MB`,
Expand Down Expand Up @@ -145,8 +153,8 @@ so they do not depend on a proxy in front of it.
1. **Access control.** One shared `demo` password. "Known users only" is true
only once Google sign-in with an exact-email allow-list is configured
(`AGENTS.md` §13a). **This is the real gate.**
2. **Uptime monitoring.** Nothing pings the site, and nothing alerts on an
incident being created.
2. **Uptime monitoring.** Only the keep-warm ping (§0), whose failed runs
email the workflow's author; nothing alerts on an incident being created.
3. **Alerts on long open transactions.** The metric exists; nothing watches it.

The rest is in `docs/GAPS.md`.
Expand Down
9 changes: 6 additions & 3 deletions docs/infra/INFRA.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,17 @@ than the code: the free tier returns 503 under load, and retired models answer

## 6. CI pipelines

Four workflows in `.github/workflows/`. Only `changes.yml` runs on pushes and pull
requests to `main`; it calls `api.yml` and `web.yml`. `llm-live.yml` is manual.
Five workflows in `.github/workflows/`. Only `changes.yml` runs on pushes and pull
requests to `main`; it calls `api.yml` and `web.yml`. `llm-live.yml` is manual;
`keep-warm.yml` runs on a schedule.

| Workflow | Role |
|---|---|
| `changes.yml` | The only entry point. Uses `dorny/paths-filter` to decide which service changed, then calls only the matching pipeline. The root `package.json`, lockfile and ESLint config fan out to both; `docker-compose.yml` counts for the api; a change only to workflows, top-level docs or the deploy files (`deploy/`, `render.yaml`, `scripts/`) runs neither. Also runs the **compose smoke and e2e** job whenever api or web changed: build the images, run `scripts/compose-smoke.sh`, then reset the stack (`down -v`, `up`) and run the Playwright journey (`npm run test:e2e -w @labops/web`); screenshots are uploaded only on failure, never traces, which hold cookies. |
| `api.yml` | build (`tsc` + `prisma validate`), lint and unit tests in parallel; then integration tests (real Postgres + Redis) and coverage; then the quality gate. Images are built by the compose smoke job whenever api or web changed |
| `web.yml` | build, lint and unit tests in parallel; then coverage; then the quality gate. Images are built by the compose smoke job whenever api or web changed |
| `llm-live.yml` | Manual only (`workflow_dispatch`): the one job that calls a real model; needs the `GEMINI_API_KEY` repository secret |
| `keep-warm.yml` | Scheduled every 5 minutes from 08:00 to midnight IST (and manual): an anonymous GET of the live `/login`, so the free service does not sleep in that window. No secrets, `permissions: {}` |

**Quality gate** (each pipeline, `if: always()` so it runs even after a failure):
1. Fails unless every upstream job succeeded.
Expand Down Expand Up @@ -253,7 +255,8 @@ https://labops.onrender.com. One container runs the API, worker and web app as
three processes, with Redis on Render Key Value and PostgreSQL on Neon. It
boots by resetting the demo database (`DEMO_RESET_ON_BOOT`), migrating, seeding
the `demo` operator and ingesting the demo scenario (`dist/seed-demo.js`), and
it sleeps after 15 minutes idle. `DEPLOYMENT.md` §0 has the costs and the steps.
it sleeps after 15 minutes idle (kept awake 08:00 to midnight IST by
`keep-warm.yml`). `DEPLOYMENT.md` §0 has the costs and the steps.

**`APP_ENV=production` changes what the API accepts.** It refuses to boot if
`SESSION_COOKIE_SECURE` is not true (a Secure cookie over http is never sent,
Expand Down
Loading