@@ -12,6 +12,14 @@ import (
12
12
13
13
type PipelineType string
14
14
15
+ type SimplifiedActivityStep struct {
16
+ Name string
17
+ Status string
18
+ StartedTimestamp time.Time
19
+ CompletedTimestamp time.Time
20
+ Duration time.Duration
21
+ }
22
+
15
23
const (
16
24
PipelineTypeRelease = PipelineType ("release" )
17
25
PipelineTypePullRequest = PipelineType ("pullrequest" )
@@ -29,6 +37,7 @@ type Pipeline struct {
29
37
StartTime time.Time
30
38
EndTime time.Time
31
39
Duration time.Duration
40
+ Steps []SimplifiedActivityStep
32
41
}
33
42
34
43
type PipelineStore struct {
@@ -56,6 +65,20 @@ func (s *PipelineStore) Migrations() []migration.Func {
56
65
duration bigint NOT NULL,
57
66
CONSTRAINT pipeline_pkey PRIMARY KEY (type, owner, repository, pull_request, context, build)
58
67
);
68
+ CREATE TABLE pipelinesteps (
69
+ type VARCHAR NOT NULL,
70
+ owner VARCHAR NOT NULL,
71
+ repository VARCHAR NOT NULL,
72
+ pull_request int,
73
+ context VARCHAR NOT NULL,
74
+ build int NOT NULL,
75
+ step_name VARCHAR NOT NULL,
76
+ step_status VARCHAR NOT NULL,
77
+ step_started_time timestamp without time zone NOT NULL,
78
+ step_completed_time timestamp without time zone NOT NULL,
79
+ step_duration bigint NOT NULL,
80
+ CONSTRAINT pipelinesteps_pkey PRIMARY KEY (type, owner, repository, pull_request, context, build, step_name)
81
+ );
59
82
` ),
60
83
}
61
84
}
@@ -74,6 +97,12 @@ func (s *PipelineStore) Add(ctx context.Context, p Pipeline) error {
74
97
return fmt .Errorf ("failed to add pipeline: %w" , err )
75
98
}
76
99
100
+ for _ , step := range p .Steps {
101
+ _ , err = tx .Exec (ctx , "INSERT INTO pipelinesteps (type, owner, repository, pull_request, context, build, step_name, step_status, step_started_time, step_completed_time, step_duration) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) ON CONFLICT DO NOTHING;" , p .Type , p .Owner , p .Repository , p .PullRequest , p .Context , p .Build , step .Name , step .Status , step .StartedTimestamp , step .CompletedTimestamp , step .Duration .Seconds ())
102
+ if err != nil {
103
+ return fmt .Errorf ("failed to add pipeline step: %w" , err )
104
+ }
105
+ }
77
106
if err = tx .Commit (ctx ); err != nil {
78
107
return fmt .Errorf ("failed to commit insertion of pipeline: %w" , err )
79
108
}
0 commit comments