# org.tangled.ci.defs

- Kind: defs
- Authority: ci.tangled.org
- Lexicon: 1
- Published by [tangled.org](https://lexicon.garden/identity/did:plc:wshs7t2adsemcrrd4snkeqli), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:wshs7t2adsemcrrd4snkeqli/org.tangled.ci.defs)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:wshs7t2adsemcrrd4snkeqli/org.tangled.ci.defs/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:wshs7t2adsemcrrd4snkeqli/org.tangled.ci.defs/analytics)

## #externalSource (`org.tangled.ci.defs#externalSource`)

Type: object

### Properties

- `link` (string · uri, required)
- `name` (string): human-readable name of external source

## #fileSource (`org.tangled.ci.defs#fileSource`)

Type: object

### Properties

- `commit` (string, required)
  - Constraints: minLength: 40, maxLength: 128
- `lines` (ref)
  - Reference: `#lineRange`
- `path` (string, required)
  - Constraints: minLength: 1
- `repo` (string · did, required)

## #lineRange (`org.tangled.ci.defs#lineRange`)

Type: object

### Properties

- `end` (integer, required)
  - Constraints: minimum: 1
- `start` (integer, required)
  - Constraints: minimum: 1

## #pipeline (`org.tangled.ci.defs#pipeline`)

Type: object

A CI pipeline. Record-like, but owned by the spindle rather than a PDS.

### Properties

- `commit` (string, required): Commit Id this pipeline is running on
- `createdAt` (string · datetime)
- `id` (string · record-key, required): Spindle-local pipeline id
- `repo` (string · did, required): Repository DID
- `sourceRepo` (string · did): Repository DID that the commit was checked out from, if different from repo (e.g. a fork for a fork-based pull request)
- `trigger` (union, required): Trigger event that triggered this pipeline.
  - One of: `org.tangled.event.push`, `org.tangled.event.pullRequest`, `org.tangled.ci.trigger.manual`, `org.tangled.ci.trigger.schedule`
- `workflows` (array, required): Triggered workflows
  - Constraints: minLength: 1, maxLength: 50
  - `items` (ref)
    - Reference: `#workflowRun`

## #workflow (`org.tangled.ci.defs#workflow`)

Type: object

A workflow definition

### Properties

- `hash` (string): Fingerprint of the workflow definition as resolved by the spindle.
- `id` (string, required)
  - Constraints: minLength: 1, maxLength: 128
- `name` (string): Human-readable name of the workflow
  - Constraints: minLength: 1, maxLength: 128
- `source` (union, required)
  - One of: `#fileSource`, `#externalSource`
- `triggers` (array, required): Event types that triggers this workflow.
  - `items` (string)
    - Constraints: knownValues: org.tangled.event.push | org.tangled.event.pullRequest | org.tangled.ci.trigger.manual | org.tangled.ci.trigger.schedule

## #workflowRun (`org.tangled.ci.defs#workflowRun`)

Type: object

### Properties

- `definition` (ref, required): Workflow definition where this workflow run is originated from.
  - Reference: `#workflow`
- `error` (string)
- `finishedAt` (string · datetime)
- `id` (string, required): Pipeline-local workflow id, usually same as name.
  - Constraints: minLength: 1, maxLength: 128
- `name` (string): Human-readable name of the workflow
  - Constraints: maxLength: 128
- `startedAt` (string · datetime)
- `status` (string, required): Workflow status
  - Constraints: enum: pending | blocked | running | failed | timeout | cancelled | success

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "externalSource": {
      "properties": {
        "link": {
          "format": "uri",
          "type": "string"
        },
        "name": {
          "description": "human-readable name of external source",
          "type": "string"
        }
      },
      "required": [
        "link"
      ],
      "type": "object"
    },
    "fileSource": {
      "properties": {
        "commit": {
          "maxLength": 128,
          "minLength": 40,
          "type": "string"
        },
        "lines": {
          "ref": "#lineRange",
          "type": "ref"
        },
        "path": {
          "minLength": 1,
          "type": "string"
        },
        "repo": {
          "format": "did",
          "type": "string"
        }
      },
      "required": [
        "repo",
        "commit",
        "path"
      ],
      "type": "object"
    },
    "lineRange": {
      "properties": {
        "end": {
          "minimum": 1,
          "type": "integer"
        },
        "start": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "type": "object"
    },
    "pipeline": {
      "description": "A CI pipeline. Record-like, but owned by the spindle rather than a PDS.",
      "properties": {
        "commit": {
          "description": "Commit Id this pipeline is running on",
          "type": "string"
        },
        "createdAt": {
          "format": "datetime",
          "type": "string"
        },
        "id": {
          "description": "Spindle-local pipeline id",
          "format": "record-key",
          "type": "string"
        },
        "repo": {
          "description": "Repository DID",
          "format": "did",
          "type": "string"
        },
        "sourceRepo": {
          "description": "Repository DID that the commit was checked out from, if different from repo (e.g. a fork for a fork-based pull request)",
          "format": "did",
          "type": "string"
        },
        "trigger": {
          "closed": false,
          "description": "Trigger event that triggered this pipeline.",
          "refs": [
            "org.tangled.event.push",
            "org.tangled.event.pullRequest",
            "org.tangled.ci.trigger.manual",
            "org.tangled.ci.trigger.schedule"
          ],
          "type": "union"
        },
        "workflows": {
          "description": "Triggered workflows",
          "items": {
            "ref": "#workflowRun",
            "type": "ref"
          },
          "maxLength": 50,
          "minLength": 1,
          "type": "array"
        }
      },
      "required": [
        "id",
        "repo",
        "trigger",
        "commit",
        "workflows"
      ],
      "type": "object"
    },
    "workflow": {
      "description": "A workflow definition",
      "properties": {
        "hash": {
          "description": "Fingerprint of the workflow definition as resolved by the spindle.",
          "type": "string"
        },
        "id": {
          "maxLength": 128,
          "minLength": 1,
          "type": "string"
        },
        "name": {
          "description": "Human-readable name of the workflow",
          "maxLength": 128,
          "minLength": 1,
          "type": "string"
        },
        "source": {
          "refs": [
            "#fileSource",
            "#externalSource"
          ],
          "type": "union"
        },
        "triggers": {
          "description": "Event types that triggers this workflow.",
          "items": {
            "knownValues": [
              "org.tangled.event.push",
              "org.tangled.event.pullRequest",
              "org.tangled.ci.trigger.manual",
              "org.tangled.ci.trigger.schedule"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "required": [
        "id",
        "source",
        "triggers"
      ],
      "type": "object"
    },
    "workflowRun": {
      "properties": {
        "definition": {
          "description": "Workflow definition where this workflow run is originated from.",
          "ref": "#workflow",
          "type": "ref"
        },
        "error": {
          "type": "string"
        },
        "finishedAt": {
          "format": "datetime",
          "type": "string"
        },
        "id": {
          "description": "Pipeline-local workflow id, usually same as name.",
          "maxLength": 128,
          "minLength": 1,
          "type": "string"
        },
        "name": {
          "description": "Human-readable name of the workflow",
          "maxLength": 128,
          "type": "string"
        },
        "startedAt": {
          "format": "datetime",
          "type": "string"
        },
        "status": {
          "description": "Workflow status",
          "enum": [
            "pending",
            "blocked",
            "running",
            "failed",
            "timeout",
            "cancelled",
            "success"
          ],
          "type": "string"
        }
      },
      "required": [
        "definition",
        "id",
        "status"
      ],
      "type": "object"
    }
  },
  "id": "org.tangled.ci.defs",
  "lexicon": 1
}
```
