From 0bce14d9cb16f7003f9303603b525c4f6a8c90fc Mon Sep 17 00:00:00 2001 From: Hannah Pho Date: Mon, 11 Nov 2024 23:30:57 -0500 Subject: [PATCH] Make stable branch commit check clearer (#4727) # Summary - Include remediation instructions in error message. - Rename check file to "Release branch checks" (release-branch-checks.yml) - This makes the prefix of the check where it's listed on a PR non-redundant, and also sets us up to potentially have more checks in there in the future. - I've called it "Release branch checks" instead of "Custom DC stable branch checks" because technically the same checks would apply if we ever wanted to use release branches for website prod and staging. - Rename job to "verify_all_commits_are_already_in_master" so the name makes sense on its own. Also, update version of checkout action to one that isn't about to be deprecated. # Screenshots ## On PR ![on PR](https://github.com/user-attachments/assets/af0e842c-19ae-485f-8d76-4e43f6e1db83) ## After clicking through from PR ![after clicking through from PR](https://github.com/user-attachments/assets/4d68bf54-f8b5-4146-8a55-bc2183cfab31) ## In Actions tab ![in actions tab](https://github.com/user-attachments/assets/f44d3bc4-a0a8-4350-bd80-236d9c0928a7) ## After clicking through from Actions tab ![after clicking through from actions tab](https://github.com/user-attachments/assets/113e4093-0f6d-4005-a64f-7f6eaa0663c3) --- ...its-in-master.yml => release-branch-checks.yml} | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) rename .github/workflows/{all-commits-in-master.yml => release-branch-checks.yml} (58%) diff --git a/.github/workflows/all-commits-in-master.yml b/.github/workflows/release-branch-checks.yml similarity index 58% rename from .github/workflows/all-commits-in-master.yml rename to .github/workflows/release-branch-checks.yml index 8ff834082a..1baef5e409 100644 --- a/.github/workflows/all-commits-in-master.yml +++ b/.github/workflows/release-branch-checks.yml @@ -1,14 +1,14 @@ -name: all-commits-in-master +name: Release branch checks on: pull_request: branches: [ "customdc_stable" ] jobs: - check_commits: + verify_all_commits_are_already_in_master: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # Fetch all history for accurate comparison fetch-depth: 0 @@ -16,7 +16,7 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} - - name: Check if commits exist in master + - name: Verify that all commits are already in the master branch run: | git remote add dc https://github.com/datacommonsorg/website.git git fetch dc @@ -26,8 +26,14 @@ jobs: MISSING_COMMITS=$(git log --pretty="%H - %s" $MASTER_BRANCH..HEAD --) if [[ -n "$MISSING_COMMITS" ]]; then + echo "" echo "ERROR: The following commits are not present in $MASTER_BRANCH:" + echo "" echo "$MISSING_COMMITS" + echo "" + echo "PRs to release branches should only contain commits that are already in master." + echo "To fix this PR, reset its branch locally to a commit at or behind https://github.com/datacommonsorg/website/commits/master/ and then force-push it." + echo "Note that a release branch PR should be based on master and not the previous version of the release branch, which contains merge commits." exit 1 fi