FredHutch / VISCtemplates

Tools for writing reproducible reports at VISC
Other
4 stars 2 forks source link

Add GitHub action to automatically render skeleton.Rmd when pull requests are made #133

Closed kelliemac closed 3 months ago

kelliemac commented 4 months ago

I thought it would be really helpful to have the report skeletons automatically render to pdf and docx when pull requests are made, so that PR issuers and reviewers can easily see the impact of template changes (and the current status of how reports look using the template skeleton).

This is a draft pull request - I would love to get feedback on, for example:

  1. Is there a better location in the repo to render these skeleton reports to?
  2. Are we concerned about this bloating the repo a bunch, since pdf and docx files are not tracked very efficiently by GitHub?
  3. Currently just the visc_empty skeleton.Rmd is rendered. There is also the visc_report skeleton.Rmd that we could consider rendering also/instead.
slager commented 4 months ago

I'm conflicted about this approach. On the one hand, it's super handy to have the PDF render on PR. On the other hand, like you say, git/GitHub aren't designed to track PDF/DOCX files and it will bloat the repo with each successive render that's committed. There also isn't the ability to diff PDF files in a useful way to see what exactly has changed, besides just doing a visual check.

I'd probably advocate the approach of just having the PR author and/or reviewer build the PDF on their own machine from the PR branch, but it might also be possible to set up this GitHub Action to render the PDF to somewhere on the cloud for viewing, without actually committing it into the repo. Something like this?

https://sha.ws/posts/automatic-upload-to-google-cloud-storage-with-github-actions/

kelliemac commented 4 months ago

All good points, Dave, and some of the same concerns I had. I just learned that you can save "artifacts" from GitHub actions and I think this may be the best solution: https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts

I'm going to mark this PR as draft and try that approach instead.

slager commented 4 months ago

Oh, very cool! That approach sounds like it could be the best of both worlds.

kelliemac commented 4 months ago

Okay, I successfully switched to the "artifacts" approach. You can now see the rendered pdf and docx by viewing the details of the render-skeleton-rmd GitHub action, for example the latest run is here: https://github.com/FredHutch/VISCtemplates/actions/runs/8179544879#artifacts

Clicking on the artifact name will download a zip file with both pdf and docx, which can easily be viewed and reviewed. No files are committed to the repo, though, so there won't be any bloating.

kelliemac commented 4 months ago

Note that this is still only rendering the visc_empty skeleton.Rmd, as there are additional complexities with rendering the visc_report skeleton.Rmd (but I can work on that too if people feel it is important - the challenge is that additional child Rmds are assumed to be in particular locations, such as background.Rmd, so a little more setup is required).

slager commented 4 months ago

This is so cool

kelliemac commented 4 months ago

Thanks for reviewing and giving feedback, @slager !