@@ -55,6 +55,7 @@ class Status:
5555 ERROR = "error"
5656 FAILURE = "failure"
5757
58+
5859class Workflow_builds (DeclEnum ):
5960 """Define GitHub Action workflow build names."""
6061
@@ -497,12 +498,12 @@ def schedule_test(gh_commit, commit, test_type, branch="master", pr_nr=0) -> Non
497498 branch = "pull_request"
498499
499500 if gh_commit is not None :
500- for platform_name in [ TestPlatform . linux . value , TestPlatform . windows . value ] :
501+ for platform in TestPlatform :
501502 try :
502503 gh_commit .post (
503504 state = Status .PENDING ,
504505 description = "Waiting for actions to complete" ,
505- context = f"CI - { platform_name } " ,
506+ context = f"CI - { platform . value } " ,
506507 )
507508 except ApiError as a :
508509 log .critical (f'Could not post to GitHub! Response: { a .response } ' )
@@ -529,12 +530,12 @@ def deschedule_test(gh_commit, commit, test_type, message="Tests have been cance
529530 from run import log
530531
531532 if gh_commit is not None :
532- for platform_name in [ TestPlatform . linux . value , TestPlatform . windows . value ] :
533+ for platform in TestPlatform :
533534 try :
534535 gh_commit .post (
535536 state = state ,
536537 description = message ,
537- context = f"CI - { platform_name } " ,
538+ context = f"CI - { platform . value } " ,
538539 )
539540 except ApiError as a :
540541 log .critical (f'Could not post to GitHub! Response: { a .response } ' )
@@ -576,12 +577,12 @@ def queue_test(db, gh_commit, commit, test_type, branch="master", pr_nr=0) -> No
576577 Test .pr_nr == pr_nr
577578 )).first ()
578579 windows_test = Test .query .filter (and_ (Test .platform == TestPlatform .windows ,
579- Test .commit == commit ,
580- Test .fork_id == fork .id ,
581- Test .test_type == test_type ,
582- Test .branch == branch ,
583- Test .pr_nr == pr_nr
584- )).first ()
580+ Test .commit == commit ,
581+ Test .fork_id == fork .id ,
582+ Test .test_type == test_type ,
583+ Test .branch == branch ,
584+ Test .pr_nr == pr_nr
585+ )).first ()
585586 add_customized_regression_tests (linux_test .id )
586587 add_customized_regression_tests (windows_test .id )
587588
@@ -761,7 +762,7 @@ def start_ci():
761762 description = "Tests cancelled" ,
762763 context = f"CI - { test .platform .value } " ,
763764 target_url = url_for ('test.by_id' , test_id = test .id , _external = True )
764- )
765+ )
765766
766767 elif event == "issues" :
767768 g .log .debug ('issues event detected' )
@@ -843,7 +844,7 @@ def start_ci():
843844 actor = payload ['sender' ]['login' ],
844845 branch = payload ['workflow_run' ]['head_branch' ]
845846 )['workflow_runs' ]:
846- if workflow ['head_sha' ] == payload [ 'workflow_run' ][ 'head_sha' ] :
847+ if workflow ['head_sha' ] == commit_hash :
847848 if workflow ['status' ] == "completed" :
848849 if workflow ['conclusion' ] != "success" :
849850 has_failed = True
@@ -861,11 +862,12 @@ def start_ci():
861862 deschedule_test (github_status , commit_hash , TestType .commit ,
862863 message = "Cancelling tests as Github Action(s) failed" )
863864 elif is_complete :
864- if payload ['workflow_run' ]['event' ]== "pull_request" :
865+ if payload ['workflow_run' ]['event' ] == "pull_request" :
865866 # In case of pull request run tests of only if it is still in open state
866867 for pull_request in repository .pulls .get (state = "open" ):
867- if pull_request ['head' ]['sha' ]== payload ['workflow_run' ]['head_sha' ] and any (builds .values ()):
868- queue_test (g .db , github_status , commit_hash , TestType .pull_request , pr_nr = pull_request ['number' ])
868+ if pull_request ['head' ]['sha' ] == commit_hash and any (builds .values ()):
869+ queue_test (g .db , github_status , commit_hash ,
870+ TestType .pull_request , pr_nr = pull_request ['number' ])
869871 elif any (builds .values ()):
870872 queue_test (g .db , github_status , commit_hash , TestType .commit )
871873 else :
0 commit comments