Skip to content

Commit 76fbd2c

Browse files
Using rtools to test precomputed bindings on Windows (#51)
* Reordered stepps * Grouped logging * Setting up rtools path * Amending libgcc_eh for rtools * Setting up MSYS2 for binding generation on Windows * Cleanup * Setting rtools as a separate job * Restoring log groups * ::endgroup:: no longer swallows exit status of cargo
1 parent 5ca8d40 commit 76fbd2c

File tree

1 file changed

+100
-6
lines changed

1 file changed

+100
-6
lines changed

.github/workflows/test.yml

Lines changed: 100 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,13 @@ jobs:
135135
id: build
136136
run: |
137137
foreach ($target in ($env:RUST_TARGETS).Split(",")) {
138-
echo "Building for target: $target"
138+
echo "::group::Building for target: $target"
139139
cargo build -vv --features use-bindgen $(if ($target -ne 'default') {"--target=$target"} )
140140
if (!$?) {
141-
echo "::error::$target" ;
141+
echo "::error::Building for target: $target" ;
142142
throw "Last exit code $LASTEXITCODE"
143143
}
144+
echo "::endgroup::"
144145
}
145146
env:
146147
LIBRSYS_BINDINGS_OUTPUT_PATH: generated_bindings
@@ -154,12 +155,13 @@ jobs:
154155
echo "::warning:: Skipping bindgen tests for target: $target"
155156
}
156157
else {
157-
echo "Running bindgen tests for target: $target"
158+
echo "::group::Running bindgen tests for target: $target"
158159
cargo test -vv --features use-bindgen $(if ($target -ne 'default') {"--target=$target"} ) -- --nocapture --test-threads=1
159160
if (!$?) {
160-
echo "::error::$target";
161+
echo "::error::Running bindgen tests for target: $target";
161162
throw "Last exit code $LASTEXITCODE"
162163
}
164+
echo "::endgroup::"
163165
}
164166
}
165167
env:
@@ -190,13 +192,105 @@ jobs:
190192
echo "::warning:: Skipping tests for target: $target"
191193
}
192194
else {
193-
echo "Running tests for target: $target"
195+
echo "::group::Running tests for target: $target"
194196
cargo test -vv $(if ($target -ne 'default') {"--target=$target"} ) -- --nocapture --test-threads=1
195197
if (!$?) {
196-
echo "::error::$target";
198+
echo "::error::Running tests for target: $target";
197199
throw "Last exit code $LASTEXITCODE"
198200
}
201+
echo "::endgroup::"
199202
}
200203
}
201204
env:
202205
NO_TEST_TARGETS: ${{ join(matrix.config.no-test-targets, ',') }}
206+
207+
test_windows_rtools:
208+
runs-on: ${{ matrix.config.os }}
209+
210+
name: ${{ matrix.config.os }} (R-${{ matrix.config.r }} rust-${{ matrix.config.rust-version }}) \w RTOOLS
211+
212+
strategy:
213+
fail-fast: false
214+
matrix:
215+
config:
216+
- {os: windows-latest, r: 'release', rust-version: 'stable-msvc', targets: ['x86_64-pc-windows-gnu', 'i686-pc-windows-gnu']}
217+
218+
env:
219+
RSPM: ${{ matrix.config.rspm }}
220+
221+
# PowerShell core is available on all platforms and can be used to unify scripts
222+
defaults:
223+
run:
224+
shell: pwsh
225+
226+
steps:
227+
228+
- uses: actions/checkout@v2
229+
230+
- name: Set up R
231+
uses: r-lib/actions/setup-r@v1
232+
with:
233+
r-version: ${{ matrix.config.r }}
234+
235+
- name: Set up Rust
236+
uses: actions-rs/toolchain@v1
237+
with:
238+
toolchain: ${{ matrix.config.rust-version }}
239+
default: true
240+
components: rustfmt, clippy
241+
242+
- name: Configure targets
243+
run: |
244+
if ($env:RUST_TARGETS -eq '') {
245+
$env:RUST_TARGETS = "default"
246+
}
247+
foreach ($target in ($env:RUST_TARGETS).Split(",")) {
248+
if ($target -ne "default") {
249+
rustup target add $target
250+
}
251+
}
252+
echo "RUST_TARGETS=$env:RUST_TARGETS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
253+
env:
254+
RUST_TARGETS: ${{ join(matrix.config.targets, ',')}}
255+
256+
# All configurations for Windows go here
257+
# Rust toolchain is used to determine target architecture
258+
- name: Configure Windows
259+
if: runner.os == 'Windows'
260+
# 1. Configure path to libclang
261+
# 2. Add path to mingw32/mingw64 -- otherwise library is linked to rtools
262+
# 3. Add path to R's i386/x64 -- to solve x86 build/test issue
263+
run: |
264+
if ($env:RUST_TARGETS -like "*x86_64*") {
265+
<# Amend rtools libgcc_eh.a #>
266+
cp C:\rtools40\mingw64\lib\gcc\x86_64-w64-mingw32\8.3.0\libgcc.a C:\rtools40\mingw64\lib\gcc\x86_64-w64-mingw32\8.3.0\libgcc_eh.a
267+
echo "C:\rtools40\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
268+
echo "$(Rscript.exe -e 'cat(normalizePath(R.home()))')\bin\x64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
269+
}
270+
if ($env:RUST_TARGETS -like "*i686*") {
271+
echo "C:\rtools40\mingw32\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
272+
echo "$(Rscript.exe -e 'cat(normalizePath(R.home()))')\bin\i386" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
273+
}
274+
275+
276+
# Run tests again using different bindings
277+
- name: Run tests on precomputed bindings shipped with libR-sys
278+
run: |
279+
foreach ($target in ($env:RUST_TARGETS).Split(",")) {
280+
if(($env:NO_TEST_TARGETS).Split(",").Contains($target)) {
281+
echo "::warning:: Skipping tests for target: $target"
282+
}
283+
else {
284+
echo "::group::Running tests for target: $target"
285+
cargo test -vv $(if ($target -ne 'default') {"--target=$target"} ) -- --nocapture --test-threads=1
286+
if (!$?) {
287+
echo "::error::Running tests for target: $target";
288+
throw "Last exit code $LASTEXITCODE"
289+
}
290+
echo "::endgroup::"
291+
}
292+
}
293+
env:
294+
NO_TEST_TARGETS: ${{ join(matrix.config.no-test-targets, ',') }}
295+
296+

0 commit comments

Comments
 (0)