Skip to content

Commit

Permalink
chore: trigger pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif committed Feb 6, 2025
1 parent 85da2b3 commit dd2f47b
Showing 1 changed file with 73 additions and 22 deletions.
95 changes: 73 additions & 22 deletions .github/workflows/temp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,78 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout Repo 🛎
uses: actions/checkout@v4

- name: Test
run: |
echo "test1"
# Bash script run
if ! command -v git > /dev/null 2>&1
then
echo "git could not be found"
exit 0
fi
if ! command -v grep > /dev/null 2>&1
then
echo "grep could not be found"
- name: Checkout Repo 🛎
uses: actions/checkout@v4

- name: Check only affected modules 🎯
run: |
# Bash script run
if ! command -v git > /dev/null 2>&1
then
echo "git could not be found"
exit 0
fi
if ! command -v grep > /dev/null 2>&1
then
echo "grep could not be found"
exit 0
fi
if ! command -v sed > /dev/null 2>&1
then
echo "sed could not be found"
exit 0
fi
# Exit early if tag is on commit message even if it set to true
test_all=$( git log -1 --pretty=%B | grep -F "[run-all-tests]" )
if [ -z "$test_all" ]
then {
echo "Last commit message forces to test everything."
exit 0
fi
if ! command -v sed > /dev/null 2>&1
then
echo "sed could not be found"
} fi
test_dir="tests/testthat/"
# Get the list of R files that have changed
# https://github.com/cloudnativeto/envoy/blob/de67446fa8af973761bb4716f5143d73643baf8b/.github/workflows/get_build_targets.sh_bak#L9
files=$(git diff --name-only HEAD FETCH_HEAD -- $test_dir R/*.R)
if [ -n "$files" ]
then {
echo "No R files affected: test everything."
exit 0
fi
echo "test1"
shell: bash
} fi
# Loop through each modified file and determine which tests to run
for file in $files; do
# Extract the base name of the file, examples:
# tests/testthat/test-shinytest2-foo.R -> foo
# R/foo.R -> foo
base_name=$(basename "$file" .R | sed s/test-shinytest2-//g)
# Find matching test files (parenthesis to not match arguments)
test_files=$(grep -l "$base_name(" "$test_dir"test-shinytest2-*.R)
td=$TESTING_DEPTH
# Modify in place so that only modified modules are tested.
if [ -n "$test_files" ] && [ -z "$test_all" ];
then {
sed -i 's/skip_if_too_deep(5)/skip_if_too_deep(3)/g' "$test_files"
TESTING_DEPTH=3
echo "Testing with shinytest2 for $test_files";
} else {
# Flag for helpers
helper_modified="yes"
git restore $test_dir
echo "Run all tests"
break;
} fi
# R file without corresponding test file: reset the testing depth
if [ -n "$helper_modified" ] || [ -n "$test_all" ];
then {
echo "Skip step or helper modifications detected."
TESTING_DEPTH=$td;
} fi
done
shell: bash

0 comments on commit dd2f47b

Please sign in to comment.