Skip to content

Commit ff4d1ab

Browse files
committed
Rewrite action using rocker/r-devel-ubsan-clang
Also: - Do not check pull requests - Try to cache installed dependencies
1 parent faeaab1 commit ff4d1ab

File tree

1 file changed

+65
-21
lines changed

1 file changed

+65
-21
lines changed

.github/workflows/sanitizers.yaml

Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,81 @@
1-
name: R-CMD-check-sanitized
2-
concurrency:
3-
group: ${{ github.event.pull_request.number || github.run_id }}
4-
cancel-in-progress: true
5-
61
on:
72
push:
83
branches:
94
- master
105
- GHA-sanitizers # during development
116
workflow_dispatch:
12-
pull_request:
7+
8+
name: R-CMD-check-sanitized
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
1313

1414
jobs:
15-
linux-containers:
15+
R-CMD-check-sanitized:
1616
runs-on: ubuntu-latest
17-
name: "Check with sanitizers enabled"
18-
strategy:
19-
fail-fast: false
2017
container:
21-
image: docker://ghcr.io/r-hub/containers/clang-asan
18+
image: docker://docker.io/rocker/r-devel-ubsan-clang
19+
20+
strategy:
21+
fail-fast: true
2222

2323
steps:
24-
- uses: r-hub/actions/checkout@v1
25-
- uses: r-hub/actions/platform-info@v1
26-
- uses: r-hub/actions/setup-deps@v1
27-
- name: "Additional setup"
24+
- uses: actions/checkout@v4
25+
26+
- name: "Environment setup"
2827
run: |
29-
# this should at least help with the build step
28+
RDscript -e '
29+
# install the dependencies into a separate directory to cache them
30+
dir.create(lib <- Sys.getenv("R_LIBS_USER"), recursive = TRUE)
31+
writeLines(paste0("R_LIBS_USER=", lib), Sys.getenv("GITHUB_ENV"))
32+
# to be used as the cache key
33+
writeLines(R.version.string, ".R_version_string")
34+
'
3035
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
3136
# fontconfig is known to leak; add more suppressions as discovered
3237
echo "LSAN_OPTIONS=suppressions=$(realpath .github/workflows/LSan.supp)" >> $GITHUB_ENV
33-
# disabled by default, so reenable (needs suppressions above)
34-
echo "ASAN_OPTIONS=detect_leaks=1" >> $GITHUB_ENV
35-
# see r-hub/containers#84
36-
sed -i 's/-fsanitize-trap\S*//g' /opt/R/devel-asan/lib/R/etc/Makeconf
37-
- uses: r-hub/actions/run-check@v1
38+
# disable for most operations just in case
39+
echo "ASAN_OPTIONS=detect_leaks=0" >> $GITHUB_ENV
40+
# needed by udunits2, sf
41+
apt-get update && apt-get install -y libudunits2-dev libgdal-dev
42+
43+
- name: "Restore dependency cache"
44+
id: dependency-cache
45+
uses: actions/cache/restore@v4
46+
with:
47+
path: ${{ env.R_LIBS_USER }}/*
48+
key: r-clang-san-deps-${{hashFiles('.R_version_string')}}
49+
50+
- name: "Install dependencies"
51+
shell: RDscript {0}
52+
run: |
53+
lib <- Sys.getenv('R_LIBS_USER') # why doesn't it work by itself?
54+
if (!requireNamespace('BiocManager')) install.packages('BiocManager', lib = lib)
55+
union(
56+
'DESCRIPTION' |> read.dcf('Suggests') |> tools:::.split_dependencies() |> names(),
57+
'inst/tests/other.Rraw' |> parse() |> _[[1]][[3]] |> eval()
58+
) |> setdiff(tools::standard_package_names()$base) |>
59+
BiocManager::install(lib = lib, update = TRUE, ask = FALSE)
60+
61+
- name: "Save dependency cache"
62+
uses: actions/cache/save@v4
63+
with:
64+
path: ${{ env.R_LIBS_USER }}/*
65+
key: ${{ steps.dependency-cache.outputs.cache-primary-key }}
66+
67+
- name: "Build"
68+
run: |
69+
rm .R_version_string # there's probably a better place for this
70+
RD CMD build .
71+
72+
- name: "Check"
73+
run: |
74+
set +e # expect some things to fail and keep going
75+
echo "::group::full R CMD check output"
76+
# only use leak checking for this run
77+
ASAN_OPTIONS=detect_leaks=1 RD CMD check --no-manual data.table_*.tar.gz; res1=$?
78+
echo "::endgroup::"
79+
perl -nle '(print, $a=1) if /: runtime error: |ERROR: LeakSanitizer/../SUMMARY.*Sanitizer/ }{ exit $a' data.table.Rcheck/**/*.Rout*; res2=$?
80+
# fail if R CMD check had failed or if sanitizer output found
81+
[ $res1 -eq 0 ] && [ $res2 -eq 0 ]

0 commit comments

Comments
 (0)