From 3d70d87b57d88439f8a71c522cb8ba66d62aab82 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 17 Sep 2024 21:46:03 +0200 Subject: [PATCH] [ticket/17396] Split merge check to master to separate yml file PHPBB-17396 --- .github/workflows/check_merge_to_master.yml | 59 ++++++++++++++++++++ .github/workflows/tests.yml | 61 --------------------- 2 files changed, 59 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/check_merge_to_master.yml diff --git a/.github/workflows/check_merge_to_master.yml b/.github/workflows/check_merge_to_master.yml new file mode 100644 index 0000000000..045436ef94 --- /dev/null +++ b/.github/workflows/check_merge_to_master.yml @@ -0,0 +1,59 @@ +name: Check merge to master + +on: + pull_request_target: + types: [ opened, synchronize, reopened ] + branches: + - 3.3.x + +jobs: + merge-check: + if: github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == '3.3.x' + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Ensure full history is fetched + + - name: Set up Git user + run: | + git config --global user.name "github-actions" + git config --global user.email "github-actions@github.com" + + - name: Fetch all branches + run: git fetch origin + + - name: Simulate merging PR into 3.3.x + id: simulate_merge + run: | + git checkout 3.3.x + git merge --no-ff ${{ github.event.pull_request.head.sha }} || exit 1 + + - name: Attempt to merge updated 3.3.x into master + id: merge_master + run: | + git checkout master + if git merge --no-ff origin/3.3.x --no-commit; then + echo "mergeable=true" >> $GITHUB_OUTPUT + else + echo "mergeable=false" >> $GITHUB_OUTPUT + git merge --abort + fi + + - name: Post comment on PR + if: always() # Ensure this step always runs, regardless of merge result + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body: | + The attempt to merge branch `3.3.x` into `master` has completed after considering the changes in this PR. + + - Merge result: ${{ steps.merge_master.outputs.mergeable == 'true' && 'Success ✅' || 'Conflict ❌' }} + + ${{ steps.merge_master.outputs.mergeable == 'true' && 'This PR is ready to be merged.' || 'A separate PR will be needed to merge `3.3.x` into `master`.' }} + + - name: Mark job as succeeded + if: always() + run: echo "Merge check completed. Ignoring the result to avoid failed status." diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 36cc997d8b..893c4c4a28 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,16 +13,10 @@ on: - 3.3.x - master - 'prep-release-*' - pull_request_target: - types: [ opened, synchronize, reopened ] - branches: - - 3.3.x - - master jobs: # Basic checks, e.g. parse errors, commit messages, etc. basic-checks: - if: github.event_name != 'pull_request_target' runs-on: ubuntu-22.04 strategy: matrix: @@ -94,7 +88,6 @@ jobs: # Tests for MySQL and MariaDB mysql-tests: - if: github.event_name != 'pull_request_target' runs-on: ubuntu-22.04 strategy: matrix: @@ -238,7 +231,6 @@ jobs: # Tests for PostgreSQL postgres-tests: - if: github.event_name != 'pull_request_target' runs-on: ubuntu-22.04 strategy: matrix: @@ -359,7 +351,6 @@ jobs: # Other database types, namely sqlite3 and mssql other-tests: - if: github.event_name != 'pull_request_target' runs-on: ubuntu-22.04 strategy: matrix: @@ -463,7 +454,6 @@ jobs: # Test with IIS & PostgreSQL on Windows windows-tests: - if: github.event_name != 'pull_request_target' runs-on: windows-latest strategy: matrix: @@ -606,54 +596,3 @@ jobs: if: ${{ matrix.type == 'functional' }} run: | phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --group functional - - merge-check: - if: github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == '3.3.x' - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Ensure full history is fetched - - - name: Set up Git user - run: | - git config --global user.name "github-actions" - git config --global user.email "github-actions@github.com" - - - name: Fetch all branches - run: git fetch origin - - - name: Simulate merging PR into 3.3.x - id: simulate_merge - run: | - git checkout 3.3.x - git merge --no-ff ${{ github.event.pull_request.head.sha }} || exit 1 - - - name: Attempt to merge updated 3.3.x into master - id: merge_master - run: | - git checkout master - if git merge --no-ff origin/3.3.x --no-commit; then - echo "mergeable=true" >> $GITHUB_OUTPUT - else - echo "mergeable=false" >> $GITHUB_OUTPUT - git merge --abort - fi - - - name: Post comment on PR - if: always() # Ensure this step always runs, regardless of merge result - uses: peter-evans/create-or-update-comment@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - issue-number: ${{ github.event.pull_request.number }} - body: | - The attempt to merge branch `3.3.x` into `master` has completed after considering the changes in this PR. - - - Merge result: ${{ steps.merge_master.outputs.mergeable == 'true' && 'Success ✅' || 'Conflict ❌' }} - - ${{ steps.merge_master.outputs.mergeable == 'false' && 'A separate PR will be needed to merge `3.3.x` into `master`.' || 'This PR is ready to be merged.' }} - - - name: Mark job as succeeded - if: always() - run: echo "Merge check completed. Ignoring the result to avoid failed status."