Skip to content

Commit 308686a

Browse files
committed
feat(build): add noop BuildManager implementation
## Summary Adds `extension/build/noop`, the first implementation of the `build.BuildManager` interface. It performs no real work: `Trigger` hands back a unique build ID and `BuildStatusSucceeded` without contacting any provider, `Status` always reports succeeded, and `Cancel`/`Close` are no-ops. An atomic counter generates unique IDs and keeps the type safe for concurrent use. Intended as a stub for wiring tests and as a best-case baseline where every build passes instantly — mirrors the role of `extension/conflict/none` for the conflict analyzer. ## Test Plan - ✅ \`make gazelle && make fmt && make lint\` - ✅ \`make check-gazelle && make check-tidy\` - ✅ \`bazel test //extension/build/noop/...\` ## Issues (none)
1 parent 39d6643 commit 308686a

3 files changed

Lines changed: 149 additions & 0 deletions

File tree

extension/build/noop/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "noop",
5+
srcs = ["noop.go"],
6+
importpath = "github.com/uber/submitqueue/extension/build/noop",
7+
visibility = ["//visibility:public"],
8+
deps = [
9+
"//entity",
10+
"//extension/build",
11+
],
12+
)
13+
14+
go_test(
15+
name = "noop_test",
16+
srcs = ["noop_test.go"],
17+
embed = [":noop"],
18+
deps = [
19+
"//entity",
20+
"//extension/build",
21+
"@com_github_stretchr_testify//assert",
22+
"@com_github_stretchr_testify//require",
23+
],
24+
)

extension/build/noop/noop.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2025 Uber Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package noop provides a build.BuildManager that performs no real work:
16+
// every triggered build immediately succeeds. It is intended as a stub for
17+
// wiring tests and as a best-case baseline where every build passes.
18+
package noop
19+
20+
import (
21+
"context"
22+
"fmt"
23+
"sync/atomic"
24+
25+
"github.com/uber/submitqueue/entity"
26+
"github.com/uber/submitqueue/extension/build"
27+
)
28+
29+
// manager is a build.BuildManager that does no real work and reports every
30+
// build as immediately succeeded. The atomic counter hands out unique build
31+
// IDs and makes the type safe for concurrent use.
32+
type manager struct {
33+
counter atomic.Uint64
34+
}
35+
36+
// New returns a build.BuildManager that performs no real work.
37+
func New() build.BuildManager {
38+
return &manager{}
39+
}
40+
41+
// Trigger returns a unique build ID and BuildStatusSucceeded without
42+
// contacting any provider. Inputs are ignored.
43+
func (m *manager) Trigger(_ context.Context, _ string, _ []entity.BuildChange) (string, entity.BuildStatus, error) {
44+
return fmt.Sprintf("noop-%d", m.counter.Add(1)), entity.BuildStatusSucceeded, nil
45+
}
46+
47+
// Status always reports BuildStatusSucceeded with no metadata.
48+
func (m *manager) Status(_ context.Context, _ string) (entity.BuildStatus, entity.BuildMetadata, error) {
49+
return entity.BuildStatusSucceeded, nil, nil
50+
}
51+
52+
// Cancel is a no-op.
53+
func (m *manager) Cancel(_ context.Context, _ string) error {
54+
return nil
55+
}
56+
57+
// Close is a no-op.
58+
func (m *manager) Close() error {
59+
return nil
60+
}

extension/build/noop/noop_test.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) 2025 Uber Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package noop
16+
17+
import (
18+
"context"
19+
"testing"
20+
21+
"github.com/stretchr/testify/assert"
22+
"github.com/stretchr/testify/require"
23+
"github.com/uber/submitqueue/entity"
24+
"github.com/uber/submitqueue/extension/build"
25+
)
26+
27+
func TestNew_ImplementsInterface(t *testing.T) {
28+
var _ build.BuildManager = New()
29+
}
30+
31+
func TestManager_Trigger(t *testing.T) {
32+
m := New()
33+
ctx := context.Background()
34+
35+
id1, status, err := m.Trigger(ctx, "queueA", []entity.BuildChange{
36+
{Action: entity.ChangeActionValidate},
37+
})
38+
require.NoError(t, err)
39+
assert.NotEmpty(t, id1)
40+
assert.Equal(t, entity.BuildStatusSucceeded, status)
41+
42+
// IDs are unique across calls, even with no changes.
43+
id2, _, err := m.Trigger(ctx, "queueA", nil)
44+
require.NoError(t, err)
45+
assert.NotEqual(t, id1, id2)
46+
}
47+
48+
func TestManager_Status(t *testing.T) {
49+
m := New()
50+
51+
status, meta, err := m.Status(context.Background(), "any-id")
52+
require.NoError(t, err)
53+
assert.Equal(t, entity.BuildStatusSucceeded, status)
54+
assert.Empty(t, meta)
55+
}
56+
57+
func TestManager_Cancel(t *testing.T) {
58+
m := New()
59+
assert.NoError(t, m.Cancel(context.Background(), "any-id"))
60+
}
61+
62+
func TestManager_Close(t *testing.T) {
63+
m := New()
64+
assert.NoError(t, m.Close())
65+
}

0 commit comments

Comments
 (0)