@@ -17,7 +17,6 @@ import (
1717 repo_model "code.gitea.io/gitea/models/repo"
1818 "code.gitea.io/gitea/models/unittest"
1919 user_model "code.gitea.io/gitea/models/user"
20- "code.gitea.io/gitea/modules/queue"
2120 "code.gitea.io/gitea/modules/setting"
2221 api "code.gitea.io/gitea/modules/structs"
2322 "code.gitea.io/gitea/modules/timeutil"
@@ -1220,70 +1219,6 @@ jobs:
12201219 })
12211220}
12221221
1223- // TestScheduleConcurrencyBlockedRunStaysBlocked verifies that a run blocked solely by
1224- // run-level concurrency is not unblocked by the job-status resolver while another run
1225- // still holds the same concurrency group.
1226- func TestScheduleConcurrencyBlockedRunStaysBlocked (t * testing.T ) {
1227- onGiteaRun (t , func (t * testing.T , u * url.URL ) {
1228- user2 := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : 2 })
1229- session := loginUser (t , user2 .Name )
1230- token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository , auth_model .AccessTokenScopeWriteUser )
1231-
1232- apiRepo := createActionsTestRepo (t , token , "actions-concurrency" , false )
1233- repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : apiRepo .ID })
1234- httpContext := NewAPITestContext (t , user2 .Name , repo .Name , auth_model .AccessTokenScopeWriteRepository )
1235- defer doAPIDeleteRepository (httpContext )(t )
1236-
1237- runner := newMockRunner ()
1238- runner .registerAsRepoRunner (t , user2 .Name , repo .Name , "mock-runner" , []string {"ubuntu-latest" }, false )
1239-
1240- wfTreePath := ".gitea/workflows/schedule-concurrency.yml"
1241- wfFileContent := `name: schedule-concurrency
1242- on:
1243- push:
1244- schedule:
1245- - cron: '@every 1m'
1246- concurrency:
1247- group: schedule-concurrency
1248- cancel-in-progress: ${{ gitea.event_name == 'push' }}
1249- jobs:
1250- job:
1251- runs-on: ubuntu-latest
1252- steps:
1253- - run: echo 'schedule workflow'
1254- `
1255- opts := getWorkflowCreateFileOptions (user2 , repo .DefaultBranch , "create " + wfTreePath , wfFileContent )
1256- createWorkflowFile (t , token , user2 .Name , repo .Name , wfTreePath , opts )
1257-
1258- // Push run picks up and holds the "schedule-concurrency" group while it runs.
1259- _ = runner .fetchTask (t )
1260-
1261- fireSchedule := func () {
1262- t .Helper ()
1263- spec := unittest .AssertExistsAndLoadBean (t , & actions_model.ActionScheduleSpec {RepoID : repo .ID })
1264- spec .Next = timeutil .TimeStampNow ()
1265- require .NoError (t , actions_model .UpdateScheduleSpec (t .Context (), spec , "next" ))
1266- require .NoError (t , actions_service .StartScheduleTasks (t .Context ()))
1267- }
1268-
1269- // Two schedule triggers: the first creates a Blocked run; the second creates another
1270- // Blocked run and cancels the first (cancel-in-progress is false for schedule, so
1271- // only Waiting/Blocked are cancelled). The cancellation queues EmitJobsIfReadyByRun
1272- // and drives the resolver against the surviving Blocked run.
1273- fireSchedule ()
1274- fireSchedule ()
1275- require .NoError (t , queue .GetManager ().FlushAll (t .Context (), 15 * time .Second ))
1276-
1277- blockedRuns , err := db .Find [actions_model.ActionRun ](t .Context (), actions_model.FindRunOptions {
1278- RepoID : repo .ID ,
1279- TriggerEvent : webhook_module .HookEventSchedule ,
1280- Status : []actions_model.Status {actions_model .StatusBlocked },
1281- })
1282- require .NoError (t , err )
1283- require .Len (t , blockedRuns , 1 )
1284- })
1285- }
1286-
12871222func TestWorkflowAndJobConcurrency (t * testing.T ) {
12881223 onGiteaRun (t , func (t * testing.T , u * url.URL ) {
12891224 user2 := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : 2 })
0 commit comments