Skip to content

Commit 62dee69

Browse files
committed
Add script to change testing depth of some tests
1 parent 261b61f commit 62dee69

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/build-check-install.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,37 @@ jobs:
515515
path: "${{ inputs.additional-caches }}"
516516
key: additional-caches-${{ runner.os }}
517517

518+
- name: Check only affected modules
519+
if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request'
520+
run: |
521+
# Get the list of files that have changed
522+
files=$(git diff --name-only main..)
523+
524+
# Base directories
525+
src_dir="R/"
526+
test_dir="tests/testthat/"
527+
528+
# Loop through each modified file and determine which tests to run
529+
for file in $files; do
530+
531+
# Extract the base name of the file, examples:
532+
# tests/testthat/test-shinytest2-foo.R -> foo
533+
# R/foo.R -> foo
534+
base_name=$(basename "$file" .R | sed s/test-shinytest2-//g)
535+
536+
# Find matching test files
537+
test_files=$(grep -l "$base_name" "$test_dir"test-shinytest2-*.R)
538+
539+
if [ -z "$test_files" ]; then
540+
echo "No test files found for modified file about $base_name."
541+
else
542+
echo "${file} matches ${test_files}"
543+
sed -i 's/skip_if_too_deep(5)/skip_if_too_deep(3)/g' "$test_files"
544+
fi
545+
done
546+
TESTING_DEPTH=3
547+
shell: bash
548+
518549
- name: Build R package 🏗
519550
run: |
520551
if [ "${{ inputs.additional-env-vars }}" != "" ]

0 commit comments

Comments
 (0)