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

Testthat snapshots not uploading #871

Closed
slager opened this issue Jun 27, 2024 · 4 comments · Fixed by #890
Closed

Testthat snapshots not uploading #871

slager opened this issue Jun 27, 2024 · 4 comments · Fixed by #890
Labels
bug an unexpected problem or unintended behavior

Comments

@slager
Copy link

slager commented Jun 27, 2024

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
FredHutch/VISCtemplates#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.

@slager slager added the bug an unexpected problem or unintended behavior label Jun 27, 2024
@gaborcsardi
Copy link
Member

If you look at the check artifacts you'll see that there is no tests/testthat/_snaps directory there, so no snapshots to upload.

@slager
Copy link
Author

slager commented Jun 27, 2024

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:

if: ${{ inputs.upload-snapshots != 'false' }}
vs the logic for running the results artifacts upload:
if: ${{ (failure() && inputs.upload-results != 'never') || (inputs.upload-results != 'false' && inputs.upload-results != 'never') }}

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 FredHutch/VISCtemplates#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.

@gaborcsardi
Copy link
Member

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.

Copy link

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants