From 62dee6901090954a43183f0256ad0c7e3db81331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 28 Jan 2025 15:42:08 +0100 Subject: [PATCH 01/58] Add script to change testing depth of some tests --- .github/workflows/build-check-install.yaml | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 681b227f..4ef68ca0 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -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 + 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" + fi + done + TESTING_DEPTH=3 + shell: bash + - name: Build R package 🏗 run: | if [ "${{ inputs.additional-env-vars }}" != "" ] From aff016aa6e81a27b7248255414e8ffea1e341816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 31 Jan 2025 11:56:06 +0100 Subject: [PATCH 02/58] Look up for only R or tests files (not vignettes, CI/CD or dependencies) --- .github/workflows/build-check-install.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 4ef68ca0..52d34167 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -518,8 +518,8 @@ jobs: - 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..) + # Get the list of R files that have changed + files=$(git diff --name-only main.. -- tests/* R/*.R) # Base directories src_dir="R/" From c142c72ba0adc3f0498b547e67f8cca4cc819944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 31 Jan 2025 11:59:12 +0100 Subject: [PATCH 03/58] Reorganize code --- .github/workflows/build-check-install.yaml | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 52d34167..d1ec061c 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -532,18 +532,25 @@ jobs: # 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) - # 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}" + # Modify in place so that only modified modules are tested. + if [[ -n "$test_files" ]] + then { sed -i 's/skip_if_too_deep(5)/skip_if_too_deep(3)/g' "$test_files" - fi + TESTING_DEPTH=3 + } else { + # Flag for helpers + helper_modified="yes" + } fi + + # R file without corresponding test file: assume it affects all + if [[ -n "$helper_modified" ]] + then { + TESTING_DEPTH=5 + } fi done - TESTING_DEPTH=3 shell: bash - name: Build R package 🏗 From 7c1c12b94bc18986522e86f39ffd1665dc9d4d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 31 Jan 2025 12:56:57 +0100 Subject: [PATCH 04/58] Add chekout action to be on the package repository --- .github/workflows/build-check-install.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index d1ec061c..9dcee110 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -517,6 +517,7 @@ jobs: - name: Check only affected modules if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' + uses: actions/checkout@v4.1.1 run: | # Get the list of R files that have changed files=$(git diff --name-only main.. -- tests/* R/*.R) From dcaedbfd7dba3aa0158b207b615ce84b03c95421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 31 Jan 2025 14:23:56 +0100 Subject: [PATCH 05/58] Add emoji --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 9dcee110..7fd1192c 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -515,7 +515,7 @@ jobs: path: "${{ inputs.additional-caches }}" key: additional-caches-${{ runner.os }} - - name: Check only affected modules + - name: Check only affected modules 🎯 if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' uses: actions/checkout@v4.1.1 run: | From efdc03b7fa99d31ef8b1dedd90ff6226037bf7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 31 Jan 2025 14:55:37 +0100 Subject: [PATCH 06/58] Reset to the previous TESTING_DEPTH --- .github/workflows/build-check-install.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 7fd1192c..cfe8195d 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -535,6 +535,7 @@ jobs: 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" ]] @@ -546,10 +547,10 @@ jobs: helper_modified="yes" } fi - # R file without corresponding test file: assume it affects all + # R file without corresponding test file: reset the testing depth if [[ -n "$helper_modified" ]] then { - TESTING_DEPTH=5 + TESTING_DEPTH=td } fi done shell: bash From 044ccf654acea43333fcb9a92ebb552162d5e46d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 09:43:27 +0100 Subject: [PATCH 07/58] Uses and run aren't compatible --- .github/workflows/build-check-install.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index cfe8195d..7a4c119f 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -515,9 +515,11 @@ jobs: path: "${{ inputs.additional-caches }}" key: additional-caches-${{ runner.os }} + - name: Setup git checkout ⚙️ + uses: actions/checkout@v4.1.1 + - name: Check only affected modules 🎯 if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' - uses: actions/checkout@v4.1.1 run: | # Get the list of R files that have changed files=$(git diff --name-only main.. -- tests/* R/*.R) From 161b1c659b78bbfda5e3c27a460b7dbc8a086d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 09:57:06 +0100 Subject: [PATCH 08/58] Checkout to the right directory --- .github/workflows/build-check-install.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 7a4c119f..0006b0e8 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -517,6 +517,7 @@ jobs: - name: Setup git checkout ⚙️ uses: actions/checkout@v4.1.1 + working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - name: Check only affected modules 🎯 if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' From 6e0c72a079282699b40597a61961e143dd2857cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 10:03:54 +0100 Subject: [PATCH 09/58] Use path instead of working-directory --- .github/workflows/build-check-install.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 0006b0e8..73457693 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -517,7 +517,8 @@ jobs: - name: Setup git checkout ⚙️ uses: actions/checkout@v4.1.1 - working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} + with: + path: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - name: Check only affected modules 🎯 if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' From 9d31c30ab6a310cfb6d72b3b9b07f15a1f929c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 10:13:46 +0100 Subject: [PATCH 10/58] Move the working directory where it should be --- .github/workflows/build-check-install.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 73457693..0a37978b 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -515,14 +515,16 @@ jobs: path: "${{ inputs.additional-caches }}" key: additional-caches-${{ runner.os }} - - name: Setup git checkout ⚙️ - uses: actions/checkout@v4.1.1 - with: - path: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - - name: Check only affected modules 🎯 if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' run: | + echo pwd + + # Set working directory where the git repo is + cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} + + ls -lh + # Get the list of R files that have changed files=$(git diff --name-only main.. -- tests/* R/*.R) From 25ce19d2f9364d42df240eeb8cbc2a8c6574a351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 10:26:41 +0100 Subject: [PATCH 11/58] Add some more info to help debug what is happening --- .github/workflows/build-check-install.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 0a37978b..1bd4bd9f 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -518,12 +518,13 @@ jobs: - name: Check only affected modules 🎯 if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' run: | - echo pwd - # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} + # Debugging + pwd ls -lh + git branch # Get the list of R files that have changed files=$(git diff --name-only main.. -- tests/* R/*.R) From b684dfc18bba1c6d7269b801deabf60549461787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 10:48:36 +0100 Subject: [PATCH 12/58] Get the default branch of the repository to compare with. --- .github/workflows/build-check-install.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 1bd4bd9f..227ec421 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -515,6 +515,14 @@ jobs: path: "${{ inputs.additional-caches }}" key: additional-caches-${{ runner.os }} + - name: Checkout default branch (PR) ⚙️ + uses: actions/checkout@v4.1.1 + if: github.event_name == 'pull_request' + with: + path: ${{ github.event.repository.name }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + fetch-depth: 1 + - name: Check only affected modules 🎯 if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' run: | From 09dd369c84e53c567f7cbfd1bb8bca2f7b24e85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 11:06:35 +0100 Subject: [PATCH 13/58] Modify fetch-depth to have also the default branch --- .github/workflows/build-check-install.yaml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 227ec421..d7e71d6d 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -297,7 +297,7 @@ jobs: ref: ${{ steps.branch-name.outputs.head_ref_branch }} path: ${{ github.event.repository.name }} repository: ${{ github.event.pull_request.head.repo.full_name }} - fetch-depth: 0 + fetch-depth: 2 - name: Checkout repo 🛎 uses: actions/checkout@v4.1.1 @@ -515,14 +515,6 @@ jobs: path: "${{ inputs.additional-caches }}" key: additional-caches-${{ runner.os }} - - name: Checkout default branch (PR) ⚙️ - uses: actions/checkout@v4.1.1 - if: github.event_name == 'pull_request' - with: - path: ${{ github.event.repository.name }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - fetch-depth: 1 - - name: Check only affected modules 🎯 if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' run: | From aa02b04356650586df1532e20bcc86a30079698f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 11:54:46 +0100 Subject: [PATCH 14/58] Check other folders --- .github/workflows/build-check-install.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index d7e71d6d..55b77179 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -524,7 +524,10 @@ jobs: # Debugging pwd ls -lh + ls -lh .. git branch + git -C .. branch + # Get the list of R files that have changed files=$(git diff --name-only main.. -- tests/* R/*.R) From 31e58e7e82a5f46733c70ed7fd2edacbaa28fc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 12:10:29 +0100 Subject: [PATCH 15/58] Fetch all branches --- .github/workflows/build-check-install.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 55b77179..7fe457e9 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -297,7 +297,7 @@ jobs: ref: ${{ steps.branch-name.outputs.head_ref_branch }} path: ${{ github.event.repository.name }} repository: ${{ github.event.pull_request.head.repo.full_name }} - fetch-depth: 2 + fetch-depth: 0 - name: Checkout repo 🛎 uses: actions/checkout@v4.1.1 @@ -522,12 +522,9 @@ jobs: cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} # Debugging - pwd - ls -lh - ls -lh .. - git branch - git -C .. branch + git fetch --all + git branch # Get the list of R files that have changed files=$(git diff --name-only main.. -- tests/* R/*.R) From decb120db9742081b5bc4f5db835c1c756c4c82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 12:27:56 +0100 Subject: [PATCH 16/58] Directly fetch the main branch from origin --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 7fe457e9..970598dd 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -523,7 +523,7 @@ jobs: # Debugging - git fetch --all + git fetch origin main git branch # Get the list of R files that have changed From 8c0189380ef28b93b1f1803e8d69ef11d147013d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 12:28:58 +0100 Subject: [PATCH 17/58] Print remotes for debugging --- .github/workflows/build-check-install.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 970598dd..91a69402 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -523,6 +523,7 @@ jobs: # Debugging + git remote -v git fetch origin main git branch From 8f4afc7a91d980d32f4a71dc82d6c12b384c8a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 12:48:10 +0100 Subject: [PATCH 18/58] Change quotes and to pull instead just fetch --- .github/workflows/build-check-install.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 91a69402..e1b6211f 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -516,7 +516,7 @@ jobs: key: additional-caches-${{ runner.os }} - name: Check only affected modules 🎯 - if: startsWith(${{ github.event.repository.name }}, "teal.modules.") && github.event_name == 'pull_request' + if: startsWith(${{ github.event.repository.name }}, 'teal.modules.') && github.event_name == 'pull_request' run: | # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} @@ -524,7 +524,7 @@ jobs: # Debugging git remote -v - git fetch origin main + git pull origin main git branch # Get the list of R files that have changed From bc4f2dba21968811f9cc78c12b335858ba6ae8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 14:20:08 +0100 Subject: [PATCH 19/58] Add three dots and the branch name. --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index e1b6211f..e2bf6129 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -528,7 +528,7 @@ jobs: git branch # Get the list of R files that have changed - files=$(git diff --name-only main.. -- tests/* R/*.R) + files=$(git diff --name-only main...${{ github.head_ref }} -- tests/* R/*.R) # Base directories src_dir="R/" From eb4b3b39f9aebdff7ba3830ef65af50464ab5757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 15:00:22 +0100 Subject: [PATCH 20/58] Fetch the branch specifically --- .github/workflows/build-check-install.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index e2bf6129..1bda1b21 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -294,7 +294,6 @@ jobs: uses: actions/checkout@v4.1.1 if: github.event_name == 'pull_request' with: - ref: ${{ steps.branch-name.outputs.head_ref_branch }} path: ${{ github.event.repository.name }} repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 @@ -523,8 +522,8 @@ jobs: # Debugging - git remote -v - git pull origin main + # https://github.com/pylint-dev/pylint/blob/acf7705968da21b0396a6532cd8e8b0f1f8cc806/.github/workflows/changelog.yml#L64 + git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} git branch # Get the list of R files that have changed From 38b63dee0b54d8b50dd360b1b40258feb081ed54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 3 Feb 2025 15:09:16 +0100 Subject: [PATCH 21/58] Use only git-diff to compare between branches? --- .github/workflows/build-check-install.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 1bda1b21..84254225 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -522,12 +522,10 @@ jobs: # Debugging - # https://github.com/pylint-dev/pylint/blob/acf7705968da21b0396a6532cd8e8b0f1f8cc806/.github/workflows/changelog.yml#L64 - git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} - git branch # Get the list of R files that have changed - files=$(git diff --name-only main...${{ github.head_ref }} -- tests/* R/*.R) + # https://github.com/cloudnativeto/envoy/blob/de67446fa8af973761bb4716f5143d73643baf8b/.github/workflows/get_build_targets.sh_bak#L9 + files=$(git diff --name-only HEAD FETCH_HEAD -- tests/* R/*.R) # Base directories src_dir="R/" From 76cfbf0197e36400ff964cfc4a12a93ad9619abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 4 Feb 2025 15:18:27 +0100 Subject: [PATCH 22/58] Undo changes and finish loop if any helper is modified --- .github/workflows/build-check-install.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 84254225..974be44f 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -550,6 +550,8 @@ jobs: } else { # Flag for helpers helper_modified="yes" + git restore . + break } fi # R file without corresponding test file: reset the testing depth From 5a5537dce992cd8321615269049e2d85dfc93f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 4 Feb 2025 15:19:17 +0100 Subject: [PATCH 23/58] Make it more general for other teal.* packages --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 974be44f..b549ddbd 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -515,7 +515,7 @@ jobs: key: additional-caches-${{ runner.os }} - name: Check only affected modules 🎯 - if: startsWith(${{ github.event.repository.name }}, 'teal.modules.') && github.event_name == 'pull_request' + if: startsWith(${{ github.event.repository.name }}, 'teal.') && github.event_name == 'pull_request' run: | # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} From 9e129a00ee1e0ac305013e1edc861ee856cf445b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 11:00:03 +0100 Subject: [PATCH 24/58] Address comments and provide informative log --- .github/workflows/build-check-install.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index b549ddbd..75487d3f 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -246,6 +246,12 @@ on: required: false type: boolean default: false + fast-tests: + description: | + Should shinytests2 tests only run per modified teal module? If enabled if only there is a module modificated only that shinytest2 file will be tested. + required: false + type: string + default: false concurrency: group: r-cmd-${{ inputs.concurrency-group }}-${{ github.event.pull_request.number || github.ref }} @@ -515,13 +521,13 @@ jobs: key: additional-caches-${{ runner.os }} - name: Check only affected modules 🎯 - if: startsWith(${{ github.event.repository.name }}, 'teal.') && github.event_name == 'pull_request' + if: ${{ inputs.fast-tests }} != 'true' && startsWith(${{ github.event.repository.name }}, 'teal.') && github.event_name == 'pull_request' run: | # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - # Debugging + test_all=git log -1 --pretty=%B | grep -F " [run-all-tests] " # Get the list of R files that have changed # https://github.com/cloudnativeto/envoy/blob/de67446fa8af973761bb4716f5143d73643baf8b/.github/workflows/get_build_targets.sh_bak#L9 @@ -543,19 +549,21 @@ jobs: td=$TESTING_DEPTH # Modify in place so that only modified modules are tested. - if [[ -n "$test_files" ]] + if [[ -n "$test_files" && ! -n "$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 . + echo "Run all tests" break } fi # R file without corresponding test file: reset the testing depth - if [[ -n "$helper_modified" ]] + if [[ -n "$helper_modified" || -n "$test_all"]] then { TESTING_DEPTH=td } fi From 05175640c7fe5c517fe8d81053710c06f11f8e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 11:43:34 +0100 Subject: [PATCH 25/58] Add missing subprocess --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 75487d3f..3e40a5a2 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -527,7 +527,7 @@ jobs: cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - test_all=git log -1 --pretty=%B | grep -F " [run-all-tests] " + test_all=$(git log -1 --pretty=%B | grep -F " [run-all-tests] ") # Get the list of R files that have changed # https://github.com/cloudnativeto/envoy/blob/de67446fa8af973761bb4716f5143d73643baf8b/.github/workflows/get_build_targets.sh_bak#L9 From f4a1bc8a01470b92b6a0d5e4a65afc035ae765ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 11:56:56 +0100 Subject: [PATCH 26/58] Fix syntax errors --- .github/workflows/build-check-install.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 3e40a5a2..f6c0fc54 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -549,23 +549,23 @@ jobs: td=$TESTING_DEPTH # Modify in place so that only modified modules are tested. - if [[ -n "$test_files" && ! -n "$test_all"]] + if [[ -n "$test_files" && ! -n "$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" + echo "Testing with shinytest2 for $test_files"; } else { # Flag for helpers helper_modified="yes" git restore . echo "Run all tests" - break + break; } fi # R file without corresponding test file: reset the testing depth - if [[ -n "$helper_modified" || -n "$test_all"]] + if [[ -n "$helper_modified" || -n "$test_all" ]]; then { - TESTING_DEPTH=td + TESTING_DEPTH=td; } fi done shell: bash From 65e160d697587e5bfbcb157272e847356ebe9a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 12:15:32 +0100 Subject: [PATCH 27/58] Further improvements --- .github/workflows/build-check-install.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index f6c0fc54..af1a9428 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -534,7 +534,6 @@ jobs: files=$(git diff --name-only HEAD FETCH_HEAD -- tests/* R/*.R) # Base directories - src_dir="R/" test_dir="tests/testthat/" # Loop through each modified file and determine which tests to run @@ -549,7 +548,7 @@ jobs: td=$TESTING_DEPTH # Modify in place so that only modified modules are tested. - if [[ -n "$test_files" && ! -n "$test_all" ]]; + 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 @@ -563,9 +562,9 @@ jobs: } fi # R file without corresponding test file: reset the testing depth - if [[ -n "$helper_modified" || -n "$test_all" ]]; + if [ -n "$helper_modified" ] || [ -n "$test_all" ]; then { - TESTING_DEPTH=td; + TESTING_DEPTH=$td; } fi done shell: bash From 642a189c718262f09c2b4d20370ec50ecfa2b897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 12:35:12 +0100 Subject: [PATCH 28/58] Make it more general and improve logging --- .github/workflows/build-check-install.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index af1a9428..7431482a 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -521,13 +521,13 @@ jobs: key: additional-caches-${{ runner.os }} - name: Check only affected modules 🎯 - if: ${{ inputs.fast-tests }} != 'true' && startsWith(${{ github.event.repository.name }}, 'teal.') && github.event_name == 'pull_request' + if: ${{ inputs.fast-tests }} == 'true' && github.event_name == 'pull_request' run: | # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - test_all=$(git log -1 --pretty=%B | grep -F " [run-all-tests] ") + test_all=$(git show -s --pretty=%B | grep -F "[run-all-tests]") # Get the list of R files that have changed # https://github.com/cloudnativeto/envoy/blob/de67446fa8af973761bb4716f5143d73643baf8b/.github/workflows/get_build_targets.sh_bak#L9 @@ -564,6 +564,7 @@ jobs: # 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 From 3a583527b06188d9b943b4030902f87455d6eb8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 13:52:18 +0100 Subject: [PATCH 29/58] Restore only modifications on tests files --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 7431482a..4e3322bc 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -556,7 +556,7 @@ jobs: } else { # Flag for helpers helper_modified="yes" - git restore . + git restore $test_dir echo "Run all tests" break; } fi From 48dcd5231847d08004561a16b789a24a0811639d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 14:12:21 +0100 Subject: [PATCH 30/58] Simplify a bit more --- .github/workflows/build-check-install.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 4e3322bc..e4e05da8 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -526,15 +526,12 @@ jobs: # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - - test_all=$(git show -s --pretty=%B | grep -F "[run-all-tests]") + test_all=$(git show -s --pretty=%B | grep -F "[run-all-tests]" ) + 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 -- tests/* R/*.R) - - # Base directories - test_dir="tests/testthat/" + files=$(git diff --name-only HEAD FETCH_HEAD -- $test_dir R/*.R) # Loop through each modified file and determine which tests to run for file in $files; do From ab60d1c3e68760922805ef7d85ae5fcfeb0339d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 14:49:43 +0100 Subject: [PATCH 31/58] Fix when to run this step! Add more logging features --- .github/workflows/build-check-install.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index e4e05da8..d3cdd3f4 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -250,7 +250,7 @@ on: description: | Should shinytests2 tests only run per modified teal module? If enabled if only there is a module modificated only that shinytest2 file will be tested. required: false - type: string + type: boolean default: false concurrency: @@ -521,18 +521,31 @@ jobs: key: additional-caches-${{ runner.os }} - name: Check only affected modules 🎯 - if: ${{ inputs.fast-tests }} == 'true' && github.event_name == 'pull_request' + if: inputs.fast-tests == 'true' && github.event_name == 'pull_request' run: | # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - test_all=$(git show -s --pretty=%B | grep -F "[run-all-tests]" ) + # 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 + 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 + # Loop through each modified file and determine which tests to run for file in $files; do From cd1922d6c1b84dfa20bdddc18fadab1171d5249f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 15:28:00 +0100 Subject: [PATCH 32/58] Use logical/boolean instead of text --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index d3cdd3f4..aec84dfb 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -521,7 +521,7 @@ jobs: key: additional-caches-${{ runner.os }} - name: Check only affected modules 🎯 - if: inputs.fast-tests == 'true' && github.event_name == 'pull_request' + if: inputs.fast-tests == true && github.event_name == 'pull_request' run: | # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} From a27ebdf51d28981c1f62f27e841e70c685272c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 15:55:43 +0100 Subject: [PATCH 33/58] Run target always not only on pull_requests --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index aec84dfb..0c636072 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -521,7 +521,7 @@ jobs: key: additional-caches-${{ runner.os }} - name: Check only affected modules 🎯 - if: inputs.fast-tests == true && github.event_name == 'pull_request' + if: inputs.fast-tests == true run: | # Set working directory where the git repo is cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} From 6e0897f72b04b83b0f97b904ed4694fab44be2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 5 Feb 2025 16:28:18 +0100 Subject: [PATCH 34/58] Start from the beginning --- .github/workflows/build-check-install.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 0c636072..4eb5265a 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -523,8 +523,7 @@ jobs: - name: Check only affected modules 🎯 if: inputs.fast-tests == true run: | - # Set working directory where the git repo is - cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} + ls # 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]" ) @@ -540,7 +539,7 @@ jobs: # 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" ] + if [ -n "$files" ] then { echo "No R files affected: test everything." exit 0 From 67c43fc7c4808db09b350f0649cafaf590936bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 6 Feb 2025 09:09:59 +0100 Subject: [PATCH 35/58] Set the working directory to the package --- .github/workflows/build-check-install.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 4eb5265a..e64e3c4e 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -523,7 +523,9 @@ jobs: - name: Check only affected modules 🎯 if: inputs.fast-tests == true run: | + cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} ls + pwd # 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]" ) From 38d02c24430397f5415577c66d3b07fac8fca20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 6 Feb 2025 09:37:14 +0100 Subject: [PATCH 36/58] Check if main commands are available --- .github/workflows/build-check-install.yaml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index e64e3c4e..a58f488e 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -522,10 +522,24 @@ jobs: - name: Check only affected modules 🎯 if: inputs.fast-tests == true + working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} run: | - cd ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} - ls - pwd + # Bash script run + if ! command -v git 2>&1 >/dev/null + then + echo "git could not be found" + exit 1 + fi + if ! command -v grep 2>&1 >/dev/null + then + echo "grep could not be found" + exit 1 + fi + if ! command -v sed 2>&1 >/dev/null + then + echo "sed could not be found" + exit 1 + 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]" ) @@ -579,7 +593,6 @@ jobs: TESTING_DEPTH=$td; } fi done - shell: bash - name: Build R package 🏗 run: | From ef84cea968b7868f01a054950a6439d8e76fccc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 6 Feb 2025 10:02:44 +0100 Subject: [PATCH 37/58] Change output and see what happens --- .github/workflows/build-check-install.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index a58f488e..42d18d59 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -525,20 +525,20 @@ jobs: working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} run: | # Bash script run - if ! command -v git 2>&1 >/dev/null + if ! command -v git > /dev/null 2>&1 then echo "git could not be found" - exit 1 + exit 0 fi - if ! command -v grep 2>&1 >/dev/null + if ! command -v grep > /dev/null 2>&1 then echo "grep could not be found" - exit 1 + exit 0 fi - if ! command -v sed 2>&1 >/dev/null + if ! command -v sed > /dev/null 2>&1 then echo "sed could not be found" - exit 1 + exit 0 fi # Exit early if tag is on commit message even if it set to true From 825ff79b411105b83c7f76fad4641c66a808ffa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 6 Feb 2025 11:13:54 +0100 Subject: [PATCH 38/58] Update description --- .github/workflows/build-check-install.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 42d18d59..2e85e7c7 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -248,7 +248,9 @@ on: default: false fast-tests: description: | - Should shinytests2 tests only run per modified teal module? If enabled if only there is a module modificated only that shinytest2 file will be tested. + Should shinytests2 tests only run per modified teal module? + If enabled if only there is a module modificated only that shinytest2 file will be tested. + Can be ignored if used [run-all-tests] on the commit message. required: false type: boolean default: false From 577fc842c58f1b6095591fab527d7b839b2376da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 6 Feb 2025 12:02:34 +0100 Subject: [PATCH 39/58] Change bash --- .github/workflows/build-check-install.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 2e85e7c7..45d14ef9 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -595,6 +595,7 @@ jobs: TESTING_DEPTH=$td; } fi done + shell: bash - name: Build R package 🏗 run: | From b843d4ef6dae5dc942081f9e3ece59da2ef5e49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 6 Feb 2025 14:15:07 +0100 Subject: [PATCH 40/58] Fix issue with grep --- .github/workflows/build-check-install.yaml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 45d14ef9..41ae0702 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -527,24 +527,12 @@ jobs: working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} 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 + commit_msg=$( git log -1 --pretty=%B ) + echo "Commit msg is ${commit_msg}" # 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]" ) + test_all=$( echo "${commit_msg}" | grep -zvF "[run-all-tests]" | tr -d '\0') + if [ -z "$test_all" ] then { echo "Last commit message forces to test everything." From dbe3631f626e0251298eca228152cf05ea293bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 6 Feb 2025 15:22:46 +0100 Subject: [PATCH 41/58] Update script to be more informative --- .github/workflows/build-check-install.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 41ae0702..3a4787c1 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -543,9 +543,9 @@ jobs: # 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) + files=$(git diff --name-only main.. -- $test_dir R/*.R) - if [ -n "$files" ] + if [ -z "$files" ] then { echo "No R files affected: test everything." exit 0 @@ -554,6 +554,8 @@ jobs: # Loop through each modified file and determine which tests to run for file in $files; do + echo "Check for $file" + # Extract the base name of the file, examples: # tests/testthat/test-shinytest2-foo.R -> foo # R/foo.R -> foo @@ -563,11 +565,12 @@ jobs: td=$TESTING_DEPTH # Modify in place so that only modified modules are tested. - if [ -n "$test_files" ] && [ -z "$test_all" ]; + if [ -n "$test_files" ] && [ -n "$test_all" ]; then { sed -i 's/skip_if_too_deep(5)/skip_if_too_deep(3)/g' "$test_files" - TESTING_DEPTH=3 + export TESTING_DEPTH="3" echo "Testing with shinytest2 for $test_files"; + echo "Settin testing_depth=$TESTING_DEPTH" } else { # Flag for helpers helper_modified="yes" @@ -577,12 +580,13 @@ jobs: } fi # R file without corresponding test file: reset the testing depth - if [ -n "$helper_modified" ] || [ -n "$test_all" ]; + if [ -n "$helper_modified" ] || [ -z "$test_all" ]; then { echo "Skip step or helper modifications detected." - TESTING_DEPTH=$td; + export TESTING_DEPTH="$td"; } fi done + echo Using "TESTING_DEPTH=${TESTING_DEPTH}" shell: bash - name: Build R package 🏗 From ccc51b313d204a1b3b61cc21a83f4226369fe033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 09:26:54 +0100 Subject: [PATCH 42/58] Revert to head and fetch --- .github/workflows/build-check-install.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 3a4787c1..13f3b5ca 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -543,7 +543,7 @@ jobs: # 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 main.. -- $test_dir R/*.R) + files=$(git diff --name-only HEAD FETCH_HEAD -- $test_dir R/*.R) if [ -z "$files" ] then { From f39761f04410a9f7c50354dfe5abeb995b26eeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 10:17:28 +0100 Subject: [PATCH 43/58] Fix path to git diff --- .github/workflows/build-check-install.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 13f3b5ca..5fe839c8 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -540,10 +540,13 @@ jobs: } fi test_dir="tests/testthat/" + git version + git branch + git status # 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) + files=$(git diff --name-only HEAD FETCH_HEAD -- "$test_dir"/*.R R/*.R) if [ -z "$files" ] then { From 45b3b316693dd9b20963a9cec964e517fbf70be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 10:55:31 +0100 Subject: [PATCH 44/58] Pull branch before comparing it --- .github/workflows/build-check-install.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 5fe839c8..30d76663 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -540,13 +540,15 @@ jobs: } fi test_dir="tests/testthat/" - git version + git branch + git pull main git branch git status # 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/*.R) + files=$( git diff main.. --name-only -- "$test_dir"/*.R R/*.R ) + echo "$files" if [ -z "$files" ] then { From 111855dd478102bff39f8ce6d52cc89c0ed6d9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 11:19:24 +0100 Subject: [PATCH 45/58] Pull directly from remote --- .github/workflows/build-check-install.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 30d76663..07be0ed7 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -541,7 +541,9 @@ jobs: test_dir="tests/testthat/" git branch - git pull main + git remote -v + remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" + git pull "$remote_repo" main git branch git status From bfd6310f47818a10241a399ce6b71a4f0306df4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 11:39:59 +0100 Subject: [PATCH 46/58] setup merging strategy --- .github/workflows/build-check-install.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 07be0ed7..7ad51c68 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -542,6 +542,7 @@ jobs: test_dir="tests/testthat/" git branch git remote -v + git config pull.rebase true remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" git pull "$remote_repo" main git branch From ca95d1eb090872a370ad48ebf14e8e60fd29c813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 12:13:10 +0100 Subject: [PATCH 47/58] Stash before merging --- .github/workflows/build-check-install.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 7ad51c68..7e99a7c0 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -540,13 +540,14 @@ jobs: } fi test_dir="tests/testthat/" - git branch - git remote -v + git status + git stash git config pull.rebase true remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" git pull "$remote_repo" main + git stash pop + git branch - git status # Get the list of R files that have changed # https://github.com/cloudnativeto/envoy/blob/de67446fa8af973761bb4716f5143d73643baf8b/.github/workflows/get_build_targets.sh_bak#L9 From abdbb86102362f183200e441e4e1bfb2de59d7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 14:12:27 +0100 Subject: [PATCH 48/58] Testing external action --- .github/workflows/build-check-install.yaml | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 7e99a7c0..03876736 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -521,10 +521,19 @@ jobs: with: path: "${{ inputs.additional-caches }}" key: additional-caches-${{ runner.os }} + steps: + - name: Get changed files 📃 + id: changed-files + uses: tj-actions/changed-files@v45 + files: | + tests/testthat/**.R + R/**.R - name: Check only affected modules 🎯 if: inputs.fast-tests == true working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} + env: + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | # Bash script run commit_msg=$( git log -1 --pretty=%B ) @@ -540,28 +549,15 @@ jobs: } fi test_dir="tests/testthat/" - git status - git stash - git config pull.rebase true - remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - git pull "$remote_repo" main - git stash pop - - git branch - - # 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 main.. --name-only -- "$test_dir"/*.R R/*.R ) - echo "$files" - if [ -z "$files" ] + if [ -z "${ALL_CHANGED_FILES} ] then { echo "No R files affected: test everything." exit 0 } fi # Loop through each modified file and determine which tests to run - for file in $files; do + for file in "${ALL_CHANGED_FILES}"; do echo "Check for $file" From ed42539f9468fb62d83daf0d5db6d6c661d54749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 14:19:08 +0100 Subject: [PATCH 49/58] fix syntax --- .github/workflows/build-check-install.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 03876736..59f8f0e1 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -525,9 +525,10 @@ jobs: - name: Get changed files 📃 id: changed-files uses: tj-actions/changed-files@v45 - files: | - tests/testthat/**.R - R/**.R + with: + files: | + tests/testthat/**.R + R/**.R - name: Check only affected modules 🎯 if: inputs.fast-tests == true From 123af45ca3707393b05b3c7facbe59fc0a5f36f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 7 Feb 2025 17:01:32 +0100 Subject: [PATCH 50/58] Modify documentation and path --- .github/workflows/build-check-install.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 59f8f0e1..17a41638 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -248,8 +248,8 @@ on: default: false fast-tests: description: | - Should shinytests2 tests only run per modified teal module? - If enabled if only there is a module modificated only that shinytest2 file will be tested. + Should shinytests2 tests only run per modified module? + If enabled and there is a module modificated only that shinytest2 file will be tested. Can be ignored if used [run-all-tests] on the commit message. required: false type: boolean @@ -526,6 +526,7 @@ jobs: id: changed-files uses: tj-actions/changed-files@v45 with: + path: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} files: | tests/testthat/**.R R/**.R From a1510055b2a5334e4ee7922caa5562f95e1cca05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 10 Feb 2025 09:26:34 +0100 Subject: [PATCH 51/58] Fix syntax problems.. --- .github/workflows/build-check-install.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 17a41638..aa5d7c56 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -552,14 +552,14 @@ jobs: test_dir="tests/testthat/" - if [ -z "${ALL_CHANGED_FILES} ] + if [ -z "${ALL_CHANGED_FILES}" ] then { echo "No R files affected: test everything." exit 0 } fi # Loop through each modified file and determine which tests to run - for file in "${ALL_CHANGED_FILES}"; do + for file in $ALL_CHANGED_FILES; do echo "Check for $file" From 0ee07f3685f9266df044f6a1d74190c727a2171a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 10 Feb 2025 10:26:32 +0100 Subject: [PATCH 52/58] Fix conditionals & export TESTING_DEPTH for GHA --- .github/workflows/build-check-install.yaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index aa5d7c56..c524a9a7 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -540,7 +540,7 @@ jobs: # Bash script run commit_msg=$( git log -1 --pretty=%B ) - echo "Commit msg is ${commit_msg}" + echo "Commit msg is: ${commit_msg}" # Exit early if tag is on commit message even if it set to true test_all=$( echo "${commit_msg}" | grep -zvF "[run-all-tests]" | tr -d '\0') @@ -552,7 +552,7 @@ jobs: test_dir="tests/testthat/" - if [ -z "${ALL_CHANGED_FILES}" ] + if [ -z "$ALL_CHANGED_FILES" ] then { echo "No R files affected: test everything." exit 0 @@ -572,12 +572,11 @@ jobs: td=$TESTING_DEPTH # Modify in place so that only modified modules are tested. - if [ -n "$test_files" ] && [ -n "$test_all" ]; + if [ -n "$test_files" ]; then { sed -i 's/skip_if_too_deep(5)/skip_if_too_deep(3)/g' "$test_files" - export TESTING_DEPTH="3" + TESTING_DEPTH="3" echo "Testing with shinytest2 for $test_files"; - echo "Settin testing_depth=$TESTING_DEPTH" } else { # Flag for helpers helper_modified="yes" @@ -590,9 +589,12 @@ jobs: if [ -n "$helper_modified" ] || [ -z "$test_all" ]; then { echo "Skip step or helper modifications detected." - export TESTING_DEPTH="$td"; + TESTING_DEPTH="$td"; } fi done + + # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable + echo "TESTING_DEPTH=${TESTING_DEPTH}" >> "$GITHUB_ENV" echo Using "TESTING_DEPTH=${TESTING_DEPTH}" shell: bash From cae30561c3232585c17d796e8e2299b2e501d60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 10 Feb 2025 10:55:03 +0100 Subject: [PATCH 53/58] Compare against main --- .github/workflows/build-check-install.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index c524a9a7..1383ca0f 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -527,9 +527,10 @@ jobs: uses: tj-actions/changed-files@v45 with: path: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} + base_sha: "main" files: | - tests/testthat/**.R - R/**.R + tests/testthat/*.R + R/*.R - name: Check only affected modules 🎯 if: inputs.fast-tests == true @@ -558,6 +559,15 @@ jobs: exit 0 } fi + # Set default TESTING_DEPTH + td=$TESTING_DEPTH + if [ -z "$td" ] + then { + echo "No TESTING_DEPTH default" + td=5 + } fi + + echo "$ALL_CHANGED_FILES" # Loop through each modified file and determine which tests to run for file in $ALL_CHANGED_FILES; do @@ -569,7 +579,6 @@ jobs: 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" ]; @@ -594,8 +603,8 @@ jobs: done # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable - echo "TESTING_DEPTH=${TESTING_DEPTH}" >> "$GITHUB_ENV" echo Using "TESTING_DEPTH=${TESTING_DEPTH}" + echo "TESTING_DEPTH=${TESTING_DEPTH}" >> "$GITHUB_ENV" shell: bash - name: Build R package 🏗 From 626121fe5a8ffafeecab156fa9e48bc883bdf0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 10 Feb 2025 14:46:23 +0100 Subject: [PATCH 54/58] Generalize the wording of the step --- .github/workflows/build-check-install.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 1383ca0f..837ff876 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -246,9 +246,9 @@ on: required: false type: boolean default: false - fast-tests: + selected-shinytests: description: | - Should shinytests2 tests only run per modified module? + Should shinytests2 tests only run per modified corresponding R file in R/ folder? If enabled and there is a module modificated only that shinytest2 file will be tested. Can be ignored if used [run-all-tests] on the commit message. required: false @@ -524,6 +524,7 @@ jobs: steps: - name: Get changed files 📃 id: changed-files + if: inputs.selected-shinytests == true uses: tj-actions/changed-files@v45 with: path: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} @@ -533,7 +534,7 @@ jobs: R/*.R - name: Check only affected modules 🎯 - if: inputs.fast-tests == true + if: inputs.selected-shinytests == true working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} From c6fa899f3903943b6019c70d23f01e6d85d69755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Mon, 10 Feb 2025 14:55:30 +0100 Subject: [PATCH 55/58] Improve wording to describe how it is done and the function being rewritten --- .github/workflows/build-check-install.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 837ff876..74fcc6bd 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -250,7 +250,8 @@ on: description: | Should shinytests2 tests only run per modified corresponding R file in R/ folder? If enabled and there is a module modificated only that shinytest2 file will be tested. - Can be ignored if used [run-all-tests] on the commit message. + Might not apply to most packages! Because it replaces skip_if_too_deep(5) to skip_if_too_deep(3). + Will be ignored if the commit message contains [run-all-tests]. required: false type: boolean default: false From b6e7d636125a9b8cbe67007f77eb3386c016aeb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 11 Feb 2025 10:11:49 +0100 Subject: [PATCH 56/58] Set default before early exiting --- .github/workflows/build-check-install.yaml | 52 +++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 74fcc6bd..8982afa5 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -543,6 +543,15 @@ jobs: # Bash script run commit_msg=$( git log -1 --pretty=%B ) + # Set default TESTING_DEPTH + td=$TESTING_DEPTH + if [ -z "$td" ] + then { + echo "No TESTING_DEPTH default" + echo "TESTING_DEPTH=5" >> "$GITHUB_ENV" + td=5 + } fi + echo "Commit msg is: ${commit_msg}" # Exit early if tag is on commit message even if it set to true test_all=$( echo "${commit_msg}" | grep -zvF "[run-all-tests]" | tr -d '\0') @@ -550,6 +559,8 @@ jobs: if [ -z "$test_all" ] then { echo "Last commit message forces to test everything." + echo Using "TESTING_DEPTH=$td" + echo "TESTING_DEPTH=$td" >> "$GITHUB_ENV" exit 0 } fi @@ -558,18 +569,11 @@ jobs: if [ -z "$ALL_CHANGED_FILES" ] then { echo "No R files affected: test everything." + echo Using "TESTING_DEPTH=$td" + echo "TESTING_DEPTH=$td" >> "$GITHUB_ENV" exit 0 } fi - # Set default TESTING_DEPTH - td=$TESTING_DEPTH - if [ -z "$td" ] - then { - echo "No TESTING_DEPTH default" - td=5 - } fi - - echo "$ALL_CHANGED_FILES" # Loop through each modified file and determine which tests to run for file in $ALL_CHANGED_FILES; do @@ -580,31 +584,27 @@ jobs: # 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) - + test_files=$(grep -l "$base_name(" "$test_dir"test-shinytest2-*.R || echo "") # Modify in place so that only modified modules are tested. - if [ -n "$test_files" ]; + if [ -z "$test_files" ]; 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" ] || [ -z "$test_all" ]; - then { - echo "Skip step or helper modifications detected." + echo "Helper modifications detected." TESTING_DEPTH="$td"; + break; + } else { + if [ -n "$test_files" ]; + 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 { + echo "Something unexpected happened" + } fi } fi done - # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable echo Using "TESTING_DEPTH=${TESTING_DEPTH}" echo "TESTING_DEPTH=${TESTING_DEPTH}" >> "$GITHUB_ENV" shell: bash From 544b78cab18cd27630d1b523c5c569911e94ff70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 11 Feb 2025 12:38:22 +0100 Subject: [PATCH 57/58] Some debugging --- .github/workflows/build-check-install.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 8982afa5..db7f8c79 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -597,16 +597,17 @@ jobs: if [ -n "$test_files" ]; 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"; + echo "TESTING_DEPTH=3" >> "$GITHUB_ENV" + echo "Testing with shinytest2 only for $test_files"; } else { echo "Something unexpected happened" } fi } fi done - echo Using "TESTING_DEPTH=${TESTING_DEPTH}" + echo "Using TESTING_DEPTH=${TESTING_DEPTH}" echo "TESTING_DEPTH=${TESTING_DEPTH}" >> "$GITHUB_ENV" + git status shell: bash - name: Build R package 🏗 From e391bb2ba6d0b1318773ff2f4dbb6c0eeaabcece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 11 Feb 2025 15:35:26 +0100 Subject: [PATCH 58/58] Save default --- .github/workflows/build-check-install.yaml | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index ece7017e..e863cce2 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -548,7 +548,8 @@ jobs: td=$TESTING_DEPTH if [ -z "$td" ] then { - echo "No TESTING_DEPTH default" + echo "No TESTING_DEPTH default." + echo "Setting TESTING_DEPTH=5" echo "TESTING_DEPTH=5" >> "$GITHUB_ENV" td=5 } fi @@ -560,7 +561,7 @@ jobs: if [ -z "$test_all" ] then { echo "Last commit message forces to test everything." - echo Using "TESTING_DEPTH=$td" + echo "Using TESTING_DEPTH=$td" echo "TESTING_DEPTH=$td" >> "$GITHUB_ENV" exit 0 } fi @@ -578,7 +579,7 @@ jobs: # Loop through each modified file and determine which tests to run for file in $ALL_CHANGED_FILES; do - echo "Check for $file" + echo "Check for $file." # Extract the base name of the file, examples: # tests/testthat/test-shinytest2-foo.R -> foo @@ -590,25 +591,19 @@ jobs: if [ -z "$test_files" ]; then { git restore $test_dir - echo "Run all tests" - echo "Helper modifications detected." + echo "Run all tests: Helpers modifications detected." TESTING_DEPTH="$td"; break; } else { - if [ -n "$test_files" ]; - then { - sed -i 's/skip_if_too_deep(5)/skip_if_too_deep(3)/g' "$test_files" - echo "TESTING_DEPTH=3" >> "$GITHUB_ENV" - echo "Testing with shinytest2 only for $test_files"; - } else { - echo "Something unexpected happened" - } fi + sed -i 's/skip_if_too_deep(5)/skip_if_too_deep(3)/g' "$test_files" + TESTING_DEPTH=3 + echo "TESTING_DEPTH=3" >> "$GITHUB_ENV" + echo "Testing with shinytest2 only for $test_files"; } fi done - echo "Using TESTING_DEPTH=${TESTING_DEPTH}" + echo "At the end, using TESTING_DEPTH=${TESTING_DEPTH}" echo "TESTING_DEPTH=${TESTING_DEPTH}" >> "$GITHUB_ENV" - git status shell: bash - name: Build R package 🏗