-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (156 loc) · 5.62 KB
/
r-dependencies-tests.yml
File metadata and controls
185 lines (156 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: r-dependencies-tests
permissions:
contents: read
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
# --- Python 3.12 on all OSes ---
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
# --- R on all OSes ---
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
r-version: "release"
- name: Fix paths for rpy2 ABI mode
shell: bash
run: |
# Find where R is
# 1. Capture and set R_HOME explicitly
R_HOME_DIR=$(R RHOME)
echo "Detected R_HOME: $R_HOME_DIR"
echo "R_HOME=$R_HOME_DIR" >> $GITHUB_ENV
# 2. Platform-specific dynamic library config
if [ "$RUNNER_OS" = "Windows" ]; then
# On Windows, DLLs are located under bin/x64 and found via PATH
R_BIN_DIR="${R_HOME_DIR}/bin/x64"
echo "Adding $R_BIN_DIR to PATH"
echo "PATH=$R_BIN_DIR${PATH:+:$PATH}" >> "$GITHUB_ENV"
else
# On Unix, libR.so lives under $R_HOME/lib and is found via LD_LIBRARY_PATH
R_LIB_DIR="${R_HOME_DIR}/lib"
echo "Adding $R_LIB_DIR to LD_LIBRARY_PATH"
echo "LD_LIBRARY_PATH=$R_LIB_DIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
fi
# 3. Use a writable location for R_LIBS_USER (per-job)
R_USERLIBS="${RUNNER_TEMP}/r-lib"
echo "Setting R_LIBS_USER to $R_USERLIBS"
mkdir -p "$R_USERLIBS"
echo "R_LIBS_USER=$R_USERLIBS" >> $GITHUB_ENV
- name: Cache Rtools 4.5 installer
if: runner.os == 'Windows'
id: cache-rtools
uses: actions/cache@v4
with:
path: rtools-cache
key: rtools45-6768-6492
- name: Download Rtools 4.5 installer
if: runner.os == 'Windows' && steps.cache-rtools.outputs.cache-hit != 'true'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\rtools-cache" | Out-Null
Invoke-WebRequest `
-Uri "https://cran.r-project.org/bin/windows/Rtools/rtools45/files/rtools45-6768-6492.exe" `
-OutFile "$env:GITHUB_WORKSPACE\rtools-cache\rtools45-6768-6492.exe"
- name: Export RTOOLS_INSTALLER_EXE env var
if: runner.os == 'Windows'
shell: pwsh
run: |
$installer = "$env:GITHUB_WORKSPACE\rtools-cache\rtools45-6768-6492.exe"
if (-not (Test-Path $installer)) {
Write-Error "Rtools installer not found at $installer"
}
"RTOOLS_INSTALLER_EXE=$installer" >> $env:GITHUB_ENV
- name: Install Python package
run: |
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov pytest-xdist arviz tqdm
python -m pip install -e ".[dev]"
shell: bash
- name: Test with pytest
env:
BRMSPY_DESTRUCTIVE_RDEPS_TESTS: "1"
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
COVERAGE_FILE: .coverage.${{ matrix.os }}
BRMSPY_RTOOLS_INSTALLER_EXE: ${{ env.RTOOLS_INSTALLER_EXE }}
RPY2_CFFI_MODE: "ABI"
shell: bash
run: set -xeuo pipefail && ./run_tests_rdeps.sh
# Upload per-OS coverage artifacts
- name: Upload coverage artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}
path: .coverage*
include-hidden-files: true
if-no-files-found: ignore
merge-coverage:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download coverage artifacts
uses: actions/download-artifact@v4
with:
# pull all coverage-* artifacts from this workflow run
pattern: coverage-*
merge-multiple: true
- name: Sanity-check downloaded coverage files
run: |
echo "Workspace contents after download:"
ls -la
echo
echo "Coverage data files:"
ls -la .coverage* || echo "No .coverage* files found"
- name: Combine coverage and generate reports
env:
COVERAGE_RCFILE: .coveragerc-r-dependencies
run: |
python -m pip install --upgrade pip
python -m pip install coverage
# Combine all .coverage.* into a single .coverage
coverage combine
# Machine-readable reports
coverage json -o coverage.json
coverage xml -o coverage.xml
# Human-readable summary (similar to pytest-cov's table)
echo "==== Combined coverage report ===="
coverage report -m
echo "=================================="
- name: Upload merged coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-rdeps-merged
path: |
.coverage
coverage.json
coverage.xml
- name: Update coverage badge
uses: ./.github/actions/cover-badge
with:
filename: coverage-rdeps.svg
label: coverage-rdeps