Skip to content

Commit 9532cfa

Browse files
committed
fix(stovepipe): match reversed BuildRunner.Trigger arg order in backends
1 parent 4e8b5d5 commit 9532cfa

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

stovepipe/extension/buildrunner/buildkite/buildkite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func newRunner(cfg buildrunner.Config, c *platformbuildkite.Client, logger *zap.
106106
// Trigger calls the Buildkite API to create the build and returns the
107107
// Buildkite build number as the build ID. Errors are propagated to the
108108
// caller so the queue consumer can nack and retry.
109-
func (r *runner) Trigger(ctx context.Context, headURI, baseURI string, metadata entity.BuildMetadata) (entity.BuildID, error) {
109+
func (r *runner) Trigger(ctx context.Context, baseURI, headURI string, metadata entity.BuildMetadata) (entity.BuildID, error) {
110110
env := map[string]string{
111111
EnvKeyHeadURI: headURI,
112112
EnvKeyBaseURI: baseURI,

stovepipe/extension/buildrunner/buildkite/buildkite_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestTrigger_SubmitsCorrectPayloadAndReturnsBuildkiteNumber(t *testing.T) {
7979
_, _ = w.Write(buildJSON(42, "scheduled", "https://buildkite.com/test-org/my-pipeline/builds/42"))
8080
}))
8181

82-
id, err := r.Trigger(context.Background(), "github://repo/head/aaa", "github://repo/base/bbb", nil)
82+
id, err := r.Trigger(context.Background(), "github://repo/base/bbb", "github://repo/head/aaa", nil)
8383
require.NoError(t, err)
8484
assert.Equal(t, platformbuildkite.EncodeBuildNumber(42), id.ID)
8585

@@ -100,7 +100,7 @@ func TestTrigger_EmptyBaseURI_FullBuild(t *testing.T) {
100100
_, _ = w.Write(buildJSON(1, "scheduled", ""))
101101
}))
102102

103-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", nil)
103+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", nil)
104104
require.NoError(t, err)
105105

106106
var req platformbuildkite.CreateBuildRequest
@@ -113,7 +113,7 @@ func TestTrigger_BuildkiteError_ReturnsError(t *testing.T) {
113113
w.WriteHeader(http.StatusInternalServerError)
114114
}))
115115

116-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", nil)
116+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", nil)
117117
require.Error(t, err)
118118
}
119119

@@ -126,7 +126,7 @@ func TestTrigger_WithMetadata_SetsEnvVar(t *testing.T) {
126126
}))
127127

128128
metadata := entity.BuildMetadata{"requester": "alice", "ticket": "SQ-42"}
129-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", metadata)
129+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", metadata)
130130
require.NoError(t, err)
131131

132132
var req platformbuildkite.CreateBuildRequest
@@ -146,7 +146,7 @@ func TestTrigger_NilMetadata_NoMetadataEnvVar(t *testing.T) {
146146
_, _ = w.Write(buildJSON(11, "scheduled", ""))
147147
}))
148148

149-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", nil)
149+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", nil)
150150
require.NoError(t, err)
151151

152152
var req platformbuildkite.CreateBuildRequest

stovepipe/extension/buildrunner/githubactions/githubactions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func newRunner(cfg buildrunner.Config, ref string, extraInputs map[string]string
126126
// Trigger dispatches the configured GitHub Actions workflow and returns the
127127
// GitHub workflow run ID as the build ID. Errors are propagated to the caller
128128
// so the queue consumer can nack and retry.
129-
func (r *runner) Trigger(ctx context.Context, headURI, baseURI string, metadata entity.BuildMetadata) (entity.BuildID, error) {
129+
func (r *runner) Trigger(ctx context.Context, baseURI, headURI string, metadata entity.BuildMetadata) (entity.BuildID, error) {
130130
inputs := make(map[string]string, len(r.extraInputs)+4)
131131
for k, v := range r.extraInputs {
132132
inputs[k] = v

stovepipe/extension/buildrunner/githubactions/githubactions_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestTrigger_DispatchesWorkflowAndReturnsRunID(t *testing.T) {
7171
_ = json.NewEncoder(w).Encode(platformgithubactions.DispatchWorkflowResponse{WorkflowRunID: 42})
7272
}))
7373

74-
id, err := r.Trigger(context.Background(), "github://repo/head/aaa", "github://repo/base/bbb", nil)
74+
id, err := r.Trigger(context.Background(), "github://repo/base/bbb", "github://repo/head/aaa", nil)
7575
require.NoError(t, err)
7676
assert.Equal(t, platformgithubactions.EncodeRunID(42), id.ID)
7777

@@ -95,7 +95,7 @@ func TestTrigger_EmptyBaseURI_FullBuild(t *testing.T) {
9595
_ = json.NewEncoder(w).Encode(platformgithubactions.DispatchWorkflowResponse{WorkflowRunID: 1})
9696
}))
9797

98-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", nil)
98+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", nil)
9999
require.NoError(t, err)
100100

101101
var req platformgithubactions.DispatchWorkflowRequest
@@ -108,7 +108,7 @@ func TestTrigger_DispatchError_ReturnsError(t *testing.T) {
108108
w.WriteHeader(http.StatusInternalServerError)
109109
}))
110110

111-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", nil)
111+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", nil)
112112
require.Error(t, err)
113113
}
114114

@@ -117,7 +117,7 @@ func TestTrigger_ErrorsWhenDispatchResponseHasNoRunID(t *testing.T) {
117117
_ = json.NewEncoder(w).Encode(platformgithubactions.DispatchWorkflowResponse{})
118118
}))
119119

120-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", nil)
120+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", nil)
121121
require.Error(t, err)
122122
assert.Contains(t, err.Error(), "response missing workflow_run_id")
123123
}
@@ -130,7 +130,7 @@ func TestTrigger_WithMetadata_SetsInput(t *testing.T) {
130130
}))
131131

132132
metadata := entity.BuildMetadata{"requester": "alice", "ticket": "SQ-42"}
133-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", metadata)
133+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", metadata)
134134
require.NoError(t, err)
135135

136136
var req platformgithubactions.DispatchWorkflowRequest
@@ -149,7 +149,7 @@ func TestTrigger_NilMetadata_NoMetadataInput(t *testing.T) {
149149
_ = json.NewEncoder(w).Encode(platformgithubactions.DispatchWorkflowResponse{WorkflowRunID: 11})
150150
}))
151151

152-
_, err := r.Trigger(context.Background(), "github://repo/head/aaa", "", nil)
152+
_, err := r.Trigger(context.Background(), "", "github://repo/head/aaa", nil)
153153
require.NoError(t, err)
154154

155155
var req platformgithubactions.DispatchWorkflowRequest

0 commit comments

Comments
 (0)