Skip to content

Commit a210b60

Browse files
committed
fix: only run tests if files under problems dir changed
1 parent 7c389fb commit a210b60

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

.github/workflows/presubmit-cpp.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ jobs:
4141
CHANGED_CPP_FILES=$(echo "$CHANGED_FILES" | \
4242
grep -E '\.(cc|cpp|cxx|c\+\+|h|hpp|hxx|h\+\+)$' || true)
4343
44+
# Filter for C++ files specifically in the problems directory
45+
CHANGED_CPP_PROBLEMS_FILES=$(echo "$CHANGED_CPP_FILES" | \
46+
grep -E '^problems/' || true)
47+
4448
# Extract unique problem directories from changed C++ files
45-
CHANGED_PROBLEMS=$(echo "$CHANGED_CPP_FILES" | \
49+
CHANGED_PROBLEMS=$(echo "$CHANGED_CPP_PROBLEMS_FILES" | \
4650
grep -E '^problems/[^/]+/' | cut -d'/' -f2 | \
4751
sort -u | tr '\n' ' ' || true)
4852
@@ -57,13 +61,15 @@ jobs:
5761
5862
echo "Changed C++ files:"
5963
echo "$CHANGED_CPP_FILES"
64+
echo "Changed C++ files in problems/:"
65+
echo "$CHANGED_CPP_PROBLEMS_FILES"
6066
echo "Changed problems: $CHANGED_PROBLEMS"
6167
echo "C++ config changes: $CPP_CONFIG_CHANGES"
6268
echo "Common directory changes: $COMMON_CHANGES"
6369
6470
# Set outputs
6571
echo "changed_problems=$CHANGED_PROBLEMS" >> $GITHUB_OUTPUT
66-
echo "has_cpp_changes=$([ -n "$CHANGED_CPP_FILES" ] && \
72+
echo "has_cpp_changes=$([ -n "$CHANGED_CPP_PROBLEMS_FILES" ] && \
6773
echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
6874
echo "has_cpp_config_changes=$([ -n "$CPP_CONFIG_CHANGES" ] && \
6975
echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
@@ -137,7 +143,7 @@ jobs:
137143
"false" ] && \
138144
[ "${{ steps.detect-changes.outputs.has_common_changes }}" = \
139145
"false" ]; then
140-
echo "- No C++ files changed - skipped all tasks" >> \
146+
echo "- No C++ files in problems/ changed - skipped all tasks" >> \
141147
$GITHUB_STEP_SUMMARY
142148
elif [ "${{ steps.detect-changes.outputs.should_run_all_tests }}" = \
143149
"true" ]; then

.github/workflows/presubmit-python.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ jobs:
4444
CHANGED_PYTHON_FILES=$(echo "$CHANGED_FILES" | \
4545
grep '\.py$' || true)
4646
47+
# Filter for Python files specifically in the problems directory
48+
CHANGED_PYTHON_PROBLEMS_FILES=$(echo "$CHANGED_PYTHON_FILES" | \
49+
grep -E '^problems/' || true)
50+
4751
# Extract unique problem directories from changed Python files
48-
CHANGED_PROBLEMS=$(echo "$CHANGED_PYTHON_FILES" | \
52+
CHANGED_PROBLEMS=$(echo "$CHANGED_PYTHON_PROBLEMS_FILES" | \
4953
grep -E '^problems/[^/]+/' | cut -d'/' -f2 | \
5054
sort -u | tr '\n' ' ' || true)
5155
@@ -55,12 +59,14 @@ jobs:
5559
5660
echo "Changed Python files:"
5761
echo "$CHANGED_PYTHON_FILES"
62+
echo "Changed Python files in problems/:"
63+
echo "$CHANGED_PYTHON_PROBLEMS_FILES"
5864
echo "Changed problems: $CHANGED_PROBLEMS"
5965
echo "Python config changes: $PYTHON_CONFIG_CHANGES"
6066
6167
# Set outputs
6268
echo "changed_problems=$CHANGED_PROBLEMS" >> $GITHUB_OUTPUT
63-
echo "has_python_changes=$([ -n "$CHANGED_PYTHON_FILES" ] && \
69+
echo "has_python_changes=$([ -n "$CHANGED_PYTHON_PROBLEMS_FILES" ] && \
6470
echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
6571
echo "has_python_config_changes=$([ -n "$PYTHON_CONFIG_CHANGES" ] && \
6672
echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
@@ -118,7 +124,7 @@ jobs:
118124
"false" ] && \
119125
[ "${{ steps.detect-changes.outputs.has_python_config_changes }}" \
120126
= "false" ]; then
121-
echo "- No Python files changed - skipped all tasks" >> \
127+
echo "- No Python files in problems/ changed - skipped all tasks" >> \
122128
$GITHUB_STEP_SUMMARY
123129
elif [ "${{ steps.detect-changes.outputs.should_run_all_tests }}" = \
124130
"true" ]; then

0 commit comments

Comments
 (0)