Gilead-BioStats / gsm

Good Statistical Monitoring R Package
https://gilead-biostats.github.io/gsm/
Apache License 2.0
39 stars 10 forks source link

QC: update `pkgdown` yamls to cache dependencies #1804

Open lauramaxwell opened 3 months ago

lauramaxwell commented 3 months ago

QC Details

r dependencies are not currently cached in the pkgdown yamls. This adds ~8 mins to the check. Update the setup-r-dependencies@v2 step to properly cache the dependencies, so only new dependencies need to be added at each run. Likely, we will need to remove local::. from the following code chunk and load the local R package in a separate step.

uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::pkgdown, local::.

Additional Comments

zdz2101 commented 2 months ago

setup-r-dependencies by default has cache: TRUE, so some sort of cache is being actively saved/used in each of the yaml files, But because each workflow looks to have its own and updates the cache, looks like it can "miss" or not hit the proper cache if those cache-keys in the background don't match or possibly expired since github acions automatically deletes if its >7 days old unaccessed. I tinkered around with setting cache as FALSE and creating a universal cache, and restoring it in a separate workflow, see the yaml that creates the cache and the respective action that ran on it.

May be worth cleaning up the cache anyway too, repo is getting close to allowable limit

jonthegeek commented 2 months ago

May be worth cleaning up the cache anyway too, repo is getting close to allowable limit

GitHub auto prunes the least-recently-used cache items, so we shouldn't need to manually prune.

jonthegeek commented 2 months ago

Huh, the r-lib action is smarter about caching than I realized:

          key: ${{ format('{0}-{1}-{2}-{3}', steps.install.outputs.os-version, steps.install.outputs.r-version, inputs.cache-version, hashFiles(format('{0}/.github/pkg.lock', inputs.working-directory ))) }}
          restore-keys: ${{ format('{0}-{1}-{2}-', steps.install.outputs.os-version, steps.install.outputs.r-version, inputs.cache-version) }}

What that means: it creates a key based on the OS, R version, cache version, and a hash of the repo's working dir (and pkg lock file), and restores based on OS, R version, and cache version. I think I overrode it in this YAML thinking it was making a cache specific to the PR (which some other actions do by default), which wasn't very helpful.

I think we can fix this by just not being as fancy about it. Get the local bit out of there and then separately install the repo's package (with pak::pak()), because the cache will always include the previous version of the package otherwise.