Skip to content
Draft
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
11 changes: 9 additions & 2 deletions core/consumer/mock/controller_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions runway/extension/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "extension",
srcs = ["extension.go"],
importpath = "github.com/uber/submitqueue/runway/extension",
visibility = ["//visibility:public"],
)
16 changes: 16 additions & 0 deletions runway/extension/extension.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2025 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package extension holds Runway-specific extension implementations.
package extension
9 changes: 9 additions & 0 deletions runway/extension/vcs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "vcs",
srcs = ["vcs.go"],
importpath = "github.com/uber/submitqueue/runway/extension/vcs",
visibility = ["//visibility:public"],
deps = ["//runway/entity"],
)
13 changes: 13 additions & 0 deletions runway/extension/vcs/mock/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "mock",
srcs = ["vcs_mock.go"],
importpath = "github.com/uber/submitqueue/runway/extension/vcs/mock",
visibility = ["//visibility:public"],
deps = [
"//runway/entity",
"//runway/extension/vcs",
"@org_uber_go_mock//gomock",
],
)
112 changes: 112 additions & 0 deletions runway/extension/vcs/mock/vcs_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions runway/extension/vcs/noop/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "noop",
srcs = ["noop.go"],
importpath = "github.com/uber/submitqueue/runway/extension/vcs/noop",
visibility = ["//visibility:public"],
deps = [
"//runway/entity",
"//runway/extension/vcs",
],
)

go_test(
name = "noop_test",
srcs = ["noop_test.go"],
embed = [":noop"],
deps = [
"//entity/change",
"//entity/mergestrategy",
"//runway/entity",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)
56 changes: 56 additions & 0 deletions runway/extension/vcs/noop/noop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2025 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package noop provides a VCS implementation that reports every check as
// mergeable and every land as committed with synthetic commit SHAs. It is
// intended for wiring and tests only, never production.
package noop

import (
"context"
"fmt"
"sync/atomic"

"github.com/uber/submitqueue/runway/entity"
"github.com/uber/submitqueue/runway/extension/vcs"
)

type noopVCS struct {
counter atomic.Uint64
}

// New returns a vcs.VCS that defaults to success for all operations.
func New() vcs.VCS {
return &noopVCS{}
}

func (n *noopVCS) CheckMergeability(_ context.Context, check entity.Check) ([]entity.MergeabilityResult, error) {
results := make([]entity.MergeabilityResult, len(check.Changes))
for i, c := range check.Changes {
results[i] = entity.MergeabilityResult{Change: c, Mergeable: true}
}
return results, nil
}

func (n *noopVCS) Land(_ context.Context, job entity.Job) ([]entity.Outcome, error) {
outcomes := make([]entity.Outcome, len(job.Items))
for i, item := range job.Items {
outcomes[i] = entity.Outcome{
RequestID: item.RequestID,
Change: item.Change,
CommitSHAs: []string{fmt.Sprintf("noop-%d", n.counter.Add(1))},
}
}
return outcomes, nil
}
105 changes: 105 additions & 0 deletions runway/extension/vcs/noop/noop_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright (c) 2025 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package noop

import (
"context"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber/submitqueue/entity/change"
"github.com/uber/submitqueue/entity/mergestrategy"
"github.com/uber/submitqueue/runway/entity"
)

func TestNoopVCS_CheckMergeability(t *testing.T) {
v := New()
check := entity.Check{
Queue: "q1",
RequestID: "q1/1",
Repo: "uber/repo",
TargetBranch: "main",
Changes: []change.Change{
{URIs: []string{"github://uber/repo/pull/1/aaaa"}},
{URIs: []string{"github://uber/repo/pull/2/bbbb"}},
},
Strategy: mergestrategy.MergeStrategyRebase,
}

results, err := v.CheckMergeability(context.Background(), check)
require.NoError(t, err)
require.Len(t, results, 2)

for _, r := range results {
assert.True(t, r.Mergeable)
assert.Empty(t, r.Reason)
}
}

func TestNoopVCS_CheckMergeability_Empty(t *testing.T) {
v := New()
check := entity.Check{Changes: []change.Change{}}

results, err := v.CheckMergeability(context.Background(), check)
require.NoError(t, err)
assert.Empty(t, results)
}

func TestNoopVCS_Land(t *testing.T) {
v := New()
job := entity.Job{
ID: "job-1",
BatchID: "q1/batch/1",
Queue: "q1",
Repo: "uber/repo",
TargetBranch: "main",
Items: []entity.JobItem{
{
RequestID: "q1/10",
Change: change.Change{URIs: []string{"github://uber/repo/pull/10/aaaa"}},
Strategy: mergestrategy.MergeStrategyRebase,
},
{
RequestID: "q1/11",
Change: change.Change{URIs: []string{"github://uber/repo/pull/11/bbbb"}},
Strategy: mergestrategy.MergeStrategySquashRebase,
},
},
}

outcomes, err := v.Land(context.Background(), job)
require.NoError(t, err)
require.Len(t, outcomes, 2)

assert.Equal(t, "q1/10", outcomes[0].RequestID)
assert.Equal(t, "q1/11", outcomes[1].RequestID)
assert.False(t, outcomes[0].AlreadyExisted)
assert.False(t, outcomes[1].AlreadyExisted)

// Each outcome has a unique commit SHA.
assert.Len(t, outcomes[0].CommitSHAs, 1)
assert.Len(t, outcomes[1].CommitSHAs, 1)
assert.NotEqual(t, outcomes[0].CommitSHAs[0], outcomes[1].CommitSHAs[0])
}

func TestNoopVCS_Land_Empty(t *testing.T) {
v := New()
job := entity.Job{Items: []entity.JobItem{}}

outcomes, err := v.Land(context.Background(), job)
require.NoError(t, err)
assert.Empty(t, outcomes)
}
Loading