/** * Lexicon for a check run against a git repository hosted in an atproto repo. * * One record per run, in the runner's own repo. The runner's DID is therefore * the record's authority, and a consumer decides which runner DIDs it trusts. * The subject strongref names the exact `dev.pdsjs.git.repo` record version * the run read, so a check cannot be re-attributed to a later push. */ export const GIT_CHECK_COLLECTION = 'dev.pdsjs.git.check'; /** * The latest check per repository and ref, under a key a reader computes. * Check records are keyed by TID, so finding the current state of one ref * means paging a runner's whole history. This collection answers the same * question in one getRecord. */ export const GIT_LATEST_CHECK_COLLECTION = 'dev.pdsjs.git.latestCheck'; /** * A run the repository's owner asked for, in the owner's own repo. The runner * has no inbound address, so the firehose it already reads is the channel that * carries this. The record's authority is the authorisation: a runner honours * a request written by the account that owns the repository, and no other. */ export const GIT_CHECK_REQUEST_COLLECTION = 'dev.pdsjs.git.checkRequest'; /** Terminal statuses, plus the one a run publishes before it starts work. */ export const CHECK_STATUSES = ['running', 'success', 'failure', 'error']; export const gitCheckLexicon = { lexicon: 1, id: GIT_CHECK_COLLECTION, defs: { main: { type: 'record', description: 'The result of running a workflow against one commit of a git repository stored as a dev.pdsjs.git.repo record.', key: 'tid', record: { type: 'object', required: ['subject', 'ref', 'sha', 'status', 'startedAt'], properties: { subject: { type: 'ref', ref: '#subject', description: 'The repository record version this run read.', }, ref: { type: 'string', maxLength: 512, description: 'Full ref name that moved, e.g. refs/heads/main.', }, sha: { type: 'string', minLength: 40, maxLength: 64, description: 'Git commit the workflow ran against.', }, workflow: { type: 'string', maxLength: 512, description: 'Workflow name from the in-tree definition.', }, status: { type: 'string', knownValues: CHECK_STATUSES, description: 'running until the run finishes. failure means a step exited non-zero; error means the run could not complete.', }, steps: { type: 'array', items: { type: 'ref', ref: '#step' }, }, logs: { type: 'blob', accept: ['text/plain'], description: 'Combined stdout and stderr of every step.', }, startedAt: { type: 'string', format: 'datetime' }, finishedAt: { type: 'string', format: 'datetime' }, }, }, }, subject: { type: 'object', required: ['uri', 'cid'], properties: { uri: { type: 'string', format: 'at-uri' }, cid: { type: 'string', format: 'cid' }, }, }, step: { type: 'object', required: ['name', 'exitCode'], properties: { name: { type: 'string', maxLength: 512 }, exitCode: { type: 'integer', description: 'Negative when a signal ended the step.', }, durationMs: { type: 'integer' }, }, }, }, }; export const gitCheckRequestLexicon = { lexicon: 1, id: GIT_CHECK_REQUEST_COLLECTION, defs: { main: { type: 'record', description: "A request that the repository's runner check one ref again. Written by the repository's owner into the owner's own repo, where the runner sees it on the firehose. The record key is derived from the repository and the ref, so a second request for the same ref replaces the first.", key: 'any', record: { type: 'object', required: ['repo', 'ref', 'requestedAt'], properties: { repo: { type: 'string', maxLength: 512, description: 'Record key of the dev.pdsjs.git.repo record to check, in the same repo as this record.', }, ref: { type: 'string', maxLength: 512, description: 'Full ref name to check, e.g. refs/heads/main.', }, sha: { type: 'string', minLength: 40, maxLength: 64, description: 'Commit to check. Absent asks for whatever the ref points at when the runner reads it.', }, requestedAt: { type: 'string', format: 'datetime', description: 'When the request was made. Two requests for one ref differ here, which is what makes the second record a new version and so a new firehose event.', }, }, }, }, }, }; export const gitLatestCheckLexicon = { lexicon: 1, id: GIT_LATEST_CHECK_COLLECTION, defs: { main: { type: 'record', description: 'The most recent check of each workflow for one ref of one repository. The record key is derived from the repository and the ref, so a reader that knows both finds this without a listing.', key: 'any', record: { type: 'object', required: ['ref', 'checks'], properties: { ref: { type: 'string', maxLength: 512 }, checks: { type: 'array', items: { type: 'ref', ref: '#entry' }, description: 'One entry per workflow, each replaced by its runs.', }, }, }, }, entry: { type: 'object', required: ['workflow', 'subject', 'check', 'sha', 'status', 'startedAt'], properties: { workflow: { type: 'string', maxLength: 512 }, subject: { type: 'ref', ref: 'dev.pdsjs.git.check#subject', description: 'The repository record version the check read.', }, check: { type: 'ref', ref: 'dev.pdsjs.git.check#subject', description: 'The check record this names.', }, sha: { type: 'string', minLength: 40, maxLength: 64 }, status: { type: 'string', knownValues: CHECK_STATUSES, description: 'running while the check named above is unfinished.', }, startedAt: { type: 'string', format: 'datetime' }, finishedAt: { type: 'string', format: 'datetime', description: 'Absent while the check is running.', }, }, }, }, };