Skip to content

add .Rbuildignore

add .Rbuildignore #44

Workflow file for this run

on:
push:
branches: [main, master]
tags: ['v*', 'build*']
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: "${{ matrix.config.os }} (R: ${{ matrix.config.r }}, Rust: ${{ matrix.config.rust }})"
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release', rust: 'stable'}
- {os: macOS-latest, r: 'release', rust: 'stable'}
- {os: ubuntu-18.04, r: 'release', rust: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
# - {os: ubuntu-18.04, r: 'devel', rust: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
# - {os: ubuntu-18.04, r: 'release', rust: 'nightly', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
# Note: In the case of pure Rust code, the result binaries have no
# difference between the legacy toolchain and the UCRT toolchain.
# So, this is probably unnecessary, but leave this as-is as this
# might be eventually useful for other package that depends on
# some C/C++ library.
- {os: windows-2022, r: 'devel-ucrt', rust: 'stable'}
env:
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
# used in tools/configure.R
ABORT_WHEN_NO_CARGO: "true"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.config.rust }}
default: true
- name: Additional Rust set up for Windows
if: runner.os == 'Windows'
run: |
rustup target add i686-pc-windows-gnu
rustup target add x86_64-pc-windows-gnu
- name: Setup R
uses: r-lib/actions/setup-r@v1
id: install-r
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
- uses: r-lib/actions/setup-pandoc@v1
- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}
- name: Restore R package cache
uses: actions/cache@v2
with:
path: |
${{ env.R_LIBS_USER }}/*
!${{ env.R_LIBS_USER }}/pak
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("rcmdcheck", execute = TRUE)
shell: Rscript {0}
- name: Install dependencies
run: |
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install(c("rcmdcheck", "pkgbuild"))
shell: Rscript {0}
- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}
- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
run: |
options(crayon.enabled = TRUE)
args <- c("--no-manual", "--as-cran")
if (identical("${{ matrix.config.r }}", "release")) {
args <- c(args, "--force-multiarch")
}
rcmdcheck::rcmdcheck(args = args, error_on = "warning", check_dir = "check")
shell: Rscript {0}
- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
path: check
- name: Test Rust Code
# TODO
# will throw error that `linking with `link.exe` failed: exit code: 1181` on windows
# ignore for now but need to be fixed in the future
if: runner.os != 'Windows'
working-directory: ./src/rust
run: cargo test
- name: Build binaries
if: startsWith(github.ref, 'refs/tags/')
run: |
dir.create("./pkgbin")
pkgbuild::build(binary = TRUE, dest_path = "./pkgbin")
shell: Rscript {0}
- name: Upload pkgbin
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@main
with:
name: pkgbin
path: pkgbin
# Upload prebuilt binaries for Windows
- name: Tweak staticlib on Windows
if: runner.os == 'Windows'
run: |
# list all staticlibs
find ./check -name libymd.a
mkdir ./staticlib
# R-devel already drops 32bit Windows!
if ( "$(Rscript -e 'cat(R.Version()$crt)')".Equals('ucrt') ) {
mv ./check/ymd.Rcheck/00_pkg_src/ymd/src/rust/target/x86_64-pc-windows-gnu/release/libymd.a staticlib/ucrt-x86_64-pc-windows-gnu-libymd.a
} else {
mv ./check/ymd.Rcheck/00_pkg_src/ymd/src-x64/rust/target/x86_64-pc-windows-gnu/release/libymd.a staticlib/x86_64-pc-windows-gnu-libymd.a
mv ./check/ymd.Rcheck/00_pkg_src/ymd/src-i386/rust/target/i686-pc-windows-gnu/release/libymd.a staticlib/i686-pc-windows-gnu-libymd.a
}
ls ./staticlib
shell: pwsh
# Upload prebuilt binaries for macOS
- name: Tweak staticlib on macOS
if: runner.os == 'macOS' && matrix.config.r == 'release'
run: |
# list all staticlibs
find ./check -name libymd.a
mkdir ./staticlib
# Intel macOS
mv ./check/ymd.Rcheck/00_pkg_src/ymd/src/rust/target/release/libymd.a staticlib/x86_64-apple-darwin-libymd.a
# For M1 macOS
rustup target add aarch64-apple-darwin
. "${HOME}/.cargo/env" && cargo build --target=aarch64-apple-darwin --lib --release --manifest-path=./check/ymd.Rcheck/00_pkg_src/ymd/src/rust/Cargo.toml
mv ./check/ymd.Rcheck/00_pkg_src/ymd/src/rust/target/aarch64-apple-darwin/release/libymd.a staticlib/aarch64-apple-darwin-libymd.a
ls ./staticlib
shell: pwsh
- name: Upload staticlib
uses: actions/upload-artifact@main
if: startsWith(github.ref, 'refs/tags/')
with:
name: staticlib
path: staticlib
release:
needs: R-CMD-check
runs-on: ubuntu-latest
# Do not run this on pull request
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
- name: Checksum staticlib
run: |
cd staticlib
sha256sum * > sha256sums.txt
- name: Release staticlib
uses: softprops/action-gh-release@v1
with:
files: 'staticlib/*'
- name: Release pkgbinary
uses: softprops/action-gh-release@v1
with:
files: "pkgbin/*"
Coverage:
needs: R-CMD-check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Install cargo-tarpaulin
uses: actions-rs/[email protected]
with:
crate: cargo-tarpaulin
version: latest
use-tool-cache: true
- name: Coverage with tarpaulin
run: cargo tarpaulin --all --all-features --timeout 600 --out Lcov -- --test-threads 1
working-directory: ./src/rust
- name: Upload coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./src/rust/lcov.info