Skip to content

Commit d3b96d0

Browse files
Merge branch '119-test-with-java-8' into dev
2 parents a55115f + f8322e3 commit d3b96d0

File tree

4 files changed

+59
-15
lines changed

4 files changed

+59
-15
lines changed

Jenkinsfile

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ boolean isPublish = BRANCH_NAME == 'publish'
77
String versionPostfix = isPublish ? '' : BRANCH_NAME // Build script detects empty string as not set.
88

99
// Note: using single quotes to avoid Groovy String interpolation leaking secrets.
10+
def signingArgs = '-PsigningKeyFile=$SIGNING_FILE -PsigningKeyId=$SIGNING_ID -PsigningPassword=$SIGNING_PWD'
1011
def gitlabRepoArgs = '-PgitlabUrl=$GITLAB_URL -PgitlabPrivateToken=$GITLAB_TOKEN'
1112
def uploadRepoArgsCentral = '-PsonatypeUsername=$OSSRH_LOGIN_USR -PsonatypePassword=$OSSRH_LOGIN_PSW'
1213

@@ -19,9 +20,9 @@ pipeline {
1920
GITLAB_TOKEN = credentials('GITLAB_TOKEN_ALL')
2021
GITLAB_INTEG_TESTS_TRIGGER_URL = credentials('gitlab-trigger-java-integ-tests')
2122
// Note: for key use Jenkins secret file with PGP key as text in ASCII-armored format.
22-
ORG_GRADLE_PROJECT_signingKeyFile = credentials('objectbox_signing_key')
23-
ORG_GRADLE_PROJECT_signingKeyId = credentials('objectbox_signing_key_id')
24-
ORG_GRADLE_PROJECT_signingPassword = credentials('objectbox_signing_key_password')
23+
SIGNING_FILE = credentials('objectbox_signing_key')
24+
SIGNING_ID = credentials('objectbox_signing_key_id')
25+
SIGNING_PWD = credentials('objectbox_signing_key_password')
2526
}
2627

2728
options {
@@ -39,8 +40,6 @@ pipeline {
3940
stages {
4041
stage('init') {
4142
steps {
42-
sh 'chmod +x gradlew'
43-
sh 'chmod +x ci/test-with-asan.sh'
4443
sh './gradlew -version'
4544

4645
// "|| true" for an OK exit code if no file is found
@@ -50,13 +49,54 @@ pipeline {
5049

5150
stage('build-java') {
5251
steps {
53-
sh "./ci/test-with-asan.sh $gradleArgs $gitlabRepoArgs clean build"
52+
sh "./ci/test-with-asan.sh $gradleArgs $signingArgs $gitlabRepoArgs clean build"
53+
}
54+
post {
55+
always {
56+
junit '**/build/test-results/**/TEST-*.xml'
57+
archiveArtifacts artifacts: 'tests/*/hs_err_pid*.log', allowEmptyArchive: true // Only on JVM crash.
58+
recordIssues(tool: spotBugs(pattern: '**/build/reports/spotbugs/*.xml', useRankAsPriority: true))
59+
}
60+
}
61+
}
62+
63+
stage("test-jdks") {
64+
matrix {
65+
axes {
66+
axis {
67+
name "TEST_JDK"
68+
values "8", "16"
69+
}
70+
}
71+
stages {
72+
stage("test") {
73+
// Set agent to start with new workspace to avoid Gradle compile issues on shared workspace
74+
agent {
75+
label 'java'
76+
}
77+
environment {
78+
TEST_JDK = "${TEST_JDK}"
79+
}
80+
steps {
81+
// "|| true" for an OK exit code if no file is found
82+
sh 'rm tests/objectbox-java-test/hs_err_pid*.log || true'
83+
// Note: do not run check task as it includes SpotBugs.
84+
sh "./ci/test-with-asan.sh $gradleArgs $gitlabRepoArgs clean :tests:objectbox-java-test:test"
85+
}
86+
post {
87+
always {
88+
junit '**/build/test-results/**/TEST-*.xml'
89+
archiveArtifacts artifacts: 'tests/*/hs_err_pid*.log', allowEmptyArchive: true // Only on JVM crash.
90+
}
91+
}
92+
}
93+
}
5494
}
5595
}
5696

5797
stage('upload-to-internal') {
5898
steps {
59-
sh "./gradlew $gradleArgs $gitlabRepoArgs -PversionPostFix=$versionPostfix publishMavenJavaPublicationToGitLabRepository"
99+
sh "./gradlew $gradleArgs $signingArgs $gitlabRepoArgs -PversionPostFix=$versionPostfix publishMavenJavaPublicationToGitLabRepository"
60100
}
61101
}
62102

@@ -70,7 +110,7 @@ pipeline {
70110
message: "*Publishing* ${currentBuild.fullDisplayName} to Central...\n${env.BUILD_URL}"
71111

72112
// Note: supply internal repo as tests use native dependencies that might not be published, yet.
73-
sh "./gradlew $gradleArgs $gitlabRepoArgs $uploadRepoArgsCentral publishMavenJavaPublicationToSonatypeRepository closeAndReleaseStagingRepository"
113+
sh "./gradlew $gradleArgs $signingArgs $gitlabRepoArgs $uploadRepoArgsCentral publishMavenJavaPublicationToSonatypeRepository closeAndReleaseStagingRepository"
74114

75115
googlechatnotification url: 'id:gchat_java',
76116
message: "Published ${currentBuild.fullDisplayName} successfully to Central - check https://repo1.maven.org/maven2/io/objectbox/ in a few minutes.\n${env.BUILD_URL}"
@@ -82,10 +122,6 @@ pipeline {
82122
// For global vars see /jenkins/pipeline-syntax/globals
83123
post {
84124
always {
85-
junit '**/build/test-results/**/TEST-*.xml'
86-
archiveArtifacts artifacts: 'tests/*/hs_err_pid*.log', allowEmptyArchive: true // Only on JVM crash.
87-
recordIssues(tool: spotBugs(pattern: '**/build/reports/spotbugs/*.xml', useRankAsPriority: true))
88-
89125
googlechatnotification url: 'id:gchat_java', message: "${currentBuild.currentResult}: ${currentBuild.fullDisplayName}\n${env.BUILD_URL}",
90126
notifyFailure: 'true', notifyUnstable: 'true', notifyBackToNormal: 'true'
91127
}

ci/test-with-asan.sh

100644100755
File mode changed.

tests/objectbox-java-test/build.gradle

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,18 @@ dependencies {
5757
}
5858

5959
test {
60-
// to run tests with 32-bit ObjectBox
61-
if (System.getenv('TEST_WITH_JAVA_X86') == 'true') {
60+
if (System.getenv("TEST_WITH_JAVA_X86") == "true") {
61+
// to run tests with 32-bit ObjectBox
6262
def javaExecutablePath = System.getenv("JAVA_HOME_X86") + "\\bin\\java"
63-
println "Running tests with ${javaExecutablePath}"
63+
println("Will run tests with $javaExecutablePath")
6464
executable = javaExecutablePath
65+
} else if (System.getenv("TEST_JDK") != null) {
66+
// to run tests on a different JDK
67+
def sdkVersionInt = System.getenv("TEST_JDK") as Integer
68+
println("Will run tests with JDK $sdkVersionInt")
69+
javaLauncher.set(javaToolchains.launcherFor {
70+
languageVersion.set(JavaLanguageVersion.of(sdkVersionInt))
71+
})
6572
}
6673

6774
// This is pretty useless now because it floods console with warnings about internal Java classes

tests/objectbox-java-test/src/test/java/io/objectbox/AbstractObjectBoxTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void setUp() throws IOException {
8686
System.out.println("ObjectBox Java version: " + BoxStore.getVersion());
8787
System.out.println("ObjectBox Core version: " + BoxStore.getVersionNative());
8888
System.out.println("First DB dir: " + boxStoreDir);
89+
System.out.println("java.version=" + System.getProperty("java.version"));
8990
}
9091

9192
store = createBoxStore();

0 commit comments

Comments
 (0)