Skip to content

Commit

Permalink
archive library snaps
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
zsigmas committed Sep 17, 2024
1 parent 0b0bb28 commit 5abcd77
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: snap_results
path: tests/testthat/_snaps
path: snaps_archive

11 changes: 11 additions & 0 deletions scripts/test_qc_pkg.R
Original file line number Diff line number Diff line change
Expand Up @@ -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("##########################")
Expand Down

0 comments on commit 5abcd77

Please sign in to comment.