fountainhead / action-wait-for-check

A GitHub Action that waits for another Check Run to have completed
MIT License
122 stars 44 forks source link

Check exits before artifacts from job are available #23

Open rkleinman-hpe opened 2 years ago

rkleinman-hpe commented 2 years ago

I am using this action to determine when another workflow finishes so I can download artifacts from it. When the workflow finishes and this action exits cleanly, it appears as though the artifacts are not ready and the workflow fails saying that the artifact doesn't exist.

Is there a way around this? I realize this might not be this action's responsibility. Perhaps the API is showing the run as complete before the artifacts are available? Is there a way for this action to check for that?

lihop commented 2 years ago

I came across this when I had two runs with the same commit but on different branches. For example, after merging a feature branch to the main branch.

2022-05-07-003451_952x163_scrot 2022-05-07-003438_925x270_scrot

Notice how it says 'Retrieved 2 check runs named Build Docker (release, 64)'. I think it is detecting the success of this check for run #80, even though this check has not finished in run #81, so the artifacts are not yet available for download in that run.

My workaround is to add the run number to the job name to make it unique:

name: 'Build Docker (${{ matrix.target }}, ${{ matrix.bits }}) #${{ github.run_number }}'
checkName: 'Build Docker (release, ${{ matrix.bits }}) #${{ github.run_number }}'
bakoontz2 commented 2 years ago

I think the problem is that listForRef() in poll.tx is called without a delay, and the check status from the previous event is being returned. I proposed a solution in #32 and have been testing it, and it appears to behave more consistently now by not immediately returning a "completed" status when it's first called. I submitted a pull request as well, so you can look at the proposed fix. (I'm horrible at JS/TS, so there might be a more graceful way to do this.)