Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion backend/internal/api/release_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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":
Expand Down
4 changes: 4 additions & 0 deletions backend/internal/api/release_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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) {
Expand Down
34 changes: 31 additions & 3 deletions backend/internal/release/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
105 changes: 103 additions & 2 deletions backend/internal/release/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
}
10 changes: 10 additions & 0 deletions backend/internal/release/fake_github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions backend/internal/release/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions backend/internal/release/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
3 changes: 3 additions & 0 deletions backend/internal/release/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions backend/internal/release/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/release/ReleaseConfirm.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'

defineProps<{ title: string; body: string; confirmLabel: string; danger?: boolean }>()
defineProps<{ title: string; body: string; confirmLabel: string; danger?: boolean; warning?: string }>()
const emit = defineEmits<{ confirm: []; cancel: [] }>()
const cancelBtn = ref<HTMLButtonElement | null>(null)
onMounted(() => cancelBtn.value?.focus())
Expand All @@ -11,6 +11,7 @@ onMounted(() => cancelBtn.value?.focus())
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50" @click.self="emit('cancel')" @keydown.esc="emit('cancel')">
<div role="dialog" aria-modal="true" data-testid="release-confirm" class="w-[min(440px,92vw)] rounded-[14px] border border-border bg-bg-card p-5 text-[13px] text-text-secondary">
<h3 class="m-0 mb-2 text-[15px] font-bold text-text-primary">{{ title }}</h3>
<p v-if="warning" data-testid="confirm-warning" role="alert" class="m-0 mb-3 rounded-[10px] border-2 border-fail p-3 text-[15px] font-bold text-fail">⚠ {{ warning }}</p>
<p class="m-0 mb-4">{{ body }}</p>
<div class="flex justify-end gap-2">
<button ref="cancelBtn" type="button" data-testid="confirm-cancel" class="cursor-pointer rounded-md border border-border bg-transparent px-3 py-[6px] text-text-primary" @click="emit('cancel')">Cancel</button>
Expand Down
Loading
Loading