From 0b0bb28da1fd1d379556708cc4f4c3ae19f54006 Mon Sep 17 00:00:00 2001 From: Luis Moris Fernandez Date: Tue, 17 Sep 2024 12:33:37 +0200 Subject: [PATCH 1/3] test_storing_fix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 50a7b0b..4e0dcc6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,7 +85,7 @@ jobs: path: inst/validation/results - name: Archive snap results ⬆️ - if: always() + if: success() || failure() uses: actions/upload-artifact@v4 with: name: snap_results From 5abcd7786513db6b03070ae096670fb96b28be3b Mon Sep 17 00:00:00 2001 From: Luis Moris Fernandez Date: Tue, 17 Sep 2024 17:31:33 +0200 Subject: [PATCH 2/3] archive library snaps - Running tests with `test_package` tests the installed package. - Updated test snapshots are stored in the `_snaps` folder within the installation library. - Archive the `_snaps` folder, not the root folder, as the root does not contain updated snapshots. --- .github/workflows/test.yml | 2 +- scripts/test_qc_pkg.R | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e0dcc6..3bc254e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,5 +89,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: snap_results - path: tests/testthat/_snaps + path: snaps_archive \ No newline at end of file diff --git a/scripts/test_qc_pkg.R b/scripts/test_qc_pkg.R index e850da5..2d6d169 100644 --- a/scripts/test_qc_pkg.R +++ b/scripts/test_qc_pkg.R @@ -46,6 +46,17 @@ test_results <- tibble::as_tibble( success[["test"]] <- sum(test_results[["failed"]]) == 0 +# Copy _snaps folder so it can be archived later for test debugging +# Empty if no errors are found +root <- Sys.getenv("GITHUB_WORKSPACE") +archive_folder <- file.path(root, "snaps_archive") +if (!dir.exists(archive_folder)) dir.create(archive_folder) + +if (!success[["test"]]) { + snap_folder <- system.file("tests/testthat/_snaps") + file.copy(snap_folder, archive_folder, recursive = TRUE) +} + message("##########################") message("###### TESTING (F) ######") message("##########################") From 64b1706fbcfea8076a028922dd673acbad039aa5 Mon Sep 17 00:00:00 2001 From: Luis Moris Fernandez Date: Wed, 18 Sep 2024 11:00:25 +0200 Subject: [PATCH 3/3] fix system.filte call --- scripts/test_qc_pkg.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test_qc_pkg.R b/scripts/test_qc_pkg.R index 2d6d169..cd50c1e 100644 --- a/scripts/test_qc_pkg.R +++ b/scripts/test_qc_pkg.R @@ -53,7 +53,7 @@ archive_folder <- file.path(root, "snaps_archive") if (!dir.exists(archive_folder)) dir.create(archive_folder) if (!success[["test"]]) { - snap_folder <- system.file("tests/testthat/_snaps") + snap_folder <- system.file("tests/testthat/_snaps", package = pkg_name, mustWork = TRUE) file.copy(snap_folder, archive_folder, recursive = TRUE) }