diff --git a/.github/workflows/dependabot-auto-merge.yaml b/.github/workflows/dependabot-auto-merge.yaml index 6ba9e86da..c77af2267 100644 --- a/.github/workflows/dependabot-auto-merge.yaml +++ b/.github/workflows/dependabot-auto-merge.yaml @@ -1,5 +1,9 @@ name: Dependabot auto-merge -on: pull_request +on: + pull_request: + pull_request_review: + check_suite: + types: [completed] permissions: contents: write @@ -9,17 +13,56 @@ jobs: dependabot: runs-on: ubuntu-latest if: | - github.event.pull_request.user.login == 'dependabot[bot]' && - github.event.pull_request.base.ref == 'main' + (github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.base.ref == 'main') || + (github.event_name == 'pull_request_review' && github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.base.ref == 'main') || + (github.event_name == 'check_suite' && github.event.check_suite.pull_requests[0] != null && startsWith(github.event.check_suite.head_branch, 'dependabot/')) steps: -# - name: Dependabot metadata -# id: metadata -# uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0 -# with: -# github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Get PR details + id: pr + run: | + if [ "${{ github.event_name }}" = "check_suite" ]; then + PR_NUMBER="${{ github.event.check_suite.pull_requests[0].number }}" + if [ -z "$PR_NUMBER" ] || [ "$PR_NUMBER" = "null" ] || ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then + echo "No valid PR number found in check_suite event (got: $PR_NUMBER)" + exit 1 + fi + PR_JSON=$(gh pr view "$PR_NUMBER" --repo "${{ github.repository }}" --json author,baseRefName) + AUTHOR=$(echo "$PR_JSON" | jq -r '.author.login') + BASE_REF=$(echo "$PR_JSON" | jq -r '.baseRefName') + + { + echo "author=$AUTHOR" + echo "base_ref=$BASE_REF" + echo "number=$PR_NUMBER" + } >> "$GITHUB_OUTPUT" + else + { + echo "author=${{ github.event.pull_request.user.login }}" + echo "base_ref=${{ github.event.pull_request.base.ref }}" + echo "number=${{ github.event.pull_request.number }}" + } >> "$GITHUB_OUTPUT" + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Enable auto-merge for Dependabot PRs - run: gh pr merge --auto --merge "$PR_URL" + if: steps.pr.outputs.author == 'dependabot[bot]' && steps.pr.outputs.base_ref == 'main' + run: | + # Attempt to enable auto-merge. The gh CLI doesn't provide structured error codes, + # so we must parse error messages. Common expected errors: + # - "auto-merge is already enabled" - auto-merge was already set + # - "not authorized for this protected branch" - branch protection requirements not yet met + # - "Required status checks" - waiting for CI checks to pass + # - "Required approving review" - waiting for approval + if ! gh pr merge --auto --merge "${{ steps.pr.outputs.number }}" --repo "${{ github.repository }}" 2>&1 | tee /tmp/gh-output.txt; then + if grep -qE "auto-merge is already enabled|not authorized for this protected branch|[Rr]equired.*status.*check|[Rr]equired.*approv" /tmp/gh-output.txt; then + echo "Auto-merge not enabled yet - this is expected when requirements are not met or already enabled" + exit 0 + else + echo "Unexpected error enabling auto-merge:" + cat /tmp/gh-output.txt + exit 1 + fi + fi env: - PR_URL: ${{github.event.pull_request.html_url}} - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Modules/Findjsonnet.cmake b/Modules/Findjsonnet.cmake index 140f72c28..d1d1483f2 100644 --- a/Modules/Findjsonnet.cmake +++ b/Modules/Findjsonnet.cmake @@ -8,8 +8,7 @@ if(JSONNET_EXE) ERROR_QUIET ) string( - REGEX REPLACE - "^.*v([0-9.]+)$" + REGEX REPLACE "^.*v([0-9.]+)$" "\\1" ${CMAKE_FIND_PACKAGE_NAME}_VERSION "${${CMAKE_FIND_PACKAGE_NAME}_VERSION}" @@ -52,8 +51,7 @@ if(${CMAKE_FIND_PACKAGE_NAME}_FOUND) ) # Extract just the install_name (second line of output) string( - REGEX REPLACE - "^[^\n]+\n(.+)$" + REGEX REPLACE "^[^\n]+\n(.+)$" "\\1" _current_install_name "${_install_name_output}" diff --git a/Modules/private/CreateCoverageTargets.cmake b/Modules/private/CreateCoverageTargets.cmake index 8ed970e7f..69078bedd 100644 --- a/Modules/private/CreateCoverageTargets.cmake +++ b/Modules/private/CreateCoverageTargets.cmake @@ -265,8 +265,7 @@ function(_create_coverage_targets_impl) foreach(_gcovr_summary_filter_path IN LISTS _gcovr_summary_filter_paths) string(REGEX REPLACE "/$" "" _gcovr_summary_filter_trimmed "${_gcovr_summary_filter_path}") string( - REGEX REPLACE - [=[([][.^$+*?()|\])]=] + REGEX REPLACE [=[([][.^$+*?()|\])]=] [=[\\\1]=] _gcovr_summary_filter_escaped "${_gcovr_summary_filter_trimmed}" @@ -444,8 +443,7 @@ function(_create_coverage_targets_impl) foreach(_gcovr_filter_path IN LISTS _gcovr_filter_paths) string(REGEX REPLACE "/$" "" _gcovr_filter_trimmed "${_gcovr_filter_path}") string( - REGEX REPLACE - [=[([][.^$+*?()|\])]=] + REGEX REPLACE [=[([][.^$+*?()|\])]=] [=[\\\1]=] _gcovr_filter_escaped "${_gcovr_filter_trimmed}"