@@ -45,7 +45,7 @@ const (
4545)
4646
4747// simpleRepo simulates a test repo with the config files required to run a workflow
48- func simpleRepo () map [string ]string {
48+ func simpleRepo (useCLI bool ) map [string ]string {
4949 return map [string ]string {
5050 "BUILD" : `
5151sh_binary(
@@ -57,6 +57,7 @@ sh_binary(
5757 "buildbuddy.yaml" : `
5858actions:
5959 - name: "Test action"
60+ use_cli: ` + strconv .FormatBool (useCLI ) + `
6061 triggers: { push: { branches: [ master ] } }
6162 bazel_commands: [ "build //:nop" ]
6263 os: ` + runtime .GOOS + `
@@ -80,6 +81,7 @@ sh_binary(
8081 "buildbuddy.yaml" : `
8182actions:
8283 - name: "Slow test action"
84+ use_cli: false
8385 triggers: { push: { branches: [ master ] } }
8486 bazel_commands: [ "run //:sleep_forever_test" ]
8587 os: ` + runtime .GOOS + `
@@ -278,38 +280,42 @@ func actionCount(t *testing.T, inv *inpb.Invocation) int {
278280}
279281
280282func TestTriggerViaWebhook (t * testing.T ) {
281- fakeGitProvider := testgit .NewFakeProvider ()
282- env , workflowService := setup (t , fakeGitProvider )
283- bb := env .GetBuildBuddyServiceClient ()
284-
285- repoContentsMap := simpleRepo ()
286- repoPath , commitSHA := makeRepo (t , repoContentsMap )
287- repoURL := fmt .Sprintf ("file://%s" , repoPath )
288-
289- ctx := env .WithUserID (context .Background (), env .UserID1 )
290- reqCtx := & ctxpb.RequestContext {
291- UserId : & uidpb.UserId {Id : env .UserID1 },
292- GroupId : env .GroupID1 ,
293- }
294- repo := createWorkflow (t , env , repoURL )
283+ for _ , useCLI := range []bool {false } {
284+ t .Run (fmt .Sprintf ("use_cli=%t" , useCLI ), func (t * testing.T ) {
285+ fakeGitProvider := testgit .NewFakeProvider ()
286+ env , workflowService := setup (t , fakeGitProvider )
287+ bb := env .GetBuildBuddyServiceClient ()
288+
289+ repoContentsMap := simpleRepo (useCLI )
290+ repoPath , commitSHA := makeRepo (t , repoContentsMap )
291+ repoURL := fmt .Sprintf ("file://%s" , repoPath )
292+
293+ ctx := env .WithUserID (context .Background (), env .UserID1 )
294+ reqCtx := & ctxpb.RequestContext {
295+ UserId : & uidpb.UserId {Id : env .UserID1 },
296+ GroupId : env .GroupID1 ,
297+ }
298+ repo := createWorkflow (t , env , repoURL )
295299
296- triggerWebhook (t , ctx , fakeGitProvider , workflowService , repo , repoContentsMap , repoURL , commitSHA )
300+ triggerWebhook (t , ctx , fakeGitProvider , workflowService , repo , repoContentsMap , repoURL , commitSHA )
297301
298- iid := waitForAnyWorkflowInvocationCreated (t , ctx , bb , reqCtx )
299- inv := waitForInvocationStatus (t , ctx , bb , reqCtx , iid , inspb .InvocationStatus_COMPLETE_INVOCATION_STATUS )
302+ iid := waitForAnyWorkflowInvocationCreated (t , ctx , bb , reqCtx )
303+ inv := waitForInvocationStatus (t , ctx , bb , reqCtx , iid , inspb .InvocationStatus_COMPLETE_INVOCATION_STATUS )
300304
301- require .True (t , inv .GetSuccess (), "workflow invocation should succeed" )
302- require .Equal (t , repoURL , inv .GetRepoUrl ())
303- require .Equal (t , commitSHA , inv .GetCommitSha ())
304- require .Equal (t , "CI_RUNNER" , inv .GetRole ())
305+ require .True (t , inv .GetSuccess (), "workflow invocation should succeed" )
306+ require .Equal (t , repoURL , inv .GetRepoUrl ())
307+ require .Equal (t , commitSHA , inv .GetCommitSha ())
308+ require .Equal (t , "CI_RUNNER" , inv .GetRole ())
309+ })
310+ }
305311}
306312
307313func TestTriggerLegacyWorkflowViaWebhook (t * testing.T ) {
308314 fakeGitProvider := testgit .NewFakeProvider ()
309315 env , workflowService := setup (t , fakeGitProvider )
310316 bb := env .GetBuildBuddyServiceClient ()
311317
312- repoContentsMap := simpleRepo ()
318+ repoContentsMap := simpleRepo (false )
313319 repoPath , commitSHA := makeRepo (t , repoContentsMap )
314320 repoURL := fmt .Sprintf ("file://%s" , repoPath )
315321
@@ -345,11 +351,11 @@ func TestTriggerLegacyWorkflowViaWebhook(t *testing.T) {
345351
346352func TestExecuteWorkflow (t * testing.T ) {
347353 fakeGitProvider := testgit .NewFakeProvider ()
348- fakeGitProvider .FileContents = simpleRepo ()
354+ fakeGitProvider .FileContents = simpleRepo (false /*useCLI*/ )
349355 env , wfService := setup (t , fakeGitProvider )
350356 bb := env .GetBuildBuddyServiceClient ()
351357
352- repoPath , commitSHA := makeRepo (t , simpleRepo ())
358+ repoPath , commitSHA := makeRepo (t , simpleRepo (false /*useCLI*/ ))
353359 repoURL := fmt .Sprintf ("file://%s" , repoPath )
354360 ctx := env .WithUserID (context .Background (), env .UserID1 )
355361 reqCtx := & ctxpb.RequestContext {
0 commit comments