actions
actions copied to clipboard
Testthat snapshots not uploading
Describe the bug
I'm using these settings in my yaml, hoping to upload my testthat snapshot files to a GitHub artifact:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
But these get uploaded instead of the snapshots:
Finished uploading artifact content to blob storage!
SHA256 hash of uploaded artifact zip is 4a1a325c91fd09fc5bbf23aa49711abc2984151c64dc5ad1364b762b6957536a
Finalizing artifact upload
Artifact Linux-X64-rrelease-3-results.zip successfully finalized. Artifact ID 1643076474
Artifact Linux-X64-rrelease-3-results has been successfully uploaded! Final size is 2408648 bytes. Artifact ID is 1643076474
To Reproduce
https://github.com/FredHutch/VISCtemplates/actions/runs/9690680996/job/26740916919 https://github.com/FredHutch/VISCtemplates/pull/168
Expected behavior
I expected the testthat snapshots to get uploaded to a GHA artifact.
Additional context
There are no original comparison snapshots, i.e. the snapshots are being created from scratch. The _snaps folder is .gitignored and .Rbuildignored. The R CMD check and test results are the same locally and on GHA.
If you look at the check artifacts you'll see that there is no tests/testthat/_snaps directory there, so no snapshots to upload.
Thanks. I fixed my path issue and can now see my snapshots inside the results artifact:
https://github.com/FredHutch/VISCtemplates/actions/runs/9701659385/job/26775775183?pr=168
However, I expected to be getting a snapshots artifact, but am still only getting the results artifact.
I think the problem is that with the current yaml, it's not possible to get a snapshots artifact when there is a test failure in the earlier block. Compare the if logic for running the snapshot artifacts upload: https://github.com/r-lib/actions/blob/fbafc3bc4ba114e72680c71e835c59b022606c46/check-r-package/action.yaml#L69 vs the logic for running the results artifacts upload: https://github.com/r-lib/actions/blob/fbafc3bc4ba114e72680c71e835c59b022606c46/check-r-package/action.yaml#L62
The results artifacts upload allows for running that block on failure of a previous block, but the snapshots upload just won't run if there's an earlier failure.
The CI runs for the two commits at https://github.com/FredHutch/VISCtemplates/pull/169 demonstrate this. f962f4d uploads snapshots with no test failures, and 0e07004 doesn't upload snapshots. The only change is forcing a test to fail.
Are you amenable to a PR that adjusts the arguments/documentation/logic for snapshots artifact upload to be like the logic for the results artifact upload? This would allow the flexibility to upload a snapshots artifact even when tests fail.
I am not sure if it is a good idea to upload snapshots after test failures, because if a test fails, the rest of the snapshots in the same test block are not recorded. Nevertheless I added an options for this.
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this issue