Skip to content

Commit c400df3

Browse files
authored
test R-package on Windows (#271)
1 parent 43aae31 commit c400df3

File tree

4 files changed

+89
-7
lines changed

4 files changed

+89
-7
lines changed

.appveyor.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,33 @@ platform:
66
- x86
77

88
environment:
9+
global:
10+
R_LIB_PATH: C:\RLibrary
911
matrix:
1012
- PYTHON_VERSION: 2.7
1113
- PYTHON_VERSION: 3.4
1214
- PYTHON_VERSION: 3.5
1315
- PYTHON_VERSION: 3.6
1416
- PYTHON_VERSION: 3.7
17+
- PYTHON_VERSION: 3.6
18+
TASK: R_PACKAGE
19+
20+
matrix:
21+
exclude:
22+
- platform: x86
23+
PYTHON_VERSION: 3.6
24+
TASK: R_PACKAGE
1525

1626
install:
1727
- set PATH=%PATH:C:\Program Files\Git\usr\bin;=% # Delete sh.exe from PATH (mingw32-make fix)
1828
- ps: >-
1929
switch($env:PYTHON_VERSION) {
20-
"2.7" {$env:MINICONDA = """C:\Miniconda"""}
21-
"3.4" {$env:MINICONDA = """C:\Miniconda34"""}
22-
"3.5" {$env:MINICONDA = """C:\Miniconda35"""}
23-
"3.6" {$env:MINICONDA = """C:\Miniconda36"""}
24-
"3.7" {$env:MINICONDA = """C:\Miniconda37"""}
25-
default {$env:MINICONDA = """C:\Miniconda37"""}
30+
"2.7" {$env:MINICONDA = "C:\Miniconda"}
31+
"3.4" {$env:MINICONDA = "C:\Miniconda34"}
32+
"3.5" {$env:MINICONDA = "C:\Miniconda35"}
33+
"3.6" {$env:MINICONDA = "C:\Miniconda36"}
34+
"3.7" {$env:MINICONDA = "C:\Miniconda37"}
35+
default {$env:MINICONDA = "C:\Miniconda37"}
2636
}
2737
- ps: >-
2838
if($env:PLATFORM -eq "x64") {
@@ -45,6 +55,12 @@ install:
4555

4656
test_script:
4757
- pytest tests/ -v
58+
- ps: >-
59+
if($env:TASK -eq "R_PACKAGE") {
60+
cd $env:APPVEYOR_BUILD_FOLDER;
61+
Get-ChildItem env: | Export-CliXml ./env-vars.clixml;
62+
& .\R-package\.R.appveyor.ps1
63+
}
4864
4965
after_test:
5066
- ps: >-
@@ -60,6 +76,9 @@ after_test:
6076
python setup.py bdist_wheel --plat-name=win32 --universal)
6177
- IF NOT "%PLATFORM%" == "x64" rename compile\RGF\bin\rgf.exe rgf32.exe
6278

79+
cache:
80+
- '%R_LIB_PATH%'
81+
6382
artifacts:
6483
- path: python-package\dist\*
6584
name: pip

R-package/.R.appveyor.ps1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
function Check-Output {
2+
param( [int]$ExitCode )
3+
if ($ExitCode -ne 0) {
4+
$host.SetShouldExit($ExitCode)
5+
Exit -1
6+
}
7+
}
8+
9+
10+
Import-CliXml .\env-vars.clixml | % { Set-Item "env:$($_.Name)" $_.Value }
11+
tzutil /s "GMT Standard Time"
12+
cd $env:APPVEYOR_BUILD_FOLDER
13+
14+
[Void][System.IO.Directory]::CreateDirectory($env:R_LIB_PATH)
15+
16+
$env:PATH = "$env:R_LIB_PATH\Rtools\bin;" + "$env:R_LIB_PATH\R\bin\x64;" + "$env:R_LIB_PATH\miktex\texmfs\install\miktex\bin;" + $env:PATH
17+
18+
if (!(Get-Command R.exe -errorAction SilentlyContinue)) {
19+
appveyor DownloadFile https://cloud.r-project.org/bin/windows/base/R-3.5.1-win.exe -FileName ./R-win.exe
20+
Start-Process -FilePath .\R-win.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /DIR=$env:R_LIB_PATH\R"
21+
22+
appveyor DownloadFile https://cloud.r-project.org/bin/windows/Rtools/Rtools35.exe -FileName ./Rtools.exe
23+
Start-Process -FilePath .\Rtools.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /DIR=$env:R_LIB_PATH\Rtools"
24+
25+
appveyor DownloadFile https://miktex.org/download/ctan/systems/win32/miktex/setup/windows-x86/miktex-portable.exe -FileName ./miktex-portable.exe
26+
7z x .\miktex-portable.exe -o"$env:R_LIB_PATH\miktex" -y > $nul
27+
}
28+
29+
initexmf --set-config-value [MPM]AutoInstall=1
30+
conda install -y --no-deps pandoc
31+
32+
cd .\R-package
33+
Add-Content .Renviron "R_LIBS=$env:R_LIB_PATH"
34+
Add-Content .Rprofile "options(repos = 'https://cran.rstudio.com')"
35+
36+
Rscript -e "if(!'devtools' %in% rownames(installed.packages())) { install.packages('devtools', dependencies = TRUE) }"
37+
Rscript -e "if(!'roxygen2' %in% rownames(installed.packages())) { install.packages('roxygen2', dependencies = TRUE) }"
38+
Rscript -e "if(!'testthat' %in% rownames(installed.packages())) { install.packages('testthat', dependencies = TRUE) }"
39+
Rscript -e "if(!'knitr' %in% rownames(installed.packages())) { install.packages('knitr', dependencies = TRUE) }"
40+
Rscript -e "if(!'covr' %in% rownames(installed.packages())) { install.packages('covr', dependencies = TRUE) }"
41+
Rscript -e "if(!'rmarkdown' %in% rownames(installed.packages())) { install.packages('rmarkdown', dependencies = TRUE) }"
42+
Rscript -e "if(!'reticulate' %in% rownames(installed.packages())) { install.packages('reticulate', dependencies = TRUE) }"
43+
Rscript -e "if(!'R6' %in% rownames(installed.packages())) { install.packages('R6', dependencies = TRUE) }"
44+
Rscript -e "if(!'Matrix' %in% rownames(installed.packages())) { install.packages('Matrix', dependencies = TRUE) }"
45+
46+
Rscript -e "update.packages(ask = FALSE, instlib = Sys.getenv('R_LIB_PATH'))"
47+
48+
Rscript -e "devtools::install_deps(pkg = '.', dependencies = TRUE)"
49+
50+
R.exe CMD build . ; Check-Output $LastExitCode
51+
52+
$PKG_FILE_NAME = Get-Item *.tar.gz
53+
$PKG_NAME = $PKG_FILE_NAME.BaseName.split("_")[0]
54+
$LOG_FILE_NAME = "$PKG_NAME.Rcheck/00check.log"
55+
56+
R.exe CMD check "${PKG_FILE_NAME}" --as-cran ; Check-Output $LastExitCode
57+
if (Get-Content "$LOG_FILE_NAME" | Select-String -Pattern "WARNING") {
58+
echo "WARNINGS have been found in the build log!"
59+
Check-Output -1
60+
}
61+
62+
Rscript -e "covr::codecov(quiet = FALSE)"

R-package/.R.travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ else
2929
sudo tlmgr install inconsolata helvetic
3030
fi
3131

32-
conda install --no-deps pandoc
32+
conda install -y --no-deps pandoc
3333

3434
Rscript -e 'if(!"devtools" %in% rownames(installed.packages())) { install.packages("devtools", dependencies = TRUE) }'
3535
Rscript -e 'if(!"roxygen2" %in% rownames(installed.packages())) { install.packages("roxygen2", dependencies = TRUE) }'

R-package/.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
^\.R\.travis\.sh$
2+
^\.R\.appveyor\.ps1$

0 commit comments

Comments
 (0)