Skip to content

Commit

Permalink
add tck run to the PR check (#58)
Browse files Browse the repository at this point in the history
* add tck run to the PR check

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj authored May 25, 2022
1 parent 44ff34f commit 8534795
Show file tree
Hide file tree
Showing 5 changed files with 248 additions and 4 deletions.
62 changes: 58 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,74 @@ jobs:
build:
name: Test on JDK ${{ matrix.java_version }}
runs-on: ubuntu-latest
outputs:
jdk: ${{ steps.build.outputs.jdk }}

strategy:
matrix:
java_version: [ 11, 17-ea ]
java_version: [ 11, 17 ]

steps:
- name: Cancel previous runs of this workflow
uses: styfle/cancel-workflow-action@0.9.1
with:
all_but_latest: true
access_token: ${{ github.token }}
- name: Checkout for build
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java_version }}
cache: 'maven'
- name: Verify
id: build
# GH action creates a merge commit which modifies files in the current year, to get over it, we have to exclude the check for the year of modification
run: mvn -B -V -U -C -Poss-release,staging clean verify org.glassfish.copyright:glassfish-copyright-maven-plugin:check -Dgpg.skip=true -Dcopyright.ignoreyear=true
run: |
mvn -B -V -U -C -Poss-release,staging clean verify org.glassfish.copyright:glassfish-copyright-maven-plugin:check -Dgpg.skip=true -Dcopyright.ignoreyear=true
echo "::set-output name=jdk::${{ matrix.java_version }}"
- name: Upload binary image
uses: actions/upload-artifact@v2
if: success()
with:
name: parsson-dist
path: bundles/dist/target/parsson-dist.zip

test:
needs: build
strategy:
fail-fast: false
matrix:
test_suite:
- mods
- standalone
name: TCK ${{ matrix.test_suite }}
runs-on: ubuntu-latest
steps:
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ needs.build.outputs.jdk }}
- name: Checkout tests
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download binaries
uses: actions/download-artifact@v2
with:
name: parsson-dist
- name: Prepare distribution
run: unzip -q -d image parsson-dist.zip
- name: Test
uses: gradle/gradle-build-action@v2
with:
gradle-version: current
build-root-directory: tck-impl
arguments: check -Pparsson.home=image/parsson-dist -Pparsson.impl=${{ matrix.test_suite }}
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: test-results
path: tck-impl/build/distributions/tck-test-results.zip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ nbproject/
# Java noise
*.class
*err_pid*.log
/tck-impl/.gradle/
/tck-impl/build/
1 change: 1 addition & 0 deletions bundles/dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<descriptors>
<descriptor>src/main/assembly/archive.xml</descriptor>
</descriptors>
<finalName>parsson-dist</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
Expand Down
169 changes: 169 additions & 0 deletions tck-impl/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

plugins {
id 'java'
}

repositories {
mavenCentral()
maven {
url "https://jakarta.oss.sonatype.org/content/repositories/staging/"
}
}

configurations {
tckTests.extendsFrom testImplementation
sigTests.extendsFrom tckTests
pluggabilityTests.extendsFrom testImplementation
testedImplementation
}

dependencies {
tckTests("jakarta.json:jakarta.json-tck-tests:2.1.0")
sigTests("org.netbeans.tools:sigtest-maven-plugin:1.6")
pluggabilityTests("jakarta.json:jakarta.json-tck-tests-pluggability:2.1.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
}

if (hasProperty("parsson.home")) {
String root = System.getenv("GITHUB_WORKSPACE")
File home = root != null ? new File(root, getProperty("parsson.home")) : new File(getProperty("parsson.home"))
File impl = new File(home, hasProperty("parsson.impl") ? getProperty("parsson.impl") : "mods")
if (!home.exists() || !home.isDirectory()) {
throw new InvalidUserDataException("invalid parsson.home, was: " + home.getAbsolutePath())
}
if (!impl.exists() || !impl.isDirectory()) {
throw new InvalidUserDataException("invalid parsson.impl, was: " + impl.getName() + "; can be: mods or standalone")
}

dependencies {
testedImplementation fileTree(impl) {
include '*.jar'
}
}
} else {
throw new InvalidUserDataException("parsson.home has to be set")
}

List<TestDescriptor> failures = new ArrayList<>()

tasks.withType(Test) {
forkEvery 1
systemProperty 'java.awt.headless', 'true'
// listen to events in the test execution lifecycle
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
ignoreFailures true

afterTest { descriptor, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
failures.add(descriptor)
}
}
}

String apiPath = ""
configurations.testedImplementation.getFiles().forEach {
apiPath += it.getAbsolutePath()
apiPath += ":"
}
String jimageDir = new File(buildDir, "jimage").getAbsolutePath()
String sigTestClasspath = "${apiPath}${jimageDir}/java.base:${jimageDir}/java.rmi:${jimageDir}/java.sql:${jimageDir}/java.naming"

testing {
suites {
test {
useJUnitJupiter()
targets {
all {
testTask.configure {
classpath = configurations.tckTests + configurations.testedImplementation
testClassesDirs += configurations.tckTests.files.findAll {
it.name.contains("tck-tests")
}.collect {
zipTree(it).matching {
exclude "**/JSONPSigTest*"
}
}.sum()
}
}
}
}

signatureTest(JvmTestSuite) {
targets {
all {
testTask.configure {
shouldRunAfter test
systemProperty 'jimage.dir', jimageDir
systemProperty 'signature.sigTestClasspath', sigTestClasspath

classpath = configurations.sigTests + configurations.testedImplementation
testClassesDirs += configurations.sigTests.files.findAll {
it.name.contains("tck-tests")
}.collect {
zipTree(it).matching {
include "**/JSONPSigTest*"
}
}.sum()
}
}
}
}

pluggabilityTest(JvmTestSuite) {
targets {
all {
testTask.configure {
shouldRunAfter test
classpath = configurations.pluggabilityTests + configurations.testedImplementation
testClassesDirs += configurations.pluggabilityTests.files.findAll { it.name.contains("tck-tests") }.collect { zipTree it }.sum()
}
}
}
}
}
}

tasks.register("packageTestResults", Zip) {
archiveFileName = "tck-test-results.zip"
from getProperty("testReportDir")
configure {
mustRunAfter(testing.suites.test)
mustRunAfter(testing.suites.pluggabilityTest)
mustRunAfter(testing.suites.signatureTest)
}

}

tasks.named('check') {
dependsOn(testing.suites.test)
dependsOn(testing.suites.pluggabilityTest)
dependsOn(testing.suites.signatureTest)
dependsOn("packageTestResults")
doLast {
if (!failures.isEmpty()) {
logger.error("There are test failures:")
failures.each { TestDescriptor td ->
logger.error(td.className + "::" + td.name)

}
throw new GradleException(failures.size() + " test(s) failed.")
}
}
}
18 changes: 18 additions & 0 deletions tck-impl/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

rootProject.name = 'parsson-tck-runner'

0 comments on commit 8534795

Please sign in to comment.