From dac13b7fc37b4831c7f4235fe6e35348f6b9a651 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 12 Nov 2024 08:13:33 +0100 Subject: [PATCH] fix(ci): synchronize updates the commit status asynchronously When a new commit is pushed to an existing pull request, the update of the commit status will happen asynchronously, via the git hook. --- FAIL: TestPullRequestCommitStatus/synchronize (2.14s) actions_trigger_test.go:331: Error Trace: /workspace/forgejo/forgejo/tests/integration/actions_trigger_test.go:331 Error: Should be true Test: TestPullRequestCommitStatus/synchronize (cherry picked from commit 983aed4268f6ba6d6bc071d81d9cf61082c71789) --- tests/integration/actions_trigger_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/integration/actions_trigger_test.go b/tests/integration/actions_trigger_test.go index 9cf2d4305f..dfd1f75b3c 100644 --- a/tests/integration/actions_trigger_test.go +++ b/tests/integration/actions_trigger_test.go @@ -328,7 +328,9 @@ jobs: sha, err := baseGitRepo.GetRefCommitID(pr.GetGitRefName()) require.NoError(t, err) // verify the commit status changes to CommitStatusSuccess when the job changes to StatusSuccess - assert.True(t, checkCommitStatus(sha, context, api.CommitStatusPending)) + require.Eventually(t, func() bool { + return checkCommitStatus(sha, context, api.CommitStatusPending) + }, 30*time.Second, 1*time.Second) for _, actionRun := range actionRuns { // verify the expected ActionRunJob was created and is StatusWaiting job := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{RunID: actionRun.ID, CommitSHA: sha}) @@ -339,7 +341,9 @@ jobs: actions_service.CreateCommitStatus(db.DefaultContext, job) } // verify the commit status changed to CommitStatusSuccess because the job(s) changed to StatusSuccess - assert.True(t, checkCommitStatus(sha, context, api.CommitStatusSuccess)) + require.Eventually(t, func() bool { + return checkCommitStatus(sha, context, api.CommitStatusSuccess) + }, 30*time.Second, 1*time.Second) testCase.assert(t, sha, testCase.onType, testCase.action, actionRuns) })