Skip to content

Commit

Permalink
refactor rchk action script
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k authored and jimhester committed Nov 10, 2021
1 parent 2a200e6 commit fd9a09a
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 50 deletions.
14 changes: 0 additions & 14 deletions run-rchk/Dockerfile

This file was deleted.

29 changes: 22 additions & 7 deletions run-rchk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <any apt dependencies, optional>
package: <R package name, optional>
```
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
Expand Down
37 changes: 29 additions & 8 deletions run-rchk/action.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 1 addition & 21 deletions run-rchk/entrypoint.sh → run-rchk/run.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions run-rchk/setup.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
Make sure you are running the container 'rhub/ubuntu-rchk'.
runs-on: ubuntu-latest
container:
image: rhub/ubuntu-rchk
options: --user=root
EOF
exit 1
fi

apt-get update && apt-get install -y sudo

cd /home/docker/R-svn/
. /home/docker/rchk/scripts/cmpconfig.inc

# these variables are defined in cmpconfig.inc
echo "CPICFLAGS=$CPICFLAGS" >> $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

0 comments on commit fd9a09a

Please sign in to comment.