-
Notifications
You must be signed in to change notification settings - Fork 591
chore(ci): add automatic rerun controller for flaky workflows #2984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+87
−0
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f320ec4
ci: add automatic rerun controller for flaky workflows
contrueCT af40258
ci: refine auto rerun controller policy
contrueCT cff1eae
ci: follow source workflow scope for reruns
contrueCT 7daedbc
ci: narrow rerun workflow write scope
contrueCT 16c6d85
ci: reduce retry delay for rerun jobs from 180 to 60 seconds
contrueCT 48d6dda
ci: increase retry delay for rerun jobs from 60 to 180 seconds
contrueCT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| name: "Rerun CI" | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: | ||
| - "HugeGraph-Server CI" | ||
| - "HugeGraph-Commons CI" | ||
| - "HugeGraph-PD & Store & Hstore CI" | ||
| - "Cluster Test CI" | ||
| types: | ||
| - completed | ||
|
|
||
| permissions: {} | ||
|
|
||
| env: | ||
| MAX_RERUNS: '2' | ||
| RETRY_DELAY_SECONDS: '180' | ||
|
|
||
| jobs: | ||
| decide-rerun-action: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| action: ${{ steps.decision.outputs.action }} | ||
| steps: | ||
| - name: Decide rerun action | ||
| id: decision | ||
| env: | ||
| WORKFLOW_NAME: ${{ github.event.workflow_run.name }} | ||
| RUN_ID: ${{ github.event.workflow_run.id }} | ||
| RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }} | ||
| CONCLUSION: ${{ github.event.workflow_run.conclusion }} | ||
| EVENT_NAME: ${{ github.event.workflow_run.event }} | ||
| HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| action="skip" | ||
| reason="non-failure" | ||
|
|
||
| if [[ "$CONCLUSION" == "failure" ]]; then | ||
| if [[ "$EVENT_NAME" != "push" && "$EVENT_NAME" != "pull_request" ]]; then | ||
| reason="unsupported event: $EVENT_NAME" | ||
| elif (( RUN_ATTEMPT > MAX_RERUNS )); then | ||
| reason="retry limit reached" | ||
| else | ||
| action="rerun" | ||
| reason="within retry limit" | ||
| fi | ||
| fi | ||
|
|
||
| { | ||
| echo "action=$action" | ||
| echo "reason=$reason" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| { | ||
| echo "### Rerun CI decision" | ||
| echo "" | ||
| echo "- Workflow: $WORKFLOW_NAME" | ||
| echo "- Source event: $EVENT_NAME" | ||
| echo "- Head branch: $HEAD_BRANCH" | ||
| echo "- Run ID: $RUN_ID" | ||
| echo "- Current attempt: $RUN_ATTEMPT" | ||
| echo "- Max automatic reruns: $MAX_RERUNS" | ||
| echo "- Delay seconds: $RETRY_DELAY_SECONDS" | ||
| echo "- Action: $action" | ||
| echo "- Reason: $reason" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| rerun-failed-jobs: | ||
| needs: decide-rerun-action | ||
| if: needs.decide-rerun-action.outputs.action == 'rerun' | ||
| permissions: | ||
| actions: write | ||
| contents: read | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Wait before rerun | ||
| run: | | ||
| sleep "$RETRY_DELAY_SECONDS" | ||
|
|
||
| - name: Rerun failed jobs | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GH_REPO: ${{ github.repository }} | ||
| run: | | ||
| gh run rerun ${{ github.event.workflow_run.id }} --failed | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.