1010 - main
1111 paths :
1212 - ' scripts/**'
13+ workflow_dispatch :
14+ inputs :
15+ package_filter :
16+ description : ' Filter packages to test (regex, e.g., "boost|cmake|llvm")'
17+ required : false
18+ type : string
19+ default : ' '
20+ max_packages :
21+ description : ' Maximum number of packages to test'
22+ required : false
23+ type : string
24+ default : ' 5'
1325
1426jobs :
1527 detect-changes :
@@ -26,14 +38,21 @@ jobs:
2638 - name : Detect changed packages
2739 id : detect
2840 run : |
41+ MAX_PACKAGES="${{ inputs.max_packages || '5' }}"
42+ PACKAGE_FILTER="${{ inputs.package_filter || '' }}"
43+
2944 # Get the base branch for comparison
3045 if [ "${{ github.event_name }}" = "pull_request" ]; then
3146 BASE="${{ github.event.pull_request.base.sha }}"
47+ elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
48+ BASE="origin/master"
3249 else
3350 BASE="origin/master"
3451 fi
3552
3653 echo "Comparing against: $BASE"
54+ echo "Max packages to test: $MAX_PACKAGES"
55+ echo "Package filter: ${PACKAGE_FILTER:-none}"
3756
3857 # Find changed package directories
3958 CHANGED_DIRS=$(git diff --name-only $BASE HEAD | grep '^scripts/' | cut -d'/' -f1-3 | sort -u)
@@ -51,24 +70,42 @@ jobs:
5170 # Convert to JSON array of {name, version} objects
5271 PACKAGES="["
5372 FIRST=true
73+ COUNT=0
5474 while IFS= read -r dir; do
5575 if [ -d "$dir" ] && [ -f "$dir/script.sh" ]; then
5676 PACKAGE_NAME=$(echo "$dir" | cut -d'/' -f2)
5777 PACKAGE_VERSION=$(echo "$dir" | cut -d'/' -f3)
5878
79+ # Apply filter if provided
80+ if [ -n "$PACKAGE_FILTER" ]; then
81+ if ! echo "$PACKAGE_NAME" | grep -E "$PACKAGE_FILTER" > /dev/null; then
82+ echo "Skipping $PACKAGE_NAME (doesn't match filter)"
83+ continue
84+ fi
85+ fi
86+
87+ # Check max packages limit
88+ if [ "$COUNT" -ge "$MAX_PACKAGES" ]; then
89+ echo "Reached max packages limit ($MAX_PACKAGES), stopping"
90+ break
91+ fi
92+
5993 if [ "$FIRST" = true ]; then
6094 FIRST=false
6195 else
6296 PACKAGES="${PACKAGES},"
6397 fi
6498
6599 PACKAGES="${PACKAGES}{\"name\":\"${PACKAGE_NAME}\",\"version\":\"${PACKAGE_VERSION}\"}"
100+ COUNT=$((COUNT + 1))
101+ echo "Will test: $PACKAGE_NAME $PACKAGE_VERSION"
66102 fi
67103 done <<< "$CHANGED_DIRS"
68104 PACKAGES="${PACKAGES}]"
69105
70106 echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
71- echo "Packages to test: $PACKAGES"
107+ echo "Total packages to test: $COUNT"
108+ echo "Packages JSON: $PACKAGES"
72109
73110 test-linux :
74111 needs : detect-changes
0 commit comments