Skip to content

Commit

Permalink
remove redundant env variables and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Oct 22, 2021
1 parent c02e83f commit 6389d2a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/r_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,6 @@ jobs:
compiler: gcc
- r_customization: csan
compiler: clang
env:
# env variables from CRAN's configuration: https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt
ASAN_OPTIONS: "detect_leaks=0:detect_odr_violation=0"
UBSAN_OPTIONS: "print_stacktrace=1"
RJAVA_JVM_STACK_WORKAROUND: 0
RGL_USE_NULL: true
R_DONT_USE_TK: true
steps:
- name: Checkout repository
uses: actions/[email protected]
Expand Down
45 changes: 35 additions & 10 deletions R-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,24 +363,49 @@ Alternatively, GitHub Actions can run code above for you. On a pull request, cre

#### UBSAN

All packages uploaded to CRAN must pass a build using `gcc` instrumented with two sanitizers: the Address Sanitizer (ASAN) and the Undefined Behavior Sanitizer (UBSAN). For more background, see [this blog post](http://dirk.eddelbuettel.com/code/sanitizers.html).
All packages uploaded to CRAN must pass builds using `gcc` and `clang`, instrumented with two sanitizers: the Address Sanitizer (ASAN) and the Undefined Behavior Sanitizer (UBSAN).

For more background, see

* [this blog post](http://dirk.eddelbuettel.com/code/sanitizers.html)
* [top-level CRAN documentation on these checks](https://cran.r-project.org/web/checks/check_issue_kinds.html)
* [CRAN's configuration of these checks](https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt)
You can replicate these checks locally using Docker.
For more information on the image used for testing, see https://github.com/wch/r-debug.
```shell
docker run \
-v $(pwd):/opt/LightGBM \
-w /opt/LightGBM \
-it rhub/rocker-gcc-san \
/bin/bash
In the code below, environment variable `R_CUSTOMIZATION` should be set to one of two environment variables.
Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.rstudio.com', Ncpus = parallel::detectCores())"
* `"san"` = replicates CRAN's `gcc-ASAN` and `gcc-UBSAN` checks
* `"csan"` = replicates CRAN's `clang-ASAN` and `clang-UBSAN` checks
```shell
docker run \
--rm \
-it \
-v $(pwd):/opt/LightGBM \
-w /opt/LightGBM \
--env R_CUSTOMIZATION=san \
wch1/r-debug:latest \
/bin/bash
# install dependencies
RDscript${R_CUSTOMIZATION} \
-e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
# install lightgbm
sh build-cran-package.sh
RD${R_CUSTOMIZATION} \
CMD INSTALL lightgbm_*.tar.gz
Rdevel CMD install lightgbm_*.tar.gz
# run tests
cd R-package/tests
Rscriptdevel testthat.R
rm -f ./tests.log
RDscript${R_CUSTOMIZATION} testthat.R >> tests.log 2>&1
# check that tests passed
echo "test exit code: $?"
tail -300 ./tests.log
```
#### Valgrind
Expand Down

0 comments on commit 6389d2a

Please sign in to comment.