diff --git a/app/cli/cmd/attestation_event.go b/app/cli/cmd/attestation_event.go index 196f55ff7..0be0e28d2 100644 --- a/app/cli/cmd/attestation_event.go +++ b/app/cli/cmd/attestation_event.go @@ -37,7 +37,10 @@ The name uses letters, digits, "_" and "-", up to 64 characters. Events with the If the event cannot be recorded, the command shows a warning and exits with success, so it never breaks the pipeline.`, Example: ` # Record the start and the end of a step chainloop attestation event --name sast-scan --status started --message "Semgrep, ruleset p/ci" - chainloop attestation event --name sast-scan --status succeeded`, + chainloop attestation event --name sast-scan --status succeeded + + # Record a step that did not run + chainloop attestation event --name dast-scan --status skipped --message "no web target"`, // the arguments are checked in RunE, so that a wrong call is a warning too Args: cobra.ArbitraryArgs, Annotations: map[string]string{ @@ -45,7 +48,7 @@ If the event cannot be recorded, the command shows a warning and exits with succ supportsFederatedAuthAnnotation: trueString, }, RunE: func(cmd *cobra.Command, args []string) error { - // a progress signal never breaks the pipeline (spec R-009), so every + // a progress signal never breaks the pipeline (spec R-013), so every // failure, also a wrong call, is a warning and the command exits with success if len(args) > 0 { logger.Warn().Msgf("the event was not recorded: unexpected arguments %q, set the step with --name", args) diff --git a/app/cli/cmd/workflow_run_timeline.go b/app/cli/cmd/workflow_run_timeline.go index 77d2fd738..3fcf3a525 100644 --- a/app/cli/cmd/workflow_run_timeline.go +++ b/app/cli/cmd/workflow_run_timeline.go @@ -396,6 +396,8 @@ func timelineSymbol(status string) string { return text.FgHiRed.Sprint("✗") case action.RunEventStatusCanceled: return text.FgYellow.Sprint("⊘") + case action.RunEventStatusSkipped: + return text.FgHiBlack.Sprint("↷") default: return text.FgYellow.Sprint("●") } diff --git a/app/cli/cmd/workflow_run_timeline_test.go b/app/cli/cmd/workflow_run_timeline_test.go index bac71dc9b..7cc5dd8a1 100644 --- a/app/cli/cmd/workflow_run_timeline_test.go +++ b/app/cli/cmd/workflow_run_timeline_test.go @@ -139,6 +139,24 @@ func TestRenderRunTimeline(t *testing.T) { "├─ 10:01:02 ● step `approval` waiting for approval\n" + "└─ 10:02:02 ✓ pushed and stored\n", }, + { + name: "stored run, with skipped custom steps", + events: []*action.RunEvent{ + started, + custom(60*time.Second, "dast-scan", "skipped", "no web target"), + custom(70*time.Second, "unit-tests", "started", ""), + custom(90*time.Second, "unit-tests", "skipped", "cached"), + {CreatedAt: at(120 * time.Second), Key: timelineKeyAttestation, Status: timelineSucceeded}, + }, + stored: &action.PolicyEvaluationStatus{}, + want: "Timeline · started 10:00:02 · finished 10:02:02 (2m0s) · stored\n" + + "├─ 10:00:02 ✓ initialized policies: 2 passed\n" + + "├─ 10:01:02 ↷ step `dast-scan` no web target\n" + + "├─ 10:01:12 ↷ step `unit-tests` took 20s\n" + + "│ ├─ 10:01:12 ● started\n" + + "│ └─ 10:01:32 ↷ cached\n" + + "└─ 10:02:02 ✓ pushed and stored\n", + }, { name: "stored run", events: []*action.RunEvent{ diff --git a/app/cli/documentation/cli-reference.md b/app/cli/documentation/cli-reference.md index f25ed893e..ce9d437cf 100644 --- a/app/cli/documentation/cli-reference.md +++ b/app/cli/documentation/cli-reference.md @@ -325,6 +325,9 @@ Examples Record the start and the end of a step chainloop attestation event --name sast-scan --status started --message "Semgrep, ruleset p/ci" chainloop attestation event --name sast-scan --status succeeded + +Record a step that did not run +chainloop attestation event --name dast-scan --status skipped --message "no web target" ``` Options @@ -334,7 +337,7 @@ Options -h, --help[=true|false] help for event --message string message of the event, up to 1 KB --name string name of the step (required), with letters, digits, _ and -, up to 64 characters ---status string status of the step (required), valid options are started, succeeded, failed, canceled +--status string status of the step (required), valid options are started, succeeded, failed, canceled, skipped ``` Options inherited from parent commands diff --git a/app/cli/pkg/action/attestation_event.go b/app/cli/pkg/action/attestation_event.go index 1ca1eace9..a21186635 100644 --- a/app/cli/pkg/action/attestation_event.go +++ b/app/cli/pkg/action/attestation_event.go @@ -35,17 +35,19 @@ const ( RunEventStatusSucceeded = "succeeded" RunEventStatusFailed = "failed" RunEventStatusCanceled = "canceled" + RunEventStatusSkipped = "skipped" ) // RunEventStatuses are the statuses that a custom run event accepts -var RunEventStatuses = []string{RunEventStatusStarted, RunEventStatusSucceeded, RunEventStatusFailed, RunEventStatusCanceled} +var RunEventStatuses = []string{RunEventStatusStarted, RunEventStatusSucceeded, RunEventStatusFailed, RunEventStatusCanceled, RunEventStatusSkipped} -// runEventStatusToPb limits the statuses that the CLI accepts to the ones of the spec (R-009) +// runEventStatusToPb limits the statuses that the CLI accepts to the ones of the spec (R-013) var runEventStatusToPb = map[string]pb.WorkflowRunEvent_Status{ RunEventStatusStarted: pb.WorkflowRunEvent_STATUS_STARTED, RunEventStatusSucceeded: pb.WorkflowRunEvent_STATUS_SUCCEEDED, RunEventStatusFailed: pb.WorkflowRunEvent_STATUS_FAILED, RunEventStatusCanceled: pb.WorkflowRunEvent_STATUS_CANCELED, + RunEventStatusSkipped: pb.WorkflowRunEvent_STATUS_SKIPPED, } // ParseRunEventStatus returns the API status of a custom run event diff --git a/app/cli/pkg/action/attestation_event_test.go b/app/cli/pkg/action/attestation_event_test.go index 7bfffb634..10da26d1e 100644 --- a/app/cli/pkg/action/attestation_event_test.go +++ b/app/cli/pkg/action/attestation_event_test.go @@ -55,6 +55,7 @@ func TestAttestationEvent(t *testing.T) { {name: "succeeded", initialized: true, status: RunEventStatusSucceeded, wantStatus: pb.WorkflowRunEvent_STATUS_SUCCEEDED}, {name: "failed", initialized: true, status: RunEventStatusFailed, wantStatus: pb.WorkflowRunEvent_STATUS_FAILED}, {name: "canceled", initialized: true, status: RunEventStatusCanceled, wantStatus: pb.WorkflowRunEvent_STATUS_CANCELED}, + {name: "skipped", initialized: true, status: RunEventStatusSkipped, wantStatus: pb.WorkflowRunEvent_STATUS_SKIPPED}, {name: "no attestation in progress", status: RunEventStatusStarted, wantErr: ErrAttestationNotInitialized}, // remote state needs no local state: the control plane checks that the run is in progress {name: "remote state", attestationID: testRunID, status: RunEventStatusSucceeded, wantStatus: pb.WorkflowRunEvent_STATUS_SUCCEEDED}, diff --git a/app/controlplane/api/controlplane/v1/workflow_run.pb.go b/app/controlplane/api/controlplane/v1/workflow_run.pb.go index 922ccb578..6bf4d259c 100644 --- a/app/controlplane/api/controlplane/v1/workflow_run.pb.go +++ b/app/controlplane/api/controlplane/v1/workflow_run.pb.go @@ -199,6 +199,8 @@ const ( WorkflowRunEvent_STATUS_SUCCEEDED WorkflowRunEvent_Status = 2 WorkflowRunEvent_STATUS_FAILED WorkflowRunEvent_Status = 3 WorkflowRunEvent_STATUS_CANCELED WorkflowRunEvent_Status = 4 + // The step did not run. Only custom events accept it. + WorkflowRunEvent_STATUS_SKIPPED WorkflowRunEvent_Status = 5 ) // Enum value maps for WorkflowRunEvent_Status. @@ -209,6 +211,7 @@ var ( 2: "STATUS_SUCCEEDED", 3: "STATUS_FAILED", 4: "STATUS_CANCELED", + 5: "STATUS_SKIPPED", } WorkflowRunEvent_Status_value = map[string]int32{ "STATUS_UNSPECIFIED": 0, @@ -216,6 +219,7 @@ var ( "STATUS_SUCCEEDED": 2, "STATUS_FAILED": 3, "STATUS_CANCELED": 4, + "STATUS_SKIPPED": 5, } ) @@ -3015,7 +3019,7 @@ const file_controlplane_v1_workflow_run_proto_rawDesc = "" + "$AttestationServiceRecordEventRequest\x120\n" + "\x0fworkflow_run_id\x18\x01 \x01(\tB\b\xbaH\x05r\x03\xb0\x01\x01R\rworkflowRunId\x12?\n" + "\x05event\x18\x02 \x01(\v2!.controlplane.v1.WorkflowRunEventB\x06\xbaH\x03\xc8\x01\x01R\x05event\"'\n" + - "%AttestationServiceRecordEventResponse\"\xe7\x0f\n" + + "%AttestationServiceRecordEventResponse\"\xfc\x0f\n" + "\x10WorkflowRunEvent\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x129\n" + "\n" + @@ -3071,13 +3075,14 @@ const file_controlplane_v1_workflow_run_proto_rawDesc = "" + "\x10TYPE_UNSPECIFIED\x10\x00\x12\x14\n" + "\x10TYPE_ATTESTATION\x10\x01\x12\x11\n" + "\rTYPE_MATERIAL\x10\x02\x12\x0f\n" + - "\vTYPE_CUSTOM\x10\x04\"\x04\b\x03\x10\x03*\tTYPE_PUSH\"r\n" + + "\vTYPE_CUSTOM\x10\x04\"\x04\b\x03\x10\x03*\tTYPE_PUSH\"\x86\x01\n" + "\x06Status\x12\x16\n" + "\x12STATUS_UNSPECIFIED\x10\x00\x12\x12\n" + "\x0eSTATUS_STARTED\x10\x01\x12\x14\n" + "\x10STATUS_SUCCEEDED\x10\x02\x12\x11\n" + "\rSTATUS_FAILED\x10\x03\x12\x13\n" + - "\x0fSTATUS_CANCELED\x10\x04B\f\n" + + "\x0fSTATUS_CANCELED\x10\x04\x12\x12\n" + + "\x0eSTATUS_SKIPPED\x10\x05B\f\n" + "\n" + "attributesJ\x04\b\f\x10\rR\x04push\"\x83\b\n" + "\x1dWorkflowRunServiceListRequest\x12\xac\x01\n" + diff --git a/app/controlplane/api/controlplane/v1/workflow_run.proto b/app/controlplane/api/controlplane/v1/workflow_run.proto index b5f16d4f9..91a2f17b2 100644 --- a/app/controlplane/api/controlplane/v1/workflow_run.proto +++ b/app/controlplane/api/controlplane/v1/workflow_run.proto @@ -269,6 +269,8 @@ message WorkflowRunEvent { STATUS_SUCCEEDED = 2; STATUS_FAILED = 3; STATUS_CANCELED = 4; + // The step did not run. Only custom events accept it. + STATUS_SKIPPED = 5; } message AttestationAttributes { diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/workflow_run.ts b/app/controlplane/api/gen/frontend/controlplane/v1/workflow_run.ts index 2a71631d4..45101266b 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/workflow_run.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/workflow_run.ts @@ -345,6 +345,8 @@ export enum WorkflowRunEvent_Status { STATUS_SUCCEEDED = 2, STATUS_FAILED = 3, STATUS_CANCELED = 4, + /** STATUS_SKIPPED - The step did not run. Only custom events accept it. */ + STATUS_SKIPPED = 5, UNRECOGNIZED = -1, } @@ -365,6 +367,9 @@ export function workflowRunEvent_StatusFromJSON(object: any): WorkflowRunEvent_S case 4: case "STATUS_CANCELED": return WorkflowRunEvent_Status.STATUS_CANCELED; + case 5: + case "STATUS_SKIPPED": + return WorkflowRunEvent_Status.STATUS_SKIPPED; case -1: case "UNRECOGNIZED": default: @@ -384,6 +389,8 @@ export function workflowRunEvent_StatusToJSON(object: WorkflowRunEvent_Status): return "STATUS_FAILED"; case WorkflowRunEvent_Status.STATUS_CANCELED: return "STATUS_CANCELED"; + case WorkflowRunEvent_Status.STATUS_SKIPPED: + return "STATUS_SKIPPED"; case WorkflowRunEvent_Status.UNRECOGNIZED: default: return "UNRECOGNIZED"; diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowRunEvent.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowRunEvent.jsonschema.json index b575ee56e..253ebdd3b 100644 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowRunEvent.jsonschema.json +++ b/app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowRunEvent.jsonschema.json @@ -59,7 +59,8 @@ "STATUS_STARTED", "STATUS_SUCCEEDED", "STATUS_FAILED", - "STATUS_CANCELED" + "STATUS_CANCELED", + "STATUS_SKIPPED" ], "title": "Status", "type": "string" diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowRunEvent.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowRunEvent.schema.json index 8a650aa07..f02345df7 100644 --- a/app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowRunEvent.schema.json +++ b/app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowRunEvent.schema.json @@ -59,7 +59,8 @@ "STATUS_STARTED", "STATUS_SUCCEEDED", "STATUS_FAILED", - "STATUS_CANCELED" + "STATUS_CANCELED", + "STATUS_SKIPPED" ], "title": "Status", "type": "string" diff --git a/app/controlplane/internal/service/workflowrun.go b/app/controlplane/internal/service/workflowrun.go index 70c97f115..6d89f5489 100644 --- a/app/controlplane/internal/service/workflowrun.go +++ b/app/controlplane/internal/service/workflowrun.go @@ -662,12 +662,14 @@ var ( pb.WorkflowRunEvent_STATUS_SUCCEEDED: biz.WorkflowRunEventStatusSucceeded, pb.WorkflowRunEvent_STATUS_FAILED: biz.WorkflowRunEventStatusFailed, pb.WorkflowRunEvent_STATUS_CANCELED: biz.WorkflowRunEventStatusCanceled, + pb.WorkflowRunEvent_STATUS_SKIPPED: biz.WorkflowRunEventStatusSkipped, } bizToPbRunEventStatus = map[biz.WorkflowRunEventStatus]pb.WorkflowRunEvent_Status{ biz.WorkflowRunEventStatusStarted: pb.WorkflowRunEvent_STATUS_STARTED, biz.WorkflowRunEventStatusSucceeded: pb.WorkflowRunEvent_STATUS_SUCCEEDED, biz.WorkflowRunEventStatusFailed: pb.WorkflowRunEvent_STATUS_FAILED, biz.WorkflowRunEventStatusCanceled: pb.WorkflowRunEvent_STATUS_CANCELED, + biz.WorkflowRunEventStatusSkipped: pb.WorkflowRunEvent_STATUS_SKIPPED, } bizToPbRunEventSource = map[biz.WorkflowRunEventSource]pb.WorkflowRunEvent_Source{ biz.WorkflowRunEventSourceCLI: pb.WorkflowRunEvent_SOURCE_CLI, diff --git a/app/controlplane/internal/service/workflowrunevent_integration_test.go b/app/controlplane/internal/service/workflowrunevent_integration_test.go index 443941c13..c63e14880 100644 --- a/app/controlplane/internal/service/workflowrunevent_integration_test.go +++ b/app/controlplane/internal/service/workflowrunevent_integration_test.go @@ -357,6 +357,22 @@ func (s *workflowRunEventRBACIntegrationSuite) TestRecordCustomEvent() { s.Zero(resp.GetProgress().GetRequiredProvided()) } +func (s *workflowRunEventRBACIntegrationSuite) TestRecordSkippedCustomEvent() { + ctx := s.attCtxForToken(s.org, s.orgToken) + runID := s.runA.ID.String() + + _, err := s.attSvc.RecordEvent(ctx, &pb.AttestationServiceRecordEventRequest{WorkflowRunId: runID, Event: &pb.WorkflowRunEvent{ + Type: pb.WorkflowRunEvent_TYPE_CUSTOM, Key: "dast-scan", Status: pb.WorkflowRunEvent_STATUS_SKIPPED, Message: "no web target", + }}) + s.Require().NoError(err) + + resp, err := s.runSvc.GetProgress(s.apiCtxForToken(s.org, s.orgToken), &pb.WorkflowRunServiceGetProgressRequest{WorkflowRunId: runID}) + s.Require().NoError(err) + s.Require().Len(resp.GetEvents(), 1) + s.Equal(pb.WorkflowRunEvent_STATUS_SKIPPED, resp.GetEvents()[0].GetStatus()) + s.Equal("no web target", resp.GetEvents()[0].GetMessage()) +} + func (s *workflowRunEventRBACIntegrationSuite) TestRecordEventValidation() { ctx := s.attCtxForToken(s.org, s.orgToken) runID := s.runA.ID.String() @@ -390,6 +406,12 @@ func (s *workflowRunEventRBACIntegrationSuite) TestRecordEventValidation() { Type: pb.WorkflowRunEvent_TYPE_CUSTOM, Key: strings.Repeat("a", 65), Status: pb.WorkflowRunEvent_STATUS_SUCCEEDED, }, }, + { + name: "skipped event that is not custom", + event: &pb.WorkflowRunEvent{ + Type: pb.WorkflowRunEvent_TYPE_MATERIAL, Key: "chainloop.material.sbom", Status: pb.WorkflowRunEvent_STATUS_SKIPPED, + }, + }, { name: "custom event with attributes", event: &pb.WorkflowRunEvent{ diff --git a/app/controlplane/pkg/biz/workflowrunevent.go b/app/controlplane/pkg/biz/workflowrunevent.go index b04cae099..1c7e28c79 100644 --- a/app/controlplane/pkg/biz/workflowrunevent.go +++ b/app/controlplane/pkg/biz/workflowrunevent.go @@ -84,6 +84,8 @@ const ( WorkflowRunEventStatusSucceeded WorkflowRunEventStatus = "succeeded" WorkflowRunEventStatusFailed WorkflowRunEventStatus = "failed" WorkflowRunEventStatusCanceled WorkflowRunEventStatus = "canceled" + // WorkflowRunEventStatusSkipped is a step that did not run. Only custom events accept it. + WorkflowRunEventStatusSkipped WorkflowRunEventStatus = "skipped" ) // Values implements the ent enum interface @@ -91,6 +93,7 @@ func (WorkflowRunEventStatus) Values() []string { return []string{ string(WorkflowRunEventStatusStarted), string(WorkflowRunEventStatusSucceeded), string(WorkflowRunEventStatusFailed), string(WorkflowRunEventStatusCanceled), + string(WorkflowRunEventStatusSkipped), } } @@ -211,6 +214,11 @@ func validateWorkflowRunEvent(ev *WorkflowRunEvent) error { return err } + // the automatic events describe actions of the CLI, which always run + if ev.Status == WorkflowRunEventStatusSkipped && ev.Type != WorkflowRunEventTypeCustom { + return NewErrValidationStr(fmt.Sprintf("only custom events can be %q", WorkflowRunEventStatusSkipped)) + } + if len(ev.Message) > MaxWorkflowRunEventMessageBytes { return NewErrValidationStr(fmt.Sprintf("event message is longer than %d bytes", MaxWorkflowRunEventMessageBytes)) } diff --git a/app/controlplane/pkg/biz/workflowrunevent_test.go b/app/controlplane/pkg/biz/workflowrunevent_test.go index f098500e2..9a7efd0e7 100644 --- a/app/controlplane/pkg/biz/workflowrunevent_test.go +++ b/app/controlplane/pkg/biz/workflowrunevent_test.go @@ -95,6 +95,20 @@ func TestValidateWorkflowRunEvent(t *testing.T) { event: &WorkflowRunEvent{Type: WorkflowRunEventTypeCustom, Key: strings.Repeat("a", MaxWorkflowRunEventCustomKeyChars+1)}, wantErr: "longer than", }, + { + name: "skipped custom event", + event: &WorkflowRunEvent{Type: WorkflowRunEventTypeCustom, Key: "dast-scan", Status: WorkflowRunEventStatusSkipped}, + }, + { + name: "skipped material event", + event: &WorkflowRunEvent{Type: WorkflowRunEventTypeMaterial, Key: sbomKey, Status: WorkflowRunEventStatusSkipped, Attributes: material}, + wantErr: "only custom events", + }, + { + name: "skipped attestation event", + event: &WorkflowRunEvent{Type: WorkflowRunEventTypeAttestation, Key: WorkflowRunEventKeyAttestation, Status: WorkflowRunEventStatusSkipped}, + wantErr: "only custom events", + }, { name: "custom event with attributes", event: &WorkflowRunEvent{Type: WorkflowRunEventTypeCustom, Key: "sast-scan", Attributes: material}, diff --git a/app/controlplane/pkg/data/ent/migrate/schema.go b/app/controlplane/pkg/data/ent/migrate/schema.go index 8f64e1983..43a03fc69 100644 --- a/app/controlplane/pkg/data/ent/migrate/schema.go +++ b/app/controlplane/pkg/data/ent/migrate/schema.go @@ -1003,7 +1003,7 @@ var ( {Name: "source", Type: field.TypeEnum, Enums: []string{"cli", "control_plane"}}, {Name: "type", Type: field.TypeEnum, Enums: []string{"attestation", "material", "custom"}}, {Name: "key", Type: field.TypeString}, - {Name: "status", Type: field.TypeEnum, Enums: []string{"started", "succeeded", "failed", "canceled"}}, + {Name: "status", Type: field.TypeEnum, Enums: []string{"started", "succeeded", "failed", "canceled", "skipped"}}, {Name: "message", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "attributes", Type: field.TypeJSON, Nullable: true}, {Name: "workflow_run_id", Type: field.TypeUUID}, diff --git a/app/controlplane/pkg/data/ent/workflowrunevent/workflowrunevent.go b/app/controlplane/pkg/data/ent/workflowrunevent/workflowrunevent.go index 388af84e6..a3d11f23c 100644 --- a/app/controlplane/pkg/data/ent/workflowrunevent/workflowrunevent.go +++ b/app/controlplane/pkg/data/ent/workflowrunevent/workflowrunevent.go @@ -99,7 +99,7 @@ func TypeValidator(_type biz.WorkflowRunEventType) error { // StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. func StatusValidator(s biz.WorkflowRunEventStatus) error { switch s { - case "started", "succeeded", "failed", "canceled": + case "started", "succeeded", "failed", "canceled", "skipped": return nil default: return fmt.Errorf("workflowrunevent: invalid enum value for status field: %q", s) diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md index e65657347..6b36d331b 100644 --- a/docs/specs/issue-3825-attestation-progress-events.md +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -113,9 +113,15 @@ Supersedes R-001. The CLI MUST record a run event at each action of the attestat Supersedes R-003. A read call next to the run view MUST return the events of a run, oldest first. It has the permissions of the run view. For a run in progress, the call MUST also return the progress of the run. The progress has one row for each expected material, with its requirement and its status: missing, provided, or failed. It also has the required counts and the attestation policy results of `init`. The control plane builds the progress, so that the CLI, the UI, and other tools show it with no logic of their own (D-012). The expected materials are the ones that `init` resolves, from the contract and its policy groups. The start event lists them. A run whose start event has no list uses the materials of its contract. - Done when: a material that a policy group requires shows as missing until it is added. A failed `add` after a successful one keeps the material as provided, with the error. -### R-012: Custom events -Supersedes R-009. `chainloop attestation event --name --status --message ` MUST record a custom event on the run of the attestation in progress. The command takes the key with the `--name` flag, not as a positional argument, as `chainloop attestation add --name` does. The status is started, succeeded, failed, or canceled. The command finds the run in the same way as the other attestation commands. A custom key MUST use the format of annotation names: letters, digits, `_`, and `-`. A custom key cannot hold a dot, so it never matches an automatic `chainloop.` key. When the command cannot record the event, it shows a warning and exits with success. This also applies to a wrong call, for example a missing `--name`, and to an older control plane. A progress signal never breaks a pipeline. -- Done when: `chainloop attestation event --name sast-scan --status started` between `init` and `push` shows the step in `describe`. Each failure shows a warning, and the command exits with 0. +### ~~R-012: Custom events~~ +Superseded by R-013. + +~~Supersedes R-009. `chainloop attestation event --name --status --message ` MUST record a custom event on the run of the attestation in progress. The command takes the key with the `--name` flag, not as a positional argument, as `chainloop attestation add --name` does. The status is started, succeeded, failed, or canceled. The command finds the run in the same way as the other attestation commands. A custom key MUST use the format of annotation names: letters, digits, `_`, and `-`. A custom key cannot hold a dot, so it never matches an automatic `chainloop.` key. When the command cannot record the event, it shows a warning and exits with success. This also applies to a wrong call, for example a missing `--name`, and to an older control plane. A progress signal never breaks a pipeline.~~ +- ~~Done when: `chainloop attestation event --name sast-scan --status started` between `init` and `push` shows the step in `describe`. Each failure shows a warning, and the command exits with 0.~~ + +### R-013: Custom events, with a skipped status +Supersedes R-012. `chainloop attestation event --name --status --message ` MUST record a custom event on the run of the attestation in progress. The command takes the key with the `--name` flag, not as a positional argument, as `chainloop attestation add --name` does. The status is started, succeeded, failed, canceled, or skipped. Skipped is a step that did not run, for example a scan with no target. Only custom events accept the skipped status (D-013). The command finds the run in the same way as the other attestation commands. A custom key MUST use the format of annotation names: letters, digits, `_`, and `-`. A custom key cannot hold a dot, so it never matches an automatic `chainloop.` key. When the command cannot record the event, it shows a warning and exits with success. This also applies to a wrong call, for example a missing `--name`, and to an older control plane. A progress signal never breaks a pipeline. +- Done when: `chainloop attestation event --name sast-scan --status started` between `init` and `push` shows the step in `describe`. `chainloop attestation event --name dast-scan --status skipped` shows the step as skipped in `describe`. Each failure shows a warning, and the command exits with 0. ## Constraints @@ -133,7 +139,8 @@ Supersedes R-009. `chainloop attestation event --name --status -- - ~~a type: attestation, material, push, or custom~~ - a type: attestation, material, or custom (D-011) - a key -- a status: started, succeeded, failed, or canceled +- ~~a status: started, succeeded, failed, or canceled~~ +- a status: started, succeeded, failed, canceled, or skipped. Only custom events can be skipped (D-013). - an optional message - typed attributes for its type @@ -258,6 +265,14 @@ Supersedes D-007. A new call of the run read API returns the events and, for a r - Add the progress and the events to the run view: one call, but every caller of the run view gets the events. - Source: implementation review of #3859 +### D-013: The skipped status is for custom events only +A custom event can have the status skipped (R-013). The control plane rejects an automatic event with the status skipped. `describe` shows a skipped step with its own symbol. +- Why: a pipeline often has steps that do not run, for example a scan with no target or a cached test suite. Before, the pipeline had to show such a step as succeeded or canceled, which is not true. The automatic events show actions of the CLI, which always run, so for them a skipped status has no meaning. +- Alternatives considered: + - A new event type for skipped steps: the type tells who records the event (D-011), not the result of the step. A skipped step is one step of the timeline, so it shares the key and the type of the other events of the step. + - Accept skipped for every event type: no automatic event needs it, and the progress logic of the materials would have to handle it. +- Source: implementation of skipped custom events + ## Open Questions None.