From 2f61f1ab6ac6cc9858c24591560cde24b2c4162f Mon Sep 17 00:00:00 2001 From: peg Date: Wed, 30 Apr 2025 13:26:38 +0200 Subject: [PATCH 1/3] Apply fix suggested by Zach --- .github/workflows/build-and-run-node-test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index abc246b3d..75c20855d 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -10,6 +10,8 @@ jobs: run_tests: ${{ steps.filter.outputs.changes_detected }} steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Check for relevant changes id: filter run: | From 3acc644ca630b984caa00a4cc403199f09495b0d Mon Sep 17 00:00:00 2001 From: Zach Mandeville Date: Thu, 1 May 2025 14:56:49 +1200 Subject: [PATCH 2/3] Add check for the first commit of a branch --- .github/workflows/build-and-run-node-test.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index 75c20855d..78ad04ee0 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -15,7 +15,11 @@ jobs: - name: Check for relevant changes id: filter run: | - if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E "^(node/|crates/|pallets/|runtime/)"; then + ## If this is the first commit on a branch, then the default behaviour of github.event.before is to show the previous ref as + ## repeated zeroes, as the previous ref is null + if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then + echo "changes_detected=true" >> $GITHUB_ENV + elif git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E "^(node/|crates/|pallets/|runtime/)"; then echo "changes_detected=true" >> $GITHUB_ENV else echo "changes_detected=false" >> $GITHUB_ENV From 3f1b0046459deb03bd4f89b0dc0f967dbc8fe875 Mon Sep 17 00:00:00 2001 From: Zach Mandeville Date: Thu, 1 May 2025 22:38:02 +1200 Subject: [PATCH 3/3] remove GITHUB_ENV redirect to simplify job --- .github/workflows/build-and-run-node-test.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index 78ad04ee0..3e44ae6b2 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -18,14 +18,12 @@ jobs: ## If this is the first commit on a branch, then the default behaviour of github.event.before is to show the previous ref as ## repeated zeroes, as the previous ref is null if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then - echo "changes_detected=true" >> $GITHUB_ENV + echo "changes_detected=true" >> $GITHUB_OUTPUT elif git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E "^(node/|crates/|pallets/|runtime/)"; then - echo "changes_detected=true" >> $GITHUB_ENV + echo "changes_detected=true" >> $GITHUB_OUTPUT else - echo "changes_detected=false" >> $GITHUB_ENV + echo "changes_detected=false" >> $GITHUB_OUTPUT fi - - name: Set output - run: echo "changes_detected=${{ env.changes_detected }}" >> $GITHUB_OUTPUT node-test: needs: code-paths-changed