File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -228,22 +228,28 @@ jobs:
228228 id : count_tests
229229 run : |
230230 git fetch origin main:main
231+ new_tests=0
231232
232233 # Get list of changed test files
233- changed_files=$(git diff --name-only main...HEAD | grep -E '.*\.(spec|test)\.(ts|tsx|js|jsx)$' || true)
234+ for file in $(git diff --name-only main...HEAD | grep -E '^tests/suites/.*\.(spec|test)\.(ts|tsx|js|jsx)$'); do
235+ # Count tests in current version
236+ if git show HEAD:"$file" > /dev/null 2>&1; then
237+ current_tests=$(git show HEAD:"$file" | grep -E "test\([\'\"]" | wc -l)
238+ else
239+ current_tests=0
240+ fi
234241
235- # Count new test cases
236- new_tests=0
237- for file in $changed_files; do
238- if git show HEAD:$file > /dev/null 2>&1; then
239- new_cases=$(git show HEAD:$file | grep -E "it[\( ][\"\']" | wc -l || true)
240- base_cases=$(git show main:$file 2>/dev/null | grep -E "it[\( ][\"\']" | wc -l || true)
241- ((new_tests += new_cases - base_cases))
242+ # Count tests in main version
243+ if git show main:"$file" > /dev/null 2>&1; then
244+ base_tests=$(git show main:"$file" | grep -E "test\([\'\"]" | wc -l)
242245 else
243- # If file is completely new, count all test cases
244- new_tests+=$(git show HEAD:$file | grep -E "it[\( ][\"\']" | wc -l || true)
246+ base_tests=0
245247 fi
248+
249+ # Add difference to total
250+ ((new_tests += current_tests - base_tests))
246251 done
252+
247253 echo "new_tests=$new_tests" >> $GITHUB_OUTPUT
248254
249255 - name : Update PR description
You can’t perform that action at this time.
0 commit comments