From 96bddabc563fb424d9c7aadd94ef0168011f7f2d Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 10:52:06 +0200 Subject: [PATCH 01/11] WIP --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4066a18eefe2..f8900d1970d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,6 +119,40 @@ jobs: ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && contains(steps.pr-labels.outputs.labels, ' ci-skip-cache ')) }} + + job_can_merge_into_develop: + name: Can Merge Into Develop + needs: job_get_metadata + runs-on: ubuntu-24.04 + # Only run this on PRs against develop + if: github.event_name == 'pull_request' && github.base_ref == 'refs/heads/develop' + steps: + - name: Check out current commit + uses: actions/checkout@v5 + with: + ref: ${{ env.HEAD_COMMIT }} + + - name: Check if master is not ahead of develop + run: | + # Get commit counts: left=develop unique commits, right=master unique commits + COUNTS=$(git rev-list --left-right --count origin/develop...origin/master) + LEFT=$(echo "$COUNTS" | cut -f1) + RIGHT=$(echo "$COUNTS" | cut -f2) + + echo "Commits unique to develop: $LEFT" + echo "Commits unique to master: $RIGHT" + + # Fail if master has commits that develop doesn't have (master is ahead) + if [ "$RIGHT" -gt 0 ]; then + echo "Error: master is ahead of develop by $RIGHT commits" + echo "Please merge master into develop or ensure master is not ahead" + exit 1 + else + echo "✓ master is not ahead of develop" + fi + + + job_build: name: Build needs: job_get_metadata @@ -1168,6 +1202,7 @@ jobs: job_lint, job_check_format, job_circular_dep_check, + job_can_merge_into_develop, ] # Always run this, even if a dependent job failed if: always() From a5c01ca5bbee7650c87ab13b71dd49e92054e393 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 10:55:33 +0200 Subject: [PATCH 02/11] fix? --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f8900d1970d3..e10f8606c7b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -125,7 +125,7 @@ jobs: needs: job_get_metadata runs-on: ubuntu-24.04 # Only run this on PRs against develop - if: github.event_name == 'pull_request' && github.base_ref == 'refs/heads/develop' + if: github.event_name == 'pull_request' && github.base_ref == 'develop' steps: - name: Check out current commit uses: actions/checkout@v5 From 26b7bb632d77640fc1e2e95e3a2e2271ca6a7782 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 10:56:42 +0200 Subject: [PATCH 03/11] fix --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e10f8606c7b6..234990e55541 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,13 +129,12 @@ jobs: steps: - name: Check out current commit uses: actions/checkout@v5 - with: - ref: ${{ env.HEAD_COMMIT }} + - name: Check if master is not ahead of develop run: | # Get commit counts: left=develop unique commits, right=master unique commits - COUNTS=$(git rev-list --left-right --count origin/develop...origin/master) + COUNTS=$(git rev-list --left-right --count develop...master) LEFT=$(echo "$COUNTS" | cut -f1) RIGHT=$(echo "$COUNTS" | cut -f2) From 02909964103d5335cf59eb82bef241e30a521cf2 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 10:58:38 +0200 Subject: [PATCH 04/11] fix fetch? --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 234990e55541..8f48d82f6c07 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,6 +129,9 @@ jobs: steps: - name: Check out current commit uses: actions/checkout@v5 + with: + ref: ${{ env.HEAD_COMMIT }} + fetch-depth: 0 - name: Check if master is not ahead of develop From 807ed97c33ffec9d6ec13c7cb464c1d0ae848bab Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 11:00:55 +0200 Subject: [PATCH 05/11] return instead of exit? --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f48d82f6c07..47bbe42ca2f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -148,7 +148,7 @@ jobs: if [ "$RIGHT" -gt 0 ]; then echo "Error: master is ahead of develop by $RIGHT commits" echo "Please merge master into develop or ensure master is not ahead" - exit 1 + return 1 else echo "✓ master is not ahead of develop" fi From 4a4d8c7e47e8b6394f1ceeb3f443adad5cbaa58a Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 11:34:08 +0200 Subject: [PATCH 06/11] fix git checkout? --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47bbe42ca2f5..f881fe9af264 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -130,10 +130,8 @@ jobs: - name: Check out current commit uses: actions/checkout@v5 with: - ref: ${{ env.HEAD_COMMIT }} fetch-depth: 0 - - name: Check if master is not ahead of develop run: | # Get commit counts: left=develop unique commits, right=master unique commits From 344659004b49d80048ddfc2e3e7d59ad7ea26438 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 11:37:03 +0200 Subject: [PATCH 07/11] use origin --- .github/workflows/build.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f881fe9af264..29f466aa0aa3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,6 +97,8 @@ jobs: - '.github/**' any_code: - '!**/*.md' + any_package_json: + - '**/package.json' - name: Get PR labels id: pr-labels @@ -110,6 +112,7 @@ jobs: is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }} changed_ci: ${{ steps.changed.outputs.workflow == 'true' }} changed_any_code: ${{ steps.changed.outputs.any_code == 'true' }} + changed_any_package_json: ${{ steps.changed.outputs.any_package_json == 'true' }} # When merging into master, or from master is_gitflow_sync: ${{ github.head_ref == 'master' || github.ref == 'refs/heads/master' }} @@ -119,13 +122,14 @@ jobs: ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && contains(steps.pr-labels.outputs.labels, ' ci-skip-cache ')) }} - job_can_merge_into_develop: name: Can Merge Into Develop needs: job_get_metadata runs-on: ubuntu-24.04 - # Only run this on PRs against develop - if: github.event_name == 'pull_request' && github.base_ref == 'develop' + # Only run this on PRs against develop, if any package.json files were changed + if: + github.event_name == 'pull_request' && github.base_ref == 'develop' && + needs.job_get_metadata.outputs.changed_any_package_json == 'true' steps: - name: Check out current commit uses: actions/checkout@v5 @@ -135,7 +139,7 @@ jobs: - name: Check if master is not ahead of develop run: | # Get commit counts: left=develop unique commits, right=master unique commits - COUNTS=$(git rev-list --left-right --count develop...master) + COUNTS=$(git rev-list --left-right --count origin/develop...origin/master) LEFT=$(echo "$COUNTS" | cut -f1) RIGHT=$(echo "$COUNTS" | cut -f2) @@ -151,8 +155,6 @@ jobs: echo "✓ master is not ahead of develop" fi - - job_build: name: Build needs: job_get_metadata From d4836b8f380021c014696241c94e94b15f1f1bb9 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 11:37:10 +0200 Subject: [PATCH 08/11] change any package.json --- packages/core/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/package.json b/packages/core/package.json index 51207a92bc13..cdec161c7887 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -57,7 +57,8 @@ "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", "test": "vitest run", "test:watch": "vitest --watch", - "yalc:publish": "yalc publish --push --sig" + "yalc:publish": "yalc publish --push --sig", + "test-change": "change" }, "volta": { "extends": "../../package.json" From 77111b4f822d7036356f569396f05a41bd777d80 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 11:42:08 +0200 Subject: [PATCH 09/11] check for prepare release --- .github/workflows/build.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29f466aa0aa3..9a56418dfb2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -122,6 +122,10 @@ jobs: ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && contains(steps.pr-labels.outputs.labels, ' ci-skip-cache ')) }} + # If you change package.json files and merge them into develop while a release is pending, + # There will often be merge conflicts when GitFlow merges master into develop. + # To avoid this, this job checks for this and fails if it detects it. + # Make sure to re-run this after the release is completed & GitFlow syncs master into develop job_can_merge_into_develop: name: Can Merge Into Develop needs: job_get_metadata @@ -155,6 +159,15 @@ jobs: echo "✓ master is not ahead of develop" fi + - name: Check is prepare release PR is open + run: | + if gh pr list --json headRefName | jq -r '.[].headRefName' | grep -q "^prepare-release"; then + echo "Error: prepare release PR is open" + return 1 + else + echo "✓ prepare release PR is not open" + fi + job_build: name: Build needs: job_get_metadata From d4525908bfb5416d41c5e76baa8d2971ab921a50 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 11:45:38 +0200 Subject: [PATCH 10/11] Revert "change any package.json" This reverts commit d4836b8f380021c014696241c94e94b15f1f1bb9. --- packages/core/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index cdec161c7887..51207a92bc13 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -57,8 +57,7 @@ "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", "test": "vitest run", "test:watch": "vitest --watch", - "yalc:publish": "yalc publish --push --sig", - "test-change": "change" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" From 68d8a55961fd2e033c3125aa87ae93291c190cd3 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Sep 2025 11:49:20 +0200 Subject: [PATCH 11/11] rename it --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a56418dfb2f..599d15e87101 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,8 +126,8 @@ jobs: # There will often be merge conflicts when GitFlow merges master into develop. # To avoid this, this job checks for this and fails if it detects it. # Make sure to re-run this after the release is completed & GitFlow syncs master into develop - job_can_merge_into_develop: - name: Can Merge Into Develop + job_check_gitflow: + name: Check Gitflow needs: job_get_metadata runs-on: ubuntu-24.04 # Only run this on PRs against develop, if any package.json files were changed @@ -159,7 +159,7 @@ jobs: echo "✓ master is not ahead of develop" fi - - name: Check is prepare release PR is open + - name: Check if prepare release PR is open run: | if gh pr list --json headRefName | jq -r '.[].headRefName' | grep -q "^prepare-release"; then echo "Error: prepare release PR is open" @@ -1217,7 +1217,7 @@ jobs: job_lint, job_check_format, job_circular_dep_check, - job_can_merge_into_develop, + job_check_gitflow, ] # Always run this, even if a dependent job failed if: always()