Skip to content

Update Github Actions for Windows #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
94c6574
Split Windows jobs in two
Ilia-Kosenkov Dec 21, 2020
7c0753a
Setting up GH actions environment
Ilia-Kosenkov Dec 21, 2020
36e48a0
Fixing indentation
Ilia-Kosenkov Dec 21, 2020
9464e1e
Fixing indentation #2
Ilia-Kosenkov Dec 21, 2020
59ca855
Testing environment
Ilia-Kosenkov Dec 21, 2020
efbac57
Fixe incorrect rustup command
Ilia-Kosenkov Dec 21, 2020
677f57f
Checking CARGO_BUILD_FLAGS
Ilia-Kosenkov Dec 21, 2020
3c60921
Running test build
Ilia-Kosenkov Dec 21, 2020
bad5bd1
Probing environment
Ilia-Kosenkov Dec 21, 2020
fb44abb
Testing new build
Ilia-Kosenkov Dec 21, 2020
d0d3a22
Fixing GITHUB_ENV/GITHUB_PATH
Ilia-Kosenkov Dec 21, 2020
d697e7c
Enabling tests
Ilia-Kosenkov Dec 21, 2020
96de673
Enabling macOS
Ilia-Kosenkov Dec 21, 2020
7ce611f
Enabling tests of precomputed bindings
Ilia-Kosenkov Dec 21, 2020
825bc96
Exporting bindings on success
Ilia-Kosenkov Dec 21, 2020
414a62a
Checking Windows paths
Ilia-Kosenkov Dec 21, 2020
a7bdc2a
Trying Win-i686 build
Ilia-Kosenkov Dec 21, 2020
e06db21
Temporary disable ubuntu::r-devel
Ilia-Kosenkov Dec 21, 2020
30200c4
Comment
Ilia-Kosenkov Dec 21, 2020
384bfec
Upload bindings if both build and test succeed
Ilia-Kosenkov Dec 21, 2020
4d508d2
Added RSPM
Ilia-Kosenkov Dec 21, 2020
853c0f5
Disabled ubuntu::r-devel; generate bindings only for stable rust
Ilia-Kosenkov Dec 21, 2020
d7085fa
Removed old code
Ilia-Kosenkov Dec 21, 2020
d583aeb
Fixed rust version comparison string
Ilia-Kosenkov Dec 21, 2020
b48ba58
Testing 'if:' condition
Ilia-Kosenkov Dec 21, 2020
69f38b5
Fixed config
Ilia-Kosenkov Dec 21, 2020
b9a436c
Testing ubuntu::r-devel
Ilia-Kosenkov Dec 21, 2020
3b28751
Bypassing R alias
Ilia-Kosenkov Dec 21, 2020
28da00b
Debugging environment
Ilia-Kosenkov Dec 21, 2020
ca67e18
Cleaning
Ilia-Kosenkov Dec 21, 2020
26c6ba7
Removed unused R_HOME
Ilia-Kosenkov Dec 21, 2020
283b268
Changed generated bindings name
Ilia-Kosenkov Dec 22, 2020
2e4b0ea
Adding Windows/MacOS workflows
Ilia-Kosenkov Dec 22, 2020
9265886
New bindings for Windows/MacOS
Ilia-Kosenkov Dec 22, 2020
e1741f2
Adding Ubuntu jobs
Ilia-Kosenkov Dec 22, 2020
45d5b58
Bindings for Linux
Ilia-Kosenkov Dec 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 117 additions & 124 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,152 +11,145 @@ on:
- master

jobs:
test_linux:
name: Run tests (Linux)
runs-on: ubuntu-20.04

test_with_bindgen:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (R-${{ matrix.config.r }} rust-${{ matrix.config.rust-version }})

strategy:
fail-fast: false
matrix:
rust-version: [stable, beta, nightly]
config:

- {os: windows-latest, r: 'release', rust-version: 'stable-x86_64-pc-windows-msvc'}
- {os: windows-latest, r: 'release', rust-version: 'nightly-x86_64-pc-windows-msvc'}
- {os: windows-latest, r: 'devel', rust-version: 'stable-x86_64-pc-windows-msvc'}
- {os: windows-latest, r: 'oldrel', rust-version: 'stable-x86_64-pc-windows-msvc'}

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
- name: Build
id: build
run: cargo build -vv --features use-bindgen
env:
LIBRSYS_BINDINGS_OUTPUT_PATH: generated_bindings
- name: Run tests
run: cargo test -vv --features use-bindgen -- --nocapture --test-threads=1
- name: Upload generated bindings
if: steps.build.outcome == 'success'
uses: actions/upload-artifact@main
with:
name: Linux ${{ matrix.rust-version }} generated bindings
path: generated_bindings
- name: Run tests on precomputed bindings shipped with libR-sys
run: cargo test -vv -- --nocapture --test-threads=1

- {os: windows-latest, r: 'release', rust-version: 'stable-i686-pc-windows-msvc'}
- {os: windows-latest, r: 'release', rust-version: 'nightly-i686-pc-windows-msvc'}
- {os: windows-latest, r: 'devel', rust-version: 'stable-i686-pc-windows-msvc'}
- {os: windows-latest, r: 'oldrel', rust-version: 'stable-i686-pc-windows-msvc'}


- {os: macOS-latest, r: 'release', rust-version: 'stable'}
- {os: macOS-latest, r: 'release', rust-version: 'nightly'}
- {os: macOS-latest, r: 'devel', rust-version: 'stable'}
- {os: macOS-latest, r: 'oldrel', rust-version: 'stable'}


- {os: ubuntu-20.04, r: 'release', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'release', rust-version: 'nightly', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
# R-devel requires LD_LIBRARY_PATH
- {os: ubuntu-20.04, r: 'devel', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'oldrel', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}

test_macos:
name: Run tests (macOS)
runs-on: macos-latest
strategy:
matrix:
rust-version: [stable]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
- name: Install dependencies
run: brew install llvm r
- name: Set dynamic environment variables
run: echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV
- name: Build
id: build
run: cargo build -vv --features use-bindgen
env:
LIBRSYS_BINDINGS_OUTPUT_PATH: generated_bindings
- name: Run tests
run: cargo test -vv --features use-bindgen -- --nocapture --test-threads=1
- name: Upload generated bindings shipped with libR-sys
if: steps.build.outcome == 'success'
uses: actions/upload-artifact@main
with:
name: macOS generated bindings
path: generated_bindings
- name: Run tests on precomputed bindings
run: cargo test -vv -- --nocapture --test-threads=1

test_windows:
name: Run tests (Windows x86_64)
runs-on: windows-latest

env:
RSPM: ${{ matrix.config.rspm }}

# PowerShell core is available on all platforms and can be used to unify scripts
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
rust-version: [stable-x86_64-pc-windows-gnu]
shell: pwsh
steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2


- name: Set up R
uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.config.rust-version }}
default: true
components: rustfmt, clippy

# This step is only needed for Windows
- name: Set up MSYS2 for Windows
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
path-type: inherit
release: false
update: false
- uses: r-lib/actions/setup-r@v1
with:
r-version: 'release'
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
target: i686-pc-windows-gnu
default: true
components: rustfmt, clippy
- name: Build

# All configurations for Windows go here
# `Rust` toolchain is used to determine target architecture
# Alternatively, `if:` conditions can be used
- name: Configure Windows
if: runner.os == 'Windows'
# 1. Add appropriate *-gnu target
# 2. Set CARGO_BUILD_FLAGS to the `rust` target
# 3. Configure path to `libclang`
# 4. Add path to `mingw32`/`mingw64` -- otherwise library is linked to `rtools`
# 5. Add path to R's `i386`/`x64` -- to solve `x86` build/test issue
run: |
if ($env:RUST_TOOLCHAIN -like "*x86_64*") {
rustup target add x86_64-pc-windows-gnu ;
echo "CARGO_BUILD_FLAGS=--target=x86_64-pc-windows-gnu" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append ;
echo "LIBCLANG_PATH=C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append ;
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
echo "$(Rscript.exe -e 'cat(normalizePath(R.home()))')\bin\x64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
}
if ($env:RUST_TOOLCHAIN -like "*i686*") {
rustup target add i686-pc-windows-gnu ;
echo "CARGO_BUILD_FLAGS=--target=i686-pc-windows-gnu" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append ;
echo "LIBCLANG_PATH=C:\msys64\mingw32\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append ;
echo "C:\msys64\mingw32\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
echo "$(Rscript.exe -e 'cat(normalizePath(R.home()))')\bin\i386" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;

}
env:
RUST_TOOLCHAIN: ${{ matrix.config.rust-version }}


# MacOS configurations, mainly `llvm` and path to `libclang`
- name: Configure MacOs
if: runner.os == 'macOS'
run: |
brew install llvm r
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append


# This is required for ubuntu r-devel
# 'Del alias:R' removes 'R' alias which prevents running R
- name: Configure Linux
if: runner.os == 'linux'
run: |
Del alias:R
echo "LD_LIBRARY_PATH=$(R -s -e 'cat(normalizePath(R.home()))')/lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

# Build and emit bindings to `./generated_bindings`
- name: Build & Emit bindings
id: build
run: |
cargo build -vv --features use-bindgen
cargo build -vv --features use-bindgen $env:CARGO_BUILD_FLAGS
env:
LIBCLANG_PATH: C:/msys64/mingw64/bin
LIBRSYS_BINDINGS_OUTPUT_PATH: generated_bindings
- name: Build i686
id: build_i686
run: |
cargo build -vv --features use-bindgen --target i686-pc-windows-gnu
env:
LIBCLANG_PATH: C:/msys64/mingw64/bin
LIBRSYS_BINDINGS_OUTPUT_PATH: generated_bindings_i686
LIBRSYS_LIBCLANG_INCLUDE_PATH: C:/msys64/mingw32/i686-w64-mingw32/include/

# Test the result of previous step
- name: Run tests
run: cargo test --features use-bindgen -- --nocapture --test-threads=1
id: test
run: |
cargo test -vv --features use-bindgen $env:CARGO_BUILD_FLAGS -- --nocapture --test-threads=1


# If success, upload bindings
- name: Upload generated bindings
if: steps.build.outcome == 'success'
if: steps.build.outcome == 'success' && steps.test.outcome == 'success' && startsWith(matrix.config.rust-version, 'stable')
uses: actions/upload-artifact@main
with:
name: Windows generated bindings
name: ${{ matrix.config.os }} (R-${{ matrix.config.r }} rust-${{ matrix.config.rust-version }}) generated bindings
path: generated_bindings
- name: Upload generated i686 bindings
if: steps.build_i686.outcome == 'success'
uses: actions/upload-artifact@main
with:
name: Windows generated i686 bindings
path: generated_bindings_i686
- name: Run tests on precomputed bindings shipped with libR-sys
run: cargo test -- --nocapture --test-threads=1

## Windows 32bit is disabled as it doesn't currently work
# test_windows_32bit:
# name: Run tests (Windows i686)
# runs-on: windows-latest
# defaults:
# run:
# shell: msys2 {0}
# strategy:
# matrix:
# rust-version: [stable-i686-pc-windows-gnu]
# steps:
# - uses: actions/checkout@v2
# - uses: msys2/setup-msys2@v2
# with:
# msystem: MINGW32
# path-type: inherit
# release: false
# update: false
# - uses: r-lib/actions/setup-r@v1
# with:
# r-version: 'release'
# - uses: actions-rs/toolchain@v1
# with:
# toolchain: ${{ matrix.rust-version }}
# default: true
# components: rustfmt, clippy
# - name: Build with precomputed bindings
# run: cargo build -vv
# - name: Run tests on precomputed bindings
# run: cargo test -vv -- --nocapture --test-threads=1

# Run tests again using different bindings
- name: Run tests on precomputed bindings shipped with libR-sys
run: cargo test -vv $env:CARGO_BUILD_FLAGS -- --nocapture --test-threads=1
Loading