| 1 | -- Runs as GitHub keeps them: every attempt with its own jobs and logs, a |
| 2 | -- step's job summary ($GITHUB_STEP_SUMMARY), debug re-runs, and cancelling |
| 3 | -- that lets a job clean up. See src/plan.rs (rerun, cancel_run, job_report) |
| 4 | -- and src/views.rs (run, logs, summaries). |
| 5 | |
| 6 | -- A job's summary, a step at a time: the Markdown each step wrote to |
| 7 | -- $GITHUB_STEP_SUMMARY, masked by the runner. Kept under the same id as the |
| 8 | -- job's logs (a live job's, or an earlier attempt's: job_attempts.log_id). |
| 9 | CREATE TABLE IF NOT EXISTS job_summaries ( |
| 10 | job_id TEXT NOT NULL, |
| 11 | step INTEGER NOT NULL, |
| 12 | markdown TEXT NOT NULL, |
| 13 | PRIMARY KEY (job_id, step) |
| 14 | ); |
| 15 | |
| 16 | -- A run's earlier attempts: how each ended, and who started it. |
| 17 | CREATE TABLE IF NOT EXISTS run_attempts ( |
| 18 | run_id TEXT NOT NULL, |
| 19 | attempt INTEGER NOT NULL, |
| 20 | repo_id TEXT NOT NULL, |
| 21 | conclusion TEXT, |
| 22 | -- Who started this attempt: the run's actor for the first, whoever |
| 23 | -- re-ran it for the rest. |
| 24 | actor TEXT, |
| 25 | debug INTEGER NOT NULL DEFAULT 0, |
| 26 | started_at TEXT, |
| 27 | finished_at TEXT, |
| 28 | PRIMARY KEY (run_id, attempt) |
| 29 | ); |
| 30 | |
| 31 | -- Each job of an earlier attempt as it ended. `id` is the snapshot's own |
| 32 | -- id, shown as the job's id when that attempt is viewed; `log_id` is where |
| 33 | -- its logs and summary are kept: the snapshot's id once the job ran again, |
| 34 | -- or the live job's while that one still carries the result (a job a |
| 35 | -- "re-run failed jobs" left alone). |
| 36 | CREATE TABLE IF NOT EXISTS job_attempts ( |
| 37 | id TEXT PRIMARY KEY, |
| 38 | run_id TEXT NOT NULL, |
| 39 | repo_id TEXT NOT NULL, |
| 40 | attempt INTEGER NOT NULL, |
| 41 | job_id TEXT NOT NULL, |
| 42 | log_id TEXT NOT NULL, |
| 43 | key TEXT NOT NULL, |
| 44 | ordinal INTEGER NOT NULL DEFAULT 0, |
| 45 | name TEXT NOT NULL, |
| 46 | needs TEXT NOT NULL DEFAULT '[]', |
| 47 | status TEXT NOT NULL, |
| 48 | conclusion TEXT, |
| 49 | steps TEXT NOT NULL DEFAULT '[]', |
| 50 | annotations TEXT NOT NULL DEFAULT '[]', |
| 51 | reason TEXT, |
| 52 | environment TEXT, |
| 53 | labels TEXT, |
| 54 | runner_name TEXT, |
| 55 | started_at TEXT, |
| 56 | finished_at TEXT |
| 57 | ); |
| 58 | CREATE INDEX IF NOT EXISTS job_attempts_by_run ON job_attempts (run_id, attempt); |
| 59 | CREATE INDEX IF NOT EXISTS job_attempts_by_log ON job_attempts (log_id); |
| 60 | |
| 61 | -- Who started the current attempt (the run's actor until it is re-run), |
| 62 | -- and whether it runs with debug logging. |
| 63 | ALTER TABLE runs ADD COLUMN triggering_actor TEXT; |
| 64 | ALTER TABLE runs ADD COLUMN debug INTEGER NOT NULL DEFAULT 0; |
| 65 | |
| 66 | -- Cancelling: a running job is told to stop and given time to run its |
| 67 | -- `if: always()` and `cancelled()` steps and its post steps. Past the grace |
| 68 | -- period it is stopped outright. |
| 69 | ALTER TABLE jobs ADD COLUMN cancel_requested_at TEXT; |