From 8534795604395f700c282952c6752a2190c7ffba Mon Sep 17 00:00:00 2001 From: Lukas Jungmann Date: Wed, 25 May 2022 09:59:41 +0200 Subject: [PATCH] add tck run to the PR check (#58) * add tck run to the PR check Signed-off-by: Lukas Jungmann --- .github/workflows/pr.yml | 62 +++++++++++++- .gitignore | 2 + bundles/dist/pom.xml | 1 + tck-impl/build.gradle | 169 +++++++++++++++++++++++++++++++++++++++ tck-impl/settings.gradle | 18 +++++ 5 files changed, 248 insertions(+), 4 deletions(-) create mode 100644 tck-impl/build.gradle create mode 100644 tck-impl/settings.gradle diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 760d3db7..b1051975 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -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 \ No newline at end of file + 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 diff --git a/.gitignore b/.gitignore index 998689f0..c8dfb82e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ nbproject/ # Java noise *.class *err_pid*.log +/tck-impl/.gradle/ +/tck-impl/build/ diff --git a/bundles/dist/pom.xml b/bundles/dist/pom.xml index 26ad8791..7b5e9bcd 100755 --- a/bundles/dist/pom.xml +++ b/bundles/dist/pom.xml @@ -63,6 +63,7 @@ src/main/assembly/archive.xml + parsson-dist false diff --git a/tck-impl/build.gradle b/tck-impl/build.gradle new file mode 100644 index 00000000..f54240c5 --- /dev/null +++ b/tck-impl/build.gradle @@ -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 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.") + } + } +} diff --git a/tck-impl/settings.gradle b/tck-impl/settings.gradle new file mode 100644 index 00000000..2e847766 --- /dev/null +++ b/tck-impl/settings.gradle @@ -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' +