Diffinery

homeflare/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

diffinery/apps/diffinery/migrations/0044_github_runners.sql
51 lines · 2.8 KBRaw History
1-- Diffinery runners for GitHub repositories (github-runners/): an instance's GitHub App is installed on a
2-- GitHub user or organization, the installation is linked to the Diffinery account that pays, and jobs whose
3-- runs-on asks for a Diffinery runner run in hosted runner containers with GitHub's own runner.
4
5-- A GitHub App installation linked to a Diffinery account. Its id is GitHub's installation id.
6CREATE TABLE IF NOT EXISTS github_installations (
7 id INTEGER PRIMARY KEY,
8 account_id TEXT NOT NULL, -- the Diffinery person or organization whose hosted minutes it uses
9 github_login TEXT NOT NULL, -- the GitHub user or organization it is installed on
10 github_type TEXT NOT NULL, -- "User" or "Organization"
11 linked_by TEXT NOT NULL, -- the Diffinery account that linked it
12 linked_at TEXT NOT NULL,
13 suspended_at TEXT -- suspended on GitHub: no runners start for it meanwhile
14);
15CREATE INDEX IF NOT EXISTS github_installations_account ON github_installations(account_id);
16
17-- One runner started (or waiting to start) for a queued GitHub job. GitHub hands a runner any queued job
18-- of the repository whose labels it has, so the job a runner runs (ran_job_id) may not be the one that
19-- asked for it (github_job_id).
20CREATE TABLE IF NOT EXISTS github_runner_jobs (
21 id TEXT PRIMARY KEY,
22 account_id TEXT NOT NULL,
23 installation_id INTEGER NOT NULL,
24 repo TEXT NOT NULL, -- owner/name on GitHub
25 github_job_id INTEGER NOT NULL,
26 run_id INTEGER,
27 workflow_name TEXT,
28 job_name TEXT,
29 html_url TEXT,
30 labels TEXT NOT NULL, -- JSON: the job's runs-on labels, which the runner registers with
31 size TEXT NOT NULL, -- runner/sizes.ts
32 status TEXT NOT NULL, -- queued, starting, running, completed, skipped, failed
33 tries INTEGER NOT NULL DEFAULT 0,
34 runner_name TEXT,
35 github_runner_id INTEGER,
36 container TEXT,
37 ran_job_id INTEGER,
38 ran_job_name TEXT,
39 conclusion TEXT, -- the GitHub job's conclusion, once GitHub reports it
40 message TEXT, -- why it waits, was skipped or failed
41 stop_reason TEXT, -- set when Diffinery stopped the runner itself
42 exit_code INTEGER,
43 created_at TEXT NOT NULL,
44 started_at TEXT,
45 picked_at TEXT,
46 ended_at TEXT
47);
48CREATE UNIQUE INDEX IF NOT EXISTS github_runner_jobs_job ON github_runner_jobs(installation_id, github_job_id);
49CREATE INDEX IF NOT EXISTS github_runner_jobs_account ON github_runner_jobs(account_id, status, created_at);
50CREATE INDEX IF NOT EXISTS github_runner_jobs_installation ON github_runner_jobs(installation_id, created_at);
51CREATE INDEX IF NOT EXISTS github_runner_jobs_runner ON github_runner_jobs(runner_name);