Skip to content

Commit 9ca6d64

Browse files
committed
simplify change detection logic
1 parent eb7ab68 commit 9ca6d64

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

.github/workflows/pr-checks.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,21 @@ jobs:
4242
4343
# Initialize array to track changed libraries
4444
CHANGED_LIBS=()
45-
46-
# Check if core library has changes
47-
if echo "$CHANGED_FILES" | grep -q "^libs/core/"; then
48-
echo "✓ Core library has changes"
49-
CHANGED_LIBS+=("core")
50-
fi
51-
52-
# Check if public_health library has changes
53-
if echo "$CHANGED_FILES" | grep -q "^libs/public_health/"; then
54-
echo "✓ Public health library has changes"
55-
CHANGED_LIBS+=("public_health")
56-
fi
45+
# Get all directories under libs/
46+
ALL_LIBS=$(find libs -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)
47+
echo "All libraries found: $ALL_LIBS"
5748
5849
# Check for root-level changes that affect all libraries
5950
if echo "$CHANGED_FILES" | grep -qE "^(pyproject.toml|Makefile|setup.sh)$"; then
6051
echo "✓ Root-level files changed, testing all libraries"
61-
CHANGED_LIBS=("core" "public_health")
52+
CHANGED_LIBS=($ALL_LIBS)
53+
else
54+
for lib in $ALL_LIBS; do
55+
if echo "$CHANGED_FILES" | grep -q "^libs/${lib}/"; then
56+
echo "✓ Library '${lib}' has changes"
57+
CHANGED_LIBS+=("${lib}")
58+
fi
59+
done
6260
fi
6361
6462
# Create matrix JSON with library and python-version combinations
@@ -67,15 +65,13 @@ jobs:
6765
echo "matrix={\"include\":[]}" >> $GITHUB_OUTPUT
6866
echo "has-changes=false" >> $GITHUB_OUTPUT
6967
else
70-
# Remove duplicates
71-
UNIQUE_LIBS=($(echo "${CHANGED_LIBS[@]}" | tr ' ' '\n' | sort -u))
7268
73-
echo "Building matrix for libraries: ${UNIQUE_LIBS[@]}"
69+
echo "Building matrix for libraries: ${CHANGED_LIBS[@]}"
7470
7571
# Build matrix with library and python-version combinations
7672
MATRIX_INCLUDE="["
7773
FIRST=true
78-
for lib in "${UNIQUE_LIBS[@]}"; do
74+
for lib in "${CHANGED_LIBS[@]}"; do
7975
# Read python versions from the library's python_versions.json
8076
PYTHON_VERSIONS=$(cat "libs/${lib}/python_versions.json" | jq -r '.[]')
8177

0 commit comments

Comments
 (0)