1- name : Check for Changes
1+ name : Check if Tests should be Skipped
22
33on :
44 workflow_call :
1111 type : string
1212 excluded-dirs :
1313 required : false
14- type : array
15- default : [ 'docs/**', ' community/**', ' examples/**']
14+ type : string
15+ default : ' docs/**, community/**, examples/**'
1616
1717jobs :
1818 check-changes :
1919 runs-on : ubuntu-latest
2020 outputs :
21- skip_tests : ${{ steps.check_changes.outputs.skip_tests}}
21+ skip_tests : ${{ steps.check_changes.outputs.skip_tests }}
2222
2323 steps :
2424 - name : Checkout code
@@ -27,15 +27,25 @@ jobs:
2727 fetch-depth : 2
2828 ref : ${{ inputs.head-sha }}
2929
30+ - name : Set excluded dirs
31+ id : set_excluded_dirs
32+ run : |
33+ # If excluded-dirs is provided, split by commas and set them as an array
34+ EXCLUDED_DIRS="${{ inputs.excluded-dirs }}"
35+ IFS=',' read -r -a EXCLUDED_DIRS_ARRAY <<< "$EXCLUDED_DIRS"
36+ echo "Excluded directories: ${EXCLUDED_DIRS_ARRAY[@]}"
37+ echo "EXCLUDED_DIRS_ARRAY=${EXCLUDED_DIRS_ARRAY[@]}" >> $GITHUB_ENV
38+
3039 - name : Check for excluded directory changes
31- id : check_changes
40+ id : check_skip_tests
3241 run : |
42+ # Check if any of the changed files are in the excluded directories
3343 CHANGED_FILES=$(git diff --name-only ${{ inputs.base-sha }} ${{ inputs.head-sha }})
3444 echo "Changed files:"
3545 echo "$CHANGED_FILES"
3646
37- # Join the excluded directories into a single pattern
38- EXCLUDE_PATTERN=$(IFS='|'; echo "${{ inputs.excluded-dirs [*] } }")
47+ # Build a regex pattern from the excluded directories
48+ EXCLUDE_PATTERN=$(IFS='|'; echo "${EXCLUDED_DIRS_ARRAY [*]}")
3949
4050 # Check if any changed file matches the exclusion patterns
4151 NON_EXCLUDED_CHANGED=$(echo "$CHANGED_FILES" | grep -Ev "^($EXCLUDE_PATTERN)" || true)
0 commit comments