-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cross version test for ml.dmlc.xgboost4j
- Loading branch information
Showing
8 changed files
with
254 additions
and
8 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import sys | ||
|
||
pom_template = """ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>ml.dmlc</groupId> | ||
<artifactId>xgboost4j-tester</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>xgboost4j-tester</name> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>{maven_compiler_source}</maven.compiler.source> | ||
<maven.compiler.target>{maven_compiler_target}</maven.compiler.target> | ||
<scala.version>{scala_version}</scala.version> | ||
<scala.binary.version>{scala_binary_version}</scala.binary.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.esotericsoftware.kryo</groupId> | ||
<artifactId>kryo</artifactId> | ||
<version>2.21</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.scala-lang</groupId> | ||
<artifactId>scala-compiler</artifactId> | ||
<version>${{scala.version}}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.scala-lang</groupId> | ||
<artifactId>scala-reflect</artifactId> | ||
<version>${{scala.version}}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.scala-lang</groupId> | ||
<artifactId>scala-library</artifactId> | ||
<version>${{scala.version}}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
<version>1.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.typesafe.akka</groupId> | ||
<artifactId>akka-actor_${{scala.binary.version}}</artifactId> | ||
<version>2.3.11</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.typesafe.akka</groupId> | ||
<artifactId>akka-testkit_${{scala.binary.version}}</artifactId> | ||
<version>2.3.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.scalatest</groupId> | ||
<artifactId>scalatest_${{scala.binary.version}}</artifactId> | ||
<version>3.0.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ml.dmlc</groupId> | ||
<artifactId>xgboost4j</artifactId> | ||
<version>{xgboost4j_version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ml.dmlc</groupId> | ||
<artifactId>xgboost4j</artifactId> | ||
<version>{xgboost4j_version}</version> | ||
<classifier>tests</classifier> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
</plugin> | ||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.7.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.1</version> | ||
<configuration> | ||
<dependenciesToScan> | ||
<dependency>ml.dmlc:xgboost4j</dependency> | ||
</dependenciesToScan> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
""" | ||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) != 6: | ||
print('Usage: {} [xgboost4j version] [maven compiler source level] [maven compiler target level] [scala version] [scala binary version]'.format(sys.argv[0])) | ||
sys.exit(1) | ||
with open('pom.xml', 'w') as f: | ||
print(pom_template.format(xgboost4j_version=sys.argv[1], | ||
maven_compiler_source=sys.argv[2], | ||
maven_compiler_target=sys.argv[3], | ||
scala_version=sys.argv[4], | ||
scala_binary_version=sys.argv[5]), file=f) |
13 changes: 13 additions & 0 deletions
13
jvm-packages/xgboost4j-tester/src/main/java/ml/dmlc/App.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ml.dmlc; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
System.out.println( "Hello World!" ); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
jvm-packages/xgboost4j-tester/src/test/java/ml/dmlc/AppTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ml.dmlc; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
public class AppTest | ||
{ | ||
/** | ||
* Rigorous Test :-) | ||
*/ | ||
@Test | ||
public void shouldAnswerWithTrue() | ||
{ | ||
assertTrue( true ); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ARG JDK_VERSION | ||
FROM ubuntu:18.04 | ||
|
||
# Environment | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# Install all basic requirements | ||
RUN \ | ||
apt-get update && \ | ||
apt-get install -y tar unzip wget openjdk-${JDK_VERSION}-jdk | ||
|
||
ENV GOSU_VERSION 1.10 | ||
|
||
# Install lightweight sudo (not bound to TTY) | ||
RUN set -ex; \ | ||
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" && \ | ||
chmod +x /usr/local/bin/gosu && \ | ||
gosu nobody true | ||
|
||
# Default entry-point to use if running locally | ||
# It will preserve attributes of created files | ||
COPY entrypoint.sh /scripts/ | ||
|
||
WORKDIR /workspace | ||
ENTRYPOINT ["/scripts/entrypoint.sh"] |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
# Initialize local Maven repository | ||
./tests/ci_build/initialize_maven.sh | ||
|
||
# Get version number of XGBoost4J and other auxiliary information | ||
cd jvm-packages | ||
xgboost4j_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
maven_compiler_source=$(mvn help:evaluate -Dexpression=maven.compiler.source -q -DforceStdout) | ||
maven_compiler_target=$(mvn help:evaluate -Dexpression=maven.compiler.target -q -DforceStdout) | ||
scala_version=$(mvn help:evaluate -Dexpression=scala.version -q -DforceStdout) | ||
scala_binary_version=$(mvn help:evaluate -Dexpression=scala.binary.version -q -DforceStdout) | ||
|
||
# Install XGBoost4J JAR into local Maven repository | ||
mvn install:install-file -Dfile=./jvm-packages/xgboost4j/target/xgboost4j-${xgboost4j_version}.jar -DgroupId=ml.dmlc -DartifactId=xgboost4j -Dversion=${xgboost4j_version} -Dpackaging=jar | ||
mvn install:install-file -Dfile=./jvm-packages/xgboost4j/target/xgboost4j-${xgboost4j_version}-tests.jar -DgroupId=ml.dmlc -DartifactId=xgboost4j -Dversion=${xgboost4j_version} -Dpackaging=test-jar -Dclassifier=tests | ||
|
||
cd xgboost4j-tester | ||
# Generate pom.xml for XGBoost4J-tester, a dummy project to run XGBoost4J tests | ||
python3 ./generate_pom.py ${xgboost4j_version} ${maven_compiler_source} ${maven_compiler_target} ${scala_version} ${scala_binary_version} | ||
# Run tests | ||
mvn test | ||
|
||
set +x | ||
set +e |