Skip to content

Commit 66cc1e0

Browse files
authored
Setup github action. (#5917)
1 parent 627cf41 commit 66cc1e0

File tree

3 files changed

+144
-12
lines changed

3 files changed

+144
-12
lines changed

.github/workflows/main.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,46 @@ on: [push, pull_request]
88

99
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1010
jobs:
11+
test-with-jvm:
12+
name: Test JVM on OS ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [windows-latest, windows-2016, ubuntu-latest]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
with:
22+
submodules: 'true'
23+
24+
- uses: actions/setup-java@v1
25+
with:
26+
java-version: 1.8
27+
28+
- name: Test JVM packages
29+
run: |
30+
cd jvm-packages
31+
mvn test -pl :xgboost4j_2.12
32+
33+
1134
test-with-R:
1235
runs-on: ${{ matrix.config.os }}
1336

14-
name: Test R on OS ${{ matrix.config.os }}, R (${{ matrix.config.r }})
37+
name: Test R on OS ${{ matrix.config.os }}, R ${{ matrix.config.r }}, Compiler ${{ matrix.config.compiler }}, Build ${{ matrix.config.build }}
1538

1639
strategy:
1740
fail-fast: false
1841
matrix:
1942
config:
20-
- {os: windows-latest, r: 'release'}
43+
- {os: windows-latest, r: 'release', compiler: 'msvc', build: 'autotools'}
44+
- {os: windows-2016, r: 'release', compiler: 'msvc', build: 'autotools'}
45+
- {os: windows-latest, r: 'release', compiler: 'msvc', build: 'cmake'}
46+
- {os: windows-2016, r: 'release', compiler: 'msvc', build: 'cmake'}
47+
- {os: windows-latest, r: 'release', compiler: 'mingw', build: 'autotools'}
48+
- {os: windows-2016, r: 'release', compiler: 'mingw', build: 'autotools'}
49+
- {os: windows-latest, r: 'release', compiler: 'mingw', build: 'cmake'}
50+
- {os: windows-2016, r: 'release', compiler: 'mingw', build: 'cmake'}
2151
env:
2252
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
2353
RSPM: ${{ matrix.config.rspm }}
@@ -37,16 +67,11 @@ jobs:
3767
install.packages(c('XML','igraph'))
3868
install.packages(c('data.table','magrittr','stringi','ggplot2','DiagrammeR','Ckmeans.1d.dp','vcd','testthat','lintr','knitr','rmarkdown'))
3969
40-
- name: Config R
41-
run: |
42-
mkdir build && cd build
43-
cmake .. -DCMAKE_CONFIGURATION_TYPES="Release" -DR_LIB=ON
44-
45-
- name: Build R
46-
run: |
47-
cmake --build build --target install --config Release
70+
- uses: actions/setup-python@v2
71+
with:
72+
python-version: '3.6' # Version range or exact version of a Python version to use, using SemVer's version range syntax
73+
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
4874

4975
- name: Test R
5076
run: |
51-
cd R-package
52-
R.exe -q -e "library(testthat); setwd('tests'); source('testthat.R')"
77+
python tests/ci_build/test_r_package.py --compiler="${{ matrix.config.compiler }}" --build-tool="${{ matrix.config.build }}"

tests/ci_build/test_r_package.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import argparse
2+
import os
3+
import subprocess
4+
5+
ROOT = os.path.normpath(
6+
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.pardir,
7+
os.path.pardir))
8+
r_package = os.path.join(ROOT, 'R-package')
9+
10+
11+
class DirectoryExcursion:
12+
def __init__(self, path: os.PathLike):
13+
self.path = path
14+
self.curdir = os.path.normpath(os.path.abspath(os.path.curdir))
15+
16+
def __enter__(self):
17+
os.chdir(self.path)
18+
19+
def __exit__(self, *args):
20+
os.chdir(self.curdir)
21+
22+
23+
def get_mingw_bin():
24+
return os.path.join('c:/rtools40/mingw64/', 'bin')
25+
26+
27+
def test_with_autotools(args):
28+
with DirectoryExcursion(r_package):
29+
if args.compiler == 'mingw':
30+
mingw_bin = get_mingw_bin()
31+
CXX = os.path.join(mingw_bin, 'g++.exe')
32+
CC = os.path.join(mingw_bin, 'gcc.exe')
33+
cmd = ['R.exe', 'CMD', 'INSTALL', str(os.path.curdir)]
34+
env = os.environ.copy()
35+
env.update({'CC': CC, 'CXX': CXX})
36+
subprocess.check_call(cmd, env=env)
37+
elif args.compiler == 'msvc':
38+
cmd = ['R.exe', 'CMD', 'INSTALL', str(os.path.curdir)]
39+
env = os.environ.copy()
40+
# autotool favor mingw by default.
41+
env.update({'CC': 'cl.exe', 'CXX': 'cl.exe'})
42+
subprocess.check_call(cmd, env=env)
43+
else:
44+
raise ValueError('Wrong compiler')
45+
subprocess.check_call([
46+
'R.exe', '-q', '-e',
47+
"library(testthat); setwd('tests'); source('testthat.R')"
48+
])
49+
50+
51+
def test_with_cmake(args):
52+
os.mkdir('build')
53+
with DirectoryExcursion('build'):
54+
if args.compiler == 'mingw':
55+
mingw_bin = get_mingw_bin()
56+
CXX = os.path.join(mingw_bin, 'g++.exe')
57+
CC = os.path.join(mingw_bin, 'gcc.exe')
58+
env = os.environ.copy()
59+
env.update({'CC': CC, 'CXX': CXX})
60+
subprocess.check_call([
61+
'cmake', os.path.pardir, '-DUSE_OPENMP=ON', '-DR_LIB=ON',
62+
'-DCMAKE_CONFIGURATION_TYPES=Release', '-G', 'Unix Makefiles',
63+
],
64+
env=env)
65+
subprocess.check_call(['make', '-j', 'install'])
66+
elif args.compiler == 'msvc':
67+
subprocess.check_call([
68+
'cmake', os.path.pardir, '-DUSE_OPENMP=ON', '-DR_LIB=ON',
69+
'-DCMAKE_CONFIGURATION_TYPES=Release', '-A', 'x64'
70+
])
71+
subprocess.check_call([
72+
'cmake', '--build', os.path.curdir, '--target', 'install',
73+
'--config', 'Release'
74+
])
75+
else:
76+
raise ValueError('Wrong compiler')
77+
with DirectoryExcursion(r_package):
78+
subprocess.check_call([
79+
'R.exe', '-q', '-e',
80+
"library(testthat); setwd('tests'); source('testthat.R')"
81+
])
82+
83+
84+
def main(args):
85+
if args.build_tool == 'autotools':
86+
test_with_autotools(args)
87+
else:
88+
test_with_cmake(args)
89+
90+
91+
if __name__ == '__main__':
92+
parser = argparse.ArgumentParser()
93+
parser.add_argument('--compiler',
94+
type=str,
95+
choices=['mingw', 'msvc'],
96+
help='Compiler used for compiling CXX code.')
97+
parser.add_argument(
98+
'--build-tool',
99+
type=str,
100+
choices=['cmake', 'autotools'],
101+
help='Build tool for compiling CXX code and install R package.')
102+
args = parser.parse_args()
103+
main(args)

tests/python/test_tracker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import pytest
44
import testing as tm
55
import numpy as np
6+
import sys
7+
8+
if sys.platform.startswith("win"):
9+
pytest.skip("Skipping dask tests on Windows", allow_module_level=True)
610

711

812
def test_rabit_tracker():

0 commit comments

Comments
 (0)