Merge branch 'cursor/pipelines-ui-65da' into 'master'
Pipelines-tab en jobconsole See merge request Timfa/bluegit!10
@@ -154,10 +154,49 @@ var en = map[string]string{
154
154
"mr.noComments": "No comments yet.",
155
155
"mr.comment": "Comment",
156
156
157
"pipe.title": "Pipelines",
158
"pipe.ref": "branch, empty is the default",
159
"pipe.none": "No pipelines yet. Add blue-ci-cd.yml in the root.",
160
"pipe.one": "Pipeline",
157
"pipe.title": "Pipelines",
158
"pipe.ref": "branch, empty is the default",
159
"pipe.none": "No pipelines yet. Add blue-ci-cd.yml in the root.",
160
"pipe.one": "Pipeline",
161
"pipe.filter": "Filter pipelines",
162
"pipe.showID": "Show Pipeline ID",
163
"pipe.col.status": "Status",
164
"pipe.col.pipeline": "Pipeline",
165
"pipe.col.by": "Created by",
166
"pipe.col.stages": "Stages",
167
"pipe.passed": "Passed",
168
"pipe.failed": "Failed",
169
"pipe.running": "Running",
170
"pipe.pending": "Pending",
171
"pipe.manual": "Manual",
172
"pipe.skipped": "Skipped",
173
"pipe.warning": "Warning",
174
"pipe.stage": "Stage",
175
"pipe.duration": "Duration",
176
"pipe.finished": "Finished",
177
"pipe.queued": "Queued",
178
"pipe.timeout": "Timeout",
179
"pipe.runner": "Runner",
180
"pipe.runnerHere": "bluegit #1",
181
"pipe.source": "Source",
182
"pipe.commit": "Commit",
183
"pipe.for": "for",
184
"pipe.related": "Related jobs",
185
"pipe.search": "Search visible log output",
186
"pipe.utc": "Log timestamps in UTC.",
187
"pipe.raw": "Raw",
188
"pipe.wrap": "Wrap",
189
"pipe.top": "Top",
190
"pipe.bottom": "Bottom",
191
"pipe.full": "Full screen",
192
"pipe.prev": "Previous result",
193
"pipe.next": "Next result",
194
"pipe.started": "Started",
195
"pipe.by": "by",
196
"pipe.emptyLog": "No log yet.",
197
"pipe.play": "Play",
198
"pipe.src.push": "Push",
199
"pipe.src.web": "Web",
161
200
162
201
"rel.none": "No releases yet.",
163
202
"rel.bytes": "bytes",
@@ -154,10 +154,49 @@ var en = map[string]string{154
"mr.noComments": "No comments yet.",154
"mr.noComments": "No comments yet.",155
"mr.comment": "Comment",155
"mr.comment": "Comment",156
156
157
"pipe.title": "Pipelines",157
"pipe.title": "Pipelines",158
"pipe.ref": "branch, empty is the default",158
"pipe.ref": "branch, empty is the default",159
"pipe.none": "No pipelines yet. Add blue-ci-cd.yml in the root.",159
"pipe.none": "No pipelines yet. Add blue-ci-cd.yml in the root.",160
"pipe.one": "Pipeline",160
"pipe.one": "Pipeline",161
"pipe.filter": "Filter pipelines",162
"pipe.showID": "Show Pipeline ID",163
"pipe.col.status": "Status",164
"pipe.col.pipeline": "Pipeline",165
"pipe.col.by": "Created by",166
"pipe.col.stages": "Stages",167
"pipe.passed": "Passed",168
"pipe.failed": "Failed",169
"pipe.running": "Running",170
"pipe.pending": "Pending",171
"pipe.manual": "Manual",172
"pipe.skipped": "Skipped",173
"pipe.warning": "Warning",174
"pipe.stage": "Stage",175
"pipe.duration": "Duration",176
"pipe.finished": "Finished",177
"pipe.queued": "Queued",178
"pipe.timeout": "Timeout",179
"pipe.runner": "Runner",180
"pipe.runnerHere": "bluegit #1",181
"pipe.source": "Source",182
"pipe.commit": "Commit",183
"pipe.for": "for",184
"pipe.related": "Related jobs",185
"pipe.search": "Search visible log output",186
"pipe.utc": "Log timestamps in UTC.",187
"pipe.raw": "Raw",188
"pipe.wrap": "Wrap",189
"pipe.top": "Top",190
"pipe.bottom": "Bottom",191
"pipe.full": "Full screen",192
"pipe.prev": "Previous result",193
"pipe.next": "Next result",194
"pipe.started": "Started",195
"pipe.by": "by",196
"pipe.emptyLog": "No log yet.",197
"pipe.play": "Play",198
"pipe.src.push": "Push",199
"pipe.src.web": "Web",161
200
162
"rel.none": "No releases yet.",201
"rel.none": "No releases yet.",163
"rel.bytes": "bytes",202
"rel.bytes": "bytes",@@ -165,6 +165,45 @@ var nl = map[string]string{
165
165
"pipe.ref": "branch, leeg is de standaard",
166
166
"pipe.none": "Nog geen pipelines. Voeg blue-ci-cd.yml toe in de root.",
167
167
"pipe.one": "Pipeline",
168
"pipe.filter": "Filter pipelines",
169
"pipe.showID": "Toon pipeline-ID",
170
"pipe.col.status": "Status",
171
"pipe.col.pipeline": "Pipeline",
172
"pipe.col.by": "Gemaakt door",
173
"pipe.col.stages": "Stages",
174
"pipe.passed": "Geslaagd",
175
"pipe.failed": "Mislukt",
176
"pipe.running": "Bezig",
177
"pipe.pending": "Wachtend",
178
"pipe.manual": "Handmatig",
179
"pipe.skipped": "Overgeslagen",
180
"pipe.warning": "Waarschuwing",
181
"pipe.stage": "Stage",
182
"pipe.duration": "Duur",
183
"pipe.finished": "Klaar",
184
"pipe.queued": "Wachtrij",
185
"pipe.timeout": "Timeout",
186
"pipe.runner": "Runner",
187
"pipe.runnerHere": "bluegit #1",
188
"pipe.source": "Bron",
189
"pipe.commit": "Commit",
190
"pipe.for": "voor",
191
"pipe.related": "Gerelateerde jobs",
192
"pipe.search": "Zoek in de zichtbare log",
193
"pipe.utc": "Logtijden in UTC.",
194
"pipe.raw": "Ruw",
195
"pipe.wrap": "Afbreken",
196
"pipe.top": "Boven",
197
"pipe.bottom": "Onder",
198
"pipe.full": "Volledig scherm",
199
"pipe.prev": "Vorig resultaat",
200
"pipe.next": "Volgend resultaat",
201
"pipe.started": "Gestart",
202
"pipe.by": "door",
203
"pipe.emptyLog": "Nog geen log.",
204
"pipe.play": "Start",
205
"pipe.src.push": "Push",
206
"pipe.src.web": "Web",
168
207
"rel.none": "Nog geen releases.",
169
208
"rel.bytes": "bytes",
170
209
"set.onlyAdmin": "Alleen een beheerder wijzigt instellingen, geheimen en webhooks. Jouw rol: %s.",
@@ -628,6 +667,45 @@ var de = map[string]string{
628
667
"pipe.ref": "Branch, leer ist der Standard",
629
668
"pipe.none": "Noch keine Pipelines. Lege blue-ci-cd.yml im Stammverzeichnis an.",
630
669
"pipe.one": "Pipeline",
670
"pipe.filter": "Pipelines filtern",
671
"pipe.showID": "Pipeline-ID anzeigen",
672
"pipe.col.status": "Status",
673
"pipe.col.pipeline": "Pipeline",
674
"pipe.col.by": "Erstellt von",
675
"pipe.col.stages": "Stages",
676
"pipe.passed": "Bestanden",
677
"pipe.failed": "Fehlgeschlagen",
678
"pipe.running": "Läuft",
679
"pipe.pending": "Wartend",
680
"pipe.manual": "Manuell",
681
"pipe.skipped": "Übersprungen",
682
"pipe.warning": "Warnung",
683
"pipe.stage": "Stage",
684
"pipe.duration": "Dauer",
685
"pipe.finished": "Beendet",
686
"pipe.queued": "Warteschlange",
687
"pipe.timeout": "Timeout",
688
"pipe.runner": "Runner",
689
"pipe.runnerHere": "bluegit #1",
690
"pipe.source": "Quelle",
691
"pipe.commit": "Commit",
692
"pipe.for": "für",
693
"pipe.related": "Verwandte Jobs",
694
"pipe.search": "Sichtbare Logausgabe durchsuchen",
695
"pipe.utc": "Zeitstempel der Logdatei in UTC.",
696
"pipe.raw": "Roh",
697
"pipe.wrap": "Umbruch",
698
"pipe.top": "Oben",
699
"pipe.bottom": "Unten",
700
"pipe.full": "Vollbild",
701
"pipe.prev": "Vorheriges Ergebnis",
702
"pipe.next": "Nächstes Ergebnis",
703
"pipe.started": "Gestartet",
704
"pipe.by": "von",
705
"pipe.emptyLog": "Noch kein Log.",
706
"pipe.play": "Starten",
707
"pipe.src.push": "Push",
708
"pipe.src.web": "Web",
631
709
"rel.none": "Noch keine Releases.",
632
710
"rel.bytes": "Bytes",
633
711
"set.onlyAdmin": "Nur ein Betreuer ändert Einstellungen, Geheimnisse und Webhooks. Deine Rolle: %s.",
@@ -1091,6 +1169,45 @@ var fr = map[string]string{
1091
1169
"pipe.ref": "branche, vide pour la branche par défaut",
1092
1170
"pipe.none": "Pas encore de pipelines. Ajoute blue-ci-cd.yml à la racine.",
1093
1171
"pipe.one": "Pipeline",
1172
"pipe.filter": "Filtrer les pipelines",
1173
"pipe.showID": "Afficher l'ID du pipeline",
1174
"pipe.col.status": "Statut",
1175
"pipe.col.pipeline": "Pipeline",
1176
"pipe.col.by": "Créé par",
1177
"pipe.col.stages": "Stages",
1178
"pipe.passed": "Réussi",
1179
"pipe.failed": "Échoué",
1180
"pipe.running": "En cours",
1181
"pipe.pending": "En attente",
1182
"pipe.manual": "Manuel",
1183
"pipe.skipped": "Ignoré",
1184
"pipe.warning": "Avertissement",
1185
"pipe.stage": "Stage",
1186
"pipe.duration": "Durée",
1187
"pipe.finished": "Terminé",
1188
"pipe.queued": "File",
1189
"pipe.timeout": "Délai",
1190
"pipe.runner": "Runner",
1191
"pipe.runnerHere": "bluegit #1",
1192
"pipe.source": "Source",
1193
"pipe.commit": "Commit",
1194
"pipe.for": "pour",
1195
"pipe.related": "Jobs liés",
1196
"pipe.search": "Chercher dans le journal visible",
1197
"pipe.utc": "Horodatage du journal en UTC.",
1198
"pipe.raw": "Brut",
1199
"pipe.wrap": "Retour à la ligne",
1200
"pipe.top": "Haut",
1201
"pipe.bottom": "Bas",
1202
"pipe.full": "Plein écran",
1203
"pipe.prev": "Résultat précédent",
1204
"pipe.next": "Résultat suivant",
1205
"pipe.started": "Démarré",
1206
"pipe.by": "par",
1207
"pipe.emptyLog": "Pas encore de journal.",
1208
"pipe.play": "Lancer",
1209
"pipe.src.push": "Push",
1210
"pipe.src.web": "Web",
1094
1211
"rel.none": "Pas encore de versions.",
1095
1212
"rel.bytes": "octets",
1096
1213
"set.onlyAdmin": "Seul un mainteneur modifie les paramètres, les secrets et les webhooks. Ton rôle : %s.",
@@ -165,6 +165,45 @@ var nl = map[string]string{165
"pipe.ref": "branch, leeg is de standaard",165
"pipe.ref": "branch, leeg is de standaard",166
"pipe.none": "Nog geen pipelines. Voeg blue-ci-cd.yml toe in de root.",166
"pipe.none": "Nog geen pipelines. Voeg blue-ci-cd.yml toe in de root.",167
"pipe.one": "Pipeline",167
"pipe.one": "Pipeline",168
"pipe.filter": "Filter pipelines",169
"pipe.showID": "Toon pipeline-ID",170
"pipe.col.status": "Status",171
"pipe.col.pipeline": "Pipeline",172
"pipe.col.by": "Gemaakt door",173
"pipe.col.stages": "Stages",174
"pipe.passed": "Geslaagd",175
"pipe.failed": "Mislukt",176
"pipe.running": "Bezig",177
"pipe.pending": "Wachtend",178
"pipe.manual": "Handmatig",179
"pipe.skipped": "Overgeslagen",180
"pipe.warning": "Waarschuwing",181
"pipe.stage": "Stage",182
"pipe.duration": "Duur",183
"pipe.finished": "Klaar",184
"pipe.queued": "Wachtrij",185
"pipe.timeout": "Timeout",186
"pipe.runner": "Runner",187
"pipe.runnerHere": "bluegit #1",188
"pipe.source": "Bron",189
"pipe.commit": "Commit",190
"pipe.for": "voor",191
"pipe.related": "Gerelateerde jobs",192
"pipe.search": "Zoek in de zichtbare log",193
"pipe.utc": "Logtijden in UTC.",194
"pipe.raw": "Ruw",195
"pipe.wrap": "Afbreken",196
"pipe.top": "Boven",197
"pipe.bottom": "Onder",198
"pipe.full": "Volledig scherm",199
"pipe.prev": "Vorig resultaat",200
"pipe.next": "Volgend resultaat",201
"pipe.started": "Gestart",202
"pipe.by": "door",203
"pipe.emptyLog": "Nog geen log.",204
"pipe.play": "Start",205
"pipe.src.push": "Push",206
"pipe.src.web": "Web",168
"rel.none": "Nog geen releases.",207
"rel.none": "Nog geen releases.",169
"rel.bytes": "bytes",208
"rel.bytes": "bytes",170
"set.onlyAdmin": "Alleen een beheerder wijzigt instellingen, geheimen en webhooks. Jouw rol: %s.",209
"set.onlyAdmin": "Alleen een beheerder wijzigt instellingen, geheimen en webhooks. Jouw rol: %s.",@@ -628,6 +667,45 @@ var de = map[string]string{628
"pipe.ref": "Branch, leer ist der Standard",667
"pipe.ref": "Branch, leer ist der Standard",629
"pipe.none": "Noch keine Pipelines. Lege blue-ci-cd.yml im Stammverzeichnis an.",668
"pipe.none": "Noch keine Pipelines. Lege blue-ci-cd.yml im Stammverzeichnis an.",630
"pipe.one": "Pipeline",669
"pipe.one": "Pipeline",670
"pipe.filter": "Pipelines filtern",671
"pipe.showID": "Pipeline-ID anzeigen",672
"pipe.col.status": "Status",673
"pipe.col.pipeline": "Pipeline",674
"pipe.col.by": "Erstellt von",675
"pipe.col.stages": "Stages",676
"pipe.passed": "Bestanden",677
"pipe.failed": "Fehlgeschlagen",678
"pipe.running": "Läuft",679
"pipe.pending": "Wartend",680
"pipe.manual": "Manuell",681
"pipe.skipped": "Übersprungen",682
"pipe.warning": "Warnung",683
"pipe.stage": "Stage",684
"pipe.duration": "Dauer",685
"pipe.finished": "Beendet",686
"pipe.queued": "Warteschlange",687
"pipe.timeout": "Timeout",688
"pipe.runner": "Runner",689
"pipe.runnerHere": "bluegit #1",690
"pipe.source": "Quelle",691
"pipe.commit": "Commit",692
"pipe.for": "für",693
"pipe.related": "Verwandte Jobs",694
"pipe.search": "Sichtbare Logausgabe durchsuchen",695
"pipe.utc": "Zeitstempel der Logdatei in UTC.",696
"pipe.raw": "Roh",697
"pipe.wrap": "Umbruch",698
"pipe.top": "Oben",699
"pipe.bottom": "Unten",700
"pipe.full": "Vollbild",701
"pipe.prev": "Vorheriges Ergebnis",702
"pipe.next": "Nächstes Ergebnis",703
"pipe.started": "Gestartet",704
"pipe.by": "von",705
"pipe.emptyLog": "Noch kein Log.",706
"pipe.play": "Starten",707
"pipe.src.push": "Push",708
"pipe.src.web": "Web",631
"rel.none": "Noch keine Releases.",709
"rel.none": "Noch keine Releases.",632
"rel.bytes": "Bytes",710
"rel.bytes": "Bytes",633
"set.onlyAdmin": "Nur ein Betreuer ändert Einstellungen, Geheimnisse und Webhooks. Deine Rolle: %s.",711
"set.onlyAdmin": "Nur ein Betreuer ändert Einstellungen, Geheimnisse und Webhooks. Deine Rolle: %s.",@@ -1091,6 +1169,45 @@ var fr = map[string]string{1091
"pipe.ref": "branche, vide pour la branche par défaut",1169
"pipe.ref": "branche, vide pour la branche par défaut",1092
"pipe.none": "Pas encore de pipelines. Ajoute blue-ci-cd.yml à la racine.",1170
"pipe.none": "Pas encore de pipelines. Ajoute blue-ci-cd.yml à la racine.",1093
"pipe.one": "Pipeline",1171
"pipe.one": "Pipeline",1172
"pipe.filter": "Filtrer les pipelines",1173
"pipe.showID": "Afficher l'ID du pipeline",1174
"pipe.col.status": "Statut",1175
"pipe.col.pipeline": "Pipeline",1176
"pipe.col.by": "Créé par",1177
"pipe.col.stages": "Stages",1178
"pipe.passed": "Réussi",1179
"pipe.failed": "Échoué",1180
"pipe.running": "En cours",1181
"pipe.pending": "En attente",1182
"pipe.manual": "Manuel",1183
"pipe.skipped": "Ignoré",1184
"pipe.warning": "Avertissement",1185
"pipe.stage": "Stage",1186
"pipe.duration": "Durée",1187
"pipe.finished": "Terminé",1188
"pipe.queued": "File",1189
"pipe.timeout": "Délai",1190
"pipe.runner": "Runner",1191
"pipe.runnerHere": "bluegit #1",1192
"pipe.source": "Source",1193
"pipe.commit": "Commit",1194
"pipe.for": "pour",1195
"pipe.related": "Jobs liés",1196
"pipe.search": "Chercher dans le journal visible",1197
"pipe.utc": "Horodatage du journal en UTC.",1198
"pipe.raw": "Brut",1199
"pipe.wrap": "Retour à la ligne",1200
"pipe.top": "Haut",1201
"pipe.bottom": "Bas",1202
"pipe.full": "Plein écran",1203
"pipe.prev": "Résultat précédent",1204
"pipe.next": "Résultat suivant",1205
"pipe.started": "Démarré",1206
"pipe.by": "par",1207
"pipe.emptyLog": "Pas encore de journal.",1208
"pipe.play": "Lancer",1209
"pipe.src.push": "Push",1210
"pipe.src.web": "Web",1094
"rel.none": "Pas encore de versions.",1211
"rel.none": "Pas encore de versions.",1095
"rel.bytes": "octets",1212
"rel.bytes": "octets",1096
"set.onlyAdmin": "Seul un mainteneur modifie les paramètres, les secrets et les webhooks. Ton rôle : %s.",1213
"set.onlyAdmin": "Seul un mainteneur modifie les paramètres, les secrets et les webhooks. Ton rôle : %s.",@@ -0,0 +1,520 @@
1
package server
2
3
import (
4
"encoding/json"
5
"net/http"
6
"strconv"
7
"strings"
8
"time"
9
10
"gitlab.com/Timfa/bluegit/internal/access"
11
"gitlab.com/Timfa/bluegit/internal/ci"
12
"gitlab.com/Timfa/bluegit/internal/i18n"
13
"gitlab.com/Timfa/bluegit/internal/store"
14
)
15
16
// PipeRow is één rij in het pipeline-overzicht.
17
type PipeRow struct {
18
ID int64
19
Status string
20
Label string
21
Duration string
22
When string
23
Title string
24
SHA string
25
Short string
26
Ref string
27
RefKind string
28
Actor string
29
Avatar string
30
Initial string
31
Stages []StageView
32
}
33
34
// StageView is één bolletje in de stages-kolom.
35
type StageView struct {
36
Name string
37
Status string
38
Label string
39
Tip string
40
Jobs []JobLink
41
}
42
43
// JobLink is een job in een stage-popover of in de zijbalk.
44
type JobLink struct {
45
ID int64
46
Name string
47
Status string
48
Label string
49
Current bool
50
Stage string
51
}
52
53
// JobPage is de console van één job.
54
type JobPage struct {
55
Job store.Job
56
Pipe store.Pipeline
57
Name string
58
Status string
59
Label string
60
Actor string
61
Avatar string
62
Initial string
63
When string
64
Duration string
65
Finished string
66
Queued string
67
Timeout string
68
Source string
69
Ref string
70
RefKind string
71
Short string
72
Title string
73
Stage string
74
PipeStatus string
75
PipeLabel string
76
Stages []string
77
Related []JobLink
78
Blocks []LogBlock
79
Running bool
80
LogBytes int
81
CanPlay bool
82
}
83
84
// LogBlock is een losse regel of een inklapbare sectie.
85
type LogBlock struct {
86
Section bool
87
Title string
88
Duration string
89
Open bool
90
Lines []LogLine
91
}
92
93
// LogLine is één regel in de console.
94
type LogLine struct {
95
N int
96
Time string
97
Text string
98
}
99
100
func (s *Server) fillPipelines(r *http.Request, v *View, repo store.Repo) {
101
lang := s.langOf(r)
102
list, _ := s.Store.ListPipelines(r.Context(), repo.ID)
103
q := strings.ToLower(strings.TrimSpace(r.URL.Query().Get("q")))
104
v.Query = r.URL.Query().Get("q")
105
users := map[string]store.User{}
106
for _, p := range list {
107
row := s.pipeRow(r, lang, repo, p, users)
108
if q != "" && !pipeMatches(row, q) {
109
continue
110
}
111
v.PipeRows = append(v.PipeRows, row)
112
}
113
}
114
115
func (s *Server) pipeRow(r *http.Request, lang i18n.Lang, repo store.Repo, p store.Pipeline, users map[string]store.User) PipeRow {
116
jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)
117
name, kind := ci.SplitRef(p.Ref)
118
status := displayStatus(p.Status, jobs)
119
actor, avatar := s.actorOf(r, p.Actor, users)
120
initial := ""
121
if actor != "" {
122
initial = strings.ToUpper(actor[:1])
123
}
124
end := p.FinishedAt
125
if end.IsZero() {
126
end = time.Now()
127
}
128
start := p.StartedAt
129
if start.IsZero() {
130
start = p.CreatedAt
131
}
132
return PipeRow{
133
ID: p.ID, Status: status, Label: s.tr(r, "pipe."+status),
134
Duration: formatClock(end.Sub(start)), When: i18n.Ago(lang, p.CreatedAt.Unix()),
135
Title: p.CommitTitle, SHA: p.CommitSHA, Short: shortSHA(p.CommitSHA),
136
Ref: name, RefKind: kind, Actor: actor, Avatar: avatar, Initial: initial,
137
Stages: stageViews(lang, jobs, func(key string) string { return s.tr(r, key) }),
138
}
139
}
140
141
func (s *Server) actorOf(r *http.Request, name string, cache map[string]store.User) (string, string) {
142
name = strings.TrimSpace(name)
143
if name == "" {
144
return "", ""
145
}
146
u, ok := cache[name]
147
if !ok {
148
found, err := s.Store.UserByUsername(r.Context(), name)
149
if err == nil {
150
u = found
151
}
152
cache[name] = u
153
}
154
if u.ID == 0 {
155
return name, ""
156
}
157
return u.Username, u.AvatarURL
158
}
159
160
func pipeMatches(row PipeRow, q string) bool {
161
bits := []string{row.Label, row.Title, row.SHA, row.Short, row.Ref, row.Actor, strconv.FormatInt(row.ID, 10), row.Status}
162
for _, st := range row.Stages {
163
bits = append(bits, st.Name)
164
for _, j := range st.Jobs {
165
bits = append(bits, j.Name)
166
}
167
}
168
for _, b := range bits {
169
if strings.Contains(strings.ToLower(b), q) {
170
return true
171
}
172
}
173
return false
174
}
175
176
func displayStatus(pipe string, jobs []store.Job) string {
177
switch pipe {
178
case "failed":
179
return "failed"
180
case "running":
181
return "running"
182
case "manual":
183
return "manual"
184
case "queued":
185
return "pending"
186
}
187
warn := false
188
for _, j := range jobs {
189
if j.Status == "failed" && j.AllowFailure {
190
warn = true
191
}
192
}
193
if warn {
194
return "warning"
195
}
196
if pipe == "success" {
197
return "passed"
198
}
199
if pipe == "" {
200
return "pending"
201
}
202
return pipe
203
}
204
205
func stageViews(lang i18n.Lang, jobs []store.Job, tr func(string) string) []StageView {
206
var order []string
207
by := map[string][]store.Job{}
208
for _, j := range jobs {
209
if _, ok := by[j.Stage]; !ok {
210
order = append(order, j.Stage)
211
}
212
by[j.Stage] = append(by[j.Stage], j)
213
}
214
var out []StageView
215
for _, name := range order {
216
group := by[name]
217
status := stageStatus(group)
218
label := tr("pipe." + status)
219
var links []JobLink
220
for _, j := range group {
221
st := jobDisplay(j)
222
links = append(links, JobLink{ID: j.ID, Name: j.Name, Status: st, Label: tr("pipe." + st), Stage: j.Stage})
223
}
224
out = append(out, StageView{Name: name, Status: status, Label: label, Tip: name + ": " + strings.ToLower(label), Jobs: links})
225
}
226
_ = lang
227
return out
228
}
229
230
func stageStatus(jobs []store.Job) string {
231
pending, failed, warning, running := false, false, false, false
232
seen := false
233
for _, j := range jobs {
234
seen = true
235
switch {
236
case j.Status == "running":
237
running = true
238
case j.Status == "failed" && !j.AllowFailure:
239
failed = true
240
case j.Status == "failed" && j.AllowFailure:
241
warning = true
242
case j.Status == "queued" || j.Status == "manual":
243
pending = true
244
}
245
}
246
if !seen {
247
return "skipped"
248
}
249
if running {
250
return "running"
251
}
252
if failed {
253
return "failed"
254
}
255
if warning {
256
return "warning"
257
}
258
if pending {
259
return "pending"
260
}
261
allSkip := true
262
for _, j := range jobs {
263
if j.Status != "skipped" {
264
allSkip = false
265
}
266
}
267
if allSkip {
268
return "skipped"
269
}
270
return "passed"
271
}
272
273
func jobDisplay(j store.Job) string {
274
if j.Status == "failed" && j.AllowFailure {
275
return "warning"
276
}
277
switch j.Status {
278
case "success":
279
return "passed"
280
case "queued":
281
return "pending"
282
case "":
283
return "pending"
284
default:
285
return j.Status
286
}
287
}
288
289
func formatClock(d time.Duration) string {
290
if d < 0 {
291
d = 0
292
}
293
s := int(d.Seconds())
294
return pad2(s/3600) + ":" + pad2((s%3600)/60) + ":" + pad2(s%60)
295
}
296
297
func pad2(n int) string {
298
if n < 10 {
299
return "0" + strconv.Itoa(n)
300
}
301
return strconv.Itoa(n)
302
}
303
304
func shortSHA(sha string) string {
305
if len(sha) > 8 {
306
return sha[:8]
307
}
308
return sha
309
}
310
311
func (s *Server) showJob(w http.ResponseWriter, r *http.Request) {
312
_, repo, role, ok := s.guard(w, r, access.RoleReadonly)
313
if !ok {
314
return
315
}
316
p, job, ok := s.jobFromRequest(w, r, repo)
317
if !ok {
318
return
319
}
320
v := s.repoView(w, r, repo, role, job.Name)
321
v.Wide = true
322
v.Page = "pipelines"
323
v.Pipe = &p
324
v.JobPage = s.jobPage(r, repo, p, job, role)
325
s.render(w, "job", v)
326
}
327
328
func (s *Server) jobLog(w http.ResponseWriter, r *http.Request) {
329
_, repo, _, ok := s.guard(w, r, access.RoleReadonly)
330
if !ok {
331
return
332
}
333
_, job, ok := s.jobFromRequest(w, r, repo)
334
if !ok {
335
return
336
}
337
if r.URL.Query().Get("raw") == "1" {
338
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
339
_, _ = w.Write([]byte(job.Log))
340
return
341
}
342
offset, _ := strconv.Atoi(r.URL.Query().Get("offset"))
343
if offset < 0 || offset > len(job.Log) {
344
offset = 0
345
}
346
w.Header().Set("Content-Type", "application/json")
347
_ = json.NewEncoder(w).Encode(map[string]any{
348
"offset": len(job.Log),
349
"status": job.Status,
350
"text": job.Log[offset:],
351
})
352
}
353
354
func (s *Server) playJob(w http.ResponseWriter, r *http.Request) {
355
_, repo, _, ok := s.guard(w, r, access.RoleDeveloper)
356
if !ok || !s.csrfOK(w, r) {
357
return
358
}
359
p, job, ok := s.jobFromRequest(w, r, repo)
360
if !ok {
361
return
362
}
363
_, _ = s.Store.QueueJob(r.Context(), job.ID)
364
s.redirect(w, r, repoURL(repo)+"/-/pipelines/"+strconv.FormatInt(p.ID, 10)+"/jobs/"+strconv.FormatInt(job.ID, 10), s.tr(r, "flash.pipeline"), "")
365
}
366
367
func (s *Server) jobFromRequest(w http.ResponseWriter, r *http.Request, repo store.Repo) (store.Pipeline, store.Job, bool) {
368
pid, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
369
if err != nil {
370
http.NotFound(w, r)
371
return store.Pipeline{}, store.Job{}, false
372
}
373
jid, err := strconv.ParseInt(r.PathValue("job"), 10, 64)
374
if err != nil {
375
http.NotFound(w, r)
376
return store.Pipeline{}, store.Job{}, false
377
}
378
p, err := s.Store.PipelineByID(r.Context(), repo.ID, pid)
379
if err != nil {
380
http.NotFound(w, r)
381
return store.Pipeline{}, store.Job{}, false
382
}
383
jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)
384
for _, j := range jobs {
385
if j.ID == jid {
386
return p, j, true
387
}
388
}
389
http.NotFound(w, r)
390
return store.Pipeline{}, store.Job{}, false
391
}
392
393
func (s *Server) jobPage(r *http.Request, repo store.Repo, p store.Pipeline, job store.Job, role access.Role) *JobPage {
394
lang := s.langOf(r)
395
jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)
396
users := map[string]store.User{}
397
actor, avatar := s.actorOf(r, p.Actor, users)
398
initial := ""
399
if actor != "" {
400
initial = strings.ToUpper(actor[:1])
401
}
402
name, kind := ci.SplitRef(p.Ref)
403
status := jobDisplay(job)
404
pipeStatus := displayStatus(p.Status, jobs)
405
end := job.FinishedAt
406
if end.IsZero() && (job.Status == "success" || job.Status == "failed" || job.Status == "skipped") {
407
end = p.FinishedAt
408
}
409
start := job.StartedAt
410
dur := ""
411
if !start.IsZero() {
412
until := end
413
if until.IsZero() {
414
until = time.Now()
415
}
416
dur = formatClock(until.Sub(start))
417
}
418
queued := ""
419
if !start.IsZero() && !p.CreatedAt.IsZero() {
420
queued = formatClock(start.Sub(p.CreatedAt))
421
}
422
timeout := formatClock(job.Timeout)
423
if job.Timeout == 0 && s.Cfg.CI.TimeoutSec > 0 {
424
timeout = formatClock(time.Duration(s.Cfg.CI.TimeoutSec) * time.Second)
425
}
426
finished := ""
427
if !end.IsZero() {
428
finished = i18n.Ago(lang, end.Unix())
429
}
430
var stages []string
431
seen := map[string]bool{}
432
var related []JobLink
433
for _, j := range jobs {
434
if !seen[j.Stage] {
435
seen[j.Stage] = true
436
stages = append(stages, j.Stage)
437
}
438
st := jobDisplay(j)
439
related = append(related, JobLink{ID: j.ID, Name: j.Name, Status: st, Label: s.tr(r, "pipe."+st), Current: j.ID == job.ID, Stage: j.Stage})
440
}
441
sourceKey := "pipe.src." + p.Source
442
source := s.tr(r, sourceKey)
443
if source == sourceKey {
444
source = p.Source
445
}
446
return &JobPage{
447
Job: job, Pipe: p, Name: job.Name, Status: status, Label: s.tr(r, "pipe."+status),
448
Actor: actor, Avatar: avatar, Initial: initial, When: i18n.Ago(lang, p.CreatedAt.Unix()),
449
Duration: dur, Finished: finished, Queued: queued, Timeout: timeout, Source: source,
450
Ref: name, RefKind: kind, Short: shortSHA(p.CommitSHA), Title: p.CommitTitle, Stage: job.Stage,
451
PipeStatus: pipeStatus, PipeLabel: s.tr(r, "pipe."+pipeStatus),
452
Stages: stages, Related: related, Blocks: parseLog(job.Log), Running: job.Status == "running" || job.Status == "queued",
453
LogBytes: len(job.Log), CanPlay: job.Status == "manual" && role.CanWriteCode(),
454
}
455
}
456
457
func parseLog(raw string) []LogBlock {
458
var blocks []LogBlock
459
var cur *LogBlock
460
n := 0
461
flush := func() {
462
if cur == nil {
463
return
464
}
465
blocks = append(blocks, *cur)
466
cur = nil
467
}
468
for _, row := range strings.Split(raw, "\n") {
469
if row == "" {
470
continue
471
}
472
ts, text := row, row
473
if i := strings.IndexByte(row, '\t'); i >= 0 {
474
ts, text = row[:i], row[i+1:]
475
}
476
if strings.HasPrefix(text, "section_start:") {
477
flush()
478
body := strings.TrimPrefix(text, "section_start:")
479
title := body
480
if i := strings.IndexByte(body, ':'); i >= 0 {
481
title = body[i+1:]
482
}
483
cur = &LogBlock{Section: true, Title: title, Open: true}
484
continue
485
}
486
if strings.HasPrefix(text, "section_end:") {
487
dur := ""
488
body := strings.TrimPrefix(text, "section_end:")
489
if i := strings.IndexByte(body, '\t'); i >= 0 {
490
dur = body[i+1:]
491
}
492
if cur != nil {
493
cur.Duration = dur
494
flush()
495
}
496
continue
497
}
498
n++
499
line := LogLine{N: n, Time: clockOf(ts), Text: text}
500
if cur != nil {
501
cur.Lines = append(cur.Lines, line)
502
continue
503
}
504
blocks = append(blocks, LogBlock{Lines: []LogLine{line}})
505
}
506
if cur != nil {
507
flush()
508
}
509
return blocks
510
}
511
512
func clockOf(ts string) string {
513
if t, err := time.Parse(time.RFC3339, ts); err == nil {
514
return t.UTC().Format("15:04:05")
515
}
516
if len(ts) >= 19 && strings.Contains(ts, "T") {
517
return ts[11:19]
518
}
519
return ""
520
}
@@ -0,0 +1,520 @@1
package server2
3
import (4
"encoding/json"5
"net/http"6
"strconv"7
"strings"8
"time"9
10
"gitlab.com/Timfa/bluegit/internal/access"11
"gitlab.com/Timfa/bluegit/internal/ci"12
"gitlab.com/Timfa/bluegit/internal/i18n"13
"gitlab.com/Timfa/bluegit/internal/store"14
)15
16
// PipeRow is één rij in het pipeline-overzicht.17
type PipeRow struct {18
ID int6419
Status string20
Label string21
Duration string22
When string23
Title string24
SHA string25
Short string26
Ref string27
RefKind string28
Actor string29
Avatar string30
Initial string31
Stages []StageView32
}33
34
// StageView is één bolletje in de stages-kolom.35
type StageView struct {36
Name string37
Status string38
Label string39
Tip string40
Jobs []JobLink41
}42
43
// JobLink is een job in een stage-popover of in de zijbalk.44
type JobLink struct {45
ID int6446
Name string47
Status string48
Label string49
Current bool50
Stage string51
}52
53
// JobPage is de console van één job.54
type JobPage struct {55
Job store.Job56
Pipe store.Pipeline57
Name string58
Status string59
Label string60
Actor string61
Avatar string62
Initial string63
When string64
Duration string65
Finished string66
Queued string67
Timeout string68
Source string69
Ref string70
RefKind string71
Short string72
Title string73
Stage string74
PipeStatus string75
PipeLabel string76
Stages []string77
Related []JobLink78
Blocks []LogBlock79
Running bool80
LogBytes int81
CanPlay bool82
}83
84
// LogBlock is een losse regel of een inklapbare sectie.85
type LogBlock struct {86
Section bool87
Title string88
Duration string89
Open bool90
Lines []LogLine91
}92
93
// LogLine is één regel in de console.94
type LogLine struct {95
N int96
Time string97
Text string98
}99
100
func (s *Server) fillPipelines(r *http.Request, v *View, repo store.Repo) {101
lang := s.langOf(r)102
list, _ := s.Store.ListPipelines(r.Context(), repo.ID)103
q := strings.ToLower(strings.TrimSpace(r.URL.Query().Get("q")))104
v.Query = r.URL.Query().Get("q")105
users := map[string]store.User{}106
for _, p := range list {107
row := s.pipeRow(r, lang, repo, p, users)108
if q != "" && !pipeMatches(row, q) {109
continue110
}111
v.PipeRows = append(v.PipeRows, row)112
}113
}114
115
func (s *Server) pipeRow(r *http.Request, lang i18n.Lang, repo store.Repo, p store.Pipeline, users map[string]store.User) PipeRow {116
jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)117
name, kind := ci.SplitRef(p.Ref)118
status := displayStatus(p.Status, jobs)119
actor, avatar := s.actorOf(r, p.Actor, users)120
initial := ""121
if actor != "" {122
initial = strings.ToUpper(actor[:1])123
}124
end := p.FinishedAt125
if end.IsZero() {126
end = time.Now()127
}128
start := p.StartedAt129
if start.IsZero() {130
start = p.CreatedAt131
}132
return PipeRow{133
ID: p.ID, Status: status, Label: s.tr(r, "pipe."+status),134
Duration: formatClock(end.Sub(start)), When: i18n.Ago(lang, p.CreatedAt.Unix()),135
Title: p.CommitTitle, SHA: p.CommitSHA, Short: shortSHA(p.CommitSHA),136
Ref: name, RefKind: kind, Actor: actor, Avatar: avatar, Initial: initial,137
Stages: stageViews(lang, jobs, func(key string) string { return s.tr(r, key) }),138
}139
}140
141
func (s *Server) actorOf(r *http.Request, name string, cache map[string]store.User) (string, string) {142
name = strings.TrimSpace(name)143
if name == "" {144
return "", ""145
}146
u, ok := cache[name]147
if !ok {148
found, err := s.Store.UserByUsername(r.Context(), name)149
if err == nil {150
u = found151
}152
cache[name] = u153
}154
if u.ID == 0 {155
return name, ""156
}157
return u.Username, u.AvatarURL158
}159
160
func pipeMatches(row PipeRow, q string) bool {161
bits := []string{row.Label, row.Title, row.SHA, row.Short, row.Ref, row.Actor, strconv.FormatInt(row.ID, 10), row.Status}162
for _, st := range row.Stages {163
bits = append(bits, st.Name)164
for _, j := range st.Jobs {165
bits = append(bits, j.Name)166
}167
}168
for _, b := range bits {169
if strings.Contains(strings.ToLower(b), q) {170
return true171
}172
}173
return false174
}175
176
func displayStatus(pipe string, jobs []store.Job) string {177
switch pipe {178
case "failed":179
return "failed"180
case "running":181
return "running"182
case "manual":183
return "manual"184
case "queued":185
return "pending"186
}187
warn := false188
for _, j := range jobs {189
if j.Status == "failed" && j.AllowFailure {190
warn = true191
}192
}193
if warn {194
return "warning"195
}196
if pipe == "success" {197
return "passed"198
}199
if pipe == "" {200
return "pending"201
}202
return pipe203
}204
205
func stageViews(lang i18n.Lang, jobs []store.Job, tr func(string) string) []StageView {206
var order []string207
by := map[string][]store.Job{}208
for _, j := range jobs {209
if _, ok := by[j.Stage]; !ok {210
order = append(order, j.Stage)211
}212
by[j.Stage] = append(by[j.Stage], j)213
}214
var out []StageView215
for _, name := range order {216
group := by[name]217
status := stageStatus(group)218
label := tr("pipe." + status)219
var links []JobLink220
for _, j := range group {221
st := jobDisplay(j)222
links = append(links, JobLink{ID: j.ID, Name: j.Name, Status: st, Label: tr("pipe." + st), Stage: j.Stage})223
}224
out = append(out, StageView{Name: name, Status: status, Label: label, Tip: name + ": " + strings.ToLower(label), Jobs: links})225
}226
_ = lang227
return out228
}229
230
func stageStatus(jobs []store.Job) string {231
pending, failed, warning, running := false, false, false, false232
seen := false233
for _, j := range jobs {234
seen = true235
switch {236
case j.Status == "running":237
running = true238
case j.Status == "failed" && !j.AllowFailure:239
failed = true240
case j.Status == "failed" && j.AllowFailure:241
warning = true242
case j.Status == "queued" || j.Status == "manual":243
pending = true244
}245
}246
if !seen {247
return "skipped"248
}249
if running {250
return "running"251
}252
if failed {253
return "failed"254
}255
if warning {256
return "warning"257
}258
if pending {259
return "pending"260
}261
allSkip := true262
for _, j := range jobs {263
if j.Status != "skipped" {264
allSkip = false265
}266
}267
if allSkip {268
return "skipped"269
}270
return "passed"271
}272
273
func jobDisplay(j store.Job) string {274
if j.Status == "failed" && j.AllowFailure {275
return "warning"276
}277
switch j.Status {278
case "success":279
return "passed"280
case "queued":281
return "pending"282
case "":283
return "pending"284
default:285
return j.Status286
}287
}288
289
func formatClock(d time.Duration) string {290
if d < 0 {291
d = 0292
}293
s := int(d.Seconds())294
return pad2(s/3600) + ":" + pad2((s%3600)/60) + ":" + pad2(s%60)295
}296
297
func pad2(n int) string {298
if n < 10 {299
return "0" + strconv.Itoa(n)300
}301
return strconv.Itoa(n)302
}303
304
func shortSHA(sha string) string {305
if len(sha) > 8 {306
return sha[:8]307
}308
return sha309
}310
311
func (s *Server) showJob(w http.ResponseWriter, r *http.Request) {312
_, repo, role, ok := s.guard(w, r, access.RoleReadonly)313
if !ok {314
return315
}316
p, job, ok := s.jobFromRequest(w, r, repo)317
if !ok {318
return319
}320
v := s.repoView(w, r, repo, role, job.Name)321
v.Wide = true322
v.Page = "pipelines"323
v.Pipe = &p324
v.JobPage = s.jobPage(r, repo, p, job, role)325
s.render(w, "job", v)326
}327
328
func (s *Server) jobLog(w http.ResponseWriter, r *http.Request) {329
_, repo, _, ok := s.guard(w, r, access.RoleReadonly)330
if !ok {331
return332
}333
_, job, ok := s.jobFromRequest(w, r, repo)334
if !ok {335
return336
}337
if r.URL.Query().Get("raw") == "1" {338
w.Header().Set("Content-Type", "text/plain; charset=utf-8")339
_, _ = w.Write([]byte(job.Log))340
return341
}342
offset, _ := strconv.Atoi(r.URL.Query().Get("offset"))343
if offset < 0 || offset > len(job.Log) {344
offset = 0345
}346
w.Header().Set("Content-Type", "application/json")347
_ = json.NewEncoder(w).Encode(map[string]any{348
"offset": len(job.Log),349
"status": job.Status,350
"text": job.Log[offset:],351
})352
}353
354
func (s *Server) playJob(w http.ResponseWriter, r *http.Request) {355
_, repo, _, ok := s.guard(w, r, access.RoleDeveloper)356
if !ok || !s.csrfOK(w, r) {357
return358
}359
p, job, ok := s.jobFromRequest(w, r, repo)360
if !ok {361
return362
}363
_, _ = s.Store.QueueJob(r.Context(), job.ID)364
s.redirect(w, r, repoURL(repo)+"/-/pipelines/"+strconv.FormatInt(p.ID, 10)+"/jobs/"+strconv.FormatInt(job.ID, 10), s.tr(r, "flash.pipeline"), "")365
}366
367
func (s *Server) jobFromRequest(w http.ResponseWriter, r *http.Request, repo store.Repo) (store.Pipeline, store.Job, bool) {368
pid, err := strconv.ParseInt(r.PathValue("id"), 10, 64)369
if err != nil {370
http.NotFound(w, r)371
return store.Pipeline{}, store.Job{}, false372
}373
jid, err := strconv.ParseInt(r.PathValue("job"), 10, 64)374
if err != nil {375
http.NotFound(w, r)376
return store.Pipeline{}, store.Job{}, false377
}378
p, err := s.Store.PipelineByID(r.Context(), repo.ID, pid)379
if err != nil {380
http.NotFound(w, r)381
return store.Pipeline{}, store.Job{}, false382
}383
jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)384
for _, j := range jobs {385
if j.ID == jid {386
return p, j, true387
}388
}389
http.NotFound(w, r)390
return store.Pipeline{}, store.Job{}, false391
}392
393
func (s *Server) jobPage(r *http.Request, repo store.Repo, p store.Pipeline, job store.Job, role access.Role) *JobPage {394
lang := s.langOf(r)395
jobs, _ := s.Store.JobsByPipeline(r.Context(), p.ID)396
users := map[string]store.User{}397
actor, avatar := s.actorOf(r, p.Actor, users)398
initial := ""399
if actor != "" {400
initial = strings.ToUpper(actor[:1])401
}402
name, kind := ci.SplitRef(p.Ref)403
status := jobDisplay(job)404
pipeStatus := displayStatus(p.Status, jobs)405
end := job.FinishedAt406
if end.IsZero() && (job.Status == "success" || job.Status == "failed" || job.Status == "skipped") {407
end = p.FinishedAt408
}409
start := job.StartedAt410
dur := ""411
if !start.IsZero() {412
until := end413
if until.IsZero() {414
until = time.Now()415
}416
dur = formatClock(until.Sub(start))417
}418
queued := ""419
if !start.IsZero() && !p.CreatedAt.IsZero() {420
queued = formatClock(start.Sub(p.CreatedAt))421
}422
timeout := formatClock(job.Timeout)423
if job.Timeout == 0 && s.Cfg.CI.TimeoutSec > 0 {424
timeout = formatClock(time.Duration(s.Cfg.CI.TimeoutSec) * time.Second)425
}426
finished := ""427
if !end.IsZero() {428
finished = i18n.Ago(lang, end.Unix())429
}430
var stages []string431
seen := map[string]bool{}432
var related []JobLink433
for _, j := range jobs {434
if !seen[j.Stage] {435
seen[j.Stage] = true436
stages = append(stages, j.Stage)437
}438
st := jobDisplay(j)439
related = append(related, JobLink{ID: j.ID, Name: j.Name, Status: st, Label: s.tr(r, "pipe."+st), Current: j.ID == job.ID, Stage: j.Stage})440
}441
sourceKey := "pipe.src." + p.Source442
source := s.tr(r, sourceKey)443
if source == sourceKey {444
source = p.Source445
}446
return &JobPage{447
Job: job, Pipe: p, Name: job.Name, Status: status, Label: s.tr(r, "pipe."+status),448
Actor: actor, Avatar: avatar, Initial: initial, When: i18n.Ago(lang, p.CreatedAt.Unix()),449
Duration: dur, Finished: finished, Queued: queued, Timeout: timeout, Source: source,450
Ref: name, RefKind: kind, Short: shortSHA(p.CommitSHA), Title: p.CommitTitle, Stage: job.Stage,451
PipeStatus: pipeStatus, PipeLabel: s.tr(r, "pipe."+pipeStatus),452
Stages: stages, Related: related, Blocks: parseLog(job.Log), Running: job.Status == "running" || job.Status == "queued",453
LogBytes: len(job.Log), CanPlay: job.Status == "manual" && role.CanWriteCode(),454
}455
}456
457
func parseLog(raw string) []LogBlock {458
var blocks []LogBlock459
var cur *LogBlock460
n := 0461
flush := func() {462
if cur == nil {463
return464
}465
blocks = append(blocks, *cur)466
cur = nil467
}468
for _, row := range strings.Split(raw, "\n") {469
if row == "" {470
continue471
}472
ts, text := row, row473
if i := strings.IndexByte(row, '\t'); i >= 0 {474
ts, text = row[:i], row[i+1:]475
}476
if strings.HasPrefix(text, "section_start:") {477
flush()478
body := strings.TrimPrefix(text, "section_start:")479
title := body480
if i := strings.IndexByte(body, ':'); i >= 0 {481
title = body[i+1:]482
}483
cur = &LogBlock{Section: true, Title: title, Open: true}484
continue485
}486
if strings.HasPrefix(text, "section_end:") {487
dur := ""488
body := strings.TrimPrefix(text, "section_end:")489
if i := strings.IndexByte(body, '\t'); i >= 0 {490
dur = body[i+1:]491
}492
if cur != nil {493
cur.Duration = dur494
flush()495
}496
continue497
}498
n++499
line := LogLine{N: n, Time: clockOf(ts), Text: text}500
if cur != nil {501
cur.Lines = append(cur.Lines, line)502
continue503
}504
blocks = append(blocks, LogBlock{Lines: []LogLine{line}})505
}506
if cur != nil {507
flush()508
}509
return blocks510
}511
512
func clockOf(ts string) string {513
if t, err := time.Parse(time.RFC3339, ts); err == nil {514
return t.UTC().Format("15:04:05")515
}516
if len(ts) >= 19 && strings.Contains(ts, "T") {517
return ts[11:19]518
}519
return ""520
}@@ -0,0 +1,216 @@
1
package server
2
3
import (
4
"context"
5
"io"
6
"net/http"
7
"net/http/cookiejar"
8
"net/http/httptest"
9
"net/url"
10
"path/filepath"
11
"strconv"
12
"strings"
13
"testing"
14
"time"
15
16
"gitlab.com/Timfa/bluegit/internal/auth"
17
"gitlab.com/Timfa/bluegit/internal/config"
18
"gitlab.com/Timfa/bluegit/internal/store"
19
)
20
21
func TestParseLogSections(t *testing.T) {
22
raw := "2026-10-22T12:00:00Z\tsection_start:script:Running script\n" +
23
"2026-10-22T12:00:01Z\thello from the job\n" +
24
"2026-10-22T12:00:08Z\tsection_end:script:done\t00:08\n" +
25
"2026-10-22T12:00:09Z\tafter\n"
26
blocks := parseLog(raw)
27
if len(blocks) != 2 || !blocks[0].Section || blocks[0].Title != "Running script" || blocks[0].Duration != "00:08" {
28
t.Fatalf("sectie: %+v", blocks)
29
}
30
if len(blocks[0].Lines) != 1 || blocks[0].Lines[0].Text != "hello from the job" || blocks[0].Lines[0].Time != "12:00:01" {
31
t.Fatalf("regel: %+v", blocks[0].Lines)
32
}
33
if blocks[1].Section || blocks[1].Lines[0].Text != "after" {
34
t.Fatalf("losse regel: %+v", blocks[1])
35
}
36
}
37
38
func TestPipelinePages(t *testing.T) {
39
storage := t.TempDir()
40
st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())
41
if err != nil {
42
t.Fatal(err)
43
}
44
t.Cleanup(func() { _ = st.Close() })
45
cfg := config.Config{
46
BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,
47
Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},
48
Git: config.Git{Binary: "git", DefaultBranch: "master"},
49
}
50
srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git"}
51
ts := httptest.NewServer(srv.Handler())
52
t.Cleanup(ts.Close)
53
jar, _ := cookiejar.New(nil)
54
client := &http.Client{Jar: jar}
55
res, err := client.Get(ts.URL + "/login")
56
if err != nil {
57
t.Fatal(err)
58
}
59
_ = res.Body.Close()
60
61
ctx := context.Background()
62
user, err := st.UserByUsername(ctx, "tim")
63
if err != nil {
64
t.Fatal(err)
65
}
66
repo, err := st.CreateRepo(ctx, "user", user.ID, "demo", "", "master", "private")
67
if err != nil {
68
t.Fatal(err)
69
}
70
sha := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
71
okID, err := st.CreatePipeline(ctx, repo.ID, sha, "refs/heads/master", "push", "tim", "feat: groene run", []store.NewJob{
72
{Name: "lint", Stage: "test", Script: "exit 0"},
73
{Name: "flake", Stage: "test", Script: "exit 1", AllowFailure: true},
74
{Name: "ship", Stage: "deploy", Script: "exit 0"},
75
})
76
if err != nil {
77
t.Fatal(err)
78
}
79
okJobs, _ := st.JobsByPipeline(ctx, okID)
80
for _, j := range okJobs {
81
switch j.Name {
82
case "flake":
83
if err := st.FinishJob(ctx, j.ID, "failed", ""); err != nil {
84
t.Fatal(err)
85
}
86
default:
87
if err := st.FinishJob(ctx, j.ID, "success", ""); err != nil {
88
t.Fatal(err)
89
}
90
}
91
}
92
if status, err := st.RefreshPipelineStatus(ctx, okID); err != nil || status != "success" {
93
t.Fatalf("warning-pipeline: %s %v", status, err)
94
}
95
96
failID, err := st.CreatePipeline(ctx, repo.ID, sha, "refs/tags/v0.0.26", "push", "tim", "fix: tag die faalt", []store.NewJob{
97
{Name: "build", Stage: "test", Script: "exit 1"},
98
{Name: "release", Stage: "deploy", Script: "exit 0"},
99
})
100
if err != nil {
101
t.Fatal(err)
102
}
103
failJobs, _ := st.JobsByPipeline(ctx, failID)
104
var buildID int64
105
stamp := time.Now().UTC().Format(time.RFC3339)
106
log := stamp + "\tsection_start:script:Running script\n" +
107
stamp + "\thello from the job\n" +
108
stamp + "\tsection_end:script:done\t00:08\n"
109
for _, j := range failJobs {
110
if j.Name == "build" {
111
buildID = j.ID
112
if err := st.FinishJob(ctx, j.ID, "failed", log); err != nil {
113
t.Fatal(err)
114
}
115
continue
116
}
117
if err := st.SkipJob(ctx, j.ID, "skipped"); err != nil {
118
t.Fatal(err)
119
}
120
}
121
if status, err := st.RefreshPipelineStatus(ctx, failID); err != nil || status != "failed" {
122
t.Fatalf("mislukte pipeline: %s %v", status, err)
123
}
124
125
manualID, err := st.CreatePipeline(ctx, repo.ID, sha, "refs/heads/master", "web", "tim", "handmatig", []store.NewJob{
126
{Name: "approve", Stage: "test", Script: "exit 0", When: "manual"},
127
})
128
if err != nil {
129
t.Fatal(err)
130
}
131
manualJobs, _ := st.JobsByPipeline(ctx, manualID)
132
133
res, err = client.Get(ts.URL + "/tim/demo/-/pipelines")
134
if err != nil {
135
t.Fatal(err)
136
}
137
page := read(t, res)
138
for _, want := range []string{
139
"Filter pipelines", "Show Pipeline ID", "Created by", "Stages",
140
"Warning", "Failed", "v0.0.26", "feat: groene run",
141
`data-tip="test: warning"`, `data-tip="deploy: skipped"`,
142
"class=\"stage-dot failed\"", "flake", "build",
143
} {
144
if !strings.Contains(page, want) {
145
t.Errorf("overzicht mist %q", want)
146
}
147
}
148
if strings.Contains(page, "pipe.col.status") {
149
t.Fatal("vertaling ontbreekt")
150
}
151
152
res, err = client.Get(ts.URL + "/tim/demo/-/pipelines?q=v0.0.26")
153
if err != nil {
154
t.Fatal(err)
155
}
156
filtered := read(t, res)
157
if !strings.Contains(filtered, "v0.0.26") || strings.Contains(filtered, "feat: groene run") {
158
t.Fatalf("filter:\n%s", filtered)
159
}
160
161
res, err = client.Get(ts.URL + "/tim/demo/-/pipelines?show=" + strconv.FormatInt(failID, 10))
162
if err != nil {
163
t.Fatal(err)
164
}
165
if !strings.HasSuffix(res.Request.URL.Path, "/pipelines/"+strconv.FormatInt(failID, 10)) {
166
t.Fatalf("show-id ging naar %s", res.Request.URL.Path)
167
}
168
169
jobURL := ts.URL + "/tim/demo/-/pipelines/" + strconv.FormatInt(failID, 10) + "/jobs/" + strconv.FormatInt(buildID, 10)
170
res, err = client.Get(jobURL)
171
if err != nil {
172
t.Fatal(err)
173
}
174
jobPage := read(t, res)
175
for _, want := range []string{
176
"Running script", "hello from the job", "00:08",
177
"Log timestamps in UTC.", "Related jobs", "bluegit #1", "Push",
178
`data-stage="deploy" hidden`, `value="test" selected`,
179
"for", "v0.0.26",
180
} {
181
if !strings.Contains(jobPage, want) {
182
t.Errorf("jobpagina mist %q", want)
183
}
184
}
185
186
res, err = client.Get(jobURL + "/log?raw=1")
187
if err != nil {
188
t.Fatal(err)
189
}
190
raw, _ := io.ReadAll(res.Body)
191
_ = res.Body.Close()
192
if !strings.Contains(string(raw), "hello from the job") {
193
t.Fatalf("ruwe log: %s", raw)
194
}
195
196
res, err = client.Get(ts.URL + "/tim/demo/-/pipelines/" + strconv.FormatInt(manualID, 10) + "/jobs/" + strconv.FormatInt(manualJobs[0].ID, 10))
197
if err != nil {
198
t.Fatal(err)
199
}
200
manualPage := read(t, res)
201
if !strings.Contains(manualPage, ">Play<") && !strings.Contains(manualPage, ">Play</button>") {
202
if !strings.Contains(manualPage, "Play") {
203
t.Fatalf("play-knop:\n%s", manualPage)
204
}
205
}
206
res, err = client.PostForm(ts.URL+"/tim/demo/-/pipelines/"+strconv.FormatInt(manualID, 10)+"/jobs/"+strconv.FormatInt(manualJobs[0].ID, 10)+"/play", url.Values{
207
"csrf": {csrfOf(t, manualPage)},
208
})
209
if err != nil {
210
t.Fatal(err)
211
}
212
played := read(t, res)
213
if !strings.Contains(played, "Pending") {
214
t.Fatalf("na play:\n%s", played)
215
}
216
}
@@ -0,0 +1,216 @@1
package server2
3
import (4
"context"5
"io"6
"net/http"7
"net/http/cookiejar"8
"net/http/httptest"9
"net/url"10
"path/filepath"11
"strconv"12
"strings"13
"testing"14
"time"15
16
"gitlab.com/Timfa/bluegit/internal/auth"17
"gitlab.com/Timfa/bluegit/internal/config"18
"gitlab.com/Timfa/bluegit/internal/store"19
)20
21
func TestParseLogSections(t *testing.T) {22
raw := "2026-10-22T12:00:00Z\tsection_start:script:Running script\n" +23
"2026-10-22T12:00:01Z\thello from the job\n" +24
"2026-10-22T12:00:08Z\tsection_end:script:done\t00:08\n" +25
"2026-10-22T12:00:09Z\tafter\n"26
blocks := parseLog(raw)27
if len(blocks) != 2 || !blocks[0].Section || blocks[0].Title != "Running script" || blocks[0].Duration != "00:08" {28
t.Fatalf("sectie: %+v", blocks)29
}30
if len(blocks[0].Lines) != 1 || blocks[0].Lines[0].Text != "hello from the job" || blocks[0].Lines[0].Time != "12:00:01" {31
t.Fatalf("regel: %+v", blocks[0].Lines)32
}33
if blocks[1].Section || blocks[1].Lines[0].Text != "after" {34
t.Fatalf("losse regel: %+v", blocks[1])35
}36
}37
38
func TestPipelinePages(t *testing.T) {39
storage := t.TempDir()40
st, err := store.Open(filepath.Join(storage, "bluegit.db"), bytes32())41
if err != nil {42
t.Fatal(err)43
}44
t.Cleanup(func() { _ = st.Close() })45
cfg := config.Config{46
BaseURL: "http://127.0.0.1:9", Listen: "127.0.0.1:0", StoragePath: storage,47
Auth: config.Auth{Mode: "dev", DevUser: "tim", DevAuthID: 1, UserAgent: "test", BaseURL: "https://auth.timfalken.com"},48
Git: config.Git{Binary: "git", DefaultBranch: "master"},49
}50
srv := &Server{Cfg: cfg, Store: st, Auth: auth.Dev{Username: "tim", AuthID: 1}, Dev: true, Git: "git"}51
ts := httptest.NewServer(srv.Handler())52
t.Cleanup(ts.Close)53
jar, _ := cookiejar.New(nil)54
client := &http.Client{Jar: jar}55
res, err := client.Get(ts.URL + "/login")56
if err != nil {57
t.Fatal(err)58
}59
_ = res.Body.Close()60
61
ctx := context.Background()62
user, err := st.UserByUsername(ctx, "tim")63
if err != nil {64
t.Fatal(err)65
}66
repo, err := st.CreateRepo(ctx, "user", user.ID, "demo", "", "master", "private")67
if err != nil {68
t.Fatal(err)69
}70
sha := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"71
okID, err := st.CreatePipeline(ctx, repo.ID, sha, "refs/heads/master", "push", "tim", "feat: groene run", []store.NewJob{72
{Name: "lint", Stage: "test", Script: "exit 0"},73
{Name: "flake", Stage: "test", Script: "exit 1", AllowFailure: true},74
{Name: "ship", Stage: "deploy", Script: "exit 0"},75
})76
if err != nil {77
t.Fatal(err)78
}79
okJobs, _ := st.JobsByPipeline(ctx, okID)80
for _, j := range okJobs {81
switch j.Name {82
case "flake":83
if err := st.FinishJob(ctx, j.ID, "failed", ""); err != nil {84
t.Fatal(err)85
}86
default:87
if err := st.FinishJob(ctx, j.ID, "success", ""); err != nil {88
t.Fatal(err)89
}90
}91
}92
if status, err := st.RefreshPipelineStatus(ctx, okID); err != nil || status != "success" {93
t.Fatalf("warning-pipeline: %s %v", status, err)94
}95
96
failID, err := st.CreatePipeline(ctx, repo.ID, sha, "refs/tags/v0.0.26", "push", "tim", "fix: tag die faalt", []store.NewJob{97
{Name: "build", Stage: "test", Script: "exit 1"},98
{Name: "release", Stage: "deploy", Script: "exit 0"},99
})100
if err != nil {101
t.Fatal(err)102
}103
failJobs, _ := st.JobsByPipeline(ctx, failID)104
var buildID int64105
stamp := time.Now().UTC().Format(time.RFC3339)106
log := stamp + "\tsection_start:script:Running script\n" +107
stamp + "\thello from the job\n" +108
stamp + "\tsection_end:script:done\t00:08\n"109
for _, j := range failJobs {110
if j.Name == "build" {111
buildID = j.ID112
if err := st.FinishJob(ctx, j.ID, "failed", log); err != nil {113
t.Fatal(err)114
}115
continue116
}117
if err := st.SkipJob(ctx, j.ID, "skipped"); err != nil {118
t.Fatal(err)119
}120
}121
if status, err := st.RefreshPipelineStatus(ctx, failID); err != nil || status != "failed" {122
t.Fatalf("mislukte pipeline: %s %v", status, err)123
}124
125
manualID, err := st.CreatePipeline(ctx, repo.ID, sha, "refs/heads/master", "web", "tim", "handmatig", []store.NewJob{126
{Name: "approve", Stage: "test", Script: "exit 0", When: "manual"},127
})128
if err != nil {129
t.Fatal(err)130
}131
manualJobs, _ := st.JobsByPipeline(ctx, manualID)132
133
res, err = client.Get(ts.URL + "/tim/demo/-/pipelines")134
if err != nil {135
t.Fatal(err)136
}137
page := read(t, res)138
for _, want := range []string{139
"Filter pipelines", "Show Pipeline ID", "Created by", "Stages",140
"Warning", "Failed", "v0.0.26", "feat: groene run",141
`data-tip="test: warning"`, `data-tip="deploy: skipped"`,142
"class=\"stage-dot failed\"", "flake", "build",143
} {144
if !strings.Contains(page, want) {145
t.Errorf("overzicht mist %q", want)146
}147
}148
if strings.Contains(page, "pipe.col.status") {149
t.Fatal("vertaling ontbreekt")150
}151
152
res, err = client.Get(ts.URL + "/tim/demo/-/pipelines?q=v0.0.26")153
if err != nil {154
t.Fatal(err)155
}156
filtered := read(t, res)157
if !strings.Contains(filtered, "v0.0.26") || strings.Contains(filtered, "feat: groene run") {158
t.Fatalf("filter:\n%s", filtered)159
}160
161
res, err = client.Get(ts.URL + "/tim/demo/-/pipelines?show=" + strconv.FormatInt(failID, 10))162
if err != nil {163
t.Fatal(err)164
}165
if !strings.HasSuffix(res.Request.URL.Path, "/pipelines/"+strconv.FormatInt(failID, 10)) {166
t.Fatalf("show-id ging naar %s", res.Request.URL.Path)167
}168
169
jobURL := ts.URL + "/tim/demo/-/pipelines/" + strconv.FormatInt(failID, 10) + "/jobs/" + strconv.FormatInt(buildID, 10)170
res, err = client.Get(jobURL)171
if err != nil {172
t.Fatal(err)173
}174
jobPage := read(t, res)175
for _, want := range []string{176
"Running script", "hello from the job", "00:08",177
"Log timestamps in UTC.", "Related jobs", "bluegit #1", "Push",178
`data-stage="deploy" hidden`, `value="test" selected`,179
"for", "v0.0.26",180
} {181
if !strings.Contains(jobPage, want) {182
t.Errorf("jobpagina mist %q", want)183
}184
}185
186
res, err = client.Get(jobURL + "/log?raw=1")187
if err != nil {188
t.Fatal(err)189
}190
raw, _ := io.ReadAll(res.Body)191
_ = res.Body.Close()192
if !strings.Contains(string(raw), "hello from the job") {193
t.Fatalf("ruwe log: %s", raw)194
}195
196
res, err = client.Get(ts.URL + "/tim/demo/-/pipelines/" + strconv.FormatInt(manualID, 10) + "/jobs/" + strconv.FormatInt(manualJobs[0].ID, 10))197
if err != nil {198
t.Fatal(err)199
}200
manualPage := read(t, res)201
if !strings.Contains(manualPage, ">Play<") && !strings.Contains(manualPage, ">Play</button>") {202
if !strings.Contains(manualPage, "Play") {203
t.Fatalf("play-knop:\n%s", manualPage)204
}205
}206
res, err = client.PostForm(ts.URL+"/tim/demo/-/pipelines/"+strconv.FormatInt(manualID, 10)+"/jobs/"+strconv.FormatInt(manualJobs[0].ID, 10)+"/play", url.Values{207
"csrf": {csrfOf(t, manualPage)},208
})209
if err != nil {210
t.Fatal(err)211
}212
played := read(t, res)213
if !strings.Contains(played, "Pending") {214
t.Fatalf("na play:\n%s", played)215
}216
}@@ -353,8 +353,16 @@ func (s *Server) pipelines(w http.ResponseWriter, r *http.Request) {
353
353
if !ok {
354
354
return
355
355
}
356
if id := strings.TrimSpace(r.URL.Query().Get("show")); id != "" {
357
if n, err := strconv.ParseInt(id, 10, 64); err == nil && n > 0 {
358
http.Redirect(w, r, repoURL(repo)+"/-/pipelines/"+id, http.StatusSeeOther)
359
return
360
}
361
}
356
362
v := s.repoView(w, r, repo, role, "title.pipelines")
357
v.Pipes, _ = s.Store.ListPipelines(r.Context(), repo.ID)
363
v.Wide = true
364
v.Page = "pipelines"
365
s.fillPipelines(r, &v, repo)
358
366
s.render(w, "pipelines", v)
359
367
}
360
368
@@ -374,6 +382,8 @@ func (s *Server) pipeline(w http.ResponseWriter, r *http.Request) {
374
382
return
375
383
}
376
384
v := s.repoView(w, r, repo, role, "title.pipeline")
385
v.Wide = true
386
v.Page = "pipelines"
377
387
v.Pipe = &p
378
388
v.Jobs, _ = s.Store.JobsByPipeline(r.Context(), p.ID)
379
389
s.render(w, "pipeline", v)
@@ -353,8 +353,16 @@ func (s *Server) pipelines(w http.ResponseWriter, r *http.Request) {353
if !ok {353
if !ok {354
return354
return355
}355
}356
if id := strings.TrimSpace(r.URL.Query().Get("show")); id != "" {357
if n, err := strconv.ParseInt(id, 10, 64); err == nil && n > 0 {358
http.Redirect(w, r, repoURL(repo)+"/-/pipelines/"+id, http.StatusSeeOther)359
return360
}361
}356
v := s.repoView(w, r, repo, role, "title.pipelines")362
v := s.repoView(w, r, repo, role, "title.pipelines")357
v.Pipes, _ = s.Store.ListPipelines(r.Context(), repo.ID)363
v.Wide = true364
v.Page = "pipelines"365
s.fillPipelines(r, &v, repo)358
s.render(w, "pipelines", v)366
s.render(w, "pipelines", v)359
}367
}360
368
@@ -374,6 +382,8 @@ func (s *Server) pipeline(w http.ResponseWriter, r *http.Request) {374
return382
return375
}383
}376
v := s.repoView(w, r, repo, role, "title.pipeline")384
v := s.repoView(w, r, repo, role, "title.pipeline")385
v.Wide = true386
v.Page = "pipelines"377
v.Pipe = &p387
v.Pipe = &p378
v.Jobs, _ = s.Store.JobsByPipeline(r.Context(), p.ID)388
v.Jobs, _ = s.Store.JobsByPipeline(r.Context(), p.ID)379
s.render(w, "pipeline", v)389
s.render(w, "pipeline", v)@@ -120,6 +120,9 @@ func (s *Server) Handler() http.Handler {
120
120
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines", s.pipelines)
121
121
mux.HandleFunc("POST /{owner}/{repo}/-/pipelines", s.runPipeline)
122
122
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}", s.pipeline)
123
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}", s.showJob)
124
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/log", s.jobLog)
125
mux.HandleFunc("POST /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/play", s.playJob)
123
126
mux.HandleFunc("GET /{owner}/{repo}/-/releases", s.releases)
124
127
mux.HandleFunc("GET /{owner}/{repo}/-/releases/{tag}/assets/{name}", s.releaseAsset)
125
128
mux.HandleFunc("GET /{owner}/{repo}/-/logo", s.repoLogo)
@@ -434,8 +437,10 @@ type View struct {
434
437
Diff string
435
438
DiffFiles []DiffFileView
436
439
Pipes []store.Pipeline
440
PipeRows []PipeRow
437
441
Pipe *store.Pipeline
438
442
Jobs []store.Job
443
JobPage *JobPage
439
444
Releases []store.Release
440
445
Members []store.Member
441
446
Secrets []store.SecretMeta
@@ -120,6 +120,9 @@ func (s *Server) Handler() http.Handler {120
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines", s.pipelines)120
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines", s.pipelines)121
mux.HandleFunc("POST /{owner}/{repo}/-/pipelines", s.runPipeline)121
mux.HandleFunc("POST /{owner}/{repo}/-/pipelines", s.runPipeline)122
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}", s.pipeline)122
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}", s.pipeline)123
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}", s.showJob)124
mux.HandleFunc("GET /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/log", s.jobLog)125
mux.HandleFunc("POST /{owner}/{repo}/-/pipelines/{id}/jobs/{job}/play", s.playJob)123
mux.HandleFunc("GET /{owner}/{repo}/-/releases", s.releases)126
mux.HandleFunc("GET /{owner}/{repo}/-/releases", s.releases)124
mux.HandleFunc("GET /{owner}/{repo}/-/releases/{tag}/assets/{name}", s.releaseAsset)127
mux.HandleFunc("GET /{owner}/{repo}/-/releases/{tag}/assets/{name}", s.releaseAsset)125
mux.HandleFunc("GET /{owner}/{repo}/-/logo", s.repoLogo)128
mux.HandleFunc("GET /{owner}/{repo}/-/logo", s.repoLogo)@@ -434,8 +437,10 @@ type View struct {434
Diff string437
Diff string435
DiffFiles []DiffFileView438
DiffFiles []DiffFileView436
Pipes []store.Pipeline439
Pipes []store.Pipeline440
PipeRows []PipeRow437
Pipe *store.Pipeline441
Pipe *store.Pipeline438
Jobs []store.Job442
Jobs []store.Job443
JobPage *JobPage439
Releases []store.Release444
Releases []store.Release440
Members []store.Member445
Members []store.Member441
Secrets []store.SecretMeta446
Secrets []store.SecretMeta@@ -0,0 +1,281 @@
1
(function () {
2
function closeStages(except) {
3
document.querySelectorAll(".stage.open").forEach(function (stage) {
4
if (stage === except) {
5
return;
6
}
7
stage.classList.remove("open");
8
var pop = stage.querySelector(".stage-pop");
9
if (pop) {
10
pop.hidden = true;
11
}
12
});
13
}
14
15
document.querySelectorAll(".stage-dot[data-tip]").forEach(function (btn) {
16
btn.addEventListener("click", function (ev) {
17
ev.stopPropagation();
18
var stage = btn.parentElement;
19
var pop = stage.querySelector(".stage-pop");
20
var open = stage.classList.contains("open");
21
closeStages(null);
22
if (!open && pop) {
23
stage.classList.add("open");
24
pop.hidden = false;
25
}
26
});
27
});
28
29
document.addEventListener("click", function () {
30
closeStages(null);
31
});
32
document.addEventListener("keydown", function (ev) {
33
if (ev.key === "Escape") {
34
closeStages(null);
35
}
36
});
37
38
document.querySelectorAll(".section-toggle").forEach(function (btn) {
39
btn.addEventListener("click", function () {
40
var sec = btn.parentElement;
41
sec.classList.toggle("open");
42
});
43
});
44
45
var log = document.querySelector("[data-log]");
46
var hits = [];
47
var hitAt = -1;
48
49
function clearHits() {
50
if (!log) {
51
return;
52
}
53
log.querySelectorAll(".hit").forEach(function (el) {
54
el.classList.remove("hit", "on");
55
});
56
hits = [];
57
hitAt = -1;
58
}
59
60
function showHit(i) {
61
if (!hits.length) {
62
return;
63
}
64
hitAt = (i + hits.length) % hits.length;
65
hits.forEach(function (el, n) {
66
el.classList.toggle("on", n === hitAt);
67
});
68
var current = hits[hitAt];
69
var sec = current.closest(".logsec");
70
if (sec) {
71
sec.classList.add("open");
72
}
73
current.scrollIntoView({ block: "center" });
74
}
75
76
var search = document.querySelector("[data-log-search]");
77
if (search && log) {
78
search.addEventListener("submit", function (ev) {
79
ev.preventDefault();
80
var q = (search.querySelector("input").value || "").toLowerCase();
81
clearHits();
82
if (!q) {
83
return;
84
}
85
log.querySelectorAll("[data-line]").forEach(function (row) {
86
var code = row.querySelector("code");
87
var text = code ? code.textContent.toLowerCase() : "";
88
if (text.indexOf(q) >= 0) {
89
row.classList.add("hit");
90
hits.push(row);
91
}
92
});
93
showHit(0);
94
});
95
}
96
var prev = document.querySelector("[data-log-prev]");
97
var next = document.querySelector("[data-log-next]");
98
if (prev) {
99
prev.addEventListener("click", function () { showHit(hitAt - 1); });
100
}
101
if (next) {
102
next.addEventListener("click", function () { showHit(hitAt + 1); });
103
}
104
var wrapBtn = document.querySelector("[data-log-wrap]");
105
if (wrapBtn && log) {
106
wrapBtn.addEventListener("click", function () {
107
log.classList.toggle("wrap");
108
});
109
}
110
var topBtn = document.querySelector("[data-log-top]");
111
var bottomBtn = document.querySelector("[data-log-bottom]");
112
if (topBtn && log) {
113
topBtn.addEventListener("click", function () { log.scrollTop = 0; });
114
}
115
if (bottomBtn && log) {
116
bottomBtn.addEventListener("click", function () { log.scrollTop = log.scrollHeight; });
117
}
118
var fullBtn = document.querySelector("[data-log-full]");
119
var wrapBox = document.querySelector("[data-console]");
120
if (fullBtn && wrapBox) {
121
fullBtn.addEventListener("click", function () {
122
if (document.fullscreenElement) {
123
document.exitFullscreen();
124
return;
125
}
126
if (wrapBox.requestFullscreen) {
127
wrapBox.requestFullscreen().catch(function () {
128
wrapBox.classList.toggle("full");
129
});
130
return;
131
}
132
wrapBox.classList.toggle("full");
133
});
134
}
135
136
var stageSelect = document.querySelector("[data-stage-select]");
137
if (stageSelect) {
138
stageSelect.addEventListener("change", function () {
139
var want = stageSelect.value;
140
document.querySelectorAll(".related li").forEach(function (li) {
141
li.hidden = li.getAttribute("data-stage") !== want;
142
});
143
});
144
}
145
146
if (!wrapBox || wrapBox.getAttribute("data-running") !== "1" || !log) {
147
return;
148
}
149
var offset = parseInt(wrapBox.getAttribute("data-offset") || "0", 10);
150
var url = wrapBox.getAttribute("data-log-url");
151
var pending = "";
152
var lineNo = 0;
153
log.querySelectorAll("[data-line]").forEach(function (row) {
154
var n = parseInt(row.getAttribute("data-line") || "0", 10);
155
if (n > lineNo) {
156
lineNo = n;
157
}
158
});
159
var currentSec = log.querySelector(".logsec.open:last-of-type");
160
161
function addLine(ts, text) {
162
lineNo += 1;
163
var row = document.createElement("div");
164
row.className = "logline";
165
row.setAttribute("data-line", String(lineNo));
166
var ln = document.createElement("span");
167
ln.className = "ln";
168
ln.textContent = String(lineNo);
169
var time = document.createElement("span");
170
time.className = "ts";
171
time.textContent = ts;
172
var code = document.createElement("code");
173
code.textContent = text;
174
row.appendChild(ln);
175
row.appendChild(time);
176
row.appendChild(code);
177
if (currentSec) {
178
var list = currentSec.querySelector("ol");
179
var li = document.createElement("li");
180
li.className = "logline";
181
li.setAttribute("data-line", String(lineNo));
182
li.appendChild(ln);
183
li.appendChild(time);
184
li.appendChild(code);
185
list.appendChild(li);
186
row = li;
187
} else {
188
log.appendChild(row);
189
}
190
log.scrollTop = log.scrollHeight;
191
}
192
193
function openSection(title) {
194
var sec = document.createElement("section");
195
sec.className = "logsec open";
196
var btn = document.createElement("button");
197
btn.type = "button";
198
btn.className = "section-toggle";
199
var chev = document.createElement("span");
200
chev.className = "chev";
201
var label = document.createElement("span");
202
label.className = "sectitle";
203
label.textContent = title;
204
btn.appendChild(chev);
205
btn.appendChild(label);
206
btn.addEventListener("click", function () { sec.classList.toggle("open"); });
207
var ol = document.createElement("ol");
208
sec.appendChild(btn);
209
sec.appendChild(ol);
210
log.appendChild(sec);
211
currentSec = sec;
212
}
213
214
function closeSection(dur) {
215
if (!currentSec) {
216
return;
217
}
218
if (dur) {
219
var pill = document.createElement("span");
220
pill.className = "pill";
221
pill.textContent = dur;
222
currentSec.querySelector("button").appendChild(pill);
223
}
224
currentSec = null;
225
}
226
227
function take(line) {
228
var tab = line.indexOf("\t");
229
var ts = "";
230
var text = line;
231
if (tab >= 0) {
232
ts = line.slice(0, tab);
233
text = line.slice(tab + 1);
234
}
235
if (ts.length >= 19 && ts.indexOf("T") === 10) {
236
ts = ts.slice(11, 19);
237
}
238
if (text.indexOf("section_start:") === 0) {
239
var body = text.slice("section_start:".length);
240
var colon = body.indexOf(":");
241
openSection(colon >= 0 ? body.slice(colon + 1) : body);
242
return;
243
}
244
if (text.indexOf("section_end:") === 0) {
245
var end = text.slice("section_end:".length);
246
var dtab = end.indexOf("\t");
247
closeSection(dtab >= 0 ? end.slice(dtab + 1) : "");
248
return;
249
}
250
addLine(ts, text);
251
}
252
253
function poll() {
254
fetch(url + "?offset=" + offset, { headers: { Accept: "application/json" } })
255
.then(function (res) { return res.json(); })
256
.then(function (data) {
257
var chunk = pending + (data.text || "");
258
var rows = chunk.split("\n");
259
pending = rows.pop();
260
rows.forEach(function (row) {
261
if (row) {
262
take(row);
263
}
264
});
265
offset = data.offset || offset;
266
if (data.status === "running" || data.status === "queued") {
267
setTimeout(poll, 1500);
268
return;
269
}
270
if (pending) {
271
take(pending);
272
pending = "";
273
}
274
window.location.reload();
275
})
276
.catch(function () {
277
setTimeout(poll, 3000);
278
});
279
}
280
setTimeout(poll, 1500);
281
})();
@@ -0,0 +1,281 @@1
(function () {2
function closeStages(except) {3
document.querySelectorAll(".stage.open").forEach(function (stage) {4
if (stage === except) {5
return;6
}7
stage.classList.remove("open");8
var pop = stage.querySelector(".stage-pop");9
if (pop) {10
pop.hidden = true;11
}12
});13
}14
15
document.querySelectorAll(".stage-dot[data-tip]").forEach(function (btn) {16
btn.addEventListener("click", function (ev) {17
ev.stopPropagation();18
var stage = btn.parentElement;19
var pop = stage.querySelector(".stage-pop");20
var open = stage.classList.contains("open");21
closeStages(null);22
if (!open && pop) {23
stage.classList.add("open");24
pop.hidden = false;25
}26
});27
});28
29
document.addEventListener("click", function () {30
closeStages(null);31
});32
document.addEventListener("keydown", function (ev) {33
if (ev.key === "Escape") {34
closeStages(null);35
}36
});37
38
document.querySelectorAll(".section-toggle").forEach(function (btn) {39
btn.addEventListener("click", function () {40
var sec = btn.parentElement;41
sec.classList.toggle("open");42
});43
});44
45
var log = document.querySelector("[data-log]");46
var hits = [];47
var hitAt = -1;48
49
function clearHits() {50
if (!log) {51
return;52
}53
log.querySelectorAll(".hit").forEach(function (el) {54
el.classList.remove("hit", "on");55
});56
hits = [];57
hitAt = -1;58
}59
60
function showHit(i) {61
if (!hits.length) {62
return;63
}64
hitAt = (i + hits.length) % hits.length;65
hits.forEach(function (el, n) {66
el.classList.toggle("on", n === hitAt);67
});68
var current = hits[hitAt];69
var sec = current.closest(".logsec");70
if (sec) {71
sec.classList.add("open");72
}73
current.scrollIntoView({ block: "center" });74
}75
76
var search = document.querySelector("[data-log-search]");77
if (search && log) {78
search.addEventListener("submit", function (ev) {79
ev.preventDefault();80
var q = (search.querySelector("input").value || "").toLowerCase();81
clearHits();82
if (!q) {83
return;84
}85
log.querySelectorAll("[data-line]").forEach(function (row) {86
var code = row.querySelector("code");87
var text = code ? code.textContent.toLowerCase() : "";88
if (text.indexOf(q) >= 0) {89
row.classList.add("hit");90
hits.push(row);91
}92
});93
showHit(0);94
});95
}96
var prev = document.querySelector("[data-log-prev]");97
var next = document.querySelector("[data-log-next]");98
if (prev) {99
prev.addEventListener("click", function () { showHit(hitAt - 1); });100
}101
if (next) {102
next.addEventListener("click", function () { showHit(hitAt + 1); });103
}104
var wrapBtn = document.querySelector("[data-log-wrap]");105
if (wrapBtn && log) {106
wrapBtn.addEventListener("click", function () {107
log.classList.toggle("wrap");108
});109
}110
var topBtn = document.querySelector("[data-log-top]");111
var bottomBtn = document.querySelector("[data-log-bottom]");112
if (topBtn && log) {113
topBtn.addEventListener("click", function () { log.scrollTop = 0; });114
}115
if (bottomBtn && log) {116
bottomBtn.addEventListener("click", function () { log.scrollTop = log.scrollHeight; });117
}118
var fullBtn = document.querySelector("[data-log-full]");119
var wrapBox = document.querySelector("[data-console]");120
if (fullBtn && wrapBox) {121
fullBtn.addEventListener("click", function () {122
if (document.fullscreenElement) {123
document.exitFullscreen();124
return;125
}126
if (wrapBox.requestFullscreen) {127
wrapBox.requestFullscreen().catch(function () {128
wrapBox.classList.toggle("full");129
});130
return;131
}132
wrapBox.classList.toggle("full");133
});134
}135
136
var stageSelect = document.querySelector("[data-stage-select]");137
if (stageSelect) {138
stageSelect.addEventListener("change", function () {139
var want = stageSelect.value;140
document.querySelectorAll(".related li").forEach(function (li) {141
li.hidden = li.getAttribute("data-stage") !== want;142
});143
});144
}145
146
if (!wrapBox || wrapBox.getAttribute("data-running") !== "1" || !log) {147
return;148
}149
var offset = parseInt(wrapBox.getAttribute("data-offset") || "0", 10);150
var url = wrapBox.getAttribute("data-log-url");151
var pending = "";152
var lineNo = 0;153
log.querySelectorAll("[data-line]").forEach(function (row) {154
var n = parseInt(row.getAttribute("data-line") || "0", 10);155
if (n > lineNo) {156
lineNo = n;157
}158
});159
var currentSec = log.querySelector(".logsec.open:last-of-type");160
161
function addLine(ts, text) {162
lineNo += 1;163
var row = document.createElement("div");164
row.className = "logline";165
row.setAttribute("data-line", String(lineNo));166
var ln = document.createElement("span");167
ln.className = "ln";168
ln.textContent = String(lineNo);169
var time = document.createElement("span");170
time.className = "ts";171
time.textContent = ts;172
var code = document.createElement("code");173
code.textContent = text;174
row.appendChild(ln);175
row.appendChild(time);176
row.appendChild(code);177
if (currentSec) {178
var list = currentSec.querySelector("ol");179
var li = document.createElement("li");180
li.className = "logline";181
li.setAttribute("data-line", String(lineNo));182
li.appendChild(ln);183
li.appendChild(time);184
li.appendChild(code);185
list.appendChild(li);186
row = li;187
} else {188
log.appendChild(row);189
}190
log.scrollTop = log.scrollHeight;191
}192
193
function openSection(title) {194
var sec = document.createElement("section");195
sec.className = "logsec open";196
var btn = document.createElement("button");197
btn.type = "button";198
btn.className = "section-toggle";199
var chev = document.createElement("span");200
chev.className = "chev";201
var label = document.createElement("span");202
label.className = "sectitle";203
label.textContent = title;204
btn.appendChild(chev);205
btn.appendChild(label);206
btn.addEventListener("click", function () { sec.classList.toggle("open"); });207
var ol = document.createElement("ol");208
sec.appendChild(btn);209
sec.appendChild(ol);210
log.appendChild(sec);211
currentSec = sec;212
}213
214
function closeSection(dur) {215
if (!currentSec) {216
return;217
}218
if (dur) {219
var pill = document.createElement("span");220
pill.className = "pill";221
pill.textContent = dur;222
currentSec.querySelector("button").appendChild(pill);223
}224
currentSec = null;225
}226
227
function take(line) {228
var tab = line.indexOf("\t");229
var ts = "";230
var text = line;231
if (tab >= 0) {232
ts = line.slice(0, tab);233
text = line.slice(tab + 1);234
}235
if (ts.length >= 19 && ts.indexOf("T") === 10) {236
ts = ts.slice(11, 19);237
}238
if (text.indexOf("section_start:") === 0) {239
var body = text.slice("section_start:".length);240
var colon = body.indexOf(":");241
openSection(colon >= 0 ? body.slice(colon + 1) : body);242
return;243
}244
if (text.indexOf("section_end:") === 0) {245
var end = text.slice("section_end:".length);246
var dtab = end.indexOf("\t");247
closeSection(dtab >= 0 ? end.slice(dtab + 1) : "");248
return;249
}250
addLine(ts, text);251
}252
253
function poll() {254
fetch(url + "?offset=" + offset, { headers: { Accept: "application/json" } })255
.then(function (res) { return res.json(); })256
.then(function (data) {257
var chunk = pending + (data.text || "");258
var rows = chunk.split("\n");259
pending = rows.pop();260
rows.forEach(function (row) {261
if (row) {262
take(row);263
}264
});265
offset = data.offset || offset;266
if (data.status === "running" || data.status === "queued") {267
setTimeout(poll, 1500);268
return;269
}270
if (pending) {271
take(pending);272
pending = "";273
}274
window.location.reload();275
})276
.catch(function () {277
setTimeout(poll, 3000);278
});279
}280
setTimeout(poll, 1500);281
})();@@ -302,8 +302,154 @@ label.sugcheck input { width: auto; }
302
302
border-width: 6px 5px 0 0; border-style: solid;
303
303
border-color: var(--blue) transparent transparent transparent;
304
304
}
305
.pipebar { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; margin: 0.4rem 0 1rem; }
306
.pipe-filter {
307
display: flex; align-items: stretch; flex: 1; max-width: 42rem;
308
border: 1px solid var(--line); border-radius: 8px; background: white; overflow: hidden;
309
}
310
.pipe-filter input { border: 0; border-radius: 0; width: 100%; }
311
.pipe-filter button.iconbtn {
312
width: 2.6rem; border: 0; border-left: 1px solid var(--line); border-radius: 0;
313
background: white; color: var(--ink); padding: 0;
314
}
315
.showid { position: relative; }
316
.showid summary {
317
list-style: none; cursor: pointer; background: white; color: var(--ink);
318
border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.75rem;
319
}
320
.showid summary::-webkit-details-marker { display: none; }
321
.showid summary::after { content: "▾"; margin-left: 0.45rem; color: var(--muted); }
322
.showid form {
323
position: absolute; right: 0; top: calc(100% + 6px); z-index: 6;
324
display: flex; gap: 0.4rem; width: 18rem; padding: 0.6rem;
325
background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
326
}
327
.showid form input { width: auto; flex: 1; }
328
table.pipes td { padding: 0.85rem 0.5rem; }
329
table.pipes .pipeid { font-weight: 700; }
330
.ellip { display: block; max-width: 28rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
331
.chips { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; margin-top: 0.28rem; }
332
.chip {
333
display: inline-flex; align-items: center; gap: 0.15rem;
334
background: #eef2f7; color: var(--ink); text-decoration: none;
335
border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.78rem;
336
}
337
.when { display: flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.82rem; margin-top: 0.18rem; }
338
svg.ico { width: 14px; height: 14px; flex: none; }
339
.avatar.sm { width: 20px; height: 20px; font-size: 0.68rem; }
340
.status {
341
display: inline-flex; align-items: center; gap: 0.32rem;
342
border-radius: 999px; padding: 0.12rem 0.55rem 0.12rem 0.28rem;
343
font-weight: 650; font-size: 0.84rem; background: #eef2f7; color: var(--ink);
344
}
345
.status.passed { background: #e5f6ec; color: #146c43; }
346
.status.failed { background: #fde8e8; color: #9f2d2d; }
347
.status.warning { background: #fff4e0; color: #8a5a00; }
348
.status.running { background: #e7f0ff; color: #1f6feb; }
349
.mark { position: relative; width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; background: #8c959f; }
350
.status.passed .mark, .stage-dot.passed .mark { background: #1aaa55; }
351
.status.failed .mark, .stage-dot.failed .mark { background: #dd2b0e; }
352
.status.warning .mark, .stage-dot.warning .mark { background: #c17d10; }
353
.status.running .mark, .stage-dot.running .mark { background: #1f75cb; }
354
.passed .mark::after {
355
content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px;
356
border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
357
}
358
.failed .mark::before, .failed .mark::after {
359
content: ""; position: absolute; left: 3px; top: 7px; width: 10px; height: 2px; background: #fff;
360
}
361
.failed .mark::before { transform: rotate(45deg); }
362
.failed .mark::after { transform: rotate(-45deg); }
363
.warning .mark::before {
364
content: ""; position: absolute; left: 7px; top: 3px; width: 2px; height: 6px; background: #fff;
365
}
366
.warning .mark::after {
367
content: ""; position: absolute; left: 7px; top: 11px; width: 2px; height: 2px; background: #fff;
368
}
369
.skipped .mark::after {
370
content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 2px; background: #fff;
371
}
372
.running .mark::after {
373
content: ""; position: absolute; left: 4px; top: 4px; width: 8px; height: 8px;
374
border: 2px solid #fff; border-radius: 50%; border-right-color: transparent; box-sizing: border-box;
375
}
376
.stages { display: flex; align-items: center; }
377
.stage { position: relative; display: flex; align-items: center; }
378
.stage + .stage::before { content: ""; width: 14px; height: 2px; background: #c5d0dc; margin: 0 2px; }
379
button.stage-dot {
380
width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
381
background: transparent; display: grid; place-items: center; position: relative;
382
}
383
button.stage-dot:hover::after, button.stage-dot:focus-visible::after {
384
content: attr(data-tip);
385
position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
386
background: #24292f; color: white; font-size: 0.75rem; font-weight: 600;
387
padding: 0.28rem 0.5rem; border-radius: 6px; white-space: nowrap; z-index: 7;
388
}
389
.stage.open button.stage-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1f75cb; }
390
.stage-pop {
391
position: absolute; top: calc(100% + 10px); left: 0; z-index: 8; min-width: 220px;
392
background: white; border: 1px solid var(--line); border-radius: 8px;
393
box-shadow: var(--shadow); padding: 0.7rem 0.85rem;
394
}
395
.stage-pop[hidden] { display: none; }
396
.stage-pop ul { list-style: none; margin: 0.35rem 0 0; padding: 0; }
397
.stage-pop a, .related a { display: flex; align-items: center; gap: 0.4rem; text-decoration: none; padding: 0.22rem 0; color: var(--ink); }
398
.stage-dot.sm { width: 16px; height: 16px; display: inline-grid; place-items: center; }
399
.stage-dot.sm .mark { width: 14px; height: 14px; }
400
.stage-dot.sm.passed .mark::after { left: 4px; top: 2px; width: 3px; height: 6px; }
401
.jobhead { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
402
.joblayout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1rem; align-items: start; }
403
.console-wrap { border: 1px solid #2a2a2a; border-radius: 8px; overflow: hidden; background: #1e1e1e; }
404
.conbar {
405
display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; flex-wrap: wrap;
406
background: #f6f8fa; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line);
407
}
408
.conbar .pipe-filter { max-width: none; flex: 1; min-width: 12rem; }
409
.contools { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }
410
.contools .ghost, .contools a.ghost { padding: 0.3rem 0.55rem; background: white; }
411
.console {
412
color: #e6edf3; font-family: ui-monospace, monospace; font-size: 0.82rem;
413
max-height: 68vh; overflow: auto; padding: 0.35rem 0 0.8rem;
414
}
415
.console.wrap code { white-space: pre-wrap; word-break: break-word; }
416
.console code { white-space: pre; }
417
.lognote { margin: 0.2rem 0.8rem 0.45rem; color: #8b949e; font-family: inherit; }
418
.logline, .logsec ol li {
419
display: grid; grid-template-columns: 3rem 5.4rem minmax(0, 1fr);
420
gap: 0.45rem; padding: 0 0.7rem; line-height: 1.45;
421
}
422
.logsec ol { list-style: none; margin: 0; padding: 0; display: none; }
423
.logsec.open ol { display: block; }
424
.ln, .ts { color: #8b949e; }
425
.ln { text-align: right; }
426
.logline.hit, .logsec li.hit { background: #3d3416; }
427
.logline.hit.on, .logsec li.hit.on { background: #6b5710; }
428
button.section-toggle {
429
width: 100%; background: transparent; color: #9ecbff; border: 0; border-radius: 0;
430
display: flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.7rem; text-align: left; font-weight: 650;
431
}
432
.section-toggle .pill { margin-left: auto; background: #2d333b; color: #d0d7de; border-color: #444c56; }
433
.chev {
434
width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
435
border-left: 6px solid currentColor; display: inline-block;
436
}
437
.logsec.open .chev { transform: rotate(90deg); }
438
.console-wrap:fullscreen { display: flex; flex-direction: column; background: #111; border-radius: 0; }
439
.console-wrap:fullscreen .console { max-height: none; flex: 1; }
440
.console-wrap.full { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; border-radius: 0; }
441
.console-wrap.full .console { max-height: none; flex: 1; }
442
.jobside {
443
background: white; border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem 1rem;
444
}
445
.jobside dt { color: var(--muted); font-size: 0.78rem; margin-top: 0.7rem; }
446
.jobside dd { margin: 0.12rem 0 0; }
447
.jobside h2 { font-size: 0.95rem; margin: 0.9rem 0 0.3rem; }
448
.related { list-style: none; margin: 0; padding: 0; }
449
.related li { display: flex; align-items: center; gap: 0.3rem; }
450
.related .arrow { width: 1rem; color: var(--muted); }
305
451
@media (max-width: 800px) {
306
.proj, .fileview { grid-template-columns: 1fr; }
452
.proj, .fileview, .joblayout { grid-template-columns: 1fr; }
307
453
.heat-foot { flex-direction: column; align-items: flex-start; }
308
454
.heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }
309
455
.repolist > li { flex-wrap: wrap; }
@@ -302,8 +302,154 @@ label.sugcheck input { width: auto; }302
border-width: 6px 5px 0 0; border-style: solid;302
border-width: 6px 5px 0 0; border-style: solid;303
border-color: var(--blue) transparent transparent transparent;303
border-color: var(--blue) transparent transparent transparent;304
}304
}305
.pipebar { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; margin: 0.4rem 0 1rem; }306
.pipe-filter {307
display: flex; align-items: stretch; flex: 1; max-width: 42rem;308
border: 1px solid var(--line); border-radius: 8px; background: white; overflow: hidden;309
}310
.pipe-filter input { border: 0; border-radius: 0; width: 100%; }311
.pipe-filter button.iconbtn {312
width: 2.6rem; border: 0; border-left: 1px solid var(--line); border-radius: 0;313
background: white; color: var(--ink); padding: 0;314
}315
.showid { position: relative; }316
.showid summary {317
list-style: none; cursor: pointer; background: white; color: var(--ink);318
border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.75rem;319
}320
.showid summary::-webkit-details-marker { display: none; }321
.showid summary::after { content: "▾"; margin-left: 0.45rem; color: var(--muted); }322
.showid form {323
position: absolute; right: 0; top: calc(100% + 6px); z-index: 6;324
display: flex; gap: 0.4rem; width: 18rem; padding: 0.6rem;325
background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);326
}327
.showid form input { width: auto; flex: 1; }328
table.pipes td { padding: 0.85rem 0.5rem; }329
table.pipes .pipeid { font-weight: 700; }330
.ellip { display: block; max-width: 28rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }331
.chips { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; margin-top: 0.28rem; }332
.chip {333
display: inline-flex; align-items: center; gap: 0.15rem;334
background: #eef2f7; color: var(--ink); text-decoration: none;335
border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.78rem;336
}337
.when { display: flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.82rem; margin-top: 0.18rem; }338
svg.ico { width: 14px; height: 14px; flex: none; }339
.avatar.sm { width: 20px; height: 20px; font-size: 0.68rem; }340
.status {341
display: inline-flex; align-items: center; gap: 0.32rem;342
border-radius: 999px; padding: 0.12rem 0.55rem 0.12rem 0.28rem;343
font-weight: 650; font-size: 0.84rem; background: #eef2f7; color: var(--ink);344
}345
.status.passed { background: #e5f6ec; color: #146c43; }346
.status.failed { background: #fde8e8; color: #9f2d2d; }347
.status.warning { background: #fff4e0; color: #8a5a00; }348
.status.running { background: #e7f0ff; color: #1f6feb; }349
.mark { position: relative; width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; background: #8c959f; }350
.status.passed .mark, .stage-dot.passed .mark { background: #1aaa55; }351
.status.failed .mark, .stage-dot.failed .mark { background: #dd2b0e; }352
.status.warning .mark, .stage-dot.warning .mark { background: #c17d10; }353
.status.running .mark, .stage-dot.running .mark { background: #1f75cb; }354
.passed .mark::after {355
content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px;356
border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);357
}358
.failed .mark::before, .failed .mark::after {359
content: ""; position: absolute; left: 3px; top: 7px; width: 10px; height: 2px; background: #fff;360
}361
.failed .mark::before { transform: rotate(45deg); }362
.failed .mark::after { transform: rotate(-45deg); }363
.warning .mark::before {364
content: ""; position: absolute; left: 7px; top: 3px; width: 2px; height: 6px; background: #fff;365
}366
.warning .mark::after {367
content: ""; position: absolute; left: 7px; top: 11px; width: 2px; height: 2px; background: #fff;368
}369
.skipped .mark::after {370
content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 2px; background: #fff;371
}372
.running .mark::after {373
content: ""; position: absolute; left: 4px; top: 4px; width: 8px; height: 8px;374
border: 2px solid #fff; border-radius: 50%; border-right-color: transparent; box-sizing: border-box;375
}376
.stages { display: flex; align-items: center; }377
.stage { position: relative; display: flex; align-items: center; }378
.stage + .stage::before { content: ""; width: 14px; height: 2px; background: #c5d0dc; margin: 0 2px; }379
button.stage-dot {380
width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;381
background: transparent; display: grid; place-items: center; position: relative;382
}383
button.stage-dot:hover::after, button.stage-dot:focus-visible::after {384
content: attr(data-tip);385
position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);386
background: #24292f; color: white; font-size: 0.75rem; font-weight: 600;387
padding: 0.28rem 0.5rem; border-radius: 6px; white-space: nowrap; z-index: 7;388
}389
.stage.open button.stage-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1f75cb; }390
.stage-pop {391
position: absolute; top: calc(100% + 10px); left: 0; z-index: 8; min-width: 220px;392
background: white; border: 1px solid var(--line); border-radius: 8px;393
box-shadow: var(--shadow); padding: 0.7rem 0.85rem;394
}395
.stage-pop[hidden] { display: none; }396
.stage-pop ul { list-style: none; margin: 0.35rem 0 0; padding: 0; }397
.stage-pop a, .related a { display: flex; align-items: center; gap: 0.4rem; text-decoration: none; padding: 0.22rem 0; color: var(--ink); }398
.stage-dot.sm { width: 16px; height: 16px; display: inline-grid; place-items: center; }399
.stage-dot.sm .mark { width: 14px; height: 14px; }400
.stage-dot.sm.passed .mark::after { left: 4px; top: 2px; width: 3px; height: 6px; }401
.jobhead { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }402
.joblayout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1rem; align-items: start; }403
.console-wrap { border: 1px solid #2a2a2a; border-radius: 8px; overflow: hidden; background: #1e1e1e; }404
.conbar {405
display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; flex-wrap: wrap;406
background: #f6f8fa; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line);407
}408
.conbar .pipe-filter { max-width: none; flex: 1; min-width: 12rem; }409
.contools { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }410
.contools .ghost, .contools a.ghost { padding: 0.3rem 0.55rem; background: white; }411
.console {412
color: #e6edf3; font-family: ui-monospace, monospace; font-size: 0.82rem;413
max-height: 68vh; overflow: auto; padding: 0.35rem 0 0.8rem;414
}415
.console.wrap code { white-space: pre-wrap; word-break: break-word; }416
.console code { white-space: pre; }417
.lognote { margin: 0.2rem 0.8rem 0.45rem; color: #8b949e; font-family: inherit; }418
.logline, .logsec ol li {419
display: grid; grid-template-columns: 3rem 5.4rem minmax(0, 1fr);420
gap: 0.45rem; padding: 0 0.7rem; line-height: 1.45;421
}422
.logsec ol { list-style: none; margin: 0; padding: 0; display: none; }423
.logsec.open ol { display: block; }424
.ln, .ts { color: #8b949e; }425
.ln { text-align: right; }426
.logline.hit, .logsec li.hit { background: #3d3416; }427
.logline.hit.on, .logsec li.hit.on { background: #6b5710; }428
button.section-toggle {429
width: 100%; background: transparent; color: #9ecbff; border: 0; border-radius: 0;430
display: flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.7rem; text-align: left; font-weight: 650;431
}432
.section-toggle .pill { margin-left: auto; background: #2d333b; color: #d0d7de; border-color: #444c56; }433
.chev {434
width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent;435
border-left: 6px solid currentColor; display: inline-block;436
}437
.logsec.open .chev { transform: rotate(90deg); }438
.console-wrap:fullscreen { display: flex; flex-direction: column; background: #111; border-radius: 0; }439
.console-wrap:fullscreen .console { max-height: none; flex: 1; }440
.console-wrap.full { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; border-radius: 0; }441
.console-wrap.full .console { max-height: none; flex: 1; }442
.jobside {443
background: white; border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem 1rem;444
}445
.jobside dt { color: var(--muted); font-size: 0.78rem; margin-top: 0.7rem; }446
.jobside dd { margin: 0.12rem 0 0; }447
.jobside h2 { font-size: 0.95rem; margin: 0.9rem 0 0.3rem; }448
.related { list-style: none; margin: 0; padding: 0; }449
.related li { display: flex; align-items: center; gap: 0.3rem; }450
.related .arrow { width: 1rem; color: var(--muted); }305
@media (max-width: 800px) {451
@media (max-width: 800px) {306
.proj, .fileview { grid-template-columns: 1fr; }452
.proj, .fileview, .joblayout { grid-template-columns: 1fr; }307
.heat-foot { flex-direction: column; align-items: flex-start; }453
.heat-foot { flex-direction: column; align-items: flex-start; }308
.heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }454
.heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }309
.repolist > li { flex-wrap: wrap; }455
.repolist > li { flex-wrap: wrap; }@@ -113,6 +113,19 @@
113
113
{{template "layout-start" .}}
114
114
<h1>{{t "pipe.title"}}</h1>
115
115
{{template "repotabs" .}}
116
<div class="pipebar">
117
<form method="get" action="/{{.Repo.FullPath}}/-/pipelines" class="pipe-filter">
118
<input name="q" value="{{.Query}}" placeholder="{{t "pipe.filter"}}" aria-label="{{t "pipe.filter"}}">
119
<button type="submit" class="iconbtn" aria-label="{{t "pipe.filter"}}">⌕</button>
120
</form>
121
<details class="showid">
122
<summary>{{t "pipe.showID"}}</summary>
123
<form method="get" action="/{{.Repo.FullPath}}/-/pipelines">
124
<input name="show" inputmode="numeric" aria-label="{{t "pipe.showID"}}">
125
<button type="submit" class="ghost">{{t "pipe.showID"}}</button>
126
</form>
127
</details>
128
</div>
116
129
{{if .CanWrite}}
117
130
<form method="post" action="/{{.Repo.FullPath}}/-/pipelines" class="row">
118
131
<input type="hidden" name="csrf" value="{{.CSRF}}">
@@ -120,9 +133,48 @@
120
133
<button type="submit">{{t "action.start"}}</button>
121
134
</form>
122
135
{{end}}
123
<ul class="clean">
124
{{range .Pipes}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{.ID}}">#{{.ID}}</a> <span class="pill">{{.Status}}</span> <span class="muted">{{.Ref}} {{short .CommitSHA}}</span></li>{{else}}<li class="muted">{{t "pipe.none"}}</li>{{end}}
125
</ul>
136
<table class="pipes">
137
<thead><tr><th>{{t "pipe.col.status"}}</th><th>{{t "pipe.col.pipeline"}}</th><th>{{t "pipe.col.by"}}</th><th>{{t "pipe.col.stages"}}</th></tr></thead>
138
<tbody>
139
{{range .PipeRows}}
140
{{$pipe := .}}
141
<tr>
142
<td>
143
<span class="status {{.Status}}"><span class="mark"></span>{{.Label}}</span>
144
<div class="when"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="5.5" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 4.8V8.2L10.2 9.4" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg> {{.Duration}}</div>
145
<div class="when"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><rect x="2.5" y="3.5" width="11" height="10" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.3"/><path d="M2.5 6.5h11M5.5 2.5v2M10.5 2.5v2" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg> {{.When}}</div>
146
</td>
147
<td>
148
<a class="pipeid" href="/{{$.Repo.FullPath}}/-/pipelines/{{.ID}}">#{{.ID}}</a>
149
{{if .Title}}<div><a class="ellip" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Title}}</a></div>{{end}}
150
<div class="chips">
151
{{if .Ref}}<a class="chip" href="/{{$.Repo.FullPath}}/-/commits?rev={{.Ref}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true">{{if eq .RefKind "tag"}}<path d="M2.2 2.2h5.2l6.2 6.2-5.2 5.2-6.2-6.2V2.2z" fill="none" stroke="currentColor" stroke-width="1.3"/><circle cx="5.2" cy="5.2" r="1" fill="currentColor"/>{{else}}<circle cx="4" cy="3.2" r="1.5" fill="currentColor"/><circle cx="4" cy="12.8" r="1.5" fill="currentColor"/><circle cx="12" cy="6.4" r="1.5" fill="currentColor"/><path d="M4 4.7v6.6M4 6.4c2.4 0 4.2.2 6 .2 1.2 0 2 1 2 1.8" fill="none" stroke="currentColor" stroke-width="1.3"/>{{end}}</svg>{{.Ref}}</a>{{end}}
152
{{if .Short}}<a class="chip" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="2.1" fill="currentColor"/><path d="M8 1.8v3.4M8 10.8v3.4" stroke="currentColor" stroke-width="1.4"/></svg>{{.Short}}</a>{{end}}
153
{{if .Actor}}{{if .Avatar}}<img class="avatar sm" src="{{.Avatar}}" alt="">{{else}}<span class="avatar sm">{{.Initial}}</span>{{end}}{{end}}
154
</div>
155
</td>
156
<td>{{if .Actor}}{{if .Avatar}}<img class="avatar" src="{{.Avatar}}" alt="{{.Actor}}">{{else}}<span class="avatar">{{.Initial}}</span>{{end}}{{end}}</td>
157
<td>
158
<div class="stages">
159
{{range .Stages}}
160
<span class="stage">
161
<button type="button" class="stage-dot {{.Status}}" data-tip="{{.Tip}}" aria-label="{{.Tip}}"><span class="mark"></span></button>
162
<div class="stage-pop" hidden>
163
<strong>{{t "pipe.stage"}}: {{.Name}}</strong>
164
<ul>
165
{{range .Jobs}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}/jobs/{{.ID}}"><span class="stage-dot sm {{.Status}}"><span class="mark"></span></span>{{.Name}}</a></li>{{end}}
166
</ul>
167
</div>
168
</span>
169
{{end}}
170
</div>
171
</td>
172
</tr>
173
{{else}}<tr><td colspan="4" class="muted">{{t "pipe.none"}}</td></tr>{{end}}
174
</tbody>
175
</table>
176
<script src="/assets/repo.js"></script>
177
<script src="/assets/pipeline.js"></script>
126
178
{{template "layout-end" .}}
127
179
{{end}}
128
180
@@ -130,13 +182,83 @@
130
182
{{template "layout-start" .}}
131
183
<h1>{{t "pipe.one"}} #{{.Pipe.ID}}</h1>
132
184
{{template "repotabs" .}}
133
<p><span class="pill">{{.Pipe.Status}}</span> {{.Pipe.Ref}} <code>{{.Pipe.CommitSHA}}</code></p>
134
{{range .Jobs}}
135
<article class="panel">
136
<h2>{{.Name}} <span class="pill">{{.Status}}</span> <span class="muted">{{.Stage}} · {{.Image}}</span></h2>
137
{{if .Log}}<pre>{{.Log}}</pre>{{end}}
138
</article>
185
<p><span class="pill">{{.Pipe.Status}}</span> {{.Pipe.Ref}} <a href="/{{.Repo.FullPath}}/-/commit/{{.Pipe.CommitSHA}}"><code>{{.Pipe.CommitSHA}}</code></a></p>
186
<ul class="clean">
187
{{range .Jobs}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$.Pipe.ID}}/jobs/{{.ID}}">{{.Name}}</a> <span class="pill">{{.Status}}</span> <span class="muted">{{.Stage}}</span></li>{{end}}
188
</ul>
189
{{template "layout-end" .}}
190
{{end}}
191
192
{{define "job"}}
193
{{template "layout-start" .}}
194
{{with .JobPage}}
195
<h1>{{.Name}}</h1>
196
{{end}}
197
{{template "repotabs" $}}
198
{{with .JobPage}}
199
{{$page := .}}
200
<p class="jobhead"><span class="status {{.Status}}"><span class="mark"></span>{{.Label}}</span> <span class="muted">{{t "pipe.started"}} {{.When}} {{t "pipe.by"}}</span> {{if .Avatar}}<img class="avatar sm" src="{{.Avatar}}" alt="">{{else if .Actor}}<span class="avatar sm">{{.Initial}}</span>{{end}} <strong>{{.Actor}}</strong></p>
201
<div class="joblayout">
202
<section class="console-wrap" data-console data-log-url="/{{$.Repo.FullPath}}/-/pipelines/{{.Pipe.ID}}/jobs/{{.Job.ID}}/log" data-offset="{{.LogBytes}}" data-running="{{if .Running}}1{{end}}">
203
<div class="conbar">
204
<form class="pipe-filter" data-log-search>
205
<input type="search" placeholder="{{t "pipe.search"}}" aria-label="{{t "pipe.search"}}">
206
<button type="submit" class="iconbtn" aria-label="{{t "pipe.search"}}">⌕</button>
207
</form>
208
<div class="contools">
209
<button type="button" class="ghost" data-log-prev aria-label="{{t "pipe.prev"}}">↑</button>
210
<button type="button" class="ghost" data-log-next aria-label="{{t "pipe.next"}}">↓</button>
211
<a class="ghost" href="/{{$.Repo.FullPath}}/-/pipelines/{{.Pipe.ID}}/jobs/{{.Job.ID}}/log?raw=1">{{t "pipe.raw"}}</a>
212
<button type="button" class="ghost" data-log-wrap>{{t "pipe.wrap"}}</button>
213
<button type="button" class="ghost" data-log-top>{{t "pipe.top"}}</button>
214
<button type="button" class="ghost" data-log-bottom>{{t "pipe.bottom"}}</button>
215
<button type="button" class="ghost" data-log-full>{{t "pipe.full"}}</button>
216
</div>
217
</div>
218
<div class="console" data-log>
219
<p class="lognote">{{t "pipe.utc"}}</p>
220
{{range .Blocks}}{{if .Section}}
221
<section class="logsec{{if .Open}} open{{end}}">
222
<button type="button" class="section-toggle"><span class="chev"></span><span class="sectitle">{{.Title}}</span>{{if .Duration}}<span class="pill">{{.Duration}}</span>{{end}}</button>
223
<ol>
224
{{range .Lines}}<li data-line="{{.N}}"><span class="ln">{{.N}}</span><span class="ts">{{.Time}}</span><code>{{.Text}}</code></li>{{end}}
225
</ol>
226
</section>
227
{{else}}{{range .Lines}}<div class="logline" data-line="{{.N}}"><span class="ln">{{.N}}</span><span class="ts">{{.Time}}</span><code>{{.Text}}</code></div>{{end}}{{end}}{{end}}
228
{{if not .Blocks}}<p class="muted">{{t "pipe.emptyLog"}}</p>{{end}}
229
</div>
230
</section>
231
<aside class="jobside">
232
<dl>
233
<dt>{{t "pipe.duration"}}</dt><dd>{{if .Duration}}{{.Duration}}{{else}}—{{end}}</dd>
234
<dt>{{t "pipe.finished"}}</dt><dd>{{if .Finished}}{{.Finished}}{{else}}—{{end}}</dd>
235
<dt>{{t "pipe.queued"}}</dt><dd>{{if .Queued}}{{.Queued}}{{else}}—{{end}}</dd>
236
<dt>{{t "pipe.timeout"}}</dt><dd>{{.Timeout}}</dd>
237
<dt>{{t "pipe.runner"}}</dt><dd>{{t "pipe.runnerHere"}}</dd>
238
<dt>{{t "pipe.source"}}</dt><dd>{{.Source}}</dd>
239
<dt>{{t "pipe.commit"}}</dt><dd><code>{{.Short}}</code> <button type="button" class="iconbtn" data-copy="{{.Pipe.CommitSHA}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button>{{if .Title}}<div>{{.Title}}</div>{{end}}</dd>
240
<dt>{{t "pipe.one"}}</dt><dd><a href="/{{$.Repo.FullPath}}/-/pipelines/{{.Pipe.ID}}">#{{.Pipe.ID}}</a> <span class="status {{.PipeStatus}}"><span class="mark"></span>{{.PipeLabel}}</span> <span class="muted">{{t "pipe.for"}} {{.Ref}}</span></dd>
241
</dl>
242
<label>{{t "pipe.stage"}}
243
<select data-stage-select>
244
{{range .Stages}}<option value="{{.}}"{{if eq . $page.Stage}} selected{{end}}>{{.}}</option>{{end}}
245
</select>
246
</label>
247
<h2>{{t "pipe.related"}}</h2>
248
<ul class="related">
249
{{range .Related}}<li data-stage="{{.Stage}}"{{if ne .Stage $page.Stage}} hidden{{end}}>{{if .Current}}<span class="arrow">→</span>{{else}}<span class="arrow"></span>{{end}}<a href="/{{$.Repo.FullPath}}/-/pipelines/{{$page.Pipe.ID}}/jobs/{{.ID}}"><span class="stage-dot sm {{.Status}}"><span class="mark"></span></span>{{.Name}}</a></li>{{end}}
250
</ul>
251
{{if .CanPlay}}
252
<form method="post" action="/{{$.Repo.FullPath}}/-/pipelines/{{.Pipe.ID}}/jobs/{{.Job.ID}}/play">
253
<input type="hidden" name="csrf" value="{{$.CSRF}}">
254
<button type="submit">{{t "pipe.play"}}</button>
255
</form>
256
{{end}}
257
</aside>
258
</div>
139
259
{{end}}
260
<script src="/assets/repo.js"></script>
261
<script src="/assets/pipeline.js"></script>
140
262
{{template "layout-end" .}}
141
263
{{end}}
142
264
@@ -113,6 +113,19 @@113
{{template "layout-start" .}}113
{{template "layout-start" .}}114
<h1>{{t "pipe.title"}}</h1>114
<h1>{{t "pipe.title"}}</h1>115
{{template "repotabs" .}}115
{{template "repotabs" .}}116
<div class="pipebar">117
<form method="get" action="/{{.Repo.FullPath}}/-/pipelines" class="pipe-filter">118
<input name="q" value="{{.Query}}" placeholder="{{t "pipe.filter"}}" aria-label="{{t "pipe.filter"}}">119
<button type="submit" class="iconbtn" aria-label="{{t "pipe.filter"}}">⌕</button>120
</form>121
<details class="showid">122
<summary>{{t "pipe.showID"}}</summary>123
<form method="get" action="/{{.Repo.FullPath}}/-/pipelines">124
<input name="show" inputmode="numeric" aria-label="{{t "pipe.showID"}}">125
<button type="submit" class="ghost">{{t "pipe.showID"}}</button>126
</form>127
</details>128
</div>116
{{if .CanWrite}}129
{{if .CanWrite}}117
<form method="post" action="/{{.Repo.FullPath}}/-/pipelines" class="row">130
<form method="post" action="/{{.Repo.FullPath}}/-/pipelines" class="row">118
<input type="hidden" name="csrf" value="{{.CSRF}}">131
<input type="hidden" name="csrf" value="{{.CSRF}}">@@ -120,9 +133,48 @@120
<button type="submit">{{t "action.start"}}</button>133
<button type="submit">{{t "action.start"}}</button>121
</form>134
</form>122
{{end}}135
{{end}}123
<ul class="clean">136
<table class="pipes">124
{{range .Pipes}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{.ID}}">#{{.ID}}</a> <span class="pill">{{.Status}}</span> <span class="muted">{{.Ref}} {{short .CommitSHA}}</span></li>{{else}}<li class="muted">{{t "pipe.none"}}</li>{{end}}137
<thead><tr><th>{{t "pipe.col.status"}}</th><th>{{t "pipe.col.pipeline"}}</th><th>{{t "pipe.col.by"}}</th><th>{{t "pipe.col.stages"}}</th></tr></thead>125
</ul>138
<tbody>139
{{range .PipeRows}}140
{{$pipe := .}}141
<tr>142
<td>143
<span class="status {{.Status}}"><span class="mark"></span>{{.Label}}</span>144
<div class="when"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="5.5" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 4.8V8.2L10.2 9.4" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg> {{.Duration}}</div>145
<div class="when"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><rect x="2.5" y="3.5" width="11" height="10" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.3"/><path d="M2.5 6.5h11M5.5 2.5v2M10.5 2.5v2" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg> {{.When}}</div>146
</td>147
<td>148
<a class="pipeid" href="/{{$.Repo.FullPath}}/-/pipelines/{{.ID}}">#{{.ID}}</a>149
{{if .Title}}<div><a class="ellip" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}">{{.Title}}</a></div>{{end}}150
<div class="chips">151
{{if .Ref}}<a class="chip" href="/{{$.Repo.FullPath}}/-/commits?rev={{.Ref}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true">{{if eq .RefKind "tag"}}<path d="M2.2 2.2h5.2l6.2 6.2-5.2 5.2-6.2-6.2V2.2z" fill="none" stroke="currentColor" stroke-width="1.3"/><circle cx="5.2" cy="5.2" r="1" fill="currentColor"/>{{else}}<circle cx="4" cy="3.2" r="1.5" fill="currentColor"/><circle cx="4" cy="12.8" r="1.5" fill="currentColor"/><circle cx="12" cy="6.4" r="1.5" fill="currentColor"/><path d="M4 4.7v6.6M4 6.4c2.4 0 4.2.2 6 .2 1.2 0 2 1 2 1.8" fill="none" stroke="currentColor" stroke-width="1.3"/>{{end}}</svg>{{.Ref}}</a>{{end}}152
{{if .Short}}<a class="chip" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="2.1" fill="currentColor"/><path d="M8 1.8v3.4M8 10.8v3.4" stroke="currentColor" stroke-width="1.4"/></svg>{{.Short}}</a>{{end}}153
{{if .Actor}}{{if .Avatar}}<img class="avatar sm" src="{{.Avatar}}" alt="">{{else}}<span class="avatar sm">{{.Initial}}</span>{{end}}{{end}}154
</div>155
</td>156
<td>{{if .Actor}}{{if .Avatar}}<img class="avatar" src="{{.Avatar}}" alt="{{.Actor}}">{{else}}<span class="avatar">{{.Initial}}</span>{{end}}{{end}}</td>157
<td>158
<div class="stages">159
{{range .Stages}}160
<span class="stage">161
<button type="button" class="stage-dot {{.Status}}" data-tip="{{.Tip}}" aria-label="{{.Tip}}"><span class="mark"></span></button>162
<div class="stage-pop" hidden>163
<strong>{{t "pipe.stage"}}: {{.Name}}</strong>164
<ul>165
{{range .Jobs}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$pipe.ID}}/jobs/{{.ID}}"><span class="stage-dot sm {{.Status}}"><span class="mark"></span></span>{{.Name}}</a></li>{{end}}166
</ul>167
</div>168
</span>169
{{end}}170
</div>171
</td>172
</tr>173
{{else}}<tr><td colspan="4" class="muted">{{t "pipe.none"}}</td></tr>{{end}}174
</tbody>175
</table>176
<script src="/assets/repo.js"></script>177
<script src="/assets/pipeline.js"></script>126
{{template "layout-end" .}}178
{{template "layout-end" .}}127
{{end}}179
{{end}}128
180
@@ -130,13 +182,83 @@130
{{template "layout-start" .}}182
{{template "layout-start" .}}131
<h1>{{t "pipe.one"}} #{{.Pipe.ID}}</h1>183
<h1>{{t "pipe.one"}} #{{.Pipe.ID}}</h1>132
{{template "repotabs" .}}184
{{template "repotabs" .}}133
<p><span class="pill">{{.Pipe.Status}}</span> {{.Pipe.Ref}} <code>{{.Pipe.CommitSHA}}</code></p>185
<p><span class="pill">{{.Pipe.Status}}</span> {{.Pipe.Ref}} <a href="/{{.Repo.FullPath}}/-/commit/{{.Pipe.CommitSHA}}"><code>{{.Pipe.CommitSHA}}</code></a></p>134
{{range .Jobs}}186
<ul class="clean">135
<article class="panel">187
{{range .Jobs}}<li><a href="/{{$.Repo.FullPath}}/-/pipelines/{{$.Pipe.ID}}/jobs/{{.ID}}">{{.Name}}</a> <span class="pill">{{.Status}}</span> <span class="muted">{{.Stage}}</span></li>{{end}}136
<h2>{{.Name}} <span class="pill">{{.Status}}</span> <span class="muted">{{.Stage}} · {{.Image}}</span></h2>188
</ul>137
{{if .Log}}<pre>{{.Log}}</pre>{{end}}189
{{template "layout-end" .}}138
</article>190
{{end}}191
192
{{define "job"}}193
{{template "layout-start" .}}194
{{with .JobPage}}195
<h1>{{.Name}}</h1>196
{{end}}197
{{template "repotabs" $}}198
{{with .JobPage}}199
{{$page := .}}200
<p class="jobhead"><span class="status {{.Status}}"><span class="mark"></span>{{.Label}}</span> <span class="muted">{{t "pipe.started"}} {{.When}} {{t "pipe.by"}}</span> {{if .Avatar}}<img class="avatar sm" src="{{.Avatar}}" alt="">{{else if .Actor}}<span class="avatar sm">{{.Initial}}</span>{{end}} <strong>{{.Actor}}</strong></p>201
<div class="joblayout">202
<section class="console-wrap" data-console data-log-url="/{{$.Repo.FullPath}}/-/pipelines/{{.Pipe.ID}}/jobs/{{.Job.ID}}/log" data-offset="{{.LogBytes}}" data-running="{{if .Running}}1{{end}}">203
<div class="conbar">204
<form class="pipe-filter" data-log-search>205
<input type="search" placeholder="{{t "pipe.search"}}" aria-label="{{t "pipe.search"}}">206
<button type="submit" class="iconbtn" aria-label="{{t "pipe.search"}}">⌕</button>207
</form>208
<div class="contools">209
<button type="button" class="ghost" data-log-prev aria-label="{{t "pipe.prev"}}">↑</button>210
<button type="button" class="ghost" data-log-next aria-label="{{t "pipe.next"}}">↓</button>211
<a class="ghost" href="/{{$.Repo.FullPath}}/-/pipelines/{{.Pipe.ID}}/jobs/{{.Job.ID}}/log?raw=1">{{t "pipe.raw"}}</a>212
<button type="button" class="ghost" data-log-wrap>{{t "pipe.wrap"}}</button>213
<button type="button" class="ghost" data-log-top>{{t "pipe.top"}}</button>214
<button type="button" class="ghost" data-log-bottom>{{t "pipe.bottom"}}</button>215
<button type="button" class="ghost" data-log-full>{{t "pipe.full"}}</button>216
</div>217
</div>218
<div class="console" data-log>219
<p class="lognote">{{t "pipe.utc"}}</p>220
{{range .Blocks}}{{if .Section}}221
<section class="logsec{{if .Open}} open{{end}}">222
<button type="button" class="section-toggle"><span class="chev"></span><span class="sectitle">{{.Title}}</span>{{if .Duration}}<span class="pill">{{.Duration}}</span>{{end}}</button>223
<ol>224
{{range .Lines}}<li data-line="{{.N}}"><span class="ln">{{.N}}</span><span class="ts">{{.Time}}</span><code>{{.Text}}</code></li>{{end}}225
</ol>226
</section>227
{{else}}{{range .Lines}}<div class="logline" data-line="{{.N}}"><span class="ln">{{.N}}</span><span class="ts">{{.Time}}</span><code>{{.Text}}</code></div>{{end}}{{end}}{{end}}228
{{if not .Blocks}}<p class="muted">{{t "pipe.emptyLog"}}</p>{{end}}229
</div>230
</section>231
<aside class="jobside">232
<dl>233
<dt>{{t "pipe.duration"}}</dt><dd>{{if .Duration}}{{.Duration}}{{else}}—{{end}}</dd>234
<dt>{{t "pipe.finished"}}</dt><dd>{{if .Finished}}{{.Finished}}{{else}}—{{end}}</dd>235
<dt>{{t "pipe.queued"}}</dt><dd>{{if .Queued}}{{.Queued}}{{else}}—{{end}}</dd>236
<dt>{{t "pipe.timeout"}}</dt><dd>{{.Timeout}}</dd>237
<dt>{{t "pipe.runner"}}</dt><dd>{{t "pipe.runnerHere"}}</dd>238
<dt>{{t "pipe.source"}}</dt><dd>{{.Source}}</dd>239
<dt>{{t "pipe.commit"}}</dt><dd><code>{{.Short}}</code> <button type="button" class="iconbtn" data-copy="{{.Pipe.CommitSHA}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button>{{if .Title}}<div>{{.Title}}</div>{{end}}</dd>240
<dt>{{t "pipe.one"}}</dt><dd><a href="/{{$.Repo.FullPath}}/-/pipelines/{{.Pipe.ID}}">#{{.Pipe.ID}}</a> <span class="status {{.PipeStatus}}"><span class="mark"></span>{{.PipeLabel}}</span> <span class="muted">{{t "pipe.for"}} {{.Ref}}</span></dd>241
</dl>242
<label>{{t "pipe.stage"}}243
<select data-stage-select>244
{{range .Stages}}<option value="{{.}}"{{if eq . $page.Stage}} selected{{end}}>{{.}}</option>{{end}}245
</select>246
</label>247
<h2>{{t "pipe.related"}}</h2>248
<ul class="related">249
{{range .Related}}<li data-stage="{{.Stage}}"{{if ne .Stage $page.Stage}} hidden{{end}}>{{if .Current}}<span class="arrow">→</span>{{else}}<span class="arrow"></span>{{end}}<a href="/{{$.Repo.FullPath}}/-/pipelines/{{$page.Pipe.ID}}/jobs/{{.ID}}"><span class="stage-dot sm {{.Status}}"><span class="mark"></span></span>{{.Name}}</a></li>{{end}}250
</ul>251
{{if .CanPlay}}252
<form method="post" action="/{{$.Repo.FullPath}}/-/pipelines/{{.Pipe.ID}}/jobs/{{.Job.ID}}/play">253
<input type="hidden" name="csrf" value="{{$.CSRF}}">254
<button type="submit">{{t "pipe.play"}}</button>255
</form>256
{{end}}257
</aside>258
</div>139
{{end}}259
{{end}}260
<script src="/assets/repo.js"></script>261
<script src="/assets/pipeline.js"></script>140
{{template "layout-end" .}}262
{{template "layout-end" .}}141
{{end}}263
{{end}}142
264
@@ -41,7 +41,7 @@
41
41
<a href="/{{.Repo.FullPath}}/-/commits{{if .Rev}}?rev={{.Rev}}{{end}}"{{if eq .Page "commits"}} class="on"{{end}}>{{t "tab.commits"}}</a>
42
42
<a href="/{{.Repo.FullPath}}/-/branches">{{t "tab.branches"}}</a>
43
43
<a href="/{{.Repo.FullPath}}/-/merge-requests">{{t "tab.mrs"}}</a>
44
<a href="/{{.Repo.FullPath}}/-/pipelines">{{t "tab.pipelines"}}</a>
44
<a href="/{{.Repo.FullPath}}/-/pipelines"{{if eq .Page "pipelines"}} class="on"{{end}}>{{t "tab.pipelines"}}</a>
45
45
<a href="/{{.Repo.FullPath}}/-/releases">{{t "tab.releases"}}</a>
46
46
{{if .CanAdmin}}<a href="/{{.Repo.FullPath}}/-/settings">{{t "tab.settings"}}</a>{{end}}
47
47
</p>
@@ -41,7 +41,7 @@41
<a href="/{{.Repo.FullPath}}/-/commits{{if .Rev}}?rev={{.Rev}}{{end}}"{{if eq .Page "commits"}} class="on"{{end}}>{{t "tab.commits"}}</a>41
<a href="/{{.Repo.FullPath}}/-/commits{{if .Rev}}?rev={{.Rev}}{{end}}"{{if eq .Page "commits"}} class="on"{{end}}>{{t "tab.commits"}}</a>42
<a href="/{{.Repo.FullPath}}/-/branches">{{t "tab.branches"}}</a>42
<a href="/{{.Repo.FullPath}}/-/branches">{{t "tab.branches"}}</a>43
<a href="/{{.Repo.FullPath}}/-/merge-requests">{{t "tab.mrs"}}</a>43
<a href="/{{.Repo.FullPath}}/-/merge-requests">{{t "tab.mrs"}}</a>44
<a href="/{{.Repo.FullPath}}/-/pipelines">{{t "tab.pipelines"}}</a>44
<a href="/{{.Repo.FullPath}}/-/pipelines"{{if eq .Page "pipelines"}} class="on"{{end}}>{{t "tab.pipelines"}}</a>45
<a href="/{{.Repo.FullPath}}/-/releases">{{t "tab.releases"}}</a>45
<a href="/{{.Repo.FullPath}}/-/releases">{{t "tab.releases"}}</a>46
{{if .CanAdmin}}<a href="/{{.Repo.FullPath}}/-/settings">{{t "tab.settings"}}</a>{{end}}46
{{if .CanAdmin}}<a href="/{{.Repo.FullPath}}/-/settings">{{t "tab.settings"}}</a>{{end}}47
</p>47
</p>