Skip to content

Commit

Permalink
feat(r-dependent-packages): new skip option to skip R package insta…
Browse files Browse the repository at this point in the history
…llation (#241)
  • Loading branch information
eitsupi committed Sep 11, 2024
1 parent 89e5e7e commit 058402c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/r-dependent-packages/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "R packages from the DESCRIPTION file (via pak)",
"id": "r-dependent-packages",
"version": "0.1.0",
"version": "0.2.0",
"description": "This Feature sets scripts to install dependent R packages from the DESCRIPTION file in the repository.",
"documentationURL": "https://github.com/rocker-org/devcontainer-features/tree/main/src/r-dependent-packages",
"options": {
Expand All @@ -11,9 +11,10 @@
"enum": [
"onCreate",
"updateContent",
"postCreate"
"postCreate",
"skip"
],
"description": "When to install the dependent R packages? Each option corresponds to the lifecycle scripts."
"description": "When to install the dependent R packages? Each option corresponds to the lifecycle scripts. 'skip' means to skip the installation."
},
"pakVersion": {
"type": "string",
Expand Down
5 changes: 3 additions & 2 deletions src/r-dependent-packages/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ install_pak "${PAK_VERSION}"

# Replace the target lifecycle script
echo "Set the lifecycle script for '${WHEN}'..."
LIFECYCLE_SCRIPT_PATH="${LIFECYCLE_SCRIPTS_DIR}/${WHEN,,}.sh"
sed \
-e "s|@ROOT@|${ROOT}|" \
-e "s|@REPOS@|${REPOS//"'"/'"'}|" \
-e "s|@DEPS@|${DEPS}|" \
lifecycle_script.sh >"${LIFECYCLE_SCRIPTS_DIR}/${WHEN,,}.sh"

lifecycle_script.sh >"${LIFECYCLE_SCRIPT_PATH}"
echo "The lifecycle script is generated at '${LIFECYCLE_SCRIPT_PATH}'"
echo "Done!"
1 change: 1 addition & 0 deletions src/r-dependent-packages/lifecycle_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fix_permissions() {

fix_permissions "${PKG_PACKAGE_CACHE_DIR}"

echo "The manifest DESCRIPTION file was set to '@ROOT@/DESCRIPTION'"
echo "Install dependent R packages..."

R -q -e \
Expand Down
12 changes: 12 additions & 0 deletions test/r-dependent-packages/r-ver-skip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
check "R pak package" bash -c "R -q -e 'names(installed.packages()[, 3])' | grep pak"

# Report result
reportResults
8 changes: 8 additions & 0 deletions test/r-dependent-packages/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
}
}
},
"r-ver-skip": {
"image": "rocker/r-ver:4",
"features": {
"r-dependent-packages": {
"when": "skip"
}
}
},
"r-ver-updatecontent": {
"image": "rocker/r-ver:4",
"features": {
Expand Down

0 comments on commit 058402c

Please sign in to comment.