Skip to content

Commit

Permalink
chore(ci): setup multiply java version in one job of github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Mar 2, 2023
1 parent 86412c3 commit 3a0c8e3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 27 deletions.
66 changes: 54 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/

8 changes: 3 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -696,7 +694,7 @@
<configuration>
<rules>
<requireJavaVersion>
<version>11</version>
<version>19</version>
</requireJavaVersion>
</rules>
</configuration>
Expand Down
17 changes: 12 additions & 5 deletions src/test/java/io/foldright/cffu/CffuTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void test_resultAllOf_exceptionally() throws Exception {
try {
Cffu.resultAllOf(
CompletableFuture.completedFuture(n),
CompletableFuture.failedFuture(rte),
failedCf(),
CompletableFuture.completedFuture(s)
).get();

Expand All @@ -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();
Expand All @@ -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();

Expand Down Expand Up @@ -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();
Expand All @@ -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();

Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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) {
Expand Down

0 comments on commit 3a0c8e3

Please sign in to comment.