ci-tests #636
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# | |
# See https://github.com/r-lib/actions/tree/v2/examples#readme for | |
# additional example workflows available for the R community. | |
name: ci-tests | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
schedule: | |
- cron: '12 23 13,28 * *' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ${{ matrix.config.os-name }}-${{ matrix.config.os-version }} | |
name: >- | |
${{ matrix.config.os-name }}-${{ matrix.config.os-version }} | |
R ${{ matrix.config.r-version}} - java ${{ matrix.config.java}} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- os-name: ubuntu # windows-2019, macos-10.15] | |
os-version: latest | |
r-version: oldrel | |
java: 17 #8 | |
vignettes: true | |
timezone-name: Europe/Zurich | |
- os-name: ubuntu # windows-2019, macos-10.15] | |
os-version: latest | |
r-version: release | |
java: 21 | |
vignettes: true | |
timezone-name: Asia/Kathmandu | |
- os-name: ubuntu # windows-2019, macos-10.15] | |
os-version: "20.04" | |
r-version: devel | |
java: 17 | |
vignettes: true | |
timezone-name: Pacific/Marquesas | |
- os-name: macos # TODO fix java / R interaction | |
os-version: latest | |
r-version: release | |
# java: 13 | |
vignettes: false | |
- os-name: windows # windows-2019, macos-10.15] | |
os-version: "2019" | |
r-version: release | |
java: 8 | |
vignettes: false | |
timezone-name: "W. Europe Standard Time" | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
XLCONNECT_JAVA_REPO_URL: ${{ matrix.config.xlc-repo }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup java (x64) | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: ${{ matrix.config.java }} | |
java-package: jdk | |
architecture: x64 | |
if: matrix.config.os-name != 'macos' && matrix.config.java != 11 | |
- name: Set up R ${{ matrix.config.r-version }} | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.config.r-version }} | |
use-public-rspm: true | |
- name: print effective R version | |
run: version | |
shell: Rscript {0} | |
- name: test additional java env var | |
if: ${{!matrix.config.vignettes}} # covering with / without the var being present | |
run: echo 'JAVA_TOOL_OPTIONS="-Dlog4j.formatMsgNoLookups=true"' >> $GITHUB_ENV | |
# todo not sure if this is run again during "Install and cache dependencies" before rJava install | |
- name: run javareconf # Yes it actually needs JAVA_HOME=$JAVA_HOME, doesn't use actual env vars (!) | |
if: runner.os != 'Windows' && matrix.config.java != 11 | |
run: | | |
java -version | |
echo java_home:$JAVA_HOME | |
echo library paths: $LD_LIBRARY_PATH | |
sudo R CMD javareconf JAVA_HOME=$JAVA_HOME | |
- name: effective java version # Yes it actually needs JAVA_HOME=$JAVA_HOME, doesn't use actual env vars (!) | |
if: runner.os == 'Windows' | |
run: java -version | |
- name: Install and cache dependencies | |
uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
cache-version: ${{ matrix.config.java }} | |
extra-packages: | | |
any::covr | |
any::rcmdcheck | |
any::remotes | |
- name: Install tinytex | |
if: matrix.config.vignettes | |
uses: r-lib/actions/setup-tinytex@v2 | |
- name: Install extra Tex packages | |
if: matrix.config.vignettes | |
run: | | |
pak::pkg_install('tinytex') | |
library(tinytex) | |
tlmgr_update(self=TRUE, all=FALSE) | |
tlmgr_install('datetime') | |
tlmgr_install('hyperref') | |
tlmgr_install('url') | |
tlmgr_install('fmtcount') | |
tinytex:::install_yihui_pkgs() | |
shell: Rscript {0} | |
- name: Install PDF system dependencies | |
if: runner.os == 'Linux' && matrix.config.vignettes | |
run: | | |
sudo apt-get install -y qpdf ghostscript tidy | |
- name: Session info | |
run: | | |
options(width = 100) | |
pkgs <- installed.packages()[, "Package"] | |
sessionInfo() | |
shell: Rscript {0} | |
- name: set TZ for tests / check | |
run: echo 'TZ=${{ matrix.config.timezone-name }}' >> $GITHUB_ENV | |
- uses: 'szenius/[email protected]' | |
if: matrix.config.os-name == 'ubuntu' | |
with: | |
timezoneLinux: ${{ matrix.config.timezone-name }} | |
- uses: 'szenius/[email protected]' | |
if: matrix.config.os-name == 'macos' | |
with: | |
timezoneMacos: ${{ matrix.config.timezone-name }} | |
- uses: 'szenius/[email protected]' | |
if: matrix.config.os-name == 'windows' | |
with: | |
timezoneWindows: ${{ matrix.config.timezone-name }} | |
- name: Check without doc | |
if: ${{!matrix.config.vignettes}} | |
uses: r-lib/actions/check-r-package@v2 | |
with: | |
args: 'c("--no-manual", "--no-vignettes", "--no-build-vignettes", "--check-subdirs=no", | |
"--no-multiarch"["${{matrix.config.os-name}}" == "windows"])' | |
build_args: 'c("--no-build-vignettes")' | |
error-on: '"error"' | |
env: | |
FULL_TEST_SUITE: 1 | |
- name: Check with doc | |
if: matrix.config.vignettes | |
uses: r-lib/actions/check-r-package@v2 | |
with: | |
args: 'c("--as-cran")' | |
build_args: 'c("--compact-vignettes=gs+qpdf")' | |
env: | |
FULL_TEST_SUITE: 0 | |
- name: run complete test suite # some tests are not run in r check, as test xls(x) files are Rbuild-ignored | |
if: always() | |
env: | |
_R_CHECK_CRAN_INCOMING_: false | |
FULL_TEST_SUITE: 1 | |
RCMDCHECK: "FALSE" | |
run: | | |
install_opts = if("${{matrix.config.os-name}}" == "windows") { | |
c("--no-multiarch") | |
} else { | |
c() | |
} | |
install.packages(list.files("./check", pattern = "XLConnect_.*.tar.gz", full.names = TRUE), repos=NULL, type="source", INSTALL_opts=install_opts) | |
setwd("tests") | |
source("run_tests.R") | |
shell: Rscript {0} | |
- name: Show test output | |
if: always() | |
run: | | |
echo $(date) | |
cat inst/unitTests/resources/XLConnect_Unit_Tests.txt || true | |
git clean -fd "*xls*" | |
grep -i "0 errors, 0 failures" inst/unitTests/resources/XLConnect_Unit_Tests.txt | |
shell: bash | |
continue-on-error: true | |
- name: coverage report | |
if: success() && matrix.config.r-version == 'release' && matrix.config.os-name == 'ubuntu' | |
run: | | |
library(covr) | |
covr::codecov(function_exclusions=c("onLoad", "onAttach", "xlcEnsureDependencies", "checkSystemPackage")) | |
shell: Rscript {0} | |
- name: Upload check results | |
if: failure() | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ matrix.config.os-name }}${{matrix.config.os-version}}-java${{ matrix.config.java }}-R${{ matrix.config.r-version }}-results | |
path: | | |
inst/unitTests/resources/XLConnect_Unit_Tests.* | |
check/XLConnect.Rcheck/ | |
!check/XLConnect.Rcheck/**/*.jar | |
!check/XLConnect.Rcheck/00_pkg_src/ | |
- name: Upload successfully built package | |
if: success() && matrix.config.vignettes | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ matrix.config.os-name }}${{matrix.config.os-version}}-java${{ matrix.config.java }}-R${{ matrix.config.r-version }}-results | |
path: | | |
check/XLConnect_*.tar.gz | |
- name: checkout XLConnect java | |
if: success() && matrix.config.r-version == 'release' && matrix.config.os-name == 'ubuntu' | |
uses: actions/checkout@v4 | |
with: | |
repository: miraisolutions/xlconnect-java | |
# specify the below if you are working on a parallel xlconnect-java branch | |
# ref: feature/... | |
- name: retrieve POM dependencies using maven | |
if: success() && matrix.config.r-version == 'release' && matrix.config.os-name == 'ubuntu' | |
run: | | |
ls -la | |
mvn dependency:copy-dependencies | |
- name: compare JAR hashes | |
if: success() && matrix.config.r-version == 'release' && matrix.config.os-name == 'ubuntu' | |
run: | | |
set -eux -o pipefail | |
XLC_JAR_PATH=$(Rscript -e "cat(.libPaths()[1])")/XLConnect/java | |
rm -f "$XLC_JAR_PATH"/XLConnect* | |
find "$XLC_JAR_PATH" -maxdepth 1 -type f -name "*.jar" -exec sha512sum {} + |\ | |
sort | awk '{print $1}' > effective_hashes | |
find "$GITHUB_WORKSPACE"/target/dependency/ -maxdepth 1 -type f -name "*.jar" -exec sha512sum {} + |\ | |
grep -v -E "poi-ooxml-lite|junit|hamcrest" |\ | |
sort | awk '{print $1}' > expected_hashes | |
cmp expected_hashes effective_hashes ||\ | |
(echo "JARs are different!" && ls -la "$GITHUB_WORKSPACE"/target/dependency/ &&\ | |
ls -la "$XLC_JAR_PATH" &&\ | |
exit 1) |