From 422e4e709000d97eff18f60d24073da7d8e13e63 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Fri, 13 Nov 2026 10:35:03 +0000 Subject: [PATCH] feat(release): a Skip QA button in the QA step After a warning and a confirmation, a user can make Release available without QA for the current head of the release PR. The skip is kept in the audit log with the head it is for, so a re-cut asks for QA again, and a comment on the PR says QA was skipped. The comment does not name the user. Signed-off-by: Ricardo Dias --- CHANGELOG.md | 4 + backend/internal/api/release_routes.go | 5 +- backend/internal/api/release_routes_test.go | 4 + backend/internal/release/actions.go | 34 +++++- backend/internal/release/actions_test.go | 105 +++++++++++++++++- backend/internal/release/fake_github_test.go | 10 ++ backend/internal/release/github.go | 8 ++ backend/internal/release/github_test.go | 18 +++ backend/internal/release/service.go | 3 + backend/internal/release/types.go | 4 + .../src/components/release/ReleaseConfirm.vue | 3 +- .../components/release/ReleaseQaStep.test.ts | 61 ++++++++++ .../src/components/release/ReleaseQaStep.vue | 38 ++++++- .../components/release/ReleaseWizard.test.ts | 1 + .../src/components/release/ReleaseWizard.vue | 3 +- frontend/src/composables/useRelease.ts | 2 +- frontend/src/types/release.ts | 5 +- 17 files changed, 291 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84dea21..e12d96f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ an example value. See `deploy/host/README.md`. ## [Unreleased] +### Added + +- The QA step of a release has a "Skip QA" button. After a warning and a confirmation it makes "Release" available without QA, for one version of the release PR, and leaves a comment on the PR. "Update to latest main & restart" asks for QA again. + ## [0.2.7] - 2026-11-12 ### Added diff --git a/backend/internal/api/release_routes.go b/backend/internal/api/release_routes.go index 61b7d4b..c181aa4 100644 --- a/backend/internal/api/release_routes.go +++ b/backend/internal/api/release_routes.go @@ -30,6 +30,7 @@ type ReleaseService interface { RetrySync(ctx context.Context, email, id, head string) error ApproveQA(ctx context.Context, email, id, head string) error RetryQA(ctx context.Context, email, id, head string) error + SkipQA(ctx context.Context, email, id, head string) error Recut(ctx context.Context, email, id, head string) error Release(ctx context.Context, email, id, head string, confirmFailed bool) error RetryRelease(ctx context.Context, email, id string) error @@ -177,7 +178,7 @@ func mountRelease(r chi.Router, svc ReleaseService, origin func(http.Handler) ht r.With(origin).Post("/api/release/releases/{id}/{action}", func(w http.ResponseWriter, req *http.Request) { id, action := chi.URLParam(req, "id"), chi.URLParam(req, "action") switch action { - case "approve-changelog", "retry-sync", "approve-qa", "retry-qa", "recut", "release", "retry-release", "abandon": + case "approve-changelog", "retry-sync", "approve-qa", "retry-qa", "skip-qa", "recut", "release", "retry-release", "abandon": default: http.NotFound(w, req) return @@ -200,6 +201,8 @@ func mountRelease(r chi.Router, svc ReleaseService, origin func(http.Handler) ht err = svc.ApproveQA(ctx, email, id, body.Head) case "retry-qa": err = svc.RetryQA(ctx, email, id, body.Head) + case "skip-qa": + err = svc.SkipQA(ctx, email, id, body.Head) case "recut": err = svc.Recut(ctx, email, id, body.Head) case "release": diff --git a/backend/internal/api/release_routes_test.go b/backend/internal/api/release_routes_test.go index 4868746..01f9118 100644 --- a/backend/internal/api/release_routes_test.go +++ b/backend/internal/api/release_routes_test.go @@ -63,6 +63,9 @@ func (s *stubRelease) ApproveQA(ctx context.Context, email, id, head string) err func (s *stubRelease) RetryQA(ctx context.Context, email, id, head string) error { return s.rec("retry-qa", ctx) } +func (s *stubRelease) SkipQA(ctx context.Context, email, id, head string) error { + return s.rec("skip-qa", ctx) +} func (s *stubRelease) Recut(ctx context.Context, email, id, head string) error { return s.rec("recut", ctx) } @@ -114,6 +117,7 @@ var releaseRoutes = []struct{ method, path, body string }{ {"POST", "/api/release/releases/r1/changelog/reset", `{"head":"h","unit":"a"}`}, {"POST", "/api/release/releases/r1/approve-changelog", `{"head":"h"}`}, {"POST", "/api/release/releases/r1/retry-qa", `{"head":"h"}`}, + {"POST", "/api/release/releases/r1/skip-qa", `{"head":"h"}`}, } func TestReleaseRoutesRequireUser(t *testing.T) { diff --git a/backend/internal/release/actions.go b/backend/internal/release/actions.go index 54b6f2e..d2db573 100644 --- a/backend/internal/release/actions.go +++ b/backend/internal/release/actions.go @@ -29,6 +29,7 @@ const ( auditRetrySync = "retry_sync" auditApproveQA = "approve_qa" auditRetryQA = "retry_qa" + auditSkipQA = "skip_qa" // Detail is the PR head the skip is for auditRecut = "recut" auditRetryRelease = "retry_release" auditAbandon = "abandon" @@ -419,6 +420,33 @@ func (s *Service) ApproveQA(ctx context.Context, email, id, head string) error { return nil } +// skipQAComment is left on the release PR when QA is skipped. It does not name +// the user: emails stay in the dashboard. +const skipQAComment = "**QA skipped.** A dashboard user explicitly decided to release commit %s without running QA on it." + +// SkipQA lets the release be made without QA having finished for this head of +// the PR. It says so on the PR. A re-cut gives the PR a new head, which the +// skip does not cover. +func (s *Service) SkipQA(ctx context.Context, email, id, head string) error { + s.actMu.Lock() + defer s.actMu.Unlock() + if s.db == nil { + return fmt.Errorf("%w: skipping QA needs the database", ErrBadRequest) + } + r, err := s.guard(ctx, id, head, func(r Release) bool { + return r.Step == StepQA && r.PR != 0 && r.QA != nil && r.QA.State != "finished" && !r.QA.Skipped + }) + if err != nil { + return err + } + if err := s.gh.Comment(ctx, r.PR, fmt.Sprintf(skipQAComment, r.HeadSHA)); err != nil { + return err + } + s.record(email, auditSkipQA, r, r.HeadSHA) + s.Invalidate() + return nil +} + // RetryQA starts QA again after it failed to start (the CDN wait or the lane // matrix failed): the qa-release label comes off and goes back on. func (s *Service) RetryQA(ctx context.Context, email, id, head string) error { @@ -518,13 +546,13 @@ func (s *Service) unitsOf(r Release) ([]string, error) { return nil, fmt.Errorf("%w: the units of this release are not known, abandon it and start again", ErrBadRequest) } -// Release merges the release PR; the release workflow then publishes it. A -// failed QA lane needs confirmFailed. +// Release merges the release PR; the release workflow then publishes it. QA +// must have finished or been skipped. A failed QA lane needs confirmFailed. func (s *Service) Release(ctx context.Context, email, id, head string, confirmFailed bool) error { s.actMu.Lock() defer s.actMu.Unlock() r, err := s.guard(ctx, id, head, func(r Release) bool { - return r.Step == StepQA && r.PR != 0 && r.QA != nil && r.QA.State == "finished" + return r.Step == StepQA && r.PR != 0 && r.QA != nil && (r.QA.State == "finished" || r.QA.Skipped) }) if err != nil { return err diff --git a/backend/internal/release/actions_test.go b/backend/internal/release/actions_test.go index e3d0793..5121664 100644 --- a/backend/internal/release/actions_test.go +++ b/backend/internal/release/actions_test.go @@ -88,7 +88,7 @@ func (fx *svcFixture) wantOneAudit(t *testing.T, action string) store.ReleaseAud func (fx *svcFixture) wantNoWrites(t *testing.T) { t.Helper() - for _, m := range []string{"AmendFile", "AddLabel", "RemoveLabel", "Dispatch", "MergePull", "ClosePull", "DeleteBranch"} { + for _, m := range []string{"AmendFile", "AddLabel", "RemoveLabel", "Comment", "Dispatch", "MergePull", "ClosePull", "DeleteBranch"} { if c := fx.gh.callsOf(m); len(c) != 0 { t.Errorf("unexpected GitHub write: %v", c) } @@ -531,7 +531,7 @@ func TestActionForkRefused(t *testing.T) { t.Errorf("%s: err = %v, want ErrConflict", name, err) } } - for _, m := range []string{"AmendFile", "AddLabel", "RemoveLabel", "Dispatch", "MergePull", "ClosePull", "DeleteBranch"} { + for _, m := range []string{"AmendFile", "AddLabel", "RemoveLabel", "Comment", "Dispatch", "MergePull", "ClosePull", "DeleteBranch"} { if c := fx.gh.callsOf(m); len(c) != 0 { t.Errorf("fork: %v", c) } @@ -937,3 +937,104 @@ func TestActionAbandonFailedFirstCutRefused(t *testing.T) { } fx.wantNoWrites(t) } + +func TestActionSkipQA(t *testing.T) { + ctx, id := context.Background(), "20261111T143210" + fx := newFixture(t) + fx.atQA(false, "completed") + // Not released before the skip. + if err := fx.svc.Release(ctx, actor, id, testHead, false); !errors.Is(err, ErrConflict) { + t.Fatalf("release before the skip: err = %v", err) + } + if err := fx.svc.SkipQA(ctx, actor, id, testHead); err != nil { + t.Fatal(err) + } + got := fx.gh.callsOf("Comment") + if len(got) != 1 || !strings.HasPrefix(got[0], "Comment 415 ") || !strings.Contains(got[0], "QA skipped") || !strings.Contains(got[0], testHead) { + t.Errorf("Comment = %v", got) + } + if strings.Contains(got[0], actor) { + t.Errorf("the comment names the user: %q", got[0]) + } + if a := fx.wantOneAudit(t, "skip_qa"); a.Detail != testHead { + t.Errorf("audit = %+v", a) + } + rel := fx.snapshot(t).Releases[0] + if rel.QA == nil || !rel.QA.Skipped || rel.QA.SkippedBy != actor || rel.QA.State != "waiting" { + t.Fatalf("qa = %+v", rel.QA) + } + // A second skip is refused, and leaves no second comment. + if err := fx.svc.SkipQA(ctx, actor, id, testHead); !errors.Is(err, ErrConflict) { + t.Fatalf("second skip: err = %v", err) + } + if n := len(fx.gh.callsOf("Comment")); n != 1 { + t.Fatalf("Comment called %d times", n) + } + if err := fx.svc.Release(ctx, actor, id, testHead, false); err != nil { + t.Fatalf("release after the skip: %v", err) + } + if got := fx.gh.callsOf("MergePull"); len(got) != 1 || got[0] != "MergePull 415 "+testHead { + t.Errorf("MergePull = %v", got) + } +} + +func TestActionSkipQAWhileRunningStillNeedsConfirmForFailedLanes(t *testing.T) { + ctx, id := context.Background(), "20261111T143210" + fx := newFixture(t) + fx.atQA(true, "in_progress", laneJob(200, "packages / pg_tde", "failure"), Job{ID: 201, Name: JobLanePrefix + "packages / pg_stat", Status: "in_progress"}) + if err := fx.svc.SkipQA(ctx, actor, id, testHead); err != nil { + t.Fatal(err) + } + if err := fx.svc.Release(ctx, actor, id, testHead, false); !errors.Is(err, ErrBadRequest) { + t.Fatalf("err = %v", err) + } + if err := fx.svc.Release(ctx, actor, id, testHead, true); err != nil { + t.Fatal(err) + } +} + +func TestActionSkipQARefused(t *testing.T) { + ctx, id := context.Background(), "20261111T143210" + // QA finished: Release is available already. + fx := newFixture(t) + fx.atQA(true, "completed", laneJob(200, "packages / pg_tde", "success")) + if err := fx.svc.SkipQA(ctx, actor, id, testHead); !errors.Is(err, ErrConflict) { + t.Fatalf("finished QA: err = %v", err) + } + fx.wantNoWrites(t) + // Not at the QA step. + fx = newFixture(t) + fx.atChangelog() + if err := fx.svc.SkipQA(ctx, actor, id, testHead); !errors.Is(err, ErrConflict) { + t.Fatalf("changelog step: err = %v", err) + } + fx.wantNoWrites(t) + // A head the user did not see. + fx = newFixture(t) + fx.atQA(false, "completed") + if err := fx.svc.SkipQA(ctx, actor, id, "otherhead"); !errors.Is(err, ErrConflict) { + t.Fatalf("stale head: err = %v", err) + } + fx.wantNoWrites(t) + // The comment could not be left: nothing is skipped. + fx.gh.commentErr = errors.New("boom") + if err := fx.svc.SkipQA(ctx, actor, id, testHead); err == nil { + t.Fatal("skipped although the comment failed") + } + if rel := fx.snapshot(t).Releases[0]; rel.QA.Skipped { + t.Fatal("skipped although the comment failed") + } +} + +func TestSkipQADoesNotCoverANewHead(t *testing.T) { + fx := newFixture(t) + fx.atQA(false, "completed") + // The skip of an earlier iteration of the PR. + fx.recordCut(t, "skip_qa", "oldhead") + if rel := fx.snapshot(t).Releases[0]; rel.QA.Skipped { + t.Fatal("a skip of another head counts") + } + if err := fx.svc.Release(context.Background(), actor, "20261111T143210", testHead, false); !errors.Is(err, ErrConflict) { + t.Fatalf("err = %v", err) + } +} diff --git a/backend/internal/release/fake_github_test.go b/backend/internal/release/fake_github_test.go index 28dafaa..bab4653 100644 --- a/backend/internal/release/fake_github_test.go +++ b/backend/internal/release/fake_github_test.go @@ -35,6 +35,7 @@ type fakeGitHub struct { calls []string err error hasClosedErr error // returned by HasClosedPull only + commentErr error // returned by Comment only deleteErr error // returned by DeleteBranch only closeErr error // returned by ClosePull only createErr error // returned by CreatePull only @@ -243,6 +244,15 @@ func (f *fakeGitHub) MergePull(ctx context.Context, number int, headSHA string) return nil } +func (f *fakeGitHub) Comment(ctx context.Context, number int, body string) error { + err := f.record("Comment", number, body) + defer f.mu.Unlock() + if err != nil { + return err + } + return f.commentErr +} + func (f *fakeGitHub) AddLabel(ctx context.Context, number int, label string) error { err := f.record("AddLabel", number, label) defer f.mu.Unlock() diff --git a/backend/internal/release/github.go b/backend/internal/release/github.go index 28d139b..373cd56 100644 --- a/backend/internal/release/github.go +++ b/backend/internal/release/github.go @@ -88,6 +88,7 @@ type GitHub interface { ClosePull(ctx context.Context, number int) error MergePull(ctx context.Context, number int, headSHA string) error AddLabel(ctx context.Context, number int, label string) error + Comment(ctx context.Context, number int, body string) error RemoveLabel(ctx context.Context, number int, label string) error Branches(ctx context.Context, prefix string) ([]Ref, error) DeleteBranch(ctx context.Context, branch string) error @@ -477,6 +478,13 @@ func (c *Client) AddLabel(ctx context.Context, number int, label string) error { return err } +// Comment adds a comment to a pull request. +func (c *Client) Comment(ctx context.Context, number int, body string) error { + _, _, err := c.do(ctx, http.MethodPost, c.repoPath("issues/"+strconv.Itoa(number)+"/comments"), + map[string]string{"body": body}, false) + return err +} + func (c *Client) RemoveLabel(ctx context.Context, number int, label string) error { _, _, err := c.do(ctx, http.MethodDelete, c.repoPath("issues/"+strconv.Itoa(number)+"/labels/"+url.PathEscape(label)), nil, false) if errors.Is(err, ErrNotFound) { diff --git a/backend/internal/release/github_test.go b/backend/internal/release/github_test.go index 34ccc5c..5028aeb 100644 --- a/backend/internal/release/github_test.go +++ b/backend/internal/release/github_test.go @@ -545,3 +545,21 @@ func TestGitHubRunActorAndApprove(t *testing.T) { t.Fatalf("approve %q %v", approved, err) } } + +func TestClientComment(t *testing.T) { + var body map[string]string + c := newGHClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != "POST" || r.URL.Path != "/repos/percona/obs-packaging/issues/7/comments" { + t.Errorf("unexpected %s %s", r.Method, r.URL.Path) + } + _ = json.NewDecoder(r.Body).Decode(&body) + w.WriteHeader(http.StatusCreated) + _, _ = w.Write([]byte(`{}`)) + })) + if err := c.Comment(context.Background(), 7, "hello"); err != nil { + t.Fatal(err) + } + if body["body"] != "hello" { + t.Fatalf("body %v", body) + } +} diff --git a/backend/internal/release/service.go b/backend/internal/release/service.go index 31d0490..ddf5cc4 100644 --- a/backend/internal/release/service.go +++ b/backend/internal/release/service.go @@ -842,6 +842,9 @@ func (s *Service) build(ctx context.Context, c candidate, cutRuns, releaseRuns [ at := a.At rel.StartedBy, rel.StartedAt = a.Email, &at } + if a.Action == auditSkipQA && rel.QA != nil && rel.HeadSHA != "" && a.Detail == rel.HeadSHA { + rel.QA.Skipped, rel.QA.SkippedBy = true, a.Email + } } if len(rel.Units) == 0 && !c.fork { if u := cutUnits(audit); len(u) > 0 { diff --git a/backend/internal/release/types.go b/backend/internal/release/types.go index bca56a6..80894c0 100644 --- a/backend/internal/release/types.go +++ b/backend/internal/release/types.go @@ -76,6 +76,10 @@ type QA struct { Lanes []Lane `json:"lanes"` URL string `json:"url"` // the QA run; "" while none is known Error string `json:"error"` // why QA could not run; set with state failure + // Skipped says a user chose to release this head of the PR without QA. + // The release may then be made whatever State is. + Skipped bool `json:"skipped"` + SkippedBy string `json:"skipped_by"` // who skipped; "" unless Skipped } type Final struct { diff --git a/frontend/src/components/release/ReleaseConfirm.vue b/frontend/src/components/release/ReleaseConfirm.vue index 3548a5d..ecf4e09 100644 --- a/frontend/src/components/release/ReleaseConfirm.vue +++ b/frontend/src/components/release/ReleaseConfirm.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/components/release/ReleaseWizard.test.ts b/frontend/src/components/release/ReleaseWizard.test.ts index b5b25da..cd5f40a 100644 --- a/frontend/src/components/release/ReleaseWizard.test.ts +++ b/frontend/src/components/release/ReleaseWizard.test.ts @@ -132,6 +132,7 @@ describe('ReleaseWizard', () => { expect(status({ step: 'sync', sync_state: 'running' })).toBe('waiting|Step 3 of 5 · Pre-release sync|Copying staging into the pre-release') expect(status({ step: 'sync', sync_state: 'failure' })).toBe('failed|Step 3 of 5 · Pre-release sync|The pre-release sync failed') expect(status({ step: 'qa', sync_state: 'success', qa: qa('waiting') })).toBe('action|Step 4 of 5 · QA|Your turn: approve the QA run') + expect(status({ step: 'qa', sync_state: 'success', qa: { ...qa('waiting'), skipped: true } })).toBe('action|Step 4 of 5 · QA|Your turn: QA skipped, release when ready') expect(status({ step: 'qa', sync_state: 'success', qa: qa('running') })).toBe('waiting|Step 4 of 5 · QA|QA is running') expect(status({ step: 'qa', sync_state: 'success', qa: qa('failure') })).toBe('failed|Step 4 of 5 · QA|QA could not start') expect(status({ step: 'qa', sync_state: 'success', qa: qa('finished', [lane('success')]) })).toBe('action|Step 4 of 5 · QA|Your turn: QA passed, release when ready') diff --git a/frontend/src/components/release/ReleaseWizard.vue b/frontend/src/components/release/ReleaseWizard.vue index becd330..dd09f19 100644 --- a/frontend/src/components/release/ReleaseWizard.vue +++ b/frontend/src/components/release/ReleaseWizard.vue @@ -36,7 +36,7 @@ const readOnly = computed(() => ['sync', 'qa', 'releasing'].includes(props.relea const draftsKept = computed(() => props.release.step !== 'changelog' && hasDrafts(props.release.id)) const ACTION_WORDS: Record = { cut: 'started the release', save_changelog: 'edited the changelog', approve_changelog: 'approved the changelog', - retry_sync: 'retried the sync', approve_qa: 'approved the QA run', retry_qa: 'retried QA', recut: 'updated to latest main', + retry_sync: 'retried the sync', approve_qa: 'approved the QA run', retry_qa: 'retried QA', skip_qa: 'skipped QA', recut: 'updated to latest main', release: 'released', retry_release: 'retried the final sync', abandon: 'abandoned', } const when = (iso: string) => { @@ -118,6 +118,7 @@ const status = computed(() => { return wait('Copying staging into the pre-release') case 'qa': { const q = r.qa + if (q?.skipped && q.state !== 'finished') return act('QA skipped, release when ready') if (!q || q.state === 'waiting') return act('approve the QA run') if (q.state === 'failure') return fail('QA could not start') if (q.state === 'running') return wait('QA is running') diff --git a/frontend/src/composables/useRelease.ts b/frontend/src/composables/useRelease.ts index 232fc85..2932e05 100644 --- a/frontend/src/composables/useRelease.ts +++ b/frontend/src/composables/useRelease.ts @@ -96,7 +96,7 @@ function shown(id: string): string | undefined { if (!r) return undefined return JSON.stringify([ r.step, r.head_sha, r.cut?.state, r.sync_state, r.sync?.map((c) => c.state), - r.qa?.state, r.qa?.lanes?.length, r.final?.state, + r.qa?.state, r.qa?.skipped, r.qa?.lanes?.length, r.final?.state, ]) } diff --git a/frontend/src/types/release.ts b/frontend/src/types/release.ts index 3de2e06..363581d 100644 --- a/frontend/src/types/release.ts +++ b/frontend/src/types/release.ts @@ -72,8 +72,9 @@ export interface ReleaseState { sync_error: string sync: InstanceCard[] removals: { project: string; item: string }[] + // skipped: a user chose to release this head of the PR without QA; Release is then available whatever the state. // url: the QA run ('' while none). error: why QA could not run, set with state 'failure'. - qa: { state: 'waiting' | 'running' | 'finished' | 'failure'; lanes: Lane[]; url: string; error: string } | null + qa: { state: 'waiting' | 'running' | 'finished' | 'failure'; lanes: Lane[]; url: string; error: string; skipped?: boolean; skipped_by?: string } | null final: { tags: string[] instances: InstanceCard[] @@ -116,4 +117,4 @@ export interface HistoryPage { } export type ReleaseAction = - | 'approve-changelog' | 'retry-sync' | 'approve-qa' | 'retry-qa' | 'recut' | 'release' | 'retry-release' | 'abandon' + | 'approve-changelog' | 'retry-sync' | 'approve-qa' | 'retry-qa' | 'skip-qa' | 'recut' | 'release' | 'retry-release' | 'abandon'