diff --git a/.github/workflows/sanitizer-check.yaml b/.github/workflows/sanitizer-check.yaml new file mode 100644 index 0000000..5be075a --- /dev/null +++ b/.github/workflows/sanitizer-check.yaml @@ -0,0 +1,21 @@ +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: Sanitizer-check + +jobs: + Sanitizer-check: + runs-on: ubuntu-latest + container: wch1/r-debug + + steps: + - uses: actions/checkout@v4 + + - name: Run sanitizer checks + run: | + Rscript -e 'install.packages("devtools", repos="http://cran.us.r-project.org")' + Rscript -e 'devtools::install_deps(dependencies = TRUE)' + Rscript scripts/run-sanitizer-checks.R diff --git a/Makefile b/Makefile index fee0eed..a43694b 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,10 @@ setup: # install tools necessary for building the package document: # generate R docs from source code Rscript -e "devtools::document()" +.PHONY: sanitizer-check +sanitizer-check: # run sanitizer checks using a docker image + docker run -it --rm -v $(pwd):/mypkg -w /mypkg wch/r-debug R -f scripts/run-sanitizer-checks.R + .PHONY: help help: # Show help for each of the Makefile recipes. @grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done diff --git a/scripts/run-sanitizer-checks.R b/scripts/run-sanitizer-checks.R new file mode 100644 index 0000000..eda02a4 --- /dev/null +++ b/scripts/run-sanitizer-checks.R @@ -0,0 +1,5 @@ +# Check for UBSan and ASan issues +# To run locally: +# docker run -it --rm -v $(pwd):/mypkg -w /mypkg wch/r-debug +# R -f scripts/run-sanitizer-checks.R +devtools::check(args = c("--as-cran"), env = c("ASAN_OPTIONS=detect_leaks=0", "_R_CHECK_AS_CRAN_" = "true"))