vcr icon indicating copy to clipboard operation
vcr copied to clipboard

Advice for vcr in CI/CD?

Open hadley opened this issue 8 months ago • 3 comments

If you use vcr for all your tests, you're vulnerable to the server API changing so that real code no longer works. It feels like the solution to this is to have a cron job (maybe once a day?) rerun your tests (only, not a full R CMD check) with vcr disabled. Do you have this advice written up and fleshed out somewhere?

hadley avatar Apr 15 '25 12:04 hadley

  • There's https://books.ropensci.org/http-testing/real-requests-chapter.html#how-to-make-real-requests - you can turn vcr off with an env var and do e.g., VCR_TURN_OFF=true Rscript -e "devtools::test()"
  • There's the config option re_record_interval - see https://github.com/ropensci/vcr/blob/main/R/cassette_class.R#L513-L548 - Though to be honest I haven't used it. It could be used though - assuming it works - to have a single GH action that sometimes records new cassettes depending on how long ago the cassettes were recorded.
  • I've done a cron job before to rewrite cassettes on a schedule (1/week) in some Python projects that use the main python vcr pkg - and the rewrites open up a PR for a human to review - but one could have the changes committed directly to main too

TBH I'm not sure I'm confident what the best practice is. And anyway it probably depends on the use case, so advice should I think consist of a few options depending on the use case

sckott avatar Apr 15 '25 19:04 sckott

we can move this to the next milestone unless you want to address for v2

sckott avatar Jun 27 '25 20:06 sckott

Yeah, next one I think.

hadley avatar Jun 27 '25 21:06 hadley