From bc3bbb89fd8ec43fd5f2074e964564c808a1c70c Mon Sep 17 00:00:00 2001 From: dawn Date: Thu, 22 Oct 2026 06:38:06 +0300 Subject: [PATCH] lexicons: add org.tangled.ci.triggerPipeline and cancelPipeline Signed-off-by: dawn --- api/org_tangled/cbor_gen.go | 349 +++++++++++++++++- api/org_tangled/cicancelPipeline.go | 34 ++ api/org_tangled/citriggerPipeline.go | 79 ++++ api/org_tangled/eventnotifyEvent.go | 2 +- api/org_tangled/eventpullRequest.go | 10 + lexicons/org/tangled/ci/cancelPipeline.json | 39 ++ lexicons/org/tangled/ci/triggerPipeline.json | 65 ++++ lexicons/org/tangled/event/notifyEvent.json | 3 +- lexicons/org/tangled/event/pullRequest.json | 36 +- web/src/lib/api/lexicons/index.ts | 2 + .../types/org/tangled/ci/cancelPipeline.ts | 42 +++ .../types/org/tangled/ci/triggerPipeline.ts | 61 +++ .../types/org/tangled/event/notifyEvent.ts | 4 +- .../types/org/tangled/event/pullRequest.ts | 32 ++ 14 files changed, 749 insertions(+), 9 deletions(-) create mode 100644 api/org_tangled/cicancelPipeline.go create mode 100644 api/org_tangled/citriggerPipeline.go create mode 100644 lexicons/org/tangled/ci/cancelPipeline.json create mode 100644 lexicons/org/tangled/ci/triggerPipeline.json create mode 100644 web/src/lib/api/lexicons/types/org/tangled/ci/cancelPipeline.ts create mode 100644 web/src/lib/api/lexicons/types/org/tangled/ci/triggerPipeline.ts diff --git a/api/org_tangled/cbor_gen.go b/api/org_tangled/cbor_gen.go index 3cb3c8f8e..f68fd7c4c 100644 --- a/api/org_tangled/cbor_gen.go +++ b/api/org_tangled/cbor_gen.go @@ -2039,11 +2039,68 @@ func (t *EventPullRequest) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) + fieldCount := 7 - if _, err := cw.Write([]byte{161}); err != nil { + if t.Action == nil { + fieldCount-- + } + + if t.Pull == nil { + fieldCount-- + } + + if t.SourceBranch == nil { + fieldCount-- + } + + if t.SourceRepo == nil { + fieldCount-- + } + + if t.SourceSha == nil { + fieldCount-- + } + + if t.TargetBranch == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { return err } + // t.Pull (string) (string) + if t.Pull != nil { + + if len("pull") > 1000000 { + return xerrors.Errorf("Value in field \"pull\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { + return err + } + if _, err := cw.WriteString(string("pull")); err != nil { + return err + } + + if t.Pull == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Pull) > 1000000 { + return xerrors.Errorf("Value in field t.Pull was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Pull))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Pull)); err != nil { + return err + } + } + } + // t.LexiconTypeID (string) (string) if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") @@ -2062,6 +2119,166 @@ func (t *EventPullRequest) MarshalCBOR(w io.Writer) error { if _, err := cw.WriteString(string("org.tangled.event.pullRequest")); err != nil { return err } + + // t.Action (string) (string) + if t.Action != nil { + + if len("action") > 1000000 { + return xerrors.Errorf("Value in field \"action\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("action"))); err != nil { + return err + } + if _, err := cw.WriteString(string("action")); err != nil { + return err + } + + if t.Action == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Action) > 1000000 { + return xerrors.Errorf("Value in field t.Action was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Action))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Action)); err != nil { + return err + } + } + } + + // t.SourceSha (string) (string) + if t.SourceSha != nil { + + if len("sourceSha") > 1000000 { + return xerrors.Errorf("Value in field \"sourceSha\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceSha"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sourceSha")); err != nil { + return err + } + + if t.SourceSha == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.SourceSha) > 1000000 { + return xerrors.Errorf("Value in field t.SourceSha was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceSha))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.SourceSha)); err != nil { + return err + } + } + } + + // t.SourceRepo (string) (string) + if t.SourceRepo != nil { + + if len("sourceRepo") > 1000000 { + return xerrors.Errorf("Value in field \"sourceRepo\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceRepo"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sourceRepo")); err != nil { + return err + } + + if t.SourceRepo == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.SourceRepo) > 1000000 { + return xerrors.Errorf("Value in field t.SourceRepo was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceRepo))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.SourceRepo)); err != nil { + return err + } + } + } + + // t.SourceBranch (string) (string) + if t.SourceBranch != nil { + + if len("sourceBranch") > 1000000 { + return xerrors.Errorf("Value in field \"sourceBranch\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sourceBranch"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sourceBranch")); err != nil { + return err + } + + if t.SourceBranch == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.SourceBranch) > 1000000 { + return xerrors.Errorf("Value in field t.SourceBranch was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.SourceBranch))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.SourceBranch)); err != nil { + return err + } + } + } + + // t.TargetBranch (string) (string) + if t.TargetBranch != nil { + + if len("targetBranch") > 1000000 { + return xerrors.Errorf("Value in field \"targetBranch\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil { + return err + } + if _, err := cw.WriteString(string("targetBranch")); err != nil { + return err + } + + if t.TargetBranch == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.TargetBranch) > 1000000 { + return xerrors.Errorf("Value in field t.TargetBranch was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.TargetBranch))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.TargetBranch)); err != nil { + return err + } + } + } return nil } @@ -2090,7 +2307,7 @@ func (t *EventPullRequest) UnmarshalCBOR(r io.Reader) (err error) { n := extra - nameBuf := make([]byte, 5) + nameBuf := make([]byte, 12) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -2106,7 +2323,28 @@ func (t *EventPullRequest) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.LexiconTypeID (string) (string) + // t.Pull (string) (string) + case "pull": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Pull = (*string)(&sval) + } + } + // t.LexiconTypeID (string) (string) case "$type": { @@ -2117,6 +2355,111 @@ func (t *EventPullRequest) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } + // t.Action (string) (string) + case "action": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Action = (*string)(&sval) + } + } + // t.SourceSha (string) (string) + case "sourceSha": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.SourceSha = (*string)(&sval) + } + } + // t.SourceRepo (string) (string) + case "sourceRepo": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.SourceRepo = (*string)(&sval) + } + } + // t.SourceBranch (string) (string) + case "sourceBranch": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.SourceBranch = (*string)(&sval) + } + } + // t.TargetBranch (string) (string) + case "targetBranch": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.TargetBranch = (*string)(&sval) + } + } default: // Field doesn't exist on this type, so ignore it diff --git a/api/org_tangled/cicancelPipeline.go b/api/org_tangled/cicancelPipeline.go new file mode 100644 index 000000000..edab43738 --- /dev/null +++ b/api/org_tangled/cicancelPipeline.go @@ -0,0 +1,34 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.cancelPipeline + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiCancelPipelineNSID = "org.tangled.ci.cancelPipeline" +) + +// CiCancelPipeline_Input is the input argument to a org.tangled.ci.cancelPipeline call. +type CiCancelPipeline_Input struct { + // pipeline: Spindle-local pipeline id + Pipeline string `json:"pipeline" cborgen:"pipeline"` + // repo: git repository DID + Repo string `json:"repo" cborgen:"repo"` + // workflows: Workflow names to filter. When not provided, entire pipeline will be canceled. + Workflows []string `json:"workflows,omitempty" cborgen:"workflows,omitempty"` +} + +// CiCancelPipeline calls the XRPC method "org.tangled.ci.cancelPipeline". +func CiCancelPipeline(ctx context.Context, c util.LexClient, input *CiCancelPipeline_Input) error { + if err := c.LexDo(ctx, util.Procedure, "application/json", "org.tangled.ci.cancelPipeline", nil, input, nil); err != nil { + return err + } + + return nil +} diff --git a/api/org_tangled/citriggerPipeline.go b/api/org_tangled/citriggerPipeline.go new file mode 100644 index 000000000..4b48fdb67 --- /dev/null +++ b/api/org_tangled/citriggerPipeline.go @@ -0,0 +1,79 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package org_tangled + +// schema: org.tangled.ci.triggerPipeline + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + CiTriggerPipelineNSID = "org.tangled.ci.triggerPipeline" +) + +// CiTriggerPipeline_Input is the input argument to a org.tangled.ci.triggerPipeline call. +type CiTriggerPipeline_Input struct { + // repo: Target repository DID. Auth is checked against this repo. + Repo string `json:"repo" cborgen:"repo"` + // trigger: Trigger metadata for this dispatch. + Trigger *CiTriggerPipeline_Input_Trigger `json:"trigger" cborgen:"trigger"` + // workflows: Workflow names to run. When not provided, every dispatchable workflow is run. + Workflows []string `json:"workflows,omitempty" cborgen:"workflows,omitempty"` +} + +// Trigger metadata for this dispatch. +type CiTriggerPipeline_Input_Trigger struct { + CiTriggerManual *CiTriggerManual + EventPullRequest *EventPullRequest +} + +func (t *CiTriggerPipeline_Input_Trigger) MarshalJSON() ([]byte, error) { + if t.CiTriggerManual != nil { + t.CiTriggerManual.LexiconTypeID = "org.tangled.ci.trigger.manual" + return json.Marshal(t.CiTriggerManual) + } + if t.EventPullRequest != nil { + t.EventPullRequest.LexiconTypeID = "org.tangled.event.pullRequest" + return json.Marshal(t.EventPullRequest) + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *CiTriggerPipeline_Input_Trigger) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "org.tangled.ci.trigger.manual": + t.CiTriggerManual = new(CiTriggerManual) + return json.Unmarshal(b, t.CiTriggerManual) + case "org.tangled.event.pullRequest": + t.EventPullRequest = new(EventPullRequest) + return json.Unmarshal(b, t.EventPullRequest) + + default: + return nil + } +} + +// CiTriggerPipeline_Output is the output of a org.tangled.ci.triggerPipeline call. +type CiTriggerPipeline_Output struct { + // pipeline: Spindle-local id of the created pipeline + Pipeline string `json:"pipeline" cborgen:"pipeline"` +} + +// CiTriggerPipeline calls the XRPC method "org.tangled.ci.triggerPipeline". +func CiTriggerPipeline(ctx context.Context, c util.LexClient, input *CiTriggerPipeline_Input) (*CiTriggerPipeline_Output, error) { + var out CiTriggerPipeline_Output + if err := c.LexDo(ctx, util.Procedure, "application/json", "org.tangled.ci.triggerPipeline", nil, input, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/org_tangled/eventnotifyEvent.go b/api/org_tangled/eventnotifyEvent.go index 9f094fae2..6930349c5 100644 --- a/api/org_tangled/eventnotifyEvent.go +++ b/api/org_tangled/eventnotifyEvent.go @@ -62,7 +62,7 @@ func (t *EventNotifyEvent_Input_Event) UnmarshalJSON(b []byte) error { // EventNotifyEvent_Output is the output of a org.tangled.event.notifyEvent call. type EventNotifyEvent_Output struct { - // pipeline: AT-URI of the scheduled pipeline + // pipeline: Spindle-local id of the scheduled pipeline Pipeline *string `json:"pipeline,omitempty" cborgen:"pipeline,omitempty"` } diff --git a/api/org_tangled/eventpullRequest.go b/api/org_tangled/eventpullRequest.go index c33917ede..68da28743 100644 --- a/api/org_tangled/eventpullRequest.go +++ b/api/org_tangled/eventpullRequest.go @@ -20,4 +20,14 @@ func init() { // RECORDTYPE: EventPullRequest type EventPullRequest struct { LexiconTypeID string `json:"$type,const=org.tangled.event.pullRequest" cborgen:"$type,const=org.tangled.event.pullRequest"` + // action: The pull request lifecycle action that produced this trigger. + Action *string `json:"action,omitempty" cborgen:"action,omitempty"` + // pull: AT-URI of the pull request record this run belongs to. + Pull *string `json:"pull,omitempty" cborgen:"pull,omitempty"` + SourceBranch *string `json:"sourceBranch,omitempty" cborgen:"sourceBranch,omitempty"` + // sourceRepo: Repository DID to check out code and workflow definitions from, if different from the target repo. + SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"` + // sourceSha: Commit id of the pull request head. + SourceSha *string `json:"sourceSha,omitempty" cborgen:"sourceSha,omitempty"` + TargetBranch *string `json:"targetBranch,omitempty" cborgen:"targetBranch,omitempty"` } diff --git a/lexicons/org/tangled/ci/cancelPipeline.json b/lexicons/org/tangled/ci/cancelPipeline.json new file mode 100644 index 000000000..b1130716e --- /dev/null +++ b/lexicons/org/tangled/ci/cancelPipeline.json @@ -0,0 +1,39 @@ +{ + "lexicon": 1, + "id": "org.tangled.ci.cancelPipeline", + "defs": { + "main": { + "type": "procedure", + "description": "Cancel running pipeline or specific workflows", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": [ + "repo", + "pipeline" + ], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "git repository DID" + }, + "pipeline": { + "type": "string", + "description": "Spindle-local pipeline id" + }, + "workflows": { + "type": "array", + "items": { + "type": "string", + "description": "workflow name" + }, + "description": "Workflow names to filter. When not provided, entire pipeline will be canceled." + } + } + } + } + } + } +} diff --git a/lexicons/org/tangled/ci/triggerPipeline.json b/lexicons/org/tangled/ci/triggerPipeline.json new file mode 100644 index 000000000..ace5381c5 --- /dev/null +++ b/lexicons/org/tangled/ci/triggerPipeline.json @@ -0,0 +1,65 @@ +{ + "lexicon": 1, + "id": "org.tangled.ci.triggerPipeline", + "defs": { + "main": { + "type": "procedure", + "description": "Trigger a pipeline at an explicit commit. Runs the named workflows, or every workflow defined in the repo when none are named.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": [ + "repo", + "trigger" + ], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "Target repository DID. Auth is checked against this repo." + }, + "trigger": { + "type": "union", + "closed": false, + "refs": [ + "org.tangled.ci.trigger.manual", + "org.tangled.event.pullRequest" + ], + "description": "Trigger metadata for this dispatch." + }, + "workflows": { + "type": "array", + "items": { + "type": "string", + "description": "workflow name" + }, + "description": "Workflow names to run. When not provided, every dispatchable workflow is run." + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": [ + "pipeline" + ], + "properties": { + "pipeline": { + "type": "string", + "description": "Spindle-local id of the created pipeline" + } + } + } + }, + "errors": [ + { + "name": "InvalidRequest", + "description": "Invalid request parameters" + } + ] + } + } +} diff --git a/lexicons/org/tangled/event/notifyEvent.json b/lexicons/org/tangled/event/notifyEvent.json index c0b2920d5..579222f64 100644 --- a/lexicons/org/tangled/event/notifyEvent.json +++ b/lexicons/org/tangled/event/notifyEvent.json @@ -35,8 +35,7 @@ "properties": { "pipeline": { "type": "string", - "format": "at-uri", - "description": "AT-URI of the scheduled pipeline" + "description": "Spindle-local id of the scheduled pipeline" } } } diff --git a/lexicons/org/tangled/event/pullRequest.json b/lexicons/org/tangled/event/pullRequest.json index ec5a911ca..ceef166f5 100644 --- a/lexicons/org/tangled/event/pullRequest.json +++ b/lexicons/org/tangled/event/pullRequest.json @@ -7,7 +7,41 @@ "main": { "type": "object", "description": "When pull request is created or resubmitted.", - "properties": {} + "properties": { + "action": { + "type": "string", + "description": "The pull request lifecycle action that produced this trigger.", + "enum": [ + "opened", + "reopened", + "closed", + "merged", + "synchronize" + ] + }, + "pull": { + "type": "string", + "format": "at-uri", + "description": "AT-URI of the pull request record this run belongs to." + }, + "sourceRepo": { + "type": "string", + "format": "did", + "description": "Repository DID to check out code and workflow definitions from, if different from the target repo." + }, + "sourceBranch": { + "type": "string" + }, + "targetBranch": { + "type": "string" + }, + "sourceSha": { + "type": "string", + "description": "Commit id of the pull request head.", + "minLength": 40, + "maxLength": 64 + } + } } } } diff --git a/web/src/lib/api/lexicons/index.ts b/web/src/lib/api/lexicons/index.ts index d2fae81d7..ca173e9c9 100644 --- a/web/src/lib/api/lexicons/index.ts +++ b/web/src/lib/api/lexicons/index.ts @@ -9,6 +9,7 @@ export * as OrgTangledActorGetTrending from "./types/org/tangled/actor/getTrendi export * as OrgTangledActorProfile from "./types/org/tangled/actor/profile.js"; export * as OrgTangledActorSearchActorsTypeahead from "./types/org/tangled/actor/searchActorsTypeahead.js"; export * as OrgTangledBobbinAwaitRecord from "./types/org/tangled/bobbin/awaitRecord.js"; +export * as OrgTangledCiCancelPipeline from "./types/org/tangled/ci/cancelPipeline.js"; export * as OrgTangledCiGetPipeline from "./types/org/tangled/ci/getPipeline.js"; export * as OrgTangledCiGetWorkflowDefinition from "./types/org/tangled/ci/getWorkflowDefinition.js"; export * as OrgTangledCiListWorkflowDefinitions from "./types/org/tangled/ci/listWorkflowDefinitions.js"; @@ -16,6 +17,7 @@ export * as OrgTangledCiPipeline from "./types/org/tangled/ci/pipeline.js"; export * as OrgTangledCiQueryPipelines from "./types/org/tangled/ci/queryPipelines.js"; export * as OrgTangledCiSubscribePipelineLogs from "./types/org/tangled/ci/subscribePipelineLogs.js"; export * as OrgTangledCiTriggerManual from "./types/org/tangled/ci/trigger/manual.js"; +export * as OrgTangledCiTriggerPipeline from "./types/org/tangled/ci/triggerPipeline.js"; export * as OrgTangledCiWorkflow from "./types/org/tangled/ci/workflow.js"; export * as OrgTangledEmbedCommit from "./types/org/tangled/embed/commit.js"; export * as OrgTangledEventNotifyEvent from "./types/org/tangled/event/notifyEvent.js"; diff --git a/web/src/lib/api/lexicons/types/org/tangled/ci/cancelPipeline.ts b/web/src/lib/api/lexicons/types/org/tangled/ci/cancelPipeline.ts new file mode 100644 index 000000000..6f7724dd2 --- /dev/null +++ b/web/src/lib/api/lexicons/types/org/tangled/ci/cancelPipeline.ts @@ -0,0 +1,42 @@ +import type {} from "@atcute/lexicons"; +import * as v from "@atcute/lexicons/validations"; +import type {} from "@atcute/lexicons/ambient"; + +const _mainSchema = /*#__PURE__*/ v.procedure("org.tangled.ci.cancelPipeline", { + params: null, + input: { + type: "lex", + schema: /*#__PURE__*/ v.object({ + /** + * Spindle-local pipeline id + */ + pipeline: /*#__PURE__*/ v.string(), + /** + * git repository DID + */ + repo: /*#__PURE__*/ v.didString(), + /** + * Workflow names to filter. When not provided, entire pipeline will be canceled. + */ + workflows: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.array(/*#__PURE__*/ v.string()), + ), + }), + }, + output: null, +}); + +type main$schematype = typeof _mainSchema; + +export interface mainSchema extends main$schematype {} + +export const mainSchema = _mainSchema as mainSchema; + +export interface $params {} +export interface $input extends v.InferXRPCBodyInput {} + +declare module "@atcute/lexicons/ambient" { + interface XRPCProcedures { + "org.tangled.ci.cancelPipeline": mainSchema; + } +} diff --git a/web/src/lib/api/lexicons/types/org/tangled/ci/triggerPipeline.ts b/web/src/lib/api/lexicons/types/org/tangled/ci/triggerPipeline.ts new file mode 100644 index 000000000..59e4786df --- /dev/null +++ b/web/src/lib/api/lexicons/types/org/tangled/ci/triggerPipeline.ts @@ -0,0 +1,61 @@ +import type {} from "@atcute/lexicons"; +import * as v from "@atcute/lexicons/validations"; +import type {} from "@atcute/lexicons/ambient"; +import * as OrgTangledCiTriggerManual from "./trigger/manual.js"; +import * as OrgTangledEventPullRequest from "../event/pullRequest.js"; + +const _mainSchema = /*#__PURE__*/ v.procedure( + "org.tangled.ci.triggerPipeline", + { + params: null, + input: { + type: "lex", + schema: /*#__PURE__*/ v.object({ + /** + * Target repository DID. Auth is checked against this repo. + */ + repo: /*#__PURE__*/ v.didString(), + /** + * Trigger metadata for this dispatch. + */ + get trigger() { + return /*#__PURE__*/ v.variant([ + OrgTangledCiTriggerManual.mainSchema, + OrgTangledEventPullRequest.mainSchema, + ]); + }, + /** + * Workflow names to run. When not provided, every dispatchable workflow is run. + */ + workflows: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.array(/*#__PURE__*/ v.string()), + ), + }), + }, + output: { + type: "lex", + schema: /*#__PURE__*/ v.object({ + /** + * Spindle-local id of the created pipeline + */ + pipeline: /*#__PURE__*/ v.string(), + }), + }, + }, +); + +type main$schematype = typeof _mainSchema; + +export interface mainSchema extends main$schematype {} + +export const mainSchema = _mainSchema as mainSchema; + +export interface $params {} +export interface $input extends v.InferXRPCBodyInput {} +export interface $output extends v.InferXRPCBodyInput {} + +declare module "@atcute/lexicons/ambient" { + interface XRPCProcedures { + "org.tangled.ci.triggerPipeline": mainSchema; + } +} diff --git a/web/src/lib/api/lexicons/types/org/tangled/event/notifyEvent.ts b/web/src/lib/api/lexicons/types/org/tangled/event/notifyEvent.ts index 593ccb5db..563bd2175 100644 --- a/web/src/lib/api/lexicons/types/org/tangled/event/notifyEvent.ts +++ b/web/src/lib/api/lexicons/types/org/tangled/event/notifyEvent.ts @@ -28,9 +28,9 @@ const _mainSchema = /*#__PURE__*/ v.procedure("org.tangled.event.notifyEvent", { type: "lex", schema: /*#__PURE__*/ v.object({ /** - * AT-URI of the scheduled pipeline + * Spindle-local id of the scheduled pipeline */ - pipeline: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.resourceUriString()), + pipeline: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.string()), }), }, }); diff --git a/web/src/lib/api/lexicons/types/org/tangled/event/pullRequest.ts b/web/src/lib/api/lexicons/types/org/tangled/event/pullRequest.ts index f4204e73e..db5a14c25 100644 --- a/web/src/lib/api/lexicons/types/org/tangled/event/pullRequest.ts +++ b/web/src/lib/api/lexicons/types/org/tangled/event/pullRequest.ts @@ -5,6 +5,38 @@ const _mainSchema = /*#__PURE__*/ v.object({ $type: /*#__PURE__*/ v.optional( /*#__PURE__*/ v.literal("org.tangled.event.pullRequest"), ), + /** + * The pull request lifecycle action that produced this trigger. + */ + action: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.literalEnum([ + "closed", + "merged", + "opened", + "reopened", + "synchronize", + ]), + ), + /** + * AT-URI of the pull request record this run belongs to. + */ + pull: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.resourceUriString()), + sourceBranch: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.string()), + /** + * Repository DID to check out code and workflow definitions from, if different from the target repo. + */ + sourceRepo: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.didString()), + /** + * Commit id of the pull request head. + * @minLength 40 + * @maxLength 64 + */ + sourceSha: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ + /*#__PURE__*/ v.stringLength(40, 64), + ]), + ), + targetBranch: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.string()), }); type main$schematype = typeof _mainSchema; -- 2.54.0