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 @@ - - 17 + 1.8 ${maven.compiler.source} UTF-8 false @@ -518,7 +517,6 @@ Maven javadoc Search redirects to "/undefined/.." url - Stack Overflow https://stackoverflow.com/questions/52326318 --> - --no-module-directories -html5 @@ -672,7 +670,7 @@ - force-jdk11-when-release + force-jdk-version-when-release performRelease @@ -696,7 +694,7 @@ - 11 + 19 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 CompletableFuture failedCf() { + CompletableFuture 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) {