Setup github action. (#5917)
This commit is contained in:
parent
627cf41a60
commit
66cc1e02aa
49
.github/workflows/main.yml
vendored
49
.github/workflows/main.yml
vendored
@ -8,16 +8,46 @@ on: [push, pull_request]
|
|||||||
|
|
||||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
jobs:
|
jobs:
|
||||||
|
test-with-jvm:
|
||||||
|
name: Test JVM on OS ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [windows-latest, windows-2016, ubuntu-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
|
||||||
|
- name: Test JVM packages
|
||||||
|
run: |
|
||||||
|
cd jvm-packages
|
||||||
|
mvn test -pl :xgboost4j_2.12
|
||||||
|
|
||||||
|
|
||||||
test-with-R:
|
test-with-R:
|
||||||
runs-on: ${{ matrix.config.os }}
|
runs-on: ${{ matrix.config.os }}
|
||||||
|
|
||||||
name: Test R on OS ${{ matrix.config.os }}, R (${{ matrix.config.r }})
|
name: Test R on OS ${{ matrix.config.os }}, R ${{ matrix.config.r }}, Compiler ${{ matrix.config.compiler }}, Build ${{ matrix.config.build }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config:
|
||||||
- {os: windows-latest, r: 'release'}
|
- {os: windows-latest, r: 'release', compiler: 'msvc', build: 'autotools'}
|
||||||
|
- {os: windows-2016, r: 'release', compiler: 'msvc', build: 'autotools'}
|
||||||
|
- {os: windows-latest, r: 'release', compiler: 'msvc', build: 'cmake'}
|
||||||
|
- {os: windows-2016, r: 'release', compiler: 'msvc', build: 'cmake'}
|
||||||
|
- {os: windows-latest, r: 'release', compiler: 'mingw', build: 'autotools'}
|
||||||
|
- {os: windows-2016, r: 'release', compiler: 'mingw', build: 'autotools'}
|
||||||
|
- {os: windows-latest, r: 'release', compiler: 'mingw', build: 'cmake'}
|
||||||
|
- {os: windows-2016, r: 'release', compiler: 'mingw', build: 'cmake'}
|
||||||
env:
|
env:
|
||||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||||
RSPM: ${{ matrix.config.rspm }}
|
RSPM: ${{ matrix.config.rspm }}
|
||||||
@ -37,16 +67,11 @@ jobs:
|
|||||||
install.packages(c('XML','igraph'))
|
install.packages(c('XML','igraph'))
|
||||||
install.packages(c('data.table','magrittr','stringi','ggplot2','DiagrammeR','Ckmeans.1d.dp','vcd','testthat','lintr','knitr','rmarkdown'))
|
install.packages(c('data.table','magrittr','stringi','ggplot2','DiagrammeR','Ckmeans.1d.dp','vcd','testthat','lintr','knitr','rmarkdown'))
|
||||||
|
|
||||||
- name: Config R
|
- uses: actions/setup-python@v2
|
||||||
run: |
|
with:
|
||||||
mkdir build && cd build
|
python-version: '3.6' # Version range or exact version of a Python version to use, using SemVer's version range syntax
|
||||||
cmake .. -DCMAKE_CONFIGURATION_TYPES="Release" -DR_LIB=ON
|
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
|
||||||
|
|
||||||
- name: Build R
|
|
||||||
run: |
|
|
||||||
cmake --build build --target install --config Release
|
|
||||||
|
|
||||||
- name: Test R
|
- name: Test R
|
||||||
run: |
|
run: |
|
||||||
cd R-package
|
python tests/ci_build/test_r_package.py --compiler="${{ matrix.config.compiler }}" --build-tool="${{ matrix.config.build }}"
|
||||||
R.exe -q -e "library(testthat); setwd('tests'); source('testthat.R')"
|
|
||||||
|
|||||||
103
tests/ci_build/test_r_package.py
Normal file
103
tests/ci_build/test_r_package.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
ROOT = os.path.normpath(
|
||||||
|
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.pardir,
|
||||||
|
os.path.pardir))
|
||||||
|
r_package = os.path.join(ROOT, 'R-package')
|
||||||
|
|
||||||
|
|
||||||
|
class DirectoryExcursion:
|
||||||
|
def __init__(self, path: os.PathLike):
|
||||||
|
self.path = path
|
||||||
|
self.curdir = os.path.normpath(os.path.abspath(os.path.curdir))
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
os.chdir(self.path)
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
os.chdir(self.curdir)
|
||||||
|
|
||||||
|
|
||||||
|
def get_mingw_bin():
|
||||||
|
return os.path.join('c:/rtools40/mingw64/', 'bin')
|
||||||
|
|
||||||
|
|
||||||
|
def test_with_autotools(args):
|
||||||
|
with DirectoryExcursion(r_package):
|
||||||
|
if args.compiler == 'mingw':
|
||||||
|
mingw_bin = get_mingw_bin()
|
||||||
|
CXX = os.path.join(mingw_bin, 'g++.exe')
|
||||||
|
CC = os.path.join(mingw_bin, 'gcc.exe')
|
||||||
|
cmd = ['R.exe', 'CMD', 'INSTALL', str(os.path.curdir)]
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update({'CC': CC, 'CXX': CXX})
|
||||||
|
subprocess.check_call(cmd, env=env)
|
||||||
|
elif args.compiler == 'msvc':
|
||||||
|
cmd = ['R.exe', 'CMD', 'INSTALL', str(os.path.curdir)]
|
||||||
|
env = os.environ.copy()
|
||||||
|
# autotool favor mingw by default.
|
||||||
|
env.update({'CC': 'cl.exe', 'CXX': 'cl.exe'})
|
||||||
|
subprocess.check_call(cmd, env=env)
|
||||||
|
else:
|
||||||
|
raise ValueError('Wrong compiler')
|
||||||
|
subprocess.check_call([
|
||||||
|
'R.exe', '-q', '-e',
|
||||||
|
"library(testthat); setwd('tests'); source('testthat.R')"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
def test_with_cmake(args):
|
||||||
|
os.mkdir('build')
|
||||||
|
with DirectoryExcursion('build'):
|
||||||
|
if args.compiler == 'mingw':
|
||||||
|
mingw_bin = get_mingw_bin()
|
||||||
|
CXX = os.path.join(mingw_bin, 'g++.exe')
|
||||||
|
CC = os.path.join(mingw_bin, 'gcc.exe')
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update({'CC': CC, 'CXX': CXX})
|
||||||
|
subprocess.check_call([
|
||||||
|
'cmake', os.path.pardir, '-DUSE_OPENMP=ON', '-DR_LIB=ON',
|
||||||
|
'-DCMAKE_CONFIGURATION_TYPES=Release', '-G', 'Unix Makefiles',
|
||||||
|
],
|
||||||
|
env=env)
|
||||||
|
subprocess.check_call(['make', '-j', 'install'])
|
||||||
|
elif args.compiler == 'msvc':
|
||||||
|
subprocess.check_call([
|
||||||
|
'cmake', os.path.pardir, '-DUSE_OPENMP=ON', '-DR_LIB=ON',
|
||||||
|
'-DCMAKE_CONFIGURATION_TYPES=Release', '-A', 'x64'
|
||||||
|
])
|
||||||
|
subprocess.check_call([
|
||||||
|
'cmake', '--build', os.path.curdir, '--target', 'install',
|
||||||
|
'--config', 'Release'
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
raise ValueError('Wrong compiler')
|
||||||
|
with DirectoryExcursion(r_package):
|
||||||
|
subprocess.check_call([
|
||||||
|
'R.exe', '-q', '-e',
|
||||||
|
"library(testthat); setwd('tests'); source('testthat.R')"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
if args.build_tool == 'autotools':
|
||||||
|
test_with_autotools(args)
|
||||||
|
else:
|
||||||
|
test_with_cmake(args)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--compiler',
|
||||||
|
type=str,
|
||||||
|
choices=['mingw', 'msvc'],
|
||||||
|
help='Compiler used for compiling CXX code.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--build-tool',
|
||||||
|
type=str,
|
||||||
|
choices=['cmake', 'autotools'],
|
||||||
|
help='Build tool for compiling CXX code and install R package.')
|
||||||
|
args = parser.parse_args()
|
||||||
|
main(args)
|
||||||
@ -3,6 +3,10 @@ import xgboost as xgb
|
|||||||
import pytest
|
import pytest
|
||||||
import testing as tm
|
import testing as tm
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.platform.startswith("win"):
|
||||||
|
pytest.skip("Skipping dask tests on Windows", allow_module_level=True)
|
||||||
|
|
||||||
|
|
||||||
def test_rabit_tracker():
|
def test_rabit_tracker():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user