@@ -333,13 +333,26 @@ jobs:
333
333
steps:
334
334
- run: echo 'wf2-job2'
335
335
`
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
+ `
336
351
337
352
opts1 := getWorkflowCreateFileOptions (user2 , repo .DefaultBranch , fmt .Sprintf ("create %s" , wf1TreePath ), wf1FileContent )
338
353
createWorkflowFile (t , token , user2 .Name , repo .Name , wf1TreePath , opts1 )
339
354
opts2 := getWorkflowCreateFileOptions (user2 , repo .DefaultBranch , fmt .Sprintf ("create %s" , wf2TreePath ), wf2FileContent )
340
355
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)
343
356
344
357
// fetch wf1-job1
345
358
wf1Job1Task := runner1 .fetchTask (t )
@@ -361,10 +374,21 @@ jobs:
361
374
result : runnerv1 .Result_RESULT_SUCCESS ,
362
375
})
363
376
// fetch wf2-job2
364
- wf2Job2Task := runner2 .fetchTask (t )
377
+ wf2Job2Task := runner1 .fetchTask (t )
365
378
_ , wf2Job2ActionJob , _ := getTaskAndJobAndRunByTaskID (t , wf2Job2Task .Id )
366
379
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 ())
368
392
369
393
httpContext := NewAPITestContext (t , user2 .Name , repo .Name , auth_model .AccessTokenScopeWriteRepository )
370
394
doAPIDeleteRepository (httpContext )(t )
0 commit comments