Skip to content

Commit

Permalink
fetching package name from description file (#16)
Browse files Browse the repository at this point in the history
* fetching package name from description file

* ignoring .RData and history

* fetching package name with R

* escaping $ for R
  • Loading branch information
j-i-l committed Feb 4, 2024
1 parent d72af7f commit c872782
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/create-publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ on:

env:
DOCKER_REGISTRY: ghcr.io # where to register the image
PACKAGE: abn
REPO_PATH: github.com:furrer-lab/devel-abn.git
# Set the path to the DESCRIPTION file in the R package you want to target
DESCRIPTION_FILE: ${{ vars.DESCRIPTION_FILE || './DESCRIPTION' }}
JAGS: JAGS-4.3.2
R_VERSION: R-devel

Expand All @@ -22,7 +23,7 @@ jobs:

strategy:
matrix:
target-os: ['fedora', 'debian']
target-os: ['fedora', ] # 'debian']
compiler: ['clang', ] # , 'gcc']
r-version: ['R-devel', ]

Expand Down Expand Up @@ -63,7 +64,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
FLAVOUR=${{ matrix.r-version }}
PACKAGE=${{ env.PACKAGE }}
DESCRIPTION_FILE=${{ env.DESCRIPTION_FILE }}
REPO_PATH=${{ env.REPO_PATH }}
JAGS=${{ env.JAGS}}
secret-files: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# vim temp. files
*.swp
# R files
.R*
# renv files
.Rprofile
renv.lock
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This is a selection of Docker container that provide r-environments for testing purposes.

## Configuration

### Releasing new versions
New registry entries are triggered by tagging the specific commit.
For the image to be built the tag needs to be a valid [semver](https://semver.org/), i.e. of the form `[MAJOR].[MINOR].[PATCH]` (e.g. `1.3.0`).
12 changes: 9 additions & 3 deletions containers/debian/clang/R-devel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM rhub/debian-clang-devel

# defines the flavour (e.g. FLAVOUR=)
ARG FLAVOUR
# ARG PACKAGE
ARG DESCRIPTION_FILE
ARG REPO_PATH
ARG SSH_PRIV_KEY
# # sets the date for the CRAN snapshot (e.g. BUILD_DATE=2023-12-20)
Expand Down Expand Up @@ -59,12 +61,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN R -e "install.packages('INLA',repos=c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'), dep=TRUE)"

###
# install all abn dependencies
# install all package dependencies
###
RUN dnf -y install \
git \
openssh-clients
WORKDIR /root/
# get a shallow copy of the target repository
# Note: If the repository is private you must use a deploy token here (ssh key)
RUN --mount=type=secret,id=key,dst=/root/.ssh/key GIT_SSH_COMMAND="ssh -i /root/.ssh/key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone --depth=1 git@$REPO_PATH target
WORKDIR target/
# get a list of all dependencies; install remaining packages
# NOTE: abn is hardcoded here
RUN R -e 'pckgs<-unique(renv::dependencies("abn")$Package);pres_pckgs<-installed.packages()[,"Package"];install.packages(pckgs[!(pckgs %in% pres_pckgs)])'
# escape=\
RUN R -e "package<-desc::desc(file='$DESCRIPTION_FILE')\$get_field('Package');pckgs<-unique(renv::dependencies(package)[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs)])"
7 changes: 4 additions & 3 deletions containers/fedora/clang/R-devel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM rhub/fedora-clang-devel

# defines the flavour (e.g. FLAVOUR=)
ARG FLAVOUR
# Folder name in the root directory that contains the package (package name)
ARG PACKAGE
# ARG PACKAGE
ARG DESCRIPTION_FILE
ARG REPO_PATH
ARG SSH_PRIV_KEY
ARG JAGS
Expand Down Expand Up @@ -87,4 +87,5 @@ WORKDIR /root/
RUN --mount=type=secret,id=key,dst=/root/.ssh/key GIT_SSH_COMMAND="ssh -i /root/.ssh/key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone --depth=1 git@$REPO_PATH target
WORKDIR target/
# get a list of all dependencies; install remaining packages
RUN R -e "pckgs<-unique(renv::dependencies('$PACKAGE')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs)])"
# escape=\
RUN R -e "package<-desc::desc(file='$DESCRIPTION_FILE')\$get_field('Package');pckgs<-unique(renv::dependencies(package)[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs)])"

0 comments on commit c872782

Please sign in to comment.