Skip to content
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

feat: log-merge-group-failure #28799

Merged
merged 12 commits into from
Dec 11, 2024
18 changes: 18 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ jobs:
name: Run tests
uses: ./.github/workflows/run-tests.yml

wait-for-circleci-workflow-status:
name: Wait for CircleCI workflow status
uses: ./.github/workflows/wait-for-circleci-workflow-status.yml

all-jobs-completed:
name: All jobs completed
runs-on: ubuntu-latest
needs:
- check-workflows
- run-tests
- wait-for-circleci-workflow-status
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
Expand All @@ -58,3 +63,16 @@ jobs:
if [[ $passed != "true" ]]; then
exit 1
fi

log-merge-group-failure:
name: Log merge group failure
# Only run this job if the merge group event fails, skip on forks
if: ${{ github.event_name == 'merge_group' && failure() && !github.event.repository.fork }}
needs:
- all-jobs-pass
uses: metamask/github-tools/.github/workflows/log-merge-group-failure.yml@157864e9ccff308a89d670c3e1a47199a3cc2507
itsyoboieltr marked this conversation as resolved.
Show resolved Hide resolved
secrets:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
SPREADSHEET_ID: ${{ secrets.GOOGLE_MERGE_QUEUE_SPREADSHEET_ID }}
SHEET_NAME: ${{ secrets.GOOGLE_MERGE_QUEUE_SHEET_NAME }}
30 changes: 30 additions & 0 deletions .github/workflows/wait-for-circleci-workflow-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Wait for CircleCI workflow status

on:
workflow_call:

jobs:
wait-for-circleci-workflow-status:
name: Wait for CircleCI workflow status
runs-on: ubuntu-latest
steps:
- name: Wait for CircleCI workflow status
env:
OWNER: ${{ github.repository_owner }}
REPOSITORY: ${{ github.event.repository.name }}
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
pipeline_id=$(curl --silent "https://circleci.com/api/v2/project/gh/$OWNER/$REPOSITORY/pipeline?branch=$BRANCH" | jq -r ".items[0].id")
workflow_status=$(curl --silent "https://circleci.com/api/v2/pipeline/$pipeline_id/workflow" | jq -r ".items[0].status")

if [ "$workflow_status" == "running" ]; then
while [ "$workflow_status" == "running" ]; do
sleep 30
workflow_status=$(curl --silent "https://circleci.com/api/v2/pipeline/$pipeline_id/workflow" | jq -r ".items[0].status")
done
fi

if [ "$workflow_status" != "success" ]; then
echo "::error::Workflow status is '$workflow_status'. Exiting with error."
exit 1
fi
Loading