Merged
Pipeline wacht op handmatige actie i.p.v. Bezig
timfa
wants to merge
1 commit
from
cursor/manual-status
into
stage
Overview Commits 1 Pipelines 1 Changes 10
Queued jobs die (transitief) op een niet-gestarte handmatige job wachten tellen niet meer als open: de pipeline krijgt API-status manual (bestaande waarde, nu gedocumenteerd in OpenAPI) i.p.v. running. UI toont Wacht op handmatige actie (grijs, pauze-icoon, tooltip; NL/EN/DE/FR). Runner herberekent lopende pipelines zodat oude pipelines (bv. posprint #395) ook omgaan.
Activity
- timfa opened this merge request 27 October 2026
- timfa Pipeline #399 is Passed 27 October 2026
- timfa merged this merge request 27 October 2026
Commits
Pipelines
- #399 Passed
Changes
@@ -0,0 +1,20 @@
1
package i18n
2
3
func init() {
4
addCatalog(en, map[string]string{
5
"pipe.blocked": "Waiting for manual action",
6
"pipe.blocked.tip": "Only manual jobs are left, plus jobs that wait for them. Start a manual job to continue; until then the pipeline does not count as running.",
7
})
8
addCatalog(nl, map[string]string{
9
"pipe.blocked": "Wacht op handmatige actie",
10
"pipe.blocked.tip": "Alleen handmatige jobs zijn nog over, plus jobs die daarop wachten. Start een handmatige job om verder te gaan; tot die tijd telt de pipeline niet als bezig.",
11
})
12
addCatalog(de, map[string]string{
13
"pipe.blocked": "Wartet auf manuelle Aktion",
14
"pipe.blocked.tip": "Nur noch manuelle Jobs und davon abhängige Jobs sind offen. Starte einen manuellen Job, um fortzufahren; bis dahin gilt die Pipeline nicht als laufend.",
15
})
16
addCatalog(fr, map[string]string{
17
"pipe.blocked": "En attente d'une action manuelle",
18
"pipe.blocked.tip": "Il ne reste que des jobs manuels et des jobs qui en dépendent. Lancez un job manuel pour continuer ; d'ici là, le pipeline ne compte pas comme en cours.",
19
})
20
}
@@ -0,0 +1,20 @@1
package i18n2
3
func init() {4
addCatalog(en, map[string]string{5
"pipe.blocked": "Waiting for manual action",6
"pipe.blocked.tip": "Only manual jobs are left, plus jobs that wait for them. Start a manual job to continue; until then the pipeline does not count as running.",7
})8
addCatalog(nl, map[string]string{9
"pipe.blocked": "Wacht op handmatige actie",10
"pipe.blocked.tip": "Alleen handmatige jobs zijn nog over, plus jobs die daarop wachten. Start een handmatige job om verder te gaan; tot die tijd telt de pipeline niet als bezig.",11
})12
addCatalog(de, map[string]string{13
"pipe.blocked": "Wartet auf manuelle Aktion",14
"pipe.blocked.tip": "Nur noch manuelle Jobs und davon abhängige Jobs sind offen. Starte einen manuellen Job, um fortzufahren; bis dahin gilt die Pipeline nicht als laufend.",15
})16
addCatalog(fr, map[string]string{17
"pipe.blocked": "En attente d'une action manuelle",18
"pipe.blocked.tip": "Il ne reste que des jobs manuels et des jobs qui en dépendent. Lancez un job manuel pour continuer ; d'ici là, le pipeline ne compte pas comme en cours.",19
})20
}@@ -152,6 +152,13 @@ func (r *Runner) Tick(ctx context.Context) {
152
152
153
153
func (r *Runner) schedule(ctx context.Context, p store.Pipeline) {
154
154
r.settle(ctx, p.ID)
155
if p.Status == "running" {
156
// Een pipeline die alleen nog op handmatige jobs wacht, is niet
157
// meer bezig (ook oude pipelines van voor deze regel).
158
if st, err := r.Store.RefreshPipelineStatus(ctx, p.ID); err == nil {
159
p.Status = st
160
}
161
}
155
162
if r.Hold != nil && r.Hold(p) {
156
163
return // wacht op de self-update
157
164
}
@@ -152,6 +152,13 @@ func (r *Runner) Tick(ctx context.Context) {152
152
153
func (r *Runner) schedule(ctx context.Context, p store.Pipeline) {153
func (r *Runner) schedule(ctx context.Context, p store.Pipeline) {154
r.settle(ctx, p.ID)154
r.settle(ctx, p.ID)155
if p.Status == "running" {156
// Een pipeline die alleen nog op handmatige jobs wacht, is niet157
// meer bezig (ook oude pipelines van voor deze regel).158
if st, err := r.Store.RefreshPipelineStatus(ctx, p.ID); err == nil {159
p.Status = st160
}161
}155
if r.Hold != nil && r.Hold(p) {162
if r.Hold != nil && r.Hold(p) {156
return // wacht op de self-update163
return // wacht op de self-update157
}164
}@@ -237,7 +237,7 @@ func apiSchemas() map[string]any {
237
237
"id": integer("Pipeline id."),
238
238
"sha": str("Commit SHA."),
239
239
"ref": str("Git ref, for example refs/heads/master."),
240
"status": str("Pipeline status. A pipeline stopped by a newer pipeline stays canceled; see cancel_reason."),
240
"status": str("Pipeline status: queued, running, success, failed, canceled, waiting_for_update, waiting_for_job or manual. manual means only manual jobs are left, plus jobs that wait on them; such a pipeline is not running and has no finished_at until a manual job is played. A pipeline stopped by a newer pipeline stays canceled; see cancel_reason."),
241
241
"display_status": str("Status as the UI shows it: obsolete when every canceled job was superseded by a newer pipeline on the same ref, otherwise equal to status. Only in list and get responses."),
242
242
"cancel_reason": str("For status canceled: superseded (a newer pipeline started for the same ref) or manual. Null otherwise. Only in list and get responses."),
243
243
"waiting_for": map[string]any{"type": "object", "nullable": true, "description": "For status waiting_for_job: the running doNotInterrupt job (job_id, job_name, pipeline_id) in an older pipeline on the same ref that this pipeline waits for. Only in list and get responses."},
@@ -237,7 +237,7 @@ func apiSchemas() map[string]any {237
"id": integer("Pipeline id."),237
"id": integer("Pipeline id."),238
"sha": str("Commit SHA."),238
"sha": str("Commit SHA."),239
"ref": str("Git ref, for example refs/heads/master."),239
"ref": str("Git ref, for example refs/heads/master."),240
"status": str("Pipeline status. A pipeline stopped by a newer pipeline stays canceled; see cancel_reason."),240
"status": str("Pipeline status: queued, running, success, failed, canceled, waiting_for_update, waiting_for_job or manual. manual means only manual jobs are left, plus jobs that wait on them; such a pipeline is not running and has no finished_at until a manual job is played. A pipeline stopped by a newer pipeline stays canceled; see cancel_reason."),241
"display_status": str("Status as the UI shows it: obsolete when every canceled job was superseded by a newer pipeline on the same ref, otherwise equal to status. Only in list and get responses."),241
"display_status": str("Status as the UI shows it: obsolete when every canceled job was superseded by a newer pipeline on the same ref, otherwise equal to status. Only in list and get responses."),242
"cancel_reason": str("For status canceled: superseded (a newer pipeline started for the same ref) or manual. Null otherwise. Only in list and get responses."),242
"cancel_reason": str("For status canceled: superseded (a newer pipeline started for the same ref) or manual. Null otherwise. Only in list and get responses."),243
"waiting_for": map[string]any{"type": "object", "nullable": true, "description": "For status waiting_for_job: the running doNotInterrupt job (job_id, job_name, pipeline_id) in an older pipeline on the same ref that this pipeline waits for. Only in list and get responses."},243
"waiting_for": map[string]any{"type": "object", "nullable": true, "description": "For status waiting_for_job: the running doNotInterrupt job (job_id, job_name, pipeline_id) in an older pipeline on the same ref that this pipeline waits for. Only in list and get responses."},@@ -329,7 +329,8 @@ func displayStatus(pipe string, jobs []store.Job) string {
329
329
case "running":
330
330
return "running"
331
331
case "manual":
332
return "manual"
332
// Alleen handmatige jobs (en wat daarop wacht) zijn over.
333
return "blocked"
333
334
case "queued":
334
335
return "pending"
335
336
case "canceled":
@@ -329,7 +329,8 @@ func displayStatus(pipe string, jobs []store.Job) string {329
case "running":329
case "running":330
return "running"330
return "running"331
case "manual":331
case "manual":332
return "manual"332
// Alleen handmatige jobs (en wat daarop wacht) zijn over.333
return "blocked"333
case "queued":334
case "queued":334
return "pending"335
return "pending"335
case "canceled":336
case "canceled":@@ -16,3 +16,9 @@ func TestRefsMoved(t *testing.T) {
16
16
t.Fatal("verwijderde branch")
17
17
}
18
18
}
19
20
func TestManualPipelineShowsBlocked(t *testing.T) {
21
if got := displayStatus("manual", nil); got != "blocked" {
22
t.Fatalf("manual toont %q", got)
23
}
24
}
@@ -16,3 +16,9 @@ func TestRefsMoved(t *testing.T) {16
t.Fatal("verwijderde branch")16
t.Fatal("verwijderde branch")17
}17
}18
}18
}19
20
func TestManualPipelineShowsBlocked(t *testing.T) {21
if got := displayStatus("manual", nil); got != "blocked" {22
t.Fatalf("manual toont %q", got)23
}24
}@@ -313,7 +313,8 @@
313
313
(function () {
314
314
var tips = {
315
315
obsolete: document.body.getAttribute("data-obsolete-tip") || "canceled because a newer pipeline started for the same ref",
316
waiting_for_job: document.body.getAttribute("data-waitjob-tip") || "waiting for a non-interruptible job in an older pipeline on the same ref"
316
waiting_for_job: document.body.getAttribute("data-waitjob-tip") || "waiting for a non-interruptible job in an older pipeline on the same ref",
317
blocked: document.body.getAttribute("data-blocked-tip") || "only manual jobs are left; start one to continue"
317
318
};
318
319
function tag() {
319
320
Object.keys(tips).forEach(function (cls) { tagOne(cls, tips[cls]); });
@@ -313,7 +313,8 @@313
(function () {313
(function () {314
var tips = {314
var tips = {315
obsolete: document.body.getAttribute("data-obsolete-tip") || "canceled because a newer pipeline started for the same ref",315
obsolete: document.body.getAttribute("data-obsolete-tip") || "canceled because a newer pipeline started for the same ref",316
waiting_for_job: document.body.getAttribute("data-waitjob-tip") || "waiting for a non-interruptible job in an older pipeline on the same ref"316
waiting_for_job: document.body.getAttribute("data-waitjob-tip") || "waiting for a non-interruptible job in an older pipeline on the same ref",317
blocked: document.body.getAttribute("data-blocked-tip") || "only manual jobs are left; start one to continue"317
};318
};318
function tag() {319
function tag() {319
Object.keys(tips).forEach(function (cls) { tagOne(cls, tips[cls]); });320
Object.keys(tips).forEach(function (cls) { tagOne(cls, tips[cls]); });@@ -632,12 +632,19 @@ svg.ico { width: 14px; height: 14px; flex: none; }
632
632
.status.running { background: #e7f0ff; color: #1f6feb; }
633
633
.status.canceled { background: #f3f0f0; color: #57606a; }
634
634
.status.obsolete { background: #f4f5f7; color: #8c959f; font-weight: 600; }
635
.status.blocked { background: #eef2f7; color: #57606a; }
635
636
.mark { position: relative; width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; background: #8c959f; }
636
637
.status.passed .mark, .stage-dot.passed .mark { background: #1aaa55; }
637
638
.status.failed .mark, .stage-dot.failed .mark { background: #dd2b0e; }
638
639
.status.warning .mark, .stage-dot.warning .mark { background: #c17d10; }
639
640
.status.running .mark, .stage-dot.running .mark { background: #1f75cb; }
640
641
.status.canceled .mark, .stage-dot.canceled .mark { background: #8c959f; }
642
.status.blocked .mark, .stage-dot.blocked .mark { background: #57606a; }
643
.blocked .mark::before, .blocked .mark::after {
644
content: ""; position: absolute; top: 4px; width: 2px; height: 8px; background: #fff;
645
}
646
.blocked .mark::before { left: 5px; }
647
.blocked .mark::after { left: 9px; }
641
648
.status.obsolete .mark, .stage-dot.obsolete .mark { background: transparent; box-shadow: inset 0 0 0 2px #afb8c1; }
642
649
.obsolete .mark::after {
643
650
content: ""; position: absolute; left: 3px; top: 7px; width: 10px; height: 2px; background: #afb8c1; transform: rotate(-45deg);
@@ -632,12 +632,19 @@ svg.ico { width: 14px; height: 14px; flex: none; }632
.status.running { background: #e7f0ff; color: #1f6feb; }632
.status.running { background: #e7f0ff; color: #1f6feb; }633
.status.canceled { background: #f3f0f0; color: #57606a; }633
.status.canceled { background: #f3f0f0; color: #57606a; }634
.status.obsolete { background: #f4f5f7; color: #8c959f; font-weight: 600; }634
.status.obsolete { background: #f4f5f7; color: #8c959f; font-weight: 600; }635
.status.blocked { background: #eef2f7; color: #57606a; }635
.mark { position: relative; width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; background: #8c959f; }636
.mark { position: relative; width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; background: #8c959f; }636
.status.passed .mark, .stage-dot.passed .mark { background: #1aaa55; }637
.status.passed .mark, .stage-dot.passed .mark { background: #1aaa55; }637
.status.failed .mark, .stage-dot.failed .mark { background: #dd2b0e; }638
.status.failed .mark, .stage-dot.failed .mark { background: #dd2b0e; }638
.status.warning .mark, .stage-dot.warning .mark { background: #c17d10; }639
.status.warning .mark, .stage-dot.warning .mark { background: #c17d10; }639
.status.running .mark, .stage-dot.running .mark { background: #1f75cb; }640
.status.running .mark, .stage-dot.running .mark { background: #1f75cb; }640
.status.canceled .mark, .stage-dot.canceled .mark { background: #8c959f; }641
.status.canceled .mark, .stage-dot.canceled .mark { background: #8c959f; }642
.status.blocked .mark, .stage-dot.blocked .mark { background: #57606a; }643
.blocked .mark::before, .blocked .mark::after {644
content: ""; position: absolute; top: 4px; width: 2px; height: 8px; background: #fff;645
}646
.blocked .mark::before { left: 5px; }647
.blocked .mark::after { left: 9px; }641
.status.obsolete .mark, .stage-dot.obsolete .mark { background: transparent; box-shadow: inset 0 0 0 2px #afb8c1; }648
.status.obsolete .mark, .stage-dot.obsolete .mark { background: transparent; box-shadow: inset 0 0 0 2px #afb8c1; }642
.obsolete .mark::after {649
.obsolete .mark::after {643
content: ""; position: absolute; left: 3px; top: 7px; width: 10px; height: 2px; background: #afb8c1; transform: rotate(-45deg);650
content: ""; position: absolute; left: 3px; top: 7px; width: 10px; height: 2px; background: #afb8c1; transform: rotate(-45deg);@@ -26,7 +26,7 @@
26
26
<link rel="icon" href="/assets/logo.svg" type="image/svg+xml">
27
27
<link rel="stylesheet" href="/assets/style.css">
28
28
</head>
29
<body data-copied="{{t "action.copied"}}" data-modal-title="{{t "modal.title"}}" data-modal-ok="{{t "modal.ok"}}" data-modal-cancel="{{t "modal.cancel"}}" data-obsolete-tip="{{t "pipe.obsolete.tip"}}" data-waitjob-tip="{{t "pipe.waiting_for_job.tip"}}">
29
<body data-copied="{{t "action.copied"}}" data-modal-title="{{t "modal.title"}}" data-modal-ok="{{t "modal.ok"}}" data-modal-cancel="{{t "modal.cancel"}}" data-obsolete-tip="{{t "pipe.obsolete.tip"}}" data-waitjob-tip="{{t "pipe.waiting_for_job.tip"}}" data-blocked-tip="{{t "pipe.blocked.tip"}}">
30
30
<header class="top">
31
31
<a class="brand" href="/"><img src="/assets/logo.svg" alt=""> BlueGit</a>
32
32
<nav>
@@ -26,7 +26,7 @@26
<link rel="icon" href="/assets/logo.svg" type="image/svg+xml">26
<link rel="icon" href="/assets/logo.svg" type="image/svg+xml">27
<link rel="stylesheet" href="/assets/style.css">27
<link rel="stylesheet" href="/assets/style.css">28
</head>28
</head>29
<body data-copied="{{t "action.copied"}}" data-modal-title="{{t "modal.title"}}" data-modal-ok="{{t "modal.ok"}}" data-modal-cancel="{{t "modal.cancel"}}" data-obsolete-tip="{{t "pipe.obsolete.tip"}}" data-waitjob-tip="{{t "pipe.waiting_for_job.tip"}}">29
<body data-copied="{{t "action.copied"}}" data-modal-title="{{t "modal.title"}}" data-modal-ok="{{t "modal.ok"}}" data-modal-cancel="{{t "modal.cancel"}}" data-obsolete-tip="{{t "pipe.obsolete.tip"}}" data-waitjob-tip="{{t "pipe.waiting_for_job.tip"}}" data-blocked-tip="{{t "pipe.blocked.tip"}}">30
<header class="top">30
<header class="top">31
<a class="brand" href="/"><img src="/assets/logo.svg" alt=""> BlueGit</a>31
<a class="brand" href="/"><img src="/assets/logo.svg" alt=""> BlueGit</a>32
<nav>32
<nav>@@ -1127,7 +1127,8 @@ func (s *Store) RefreshPipelineStatus(ctx context.Context, pipelineID int64) (st
1127
1127
open := false
1128
1128
manual := false
1129
1129
canceled := false
1130
for _, j := range jobs {
1130
blocked := manualBlocked(jobs)
1131
for i, j := range jobs {
1131
1132
switch j.Status {
1132
1133
case "failed":
1133
1134
if !j.AllowFailure {
@@ -1137,8 +1138,16 @@ func (s *Store) RefreshPipelineStatus(ctx context.Context, pipelineID int64) (st
1137
1138
if !j.AllowFailure {
1138
1139
canceled = true
1139
1140
}
1140
case "queued", "running":
1141
case "running":
1141
1142
open = true
1143
case "queued":
1144
// Een job die alleen nog op een handmatige job wacht, telt niet
1145
// als bezig: de pipeline wacht dan op een handmatige actie.
1146
if blocked[i] {
1147
manual = true
1148
} else {
1149
open = true
1150
}
1142
1151
case "manual":
1143
1152
manual = true
1144
1153
}
@@ -1633,3 +1642,30 @@ func (s *Store) SetWebhookActive(ctx context.Context, scopeKind string, scopeID,
1633
1642
_, err := s.db.ExecContext(ctx, `UPDATE webhooks SET active = ? WHERE id = ? AND scope_kind = ? AND scope_id = ?`, boolInt(on), id, scopeKind, scopeID)
1634
1643
return err
1635
1644
}
1645
1646
// manualBlocked markeert queued jobs die (direct of via andere wachtende
1647
// jobs) op een handmatige job wachten die nog niet gestart is. Een
1648
// handmatige job met allow_failure blokkeert niet, net als in ci.Gate.
1649
func manualBlocked(jobs []Job) map[int]bool {
1650
preds := predecessorIndexes(jobs)
1651
blocked := map[int]bool{}
1652
for {
1653
moved := false
1654
for i, j := range jobs {
1655
if blocked[i] || j.Status != "queued" {
1656
continue
1657
}
1658
for _, p := range preds[i] {
1659
pj := jobs[p]
1660
if (pj.Status == "manual" && !pj.AllowFailure) || blocked[p] {
1661
blocked[i] = true
1662
moved = true
1663
break
1664
}
1665
}
1666
}
1667
if !moved {
1668
return blocked
1669
}
1670
}
1671
}
@@ -1127,7 +1127,8 @@ func (s *Store) RefreshPipelineStatus(ctx context.Context, pipelineID int64) (st1127
open := false1127
open := false1128
manual := false1128
manual := false1129
canceled := false1129
canceled := false1130
for _, j := range jobs {1130
blocked := manualBlocked(jobs)1131
for i, j := range jobs {1131
switch j.Status {1132
switch j.Status {1132
case "failed":1133
case "failed":1133
if !j.AllowFailure {1134
if !j.AllowFailure {@@ -1137,8 +1138,16 @@ func (s *Store) RefreshPipelineStatus(ctx context.Context, pipelineID int64) (st1137
if !j.AllowFailure {1138
if !j.AllowFailure {1138
canceled = true1139
canceled = true1139
}1140
}1140
case "queued", "running":1141
case "running":1141
open = true1142
open = true1143
case "queued":1144
// Een job die alleen nog op een handmatige job wacht, telt niet1145
// als bezig: de pipeline wacht dan op een handmatige actie.1146
if blocked[i] {1147
manual = true1148
} else {1149
open = true1150
}1142
case "manual":1151
case "manual":1143
manual = true1152
manual = true1144
}1153
}@@ -1633,3 +1642,30 @@ func (s *Store) SetWebhookActive(ctx context.Context, scopeKind string, scopeID,1633
_, err := s.db.ExecContext(ctx, `UPDATE webhooks SET active = ? WHERE id = ? AND scope_kind = ? AND scope_id = ?`, boolInt(on), id, scopeKind, scopeID)1642
_, err := s.db.ExecContext(ctx, `UPDATE webhooks SET active = ? WHERE id = ? AND scope_kind = ? AND scope_id = ?`, boolInt(on), id, scopeKind, scopeID)1634
return err1643
return err1635
}1644
}1645
1646
// manualBlocked markeert queued jobs die (direct of via andere wachtende1647
// jobs) op een handmatige job wachten die nog niet gestart is. Een1648
// handmatige job met allow_failure blokkeert niet, net als in ci.Gate.1649
func manualBlocked(jobs []Job) map[int]bool {1650
preds := predecessorIndexes(jobs)1651
blocked := map[int]bool{}1652
for {1653
moved := false1654
for i, j := range jobs {1655
if blocked[i] || j.Status != "queued" {1656
continue1657
}1658
for _, p := range preds[i] {1659
pj := jobs[p]1660
if (pj.Status == "manual" && !pj.AllowFailure) || blocked[p] {1661
blocked[i] = true1662
moved = true1663
break1664
}1665
}1666
}1667
if !moved {1668
return blocked1669
}1670
}1671
}@@ -0,0 +1,72 @@
1
package store
2
3
import (
4
"context"
5
"testing"
6
)
7
8
func TestPipelineWaitingOnManualIsNotRunning(t *testing.T) {
9
s := openTest(t)
10
ctx := context.Background()
11
tim, err := s.UpsertUser(ctx, 1, "tim", "", false)
12
if err != nil {
13
t.Fatal(err)
14
}
15
repo, err := s.CreateRepo(ctx, "user", tim.ID, "pp", "", "master", "private")
16
if err != nil {
17
t.Fatal(err)
18
}
19
id, err := s.CreatePipeline(ctx, repo.ID, "abc", "refs/heads/master", "push", "tim", "rel", []NewJob{
20
{Name: "build", Stage: "build", Script: "true"},
21
{Name: "release", Stage: "release", Script: "true", When: "manual"},
22
{Name: "publish", Stage: "publish", Script: "true", Needs: []string{"release"}, NeedsSet: true},
23
{Name: "after", Stage: "post", Script: "true"},
24
})
25
if err != nil {
26
t.Fatal(err)
27
}
28
jobs, _ := s.JobsByPipeline(ctx, id)
29
byName := map[string]Job{}
30
for _, j := range jobs {
31
byName[j.Name] = j
32
}
33
if byName["release"].Status != "manual" || byName["publish"].Status != "queued" {
34
t.Fatalf("opzet: %s %s", byName["release"].Status, byName["publish"].Status)
35
}
36
// build loopt nog: de pipeline is bezig.
37
if st, _ := s.RefreshPipelineStatus(ctx, id); st != "running" {
38
t.Fatalf("met open build: %s", st)
39
}
40
if err := s.FinishJob(ctx, byName["build"].ID, "success", ""); err != nil {
41
t.Fatal(err)
42
}
43
st, err := s.RefreshPipelineStatus(ctx, id)
44
if err != nil || st != "manual" {
45
t.Fatalf("alleen handmatig over hoort manual te zijn: %s %v", st, err)
46
}
47
p, _ := s.PipelineByID(ctx, repo.ID, id)
48
if p.Status != "manual" {
49
t.Fatalf("opgeslagen status %s", p.Status)
50
}
51
// Na het starten van de handmatige job is hij weer bezig.
52
if ok, _ := s.QueueJob(ctx, byName["release"].ID); !ok {
53
t.Fatal("queue")
54
}
55
if st, _ := s.RefreshPipelineStatus(ctx, id); st != "running" {
56
t.Fatalf("na play: %s", st)
57
}
58
}
59
60
func TestManualAllowFailureDoesNotBlock(t *testing.T) {
61
jobs := []Job{
62
{Name: "opt", Stage: "a", Status: "manual", AllowFailure: true},
63
{Name: "next", Stage: "b", Status: "queued"},
64
}
65
if manualBlocked(jobs)[1] {
66
t.Fatal("allow_failure-manual blokkeert niet")
67
}
68
jobs[0].AllowFailure = false
69
if !manualBlocked(jobs)[1] {
70
t.Fatal("manual blokkeert")
71
}
72
}
@@ -0,0 +1,72 @@1
package store2
3
import (4
"context"5
"testing"6
)7
8
func TestPipelineWaitingOnManualIsNotRunning(t *testing.T) {9
s := openTest(t)10
ctx := context.Background()11
tim, err := s.UpsertUser(ctx, 1, "tim", "", false)12
if err != nil {13
t.Fatal(err)14
}15
repo, err := s.CreateRepo(ctx, "user", tim.ID, "pp", "", "master", "private")16
if err != nil {17
t.Fatal(err)18
}19
id, err := s.CreatePipeline(ctx, repo.ID, "abc", "refs/heads/master", "push", "tim", "rel", []NewJob{20
{Name: "build", Stage: "build", Script: "true"},21
{Name: "release", Stage: "release", Script: "true", When: "manual"},22
{Name: "publish", Stage: "publish", Script: "true", Needs: []string{"release"}, NeedsSet: true},23
{Name: "after", Stage: "post", Script: "true"},24
})25
if err != nil {26
t.Fatal(err)27
}28
jobs, _ := s.JobsByPipeline(ctx, id)29
byName := map[string]Job{}30
for _, j := range jobs {31
byName[j.Name] = j32
}33
if byName["release"].Status != "manual" || byName["publish"].Status != "queued" {34
t.Fatalf("opzet: %s %s", byName["release"].Status, byName["publish"].Status)35
}36
// build loopt nog: de pipeline is bezig.37
if st, _ := s.RefreshPipelineStatus(ctx, id); st != "running" {38
t.Fatalf("met open build: %s", st)39
}40
if err := s.FinishJob(ctx, byName["build"].ID, "success", ""); err != nil {41
t.Fatal(err)42
}43
st, err := s.RefreshPipelineStatus(ctx, id)44
if err != nil || st != "manual" {45
t.Fatalf("alleen handmatig over hoort manual te zijn: %s %v", st, err)46
}47
p, _ := s.PipelineByID(ctx, repo.ID, id)48
if p.Status != "manual" {49
t.Fatalf("opgeslagen status %s", p.Status)50
}51
// Na het starten van de handmatige job is hij weer bezig.52
if ok, _ := s.QueueJob(ctx, byName["release"].ID); !ok {53
t.Fatal("queue")54
}55
if st, _ := s.RefreshPipelineStatus(ctx, id); st != "running" {56
t.Fatalf("na play: %s", st)57
}58
}59
60
func TestManualAllowFailureDoesNotBlock(t *testing.T) {61
jobs := []Job{62
{Name: "opt", Stage: "a", Status: "manual", AllowFailure: true},63
{Name: "next", Stage: "b", Status: "queued"},64
}65
if manualBlocked(jobs)[1] {66
t.Fatal("allow_failure-manual blokkeert niet")67
}68
jobs[0].AllowFailure = false69
if !manualBlocked(jobs)[1] {70
t.Fatal("manual blokkeert")71
}72
}