Cotton code
471 lines · 11.4 KB · JSONRaw
{  "format_version": 1,  "id": "run",  "setup": true,  "name": "CI run",  "plural": "CI runs",  "picture": null,  "builtin": true,  "engine": "ci",  "screen_family": "core",  "columns": [    {      "key": "repo_id",      "name": "Repository",      "type": "link",      "link_to": "repository",      "readonly": true    },    {      "key": "index_in_repo",      "name": "Run number",      "type": "number",      "readonly": true    },    {      "key": "workflow",      "type": "text",      "readonly": true    },    {      "key": "workflow_name",      "name": "Name",      "type": "text",      "readonly": true    },    {      "key": "event",      "type": "choice",      "choices": [        "push",        "pull_request",        "merge_group",        "schedule",        "workflow_dispatch"      ],      "readonly": true    },    {      "key": "ref",      "name": "Branch or tag",      "type": "text",      "readonly": true    },    {      "key": "sha",      "name": "Commit",      "type": "text",      "readonly": true    },    {      "key": "pull_id",      "name": "Pull request",      "type": "link",      "link_to": "pull",      "readonly": true    },    {      "key": "status",      "name": "State",      "labels": {"queued": "Waiting for a runner", "in_progress": "Running", "completed": "Finished"},      "type": "choice",      "choices": [        "queued",        "in_progress",        "completed"      ],      "readonly": true    },    {      "key": "conclusion",      "name": "Result",      "labels": {"success": "Passed", "failure": "Failed", "cancelled": "Cancelled", "skipped": "Skipped", "timed_out": "Ran out of time"},      "type": "choice",      "choices": [        "success",        "failure",        "cancelled",        "skipped",        "timed_out"      ],      "readonly": true    },    {      "key": "triggered_by",      "name": "Started by",      "type": "choice",      "choices": [        "worker",        "owner",        "schedule"      ],      "readonly": true    },    {      "key": "started_at",      "name": "Started",      "type": "date",      "readonly": true    },    {      "key": "finished_at",      "name": "Finished",      "type": "date",      "readonly": true    },    {      "key": "title_line",      "name": "Run",      "type": "text",      "readonly": true    },    {      "key": "run_line",      "name": "Set off by",      "type": "text",      "readonly": true    },    {      "key": "duration",      "name": "Took",      "type": "text",      "readonly": true    },    {      "key": "triggered_line",      "name": "Started",      "type": "text",      "readonly": true    },    {      "key": "jobs",      "name": "Jobs",      "type": "longtext",      "readonly": true    },    {      "key": "job_ids",      "name": "Job ids",      "type": "longtext",      "readonly": true    }  ],  "title": "title_line",  "date": "started_at",  "project": null,  "order": null,  "slip": {    "title": "title_line",    "subtitle": ["conclusion", "status"],    "subtitle_first": true,    "trailing": "duration",    "caption": {      "columns": [        "run_line"      ],      "dates": []    },    "photo": null,    "toggle": null  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "title_line",        "duration",        "run_line",        "triggered_line",        "sha"      ]    },    {      "heading": "Jobs",      "columns": [        "jobs"      ]    },    {      "heading": "Details",      "columns": [        "workflow_name",        "workflow",        "index_in_repo",        "status",        "conclusion"      ]    },    {      "heading": "Trigger",      "columns": [        "event",        "ref",        "pull_id",        "triggered_by",        "repo_id"      ]    },    {      "heading": "Timing",      "columns": [        "started_at",        "finished_at"      ]    }  ],  "instructions": "A CI run is one run of a workflow for a repository hosted in Cotton, numbered within the repository. Status is queued, in progress or completed, and a completed run has a conclusion. Its log is a file on the Mac that ran it, not part of the record.",  "add": false,  "empty": {    "title": "No runs yet.",    "message": "A repository Cotton hosts runs its workflows on your Macs (Run on its page starts one); a repository hosted elsewhere runs them on its host."  },  "sort": {    "column": "index_in_repo",    "descending": true  },  "tables": [    {      "name": "cotton_repo_runs",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "workspace_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    workspace_id TEXT NOT NULL",          "position": 1        },        {          "name": "repo_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    repo_id TEXT NOT NULL",          "position": 2        },        {          "name": "index_in_repo",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    index_in_repo INTEGER NOT NULL",          "position": 3        },        {          "name": "workflow",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    workflow TEXT NOT NULL",          "position": 4        },        {          "name": "workflow_name",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    workflow_name TEXT",          "position": 5        },        {          "name": "event",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    event TEXT NOT NULL",          "position": 6        },        {          "name": "ref",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    ref TEXT NOT NULL",          "position": 7        },        {          "name": "sha",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    sha TEXT NOT NULL",          "position": 8        },        {          "name": "pull_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    pull_id TEXT",          "position": 9        },        {          "name": "status",          "type": "TEXT",          "default": "'queued'",          "nullable": false,          "primary_key": false,          "declaration": "\n    status TEXT NOT NULL DEFAULT 'queued'",          "position": 10        },        {          "name": "conclusion",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    conclusion TEXT",          "position": 11        },        {          "name": "triggered_by",          "type": "TEXT",          "default": "'worker'",          "nullable": false,          "primary_key": false,          "declaration": "\n    triggered_by TEXT NOT NULL DEFAULT 'worker'",          "position": 12        },        {          "name": "started_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    started_at TEXT",          "position": 13        },        {          "name": "finished_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    finished_at TEXT",          "position": 14        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 15        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 16        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 17        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 18        }      ],      "constraints": [        {          "declaration": "\n    UNIQUE (workspace_id, repo_id, index_in_repo)",          "position": 19        },        {          "declaration": "\n    CHECK (index_in_repo > 0)",          "position": 20        },        {          "declaration": "\n    CHECK (length(trim(workflow)) > 0)",          "position": 21        },        {          "declaration": "\n    CHECK (event IN ('push', 'pull_request', 'merge_group', 'schedule', 'workflow_dispatch'))",          "position": 22        },        {          "declaration": "\n    CHECK (length(trim(ref)) > 0)",          "position": 23        },        {          "declaration": "\n    CHECK (length(sha) BETWEEN 7 AND 64)",          "position": 24        },        {          "declaration": "\n    CHECK (status IN ('queued', 'in_progress', 'completed'))",          "position": 25        },        {          "declaration": "\n    CHECK (conclusion IS NULL OR conclusion IN ('success', 'failure', 'cancelled', 'skipped', 'timed_out'))",          "position": 26        },        {          "declaration": "\n    CHECK (status <> 'completed' OR conclusion IS NOT NULL)",          "position": 27        },        {          "declaration": "\n    CHECK (status = 'completed' OR conclusion IS NULL)",          "position": 28        },        {          "declaration": "\n    CHECK (triggered_by IN ('worker', 'owner', 'schedule'))",          "position": 29        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE",          "position": 30        },        {          "declaration": "\n    FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n  ",          "position": 31        }      ],      "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_runs (",      "suffix": ")",      "indexes": [        "CREATE INDEX IF NOT EXISTS idx_cotton_repo_runs_repo ON cotton_repo_runs (workspace_id, repo_id, index_in_repo DESC)",        "CREATE INDEX IF NOT EXISTS idx_cotton_repo_runs_sha ON cotton_repo_runs (workspace_id, repo_id, sha)",        "CREATE INDEX IF NOT EXISTS idx_cotton_repo_runs_author ON cotton_repo_runs (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ]}