From e4c13f0673e27a4e53ef5ef90ffceb527dc31035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daphn=C3=A9=20Grasselly?= <56442075+dgrassellyb@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:35:40 +0100 Subject: [PATCH] remove unwanted deps on renv.lock (#180) * remove unwanted deps on renv.lock * remove duplicate * update DEPS_IGNORE * fix cat cmd * apply suggestions --------- Co-authored-by: pharmaverse-bot <113703390+pharmaverse-bot@users.noreply.github.com> --- .github/workflows/r-cmd-check.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/r-cmd-check.yml b/.github/workflows/r-cmd-check.yml index 60a47671..b9022b3f 100644 --- a/.github/workflows/r-cmd-check.yml +++ b/.github/workflows/r-cmd-check.yml @@ -40,15 +40,27 @@ 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: @@ -56,7 +68,7 @@ jobs: 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: @@ -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=".") @@ -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