ci: cancel duplicate workflow to reduce CI queue time #4050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: yiyiyimu wosoyoung@gmail.com
What this PR does / why we need it:
We always wait for CI queue time, and we always trying to reduce waiting time. Here is another method to achieve it.
The method is that whenever a new commit added to PR, the previous running CI could be canceled since it is of no use. This could be achieved by using Github API, find the workflow on the same branch but with different SHA. And we could achieve this with potiuk/cancel-workflow-runs which is also used in Apache Airflow.
To bypass the limit of third party Actions, the recommendation provided by Apache Infra is to use submodules.
Since the "cancel" workflow could only be triggered after merged, so I could not test it in this PR. Thus I duplicate the same situation in my own repo, and it works as expect. See Yiyiyimu/GithubActionsTest#5 you could find previous running workflow got cancelled when a new one coming in. Also see https://github.com/Yiyiyimu/GithubActionsTest/runs/2344066993?check_suite_focus=true for cancellation detail.
Pre-submission checklist: