[CI] Fix JVM tests on GH Action (#10064)
--------- Co-authored-by: Hyunsu Cho <chohyu01@cs.washington.edu>
This commit is contained in:
parent
b9171d8f0b
commit
eb281ff9b4
32
.github/workflows/jvm_tests.yml
vendored
32
.github/workflows/jvm_tests.yml
vendored
@ -15,31 +15,35 @@ jobs:
|
|||||||
os: [windows-latest, ubuntu-latest, macos-11]
|
os: [windows-latest, ubuntu-latest, macos-11]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
|
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
with:
|
with:
|
||||||
submodules: 'true'
|
submodules: 'true'
|
||||||
|
|
||||||
- uses: actions/setup-python@7f80679172b057fc5e90d70d197929d454754a5a # v4.3.0
|
- uses: mamba-org/setup-micromamba@422500192359a097648154e8db4e39bdb6c6eed7 # v1.8.1
|
||||||
with:
|
with:
|
||||||
python-version: '3.8'
|
micromamba-version: '1.5.6-0'
|
||||||
architecture: 'x64'
|
environment-name: jvm_tests
|
||||||
|
extra-specs: >-
|
||||||
- uses: actions/setup-java@d202f5dbf7256730fb690ec59f6381650114feb2 # v3.6.0
|
python=3.10
|
||||||
with:
|
awscli
|
||||||
java-version: 1.8
|
cache-downloads: true
|
||||||
|
cache-env: true
|
||||||
- name: Install Python packages
|
|
||||||
run: |
|
|
||||||
python -m pip install wheel setuptools
|
|
||||||
python -m pip install awscli
|
|
||||||
|
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3.2.5
|
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('./jvm-packages/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('./jvm-packages/pom.xml') }}
|
||||||
restore-keys: ${{ runner.os }}-m2-${{ hashFiles('./jvm-packages/pom.xml') }}
|
restore-keys: ${{ runner.os }}-m2-${{ hashFiles('./jvm-packages/pom.xml') }}
|
||||||
|
|
||||||
|
- name: Build xgboost4j.dll
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -G"Visual Studio 17 2022" -A x64 -DJVM_BINDINGS=ON
|
||||||
|
cmake --build . --config Release
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
|
||||||
- name: Test XGBoost4J (Core)
|
- name: Test XGBoost4J (Core)
|
||||||
run: |
|
run: |
|
||||||
cd jvm-packages
|
cd jvm-packages
|
||||||
|
|||||||
@ -81,12 +81,7 @@ def native_build(args):
|
|||||||
with cd(".."):
|
with cd(".."):
|
||||||
build_dir = "build-gpu" if cli_args.use_cuda == "ON" else "build"
|
build_dir = "build-gpu" if cli_args.use_cuda == "ON" else "build"
|
||||||
maybe_makedirs(build_dir)
|
maybe_makedirs(build_dir)
|
||||||
with cd(build_dir):
|
|
||||||
if sys.platform == "win32":
|
|
||||||
# Force x64 build on Windows.
|
|
||||||
maybe_generator = " -A x64"
|
|
||||||
else:
|
|
||||||
maybe_generator = ""
|
|
||||||
if sys.platform == "linux":
|
if sys.platform == "linux":
|
||||||
maybe_parallel_build = " -- -j $(nproc)"
|
maybe_parallel_build = " -- -j $(nproc)"
|
||||||
else:
|
else:
|
||||||
@ -111,10 +106,30 @@ def native_build(args):
|
|||||||
if gpu_arch_flag is not None:
|
if gpu_arch_flag is not None:
|
||||||
args.append("%s" % gpu_arch_flag)
|
args.append("%s" % gpu_arch_flag)
|
||||||
|
|
||||||
|
with cd(build_dir):
|
||||||
lib_dir = os.path.join(os.pardir, "lib")
|
lib_dir = os.path.join(os.pardir, "lib")
|
||||||
if os.path.exists(lib_dir):
|
if os.path.exists(lib_dir):
|
||||||
shutil.rmtree(lib_dir)
|
shutil.rmtree(lib_dir)
|
||||||
run("cmake .. " + " ".join(args) + maybe_generator)
|
|
||||||
|
# Same trick as Python build, just test all possible generators.
|
||||||
|
if sys.platform == "win32":
|
||||||
|
supported_generators = (
|
||||||
|
"", # empty, decided by cmake
|
||||||
|
'-G"Visual Studio 17 2022" -A x64',
|
||||||
|
'-G"Visual Studio 16 2019" -A x64',
|
||||||
|
'-G"Visual Studio 15 2017" -A x64',
|
||||||
|
)
|
||||||
|
for generator in supported_generators:
|
||||||
|
try:
|
||||||
|
run("cmake .. " + " ".join(args + [generator]))
|
||||||
|
break
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Failed to build with generator: {generator}", e)
|
||||||
|
with cd(os.path.pardir):
|
||||||
|
shutil.rmtree(build_dir)
|
||||||
|
maybe_makedirs(build_dir)
|
||||||
|
else:
|
||||||
|
run("cmake .. " + " ".join(args))
|
||||||
run("cmake --build . --config Release" + maybe_parallel_build)
|
run("cmake --build . --config Release" + maybe_parallel_build)
|
||||||
|
|
||||||
with cd("demo/CLI/regression"):
|
with cd("demo/CLI/regression"):
|
||||||
|
|||||||
@ -32,7 +32,10 @@ def build_libxgboost(
|
|||||||
build_dir: pathlib.Path,
|
build_dir: pathlib.Path,
|
||||||
build_config: BuildConfiguration,
|
build_config: BuildConfiguration,
|
||||||
) -> pathlib.Path:
|
) -> pathlib.Path:
|
||||||
"""Build libxgboost in a temporary directory and obtain the path to built libxgboost"""
|
"""Build libxgboost in a temporary directory and obtain the path to built
|
||||||
|
libxgboost.
|
||||||
|
|
||||||
|
"""
|
||||||
logger = logging.getLogger("xgboost.packager.build_libxgboost")
|
logger = logging.getLogger("xgboost.packager.build_libxgboost")
|
||||||
|
|
||||||
if not cpp_src_dir.is_dir():
|
if not cpp_src_dir.is_dir():
|
||||||
@ -51,8 +54,8 @@ def build_libxgboost(
|
|||||||
cmake_cmd.extend(build_config.get_cmake_args())
|
cmake_cmd.extend(build_config.get_cmake_args())
|
||||||
|
|
||||||
# Flag for cross-compiling for Apple Silicon
|
# Flag for cross-compiling for Apple Silicon
|
||||||
# We use environment variable because it's the only way to pass down custom flags
|
# We use environment variable because it's the only way to pass down custom
|
||||||
# through the cibuildwheel package, which calls `pip wheel` command.
|
# flags through the cibuildwheel package, which calls `pip wheel` command.
|
||||||
if "CIBW_TARGET_OSX_ARM64" in os.environ:
|
if "CIBW_TARGET_OSX_ARM64" in os.environ:
|
||||||
cmake_cmd.append("-DCMAKE_OSX_ARCHITECTURES=arm64")
|
cmake_cmd.append("-DCMAKE_OSX_ARCHITECTURES=arm64")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user