From c8643f7d64da7fa64fc8bd869dc9dc94ad223c43 Mon Sep 17 00:00:00 2001 From: Danny Meijer <10511979+dannymeijer@users.noreply.github.com> Date: Fri, 7 Jun 2024 11:19:17 +0200 Subject: [PATCH] fix for workflow --- .github/workflows/test.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 62eb51a..5aae361 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,17 +47,20 @@ jobs: # Set the base reference for the git diff BASE_REF=${{ github.event.pull_request.base.ref || 'main' }} - # Check for changes in Python or TOML files - python_changed=$(git diff --name-only $BASE_REF ${{ github.event.after }} | grep '\.py$') - toml_changed=$(git diff --name-only $BASE_REF ${{ github.event.after }} | grep '\.toml$') + # Check for changes in this PR / commit + git_diff_output=$(git diff --name-only $BASE_REF ${{ github.event.after }}) + + # Count the number of changes to Python and TOML files + python_changed=$(echo "$git_diff_output" | grep '\.py$' | wc -l) + toml_changed=$(echo "$git_diff_output" | grep '\.toml$' | wc -l) # Write the changes to the GITHUB_OUTPUT environment file - echo "python_changed=$python_changed" >> "$GITHUB_OUTPUT" - echo "toml_changed=$toml_changed" >> "$GITHUB_OUTPUT" + echo "python_changed=$python_changed" >> $GITHUB_OUTPUT + echo "toml_changed=$toml_changed" >> $GITHUB_OUTPUT tests: needs: check_changes - if: needs.check_changes.outputs.python_changed != '' || needs.check_changes.outputs.toml_changed != '' || github.event_name == 'workflow_dispatch' + if: needs.check_changes.outputs.python_changed > 0 || needs.check_changes.outputs.toml_changed > 0 || github.event_name == 'workflow_dispatch' name: Python ${{ matrix.python-version }} with PySpark ${{ matrix.pyspark-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} runs-on: ${{ matrix.os }}