diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2554557b9c35..c7907455701d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -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@6bbad335a01fce1a9ec1eabd9515542c225d46c0 + 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 }} diff --git a/.github/workflows/wait-for-circleci-workflow-status.yml b/.github/workflows/wait-for-circleci-workflow-status.yml new file mode 100644 index 000000000000..18e5ef7825d5 --- /dev/null +++ b/.github/workflows/wait-for-circleci-workflow-status.yml @@ -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