From fd9a09a778173fe57e2801815a36d73473f8bba7 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Sat, 6 Nov 2021 20:53:55 -0700 Subject: [PATCH] refactor rchk action script --- run-rchk/Dockerfile | 14 ----------- run-rchk/README.md | 29 ++++++++++++++++------ run-rchk/action.yml | 37 ++++++++++++++++++++++------ run-rchk/{entrypoint.sh => run.sh} | 22 +---------------- run-rchk/setup.sh | 39 ++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 50 deletions(-) delete mode 100644 run-rchk/Dockerfile rename run-rchk/{entrypoint.sh => run.sh} (50%) mode change 100755 => 100644 create mode 100644 run-rchk/setup.sh diff --git a/run-rchk/Dockerfile b/run-rchk/Dockerfile deleted file mode 100644 index 53f691a24..000000000 --- a/run-rchk/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM rhub/ubuntu-rchk - -USER root -RUN apt-get update -RUN apt-get install sudo -y - -RUN echo "docker ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/user && \ - chmod 0440 /etc/sudoers.d/user - -USER docker - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/run-rchk/README.md b/run-rchk/README.md index 5add7847f..eebe0335b 100644 --- a/run-rchk/README.md +++ b/run-rchk/README.md @@ -13,18 +13,33 @@ Basic: ```yml rchk: runs-on: ubuntu-latest + container: + image: rhub/ubuntu-rchk + options: --user=root steps: - uses: actions/checkout@v1 - uses: r-lib/actions/run-rchk@master - with: - apt: - package: ``` -Any `apt` dependencies could be installed by providing the `apt` argument. For example, `apt: libxml2-dev libssl-dev` etc. - -The `package` is the optional package name. If left empty, it will be determined from the repo name. - +If you want to have more control +```yml + rchk: + runs-on: ubuntu-latest + container: + image: rhub/ubuntu-rchk + options: --user=root + steps: + - uses: actions/checkout@v1 + - uses: r-lib/actions/run-rchk@master + with: + setup-only: true + - uses: r-lib/actions/setup-r-dependencies@v1 + with: + cache-version: rchk-1 + - uses: r-lib/actions/run-rchk@master + with: + run-only: true +``` # License diff --git a/run-rchk/action.yml b/run-rchk/action.yml index 76b83c2f5..98097a7b7 100644 --- a/run-rchk/action.yml +++ b/run-rchk/action.yml @@ -1,10 +1,31 @@ -name: 'Run rchk tests' -description: 'Run rchk tests' +name: Setup and run rchk test +description: Setup and run rchk test inputs: - apt: - default: '' - package: - default: '' + setup-only: + description: Setup rchk only and skip running the test. + required: false + default: false + run-only: + description: Skip the setup step and run the test directly assuming that setup was run. + required: false + default: false + cache-version: + description: The version of the cache, change this from the default (rchk-1) to start over with a fresh cache + required: false + default: rchk-1 runs: - using: 'docker' - image: 'Dockerfile' + using: 'composite' + steps: + - if: inputs.run-only != 'true' + name: Setup rchk + run: bash $GITHUB_ACTION_PATH/setup.sh + shell: bash + - if: inputs.setup-only != 'true' && inputs.run-only != 'true' + uses: r-lib/actions/setup-r-dependencies@v1 + with: + cache-version: ${{ inputs.cache-version }} + - if: inputs.setup-only != 'true' + name: Run rchk + run: | + bash $GITHUB_ACTION_PATH/run.sh + shell: bash diff --git a/run-rchk/entrypoint.sh b/run-rchk/run.sh old mode 100755 new mode 100644 similarity index 50% rename from run-rchk/entrypoint.sh rename to run-rchk/run.sh index 23a21eaa5..75ef342bf --- a/run-rchk/entrypoint.sh +++ b/run-rchk/run.sh @@ -2,29 +2,9 @@ set -eo pipefail -cd /home/docker/R-svn/ -. /home/docker/rchk/scripts/cmpconfig.inc -cd - - -APT="$INPUT_APT" -if [ -n "$APT" ]; then - sudo apt-get install $APT -y -fi - -R --slave -e "install.packages('remotes', repos = 'https://cloud.r-project.org')" - -R --slave -e "remotes::install_local(repos = 'https://cloud.r-project.org')" - -PACKAGE="$INPUT_PACKAGE" - -if [ -z "$PACKAGE" ]; then - PACKAGE=$(echo ${GITHUB_REPOSITORY#*/}) -fi - -echo "running rchk tests for $PACKAGE" +PACKAGE=$(Rscript -e "d=read.dcf('DESCRIPTION');cat(d[,colnames(d)=='Package',drop=TRUE])") cd /home/docker/R-svn/ -. /home/docker/rchk/scripts/cmpconfig.inc /home/docker/rchk/scripts/check_package.sh $PACKAGE if [ $(cat packages/lib/$PACKAGE/libs/$PACKAGE.so.bcheck | wc -l) -gt 3 ]; then FAIL=1 diff --git a/run-rchk/setup.sh b/run-rchk/setup.sh new file mode 100644 index 000000000..216f66978 --- /dev/null +++ b/run-rchk/setup.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -eo pipefail + +# check if user is running rhub/ubuntu-rchk docker image + +if [[ ! -d /home/docker/R-svn/ ]]; then + echo <> $GITHUB_ENV +echo "CFLAGS=$CFLAGS" >> $GITHUB_ENV +echo "CXXFLAGS=$CXXFLAGS" >> $GITHUB_ENV +echo "CC=$CC" >> $GITHUB_ENV +echo "CXX=$CXX" >> $GITHUB_ENV +echo "PATH=$PATH" >> $GITHUB_ENV +echo "LLVM_COMPILER=$LLVM_COMPILER" >> $GITHUB_ENV +echo "PKG_BUILD_DIR=$PKG_BUILD_DIR" >> $GITHUB_ENV +echo "R_LIBS=$R_LIBS" >> $GITHUB_ENV +echo "R_LIBSONLY=$R_LIBSONLY" >> $GITHUB_ENV +echo "LD=$LD" >> $GITHUB_ENV + +# R_LIBS_USER is needed for caching dependencies +echo "R_LIBS_USER=$R_LIBS" >> $GITHUB_ENV