Skip to content

Commit

Permalink
remove unwanted deps on renv.lock (#180)
Browse files Browse the repository at this point in the history
* remove unwanted deps on renv.lock

* remove duplicate

* update DEPS_IGNORE

* fix cat cmd

* apply suggestions

---------

Co-authored-by: pharmaverse-bot <[email protected]>
  • Loading branch information
dgrassellyb and pharmaverse-bot authored Jan 17, 2024
1 parent a25b02b commit e4c13f0
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/r-cmd-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,35 @@ jobs:
R_KEEP_PKG_SOURCE: true
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
R_REPOS: "https://cran.r-project.org"
DEPS_IGNORE: >-
pharmaversesdtm,
pharmaverseadam,
admiral,
admiraldev,
admiralophtha,
admiralonco,
admiralvaccine,
staged.dependencies
# DEPS_IGNORE: env variable to ignore package when building renv.lock (step Upload dependencies artifact)
# (improvments ideas : get this list of deps to ignore from staged.dependencies yml file)

steps:
##################### BEGIN boilerplate steps #####################
- name: Get branch names
id: branch-name
uses: tj-actions/branch-names@v5.4
uses: tj-actions/branch-names@v8

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v3
uses: actions/checkout@v4
if: |
github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
if: |
github.event_name != 'pull_request'
with:
Expand Down Expand Up @@ -100,14 +112,15 @@ jobs:
dir.create("/workspace/tmp")
library(dplyr)
installed_packages <- as.data.frame(installed.packages())
packages_to_remove <- Sys.getenv("DEPS_IGNORE", "")
packages_to_remove <- unlist(strsplit(packages_to_remove, ","))
installed_packages <- installed_packages %>% filter(LibPath != "/usr/local/lib/R/library") %>% # remove pre-built deps
filter(!Package %in% packages_to_remove)
# save deps as csv file
write.csv(installed_packages, "/workspace/tmp/deps-${{ matrix.r_version }}.csv", row.names = FALSE)
# create also renv.lock file
setwd("/workspace/tmp")
installed_packages <- as.data.frame(installed.packages())
installed_packages <- installed_packages %>% filter(LibPath != "/usr/local/lib/R/library")
renv_lock <- list(
"R" = list(
"Version" = paste(R.version$major, R.version$minor, sep=".")
Expand Down Expand Up @@ -152,7 +165,7 @@ jobs:
# Write the list to a JSON file (renv.lock)
writeLines(jsonlite::toJSON(renv_lock, pretty = TRUE, auto_unbox = TRUE), "renv-${{ matrix.r_version }}.lock")
print("generated renv.lock content")
system("cat renv.lock")
system("cat renv-${{ matrix.r_version }}.lock")
shell: Rscript {0}

- name: Upload deps.csv and renv.lock artifacts
Expand Down

0 comments on commit e4c13f0

Please sign in to comment.