Rewrite action using rocker/r-devel-ubsan-clang #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- master | |
- GHA-sanitizers # during development | |
workflow_dispatch: | |
name: R-CMD-check-sanitized | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
R-CMD-check-sanitized: | |
runs-on: ubuntu-latest | |
container: | |
image: docker://docker.io/rocker/r-devel-ubsan-clang | |
strategy: | |
fail-fast: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "Environment setup" | |
run: | | |
RDscript -e ' | |
# install the dependencies into a separate directory to cache them | |
dir.create(lib <- Sys.getenv("R_LIBS_USER"), recursive = TRUE) | |
writeLines(paste0("R_LIBS_USER=", lib), Sys.getenv("GITHUB_ENV")) | |
# to be used as the cache key | |
writeLines(R.version.string, ".R_version_string") | |
' | |
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV | |
# fontconfig is known to leak; add more suppressions as discovered | |
echo "LSAN_OPTIONS=suppressions=$(realpath .github/workflows/LSan.supp)" >> $GITHUB_ENV | |
# disable for most operations just in case | |
echo "ASAN_OPTIONS=detect_leaks=0" >> $GITHUB_ENV | |
# needed by udunits2 | |
apt-get update && apt-get install -y libudunits2-dev | |
- name: "Restore dependency cache" | |
id: dependency-cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.R_LIBS_USER }}/* | |
key: r-clang-san-deps-${{hashFiles('.R_version_string')}} | |
- name: "Install dependencies" | |
shell: RDscript {0} | |
run: | | |
if (!requireNamespace('BiocManager')) install.packages('BiocManager') | |
union( | |
'DESCRIPTION' |> read.dcf('Suggests') |> tools:::.split_dependencies() |> names(), | |
'inst/tests/other.Rraw' |> parse() |> _[[1]][[3]] |> eval() | |
) |> setdiff(tools::standard_package_names()$base) |> | |
BiocManager::install(lib = Sys.getenv('R_LIBS_USER'), update = TRUE, ask = FALSE) | |
- name: "Save dependency cache" | |
uses: actions/cache/save@v4 | |
with: | |
path: ${{ env.R_LIBS_USER }}/* | |
key: ${{ steps.dependency-cache.outputs.cache-primary-key }} | |
- name: "Build" | |
run: RD CMD build . | |
- name: "Check" | |
run: | | |
set +e # expect some things to fail and keep going | |
echo "::group::full R CMD check output" | |
# only use leak checking for this run | |
ASAN_OPTIONS=detect_leaks=1 RD CMD check --no-manual data.table_*.tar.gz; res1=$? | |
echo "::endgroup::" | |
perl -nle '(print, $a=1) if /: runtime error: |ERROR: LeakSanitizer/../SUMMARY.*Sanitizer/ }{ exit $a' data.table.Rcheck/**/*.Rout*; res2=$? | |
# fail if R CMD check had failed or if sanitizer output found | |
[ $res1 -eq 0 ] && [ $res2 -eq 0 ] |