From 3a0c8e387ee78f24cc8b4e6f6c86a7b885d0e42b Mon Sep 17 00:00:00 2001 From: Jerry Lee <oldratlee@gmail.com> Date: Fri, 3 Mar 2023 01:21:01 +0800 Subject: [PATCH] chore(ci): setup multiply java version in one job of github actions --- .github/workflows/ci.yaml | 66 +++++++++++++++---- pom.xml | 8 +-- src/test/java/io/foldright/cffu/CffuTest.java | 17 +++-- .../CompletableFutureUsageShowcaseTest.kt | 10 +-- 4 files changed, 74 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a8260370..d3036a46 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,22 +5,64 @@ name: CI on: [ push, pull_request, workflow_dispatch ] jobs: test: + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - matrix: - # TODO: need add back java 8 later - # java: [ 8, 11, 17, 19 ] - java: [ 17, 19 ] - fail-fast: false - max-parallel: 64 - name: Test JDK ${{ matrix.java }} + timeout-minutes: 20 + name: test by multiply java versions steps: - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + + - name: setup java19 + uses: actions/setup-java@v3 + with: + java-version: 19 + distribution: temurin + cache: maven + + - name: build and test with java 19 + run: > + ./mvnw -V --no-transfer-progress + help:evaluate -Dexpression=settings.localRepository + -DperformRelease -P'!gen-sign' + clean install + + - name: setup java8 + uses: actions/setup-java@v3 with: - java-version: ${{ matrix.java }} + java-version: 8 distribution: zulu cache: maven - - run: ./mvnw -V --no-transfer-progress clean package + + - run: ./mvnw -V surefire:test + + - name: setup java11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: microsoft + cache: maven + + - run: ./mvnw -V surefire:test + + - name: setup java17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: microsoft + cache: maven + + - run: ./mvnw -V surefire:test + + - name: setup java20 + uses: actions/setup-java@v3 + with: + java-version: 20-ea + distribution: zulu + cache: maven + + - run: ./mvnw -V surefire:test + + - name: remove self maven install files + run: rm -rf $HOME/.m2/repository/io/foldright/cffu/ + diff --git a/pom.xml b/pom.xml index fe37e477..d930e820 100644 --- a/pom.xml +++ b/pom.xml @@ -29,8 +29,7 @@ </issueManagement> <properties> - <!-- TODO: set back to 1.8 after CI setting --> - <maven.compiler.source>17</maven.compiler.source> + <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>${maven.compiler.source}</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.deploy.skip>false</maven.deploy.skip> @@ -518,7 +517,6 @@ Maven javadoc Search redirects to "/undefined/.." url - Stack Overflow https://stackoverflow.com/questions/52326318 --> - <additionalOption>--no-module-directories</additionalOption> <additionalOption>-html5</additionalOption> </additionalOptions> <additionalJOptions> @@ -672,7 +670,7 @@ </build> </profile> <profile> - <id>force-jdk11-when-release</id> + <id>force-jdk-version-when-release</id> <activation> <property> <name>performRelease</name> @@ -696,7 +694,7 @@ <configuration> <rules> <requireJavaVersion> - <version>11</version> + <version>19</version> </requireJavaVersion> </rules> </configuration> diff --git a/src/test/java/io/foldright/cffu/CffuTest.java b/src/test/java/io/foldright/cffu/CffuTest.java index 702c08dc..362343c9 100644 --- a/src/test/java/io/foldright/cffu/CffuTest.java +++ b/src/test/java/io/foldright/cffu/CffuTest.java @@ -65,7 +65,7 @@ void test_resultAllOf_exceptionally() throws Exception { try { Cffu.resultAllOf( CompletableFuture.completedFuture(n), - CompletableFuture.failedFuture(rte), + failedCf(), CompletableFuture.completedFuture(s) ).get(); @@ -80,7 +80,7 @@ void test_resultOf_2_or_3_exceptionally() throws Exception { try { Cffu.resultOf( CompletableFuture.completedFuture(n), - CompletableFuture.failedFuture(rte) + failedCf() ).get(); fail(); @@ -91,7 +91,7 @@ void test_resultOf_2_or_3_exceptionally() throws Exception { try { Cffu.resultOf( CompletableFuture.completedFuture(n), - CompletableFuture.failedFuture(rte), + failedCf(), CompletableFuture.completedFuture(s) ).get(); @@ -124,7 +124,7 @@ public void test_anyOf_exceptionally() throws Exception { Cffu.anyOf( createNormallyCompletedFutureWithSleep(another_n), createNormallyCompletedFutureWithSleep(another_n), - CompletableFuture.failedFuture(rte) + failedCf() ).get(); fail(); @@ -135,7 +135,7 @@ public void test_anyOf_exceptionally() throws Exception { try { Cffu.anyOf(Arrays.asList( createNormallyCompletedFutureWithSleep(another_n), - CompletableFuture.failedFuture(rte), + failedCf(), createNormallyCompletedFutureWithSleep(another_n) )).get(); @@ -159,4 +159,11 @@ public void test_anyOf_exceptionally() throws Exception { createExceptionallyCompletedFutureWithSleep(rte) )).get()); } + + + private static <T> CompletableFuture<T> failedCf() { + CompletableFuture<T> cf = new CompletableFuture<>(); + cf.completeExceptionally(rte); + return cf; + } } diff --git a/src/test/java/io/foldright/showcases/CompletableFutureUsageShowcaseTest.kt b/src/test/java/io/foldright/showcases/CompletableFutureUsageShowcaseTest.kt index 8fd9321a..fa25ca80 100644 --- a/src/test/java/io/foldright/showcases/CompletableFutureUsageShowcaseTest.kt +++ b/src/test/java/io/foldright/showcases/CompletableFutureUsageShowcaseTest.kt @@ -330,7 +330,7 @@ class CompletableFutureUsageShowcaseTest : FunSpec({ sequenceChecker.assertSeq("in completeAsync", 4) } - test("timeout control: normally completed with replacement value") { + test("timeout control: normally completed with replacement value").config(enabledIf = java9Plus) { val f = CompletableFuture.supplyAsync { sleep(10) n @@ -340,7 +340,7 @@ class CompletableFutureUsageShowcaseTest : FunSpec({ f.get() shouldBe anotherN } - test("timeout control: exceptionally completed with java.util.concurrent.TimeoutException") { + test("timeout control: exceptionally completed with java.util.concurrent.TimeoutException").config(enabledIf = java9Plus) { val f = CompletableFuture .supplyAsync { sleep(10) @@ -356,9 +356,9 @@ class CompletableFutureUsageShowcaseTest : FunSpec({ f.get() shouldBe anotherN } - test("delay execution") { + test("delay execution").config(enabledIf = java9Plus) { val tick = currentTimeMillis() - val delay = 5L + val delay = 10L val delayer = CompletableFuture.delayedExecutor(delay, TimeUnit.MILLISECONDS) @@ -367,7 +367,7 @@ class CompletableFutureUsageShowcaseTest : FunSpec({ currentTimeMillis() - tick }, delayer).get() - duration.shouldBeBetween(delay, delay + 2) + duration.shouldBeBetween(delay, delay + 4) } xtest("performance CF then*").config(invocations = 10) {