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
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 = [
"//platform/base/change",
"//platform/base/mergestrategy",
"//runway/entity",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)
65 changes: 65 additions & 0 deletions runway/extension/vcs/noop/noop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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 no-op VCS implementation for local development and
// testing. CheckMergeability always reports success; Land produces synthetic
// output IDs from an atomic counter.
package noop

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

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

var _ vcs.VCS = (*VCS)(nil)

// VCS is a no-op implementation that always succeeds.
type VCS struct {
seq atomic.Uint64
}

// New returns a new no-op VCS instance.
func New() *VCS { return &VCS{} }

func (v *VCS) CheckMergeability(_ context.Context, req entity.MergeRequest) (entity.MergeResult, error) {
steps := make([]entity.StepResult, len(req.Steps))
for i, s := range req.Steps {
steps[i] = entity.StepResult{StepID: s.StepID}
}
return entity.MergeResult{
ID: req.ID,
Success: true,
Steps: steps,
}, nil
}

func (v *VCS) Land(_ context.Context, req entity.MergeRequest) (entity.MergeResult, error) {
steps := make([]entity.StepResult, len(req.Steps))
for i, s := range req.Steps {
n := v.seq.Add(1)
steps[i] = entity.StepResult{
StepID: s.StepID,
OutputIDs: []string{fmt.Sprintf("%040x", n)},
}
}
return entity.MergeResult{
ID: req.ID,
Success: true,
Steps: steps,
}, nil
}
91 changes: 91 additions & 0 deletions runway/extension/vcs/noop/noop_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// 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/platform/base/change"
"github.com/uber/submitqueue/platform/base/mergestrategy"
"github.com/uber/submitqueue/runway/entity"
)

func testRequest() entity.MergeRequest {
return entity.MergeRequest{
ID: "queue-a/42",
QueueName: "queue-a",
Steps: []entity.MergeStep{
{
StepID: "queue-a/1",
Changes: []change.Change{{URIs: []string{"github://uber/repo/pull/1/abcdef0123456789abcdef0123456789abcdef01"}}},
Strategy: mergestrategy.MergeStrategyRebase,
},
{
StepID: "queue-a/2",
Changes: []change.Change{{URIs: []string{"github://uber/repo/pull/2/89abcdef0123456789abcdef0123456789abcdef"}}},
Strategy: mergestrategy.MergeStrategyMerge,
},
},
}
}

func TestCheckMergeability(t *testing.T) {
v := New()
req := testRequest()

res, err := v.CheckMergeability(context.Background(), req)
require.NoError(t, err)

assert.Equal(t, req.ID, res.ID)
assert.True(t, res.Success)
require.Len(t, res.Steps, 2)
assert.Equal(t, "queue-a/1", res.Steps[0].StepID)
assert.Empty(t, res.Steps[0].OutputIDs)
assert.Equal(t, "queue-a/2", res.Steps[1].StepID)
assert.Empty(t, res.Steps[1].OutputIDs)
}

func TestLand(t *testing.T) {
v := New()
req := testRequest()

res, err := v.Land(context.Background(), req)
require.NoError(t, err)

assert.Equal(t, req.ID, res.ID)
assert.True(t, res.Success)
require.Len(t, res.Steps, 2)
assert.Equal(t, "queue-a/1", res.Steps[0].StepID)
require.Len(t, res.Steps[0].OutputIDs, 1)
assert.NotEmpty(t, res.Steps[0].OutputIDs[0])
assert.Equal(t, "queue-a/2", res.Steps[1].StepID)
require.Len(t, res.Steps[1].OutputIDs, 1)
assert.NotEmpty(t, res.Steps[1].OutputIDs[0])
}

func TestLand_UniqueOutputIDs(t *testing.T) {
v := New()
req := testRequest()

res1, err := v.Land(context.Background(), req)
require.NoError(t, err)
res2, err := v.Land(context.Background(), req)
require.NoError(t, err)

assert.NotEqual(t, res1.Steps[0].OutputIDs[0], res2.Steps[0].OutputIDs[0])
}
Loading