@@ -333,13 +333,26 @@ jobs:
333333 steps:
334334 - run: echo 'wf2-job2'
335335`
336+ wf3TreePath := ".gitea/workflows/concurrent-workflow-3.yml"
337+ wf3FileContent := `name: concurrent-workflow-3
338+ on:
339+ push:
340+ paths:
341+ - '.gitea/workflows/concurrent-workflow-3.yml'
342+ jobs:
343+ wf3-job1:
344+ runs-on: runner1
345+ concurrency:
346+ group: job-main-${{ vars.version_var }}
347+ cancel-in-progress: ${{ vars.version_var == 'v1.23.0' }}
348+ steps:
349+ - run: echo 'wf3-job1'
350+ `
336351
337352 opts1 := getWorkflowCreateFileOptions (user2 , repo .DefaultBranch , fmt .Sprintf ("create %s" , wf1TreePath ), wf1FileContent )
338353 createWorkflowFile (t , token , user2 .Name , repo .Name , wf1TreePath , opts1 )
339354 opts2 := getWorkflowCreateFileOptions (user2 , repo .DefaultBranch , fmt .Sprintf ("create %s" , wf2TreePath ), wf2FileContent )
340355 createWorkflowFile (t , token , user2 .Name , repo .Name , wf2TreePath , opts2 )
341- // opts3 := getWorkflowCreateFileOptions(user2, repo.DefaultBranch, fmt.Sprintf("create %s", wf3TreePath), wf3FileContent)
342- // createWorkflowFile(t, token, user2.Name, repo.Name, wf3TreePath, opts3)
343356
344357 // fetch wf1-job1
345358 wf1Job1Task := runner1 .fetchTask (t )
@@ -361,10 +374,21 @@ jobs:
361374 result : runnerv1 .Result_RESULT_SUCCESS ,
362375 })
363376 // fetch wf2-job2
364- wf2Job2Task := runner2 .fetchTask (t )
377+ wf2Job2Task := runner1 .fetchTask (t )
365378 _ , wf2Job2ActionJob , _ := getTaskAndJobAndRunByTaskID (t , wf2Job2Task .Id )
366379 assert .Equal (t , "job-main-v1.23.0" , wf2Job2ActionJob .ConcurrencyGroup )
367- assert .True (t , wf1Job1ActionJob .Status .IsRunning ())
380+ assert .True (t , wf2Job2ActionJob .Status .IsRunning ())
381+ // push workflow3 to trigger wf3-job1
382+ opts3 := getWorkflowCreateFileOptions (user2 , repo .DefaultBranch , fmt .Sprintf ("create %s" , wf3TreePath ), wf3FileContent )
383+ createWorkflowFile (t , token , user2 .Name , repo .Name , wf3TreePath , opts3 )
384+ // fetch wf3-job1
385+ wf3Job1Task := runner1 .fetchTask (t )
386+ _ , wf3Job1ActionJob , _ := getTaskAndJobAndRunByTaskID (t , wf3Job1Task .Id )
387+ assert .Equal (t , "job-main-v1.23.0" , wf3Job1ActionJob .ConcurrencyGroup )
388+ assert .True (t , wf3Job1ActionJob .Status .IsRunning ())
389+ // wf2-job2 has been cancelled
390+ _ , wf2Job2ActionJob , _ = getTaskAndJobAndRunByTaskID (t , wf2Job2Task .Id )
391+ assert .True (t , wf2Job2ActionJob .Status .IsCancelled ())
368392
369393 httpContext := NewAPITestContext (t , user2 .Name , repo .Name , auth_model .AccessTokenScopeWriteRepository )
370394 doAPIDeleteRepository (httpContext )(t )
0 commit comments