Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run shinytests2 only if the modules are affected #273

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
62dee69
Add script to change testing depth of some tests
llrs-roche Jan 28, 2025
aff016a
Look up for only R or tests files (not vignettes, CI/CD or dependencies)
llrs-roche Jan 31, 2025
c142c72
Reorganize code
llrs-roche Jan 31, 2025
7f5ed65
Merge branch 'main' into 580_module_tests@main
llrs-roche Jan 31, 2025
7c1c12b
Add chekout action to be on the package repository
llrs-roche Jan 31, 2025
58fa831
Merge branch '580_module_tests@main' of https://github.com/insightsen…
llrs-roche Jan 31, 2025
dcaedbf
Add emoji
llrs-roche Jan 31, 2025
efdc03b
Reset to the previous TESTING_DEPTH
llrs-roche Jan 31, 2025
044ccf6
Uses and run aren't compatible
llrs-roche Feb 3, 2025
161b1c6
Checkout to the right directory
llrs-roche Feb 3, 2025
6e0c72a
Use path instead of working-directory
llrs-roche Feb 3, 2025
9d31c30
Move the working directory where it should be
llrs-roche Feb 3, 2025
25ce19d
Add some more info to help debug what is happening
llrs-roche Feb 3, 2025
b684dfc
Get the default branch of the repository to compare with.
llrs-roche Feb 3, 2025
09dd369
Modify fetch-depth to have also the default branch
llrs-roche Feb 3, 2025
aa02b04
Check other folders
llrs-roche Feb 3, 2025
31e58e7
Fetch all branches
llrs-roche Feb 3, 2025
decb120
Directly fetch the main branch from origin
llrs-roche Feb 3, 2025
8c01893
Print remotes for debugging
llrs-roche Feb 3, 2025
8f4afc7
Change quotes and to pull instead just fetch
llrs-roche Feb 3, 2025
bc4f2db
Add three dots and the branch name.
llrs-roche Feb 3, 2025
eb4b3b3
Fetch the branch specifically
llrs-roche Feb 3, 2025
38b63de
Use only git-diff to compare between branches?
llrs-roche Feb 3, 2025
76cfbf0
Undo changes and finish loop if any helper is modified
llrs-roche Feb 4, 2025
5a5537d
Make it more general for other teal.* packages
llrs-roche Feb 4, 2025
9e129a0
Address comments and provide informative log
llrs-roche Feb 5, 2025
0517564
Add missing subprocess
llrs-roche Feb 5, 2025
f4a1bc8
Fix syntax errors
llrs-roche Feb 5, 2025
65e160d
Further improvements
llrs-roche Feb 5, 2025
642a189
Make it more general and improve logging
llrs-roche Feb 5, 2025
3a58352
Restore only modifications on tests files
llrs-roche Feb 5, 2025
48dcd52
Simplify a bit more
llrs-roche Feb 5, 2025
ab60d1c
Fix when to run this step!
llrs-roche Feb 5, 2025
cd1922d
Use logical/boolean instead of text
llrs-roche Feb 5, 2025
a27ebdf
Run target always not only on pull_requests
llrs-roche Feb 5, 2025
6e0897f
Start from the beginning
llrs-roche Feb 5, 2025
67c43fc
Set the working directory to the package
llrs-roche Feb 6, 2025
38d02c2
Check if main commands are available
llrs-roche Feb 6, 2025
ef84cea
Change output and see what happens
llrs-roche Feb 6, 2025
825ff79
Update description
llrs-roche Feb 6, 2025
577fc84
Change bash
llrs-roche Feb 6, 2025
b843d4e
Fix issue with grep
llrs-roche Feb 6, 2025
dbe3631
Update script to be more informative
llrs-roche Feb 6, 2025
ccc51b3
Revert to head and fetch
llrs-roche Feb 7, 2025
f39761f
Fix path to git diff
llrs-roche Feb 7, 2025
45b3b31
Pull branch before comparing it
llrs-roche Feb 7, 2025
111855d
Pull directly from remote
llrs-roche Feb 7, 2025
bfd6310
setup merging strategy
llrs-roche Feb 7, 2025
ca95d1e
Stash before merging
llrs-roche Feb 7, 2025
abdbb86
Testing external action
llrs-roche Feb 7, 2025
ed42539
fix syntax
llrs-roche Feb 7, 2025
123af45
Modify documentation and path
llrs-roche Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/build-check-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,37 @@ jobs:
path: "${{ inputs.additional-caches }}"
key: additional-caches-${{ runner.os }}

- name: Check only affected modules
if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request'
run: |
# Get the list of files that have changed
files=$(git diff --name-only main..)

# Base directories
src_dir="R/"
test_dir="tests/testthat/"

# Loop through each modified file and determine which tests to run
llrs-roche marked this conversation as resolved.
Show resolved Hide resolved
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
test_files=$(grep -l "$base_name" "$test_dir"test-shinytest2-*.R)

if [ -z "$test_files" ]; then
echo "No test files found for modified file about $base_name."
else
echo "${file} matches ${test_files}"
sed -i 's/skip_if_too_deep(5)/skip_if_too_deep(3)/g' "$test_files"
m7pr marked this conversation as resolved.
Show resolved Hide resolved
fi
done
TESTING_DEPTH=3
m7pr marked this conversation as resolved.
Show resolved Hide resolved
shell: bash

- name: Build R package 🏗
run: |
if [ "${{ inputs.additional-env-vars }}" != "" ]
Expand Down