From f78a789d66dc8c933cc398a565cd66228036e1af Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Mon, 31 Jan 2022 15:03:26 -0800 Subject: [PATCH 1/8] Create build-validation.yml --- .github/workflows/build-validation.yml | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/build-validation.yml diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml new file mode 100644 index 00000000..a9d61862 --- /dev/null +++ b/.github/workflows/build-validation.yml @@ -0,0 +1,31 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build Validation + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514 + with: + arguments: build From f391f7191b20f5cd13f45581d53e1fb777bfc07b Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Mon, 31 Jan 2022 15:07:48 -0800 Subject: [PATCH 2/8] Make gradlew executable --- gradlew | 0 .../test/java/com/microsoft/durabletask/IntegrationTests.java | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/sdk/src/test/java/com/microsoft/durabletask/IntegrationTests.java b/sdk/src/test/java/com/microsoft/durabletask/IntegrationTests.java index 7351ba05..14c9ce6a 100644 --- a/sdk/src/test/java/com/microsoft/durabletask/IntegrationTests.java +++ b/sdk/src/test/java/com/microsoft/durabletask/IntegrationTests.java @@ -89,7 +89,7 @@ void singleTimer() throws IOException { } @Test - public void isReplaying() throws IOException, InterruptedException { + void isReplaying() throws IOException, InterruptedException { final String orchestratorName = "SingleTimer"; DurableTaskGrpcWorker worker = this.createWorkerBuilder() .addOrchestrator(orchestratorName, ctx -> { From 7c75cdc2ae46b7001465c8c063975f9e590cf3e5 Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Mon, 31 Jan 2022 15:13:30 -0800 Subject: [PATCH 3/8] Submodules + Microsoft JDK --- .github/workflows/build-validation.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index a9d61862..9a619aef 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -20,11 +20,13 @@ jobs: steps: - uses: actions/checkout@v2 + with: + submodules: true - name: Set up JDK 11 uses: actions/setup-java@v2 with: java-version: '11' - distribution: 'temurin' + distribution: 'microsoft' - name: Build with Gradle uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514 with: From 42c52581f77762a8d05897275e470fc41d79b04b Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Tue, 1 Feb 2022 11:20:48 -0800 Subject: [PATCH 4/8] Add integration testing --- .github/workflows/build-validation.yml | 7 ++++++ sdk/build.gradle | 24 +++++++++++++++---- .../durabletask/IntegrationTests.java | 2 ++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index 9a619aef..c1c30a1c 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -31,3 +31,10 @@ jobs: uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514 with: arguments: build + # TODO: Move the sidecar into a central image repository + - name: Initialize Durable Task Sidecar + run: docker run --name durabletask-sidecar -p 4001:4001 --env 'DURABLETASK_SIDECAR_LOGLEVEL=Debug' -d cgillum/durabletask-sidecar:latest start --backend Emulator + - name: Integration Tests with Gradle + uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514 + with: + arguments: check diff --git a/sdk/build.gradle b/sdk/build.gradle index 9c21ceed..fde9a4b9 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -1,5 +1,5 @@ plugins { - id "java" + id 'java' id 'com.google.protobuf' version '0.8.16' // Generate IntelliJ IDEA's .idea & .iml project files id 'idea' @@ -55,8 +55,22 @@ sourceSets { } test { - useJUnitPlatform() + useJUnitPlatform { + // Skip tests tagged as "integration" since those are slower + // and require external dependencies. + excludeTags "integration" + } +} + +// Unlike normal unit tests, some tests are considered "integration tests" and shouldn't be +// run during a build. We instead tag them as "integration" tests and only run them as part +// of this custom integrationTest task. Normal builds won't execute this, but CI builds will +// by running "gradle check" (see the dependsOn() further down). +task integrationTest(type: Test) { + useJUnitPlatform { + includeTags 'integration' + } + shouldRunAfter test +} - // Integration tests require the dt sidecar to be running - exclude 'com/microsoft/durabletask/IntegrationTests.class' -} \ No newline at end of file +check.dependsOn(integrationTest) diff --git a/sdk/src/test/java/com/microsoft/durabletask/IntegrationTests.java b/sdk/src/test/java/com/microsoft/durabletask/IntegrationTests.java index 14c9ce6a..b15398e0 100644 --- a/sdk/src/test/java/com/microsoft/durabletask/IntegrationTests.java +++ b/sdk/src/test/java/com/microsoft/durabletask/IntegrationTests.java @@ -17,6 +17,7 @@ import java.util.stream.IntStream; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -29,6 +30,7 @@ * running on the local machine (the sidecar is what accepts the client operations and * sends invocation instructions to the DurableTaskWorker). */ +@Tag("integration") public class IntegrationTests { static final Duration defaultTimeout = Duration.ofSeconds(100); From a01408b154ac0dbb1b8fb7f6ae58e6f9657c4a52 Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Tue, 1 Feb 2022 11:48:51 -0800 Subject: [PATCH 5/8] Separate integration tests from standard build --- .github/workflows/build-validation.yml | 2 +- sdk/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index c1c30a1c..756e47f9 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -37,4 +37,4 @@ jobs: - name: Integration Tests with Gradle uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514 with: - arguments: check + arguments: integrationTest diff --git a/sdk/build.gradle b/sdk/build.gradle index fde9a4b9..6f30bffa 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -70,7 +70,7 @@ task integrationTest(type: Test) { useJUnitPlatform { includeTags 'integration' } + dependsOn build shouldRunAfter test } -check.dependsOn(integrationTest) From c6076ca043412220d41245d8320e771a37cc9922 Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Tue, 1 Feb 2022 12:02:42 -0800 Subject: [PATCH 6/8] Upload artifacts + build status badge --- .github/workflows/build-validation.yml | 10 ++++++++++ README.md | 2 ++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index 756e47f9..bae57831 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -38,3 +38,13 @@ jobs: uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514 with: arguments: integrationTest + - name: Archive test report + uses: actions/upload-artifact@v2 + with: + name: Test report + path: build/reports/tests/test + - name: Upload JAR output + uses: actions/upload-artifact@v2 + with: + name: Package + path: build/libs diff --git a/README.md b/README.md index 1fc3cc55..492daf7f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Java SDK for the Durable Task Framework +[![Build](https://github.com/microsoft/durabletask-java/actions/workflows/build-validation.yml/badge.svg)](https://github.com/microsoft/durabletask-java/actions/workflows/build-validation.yml) + This repo contains the Java SDK for the Durable Task Framework. ⚠ This README is currently under construction ⚠ From e8417545cf9882d5c248e1bca7217336e9a0852a Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Tue, 1 Feb 2022 12:11:00 -0800 Subject: [PATCH 7/8] Fix artifact upload paths --- .github/workflows/build-validation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index bae57831..7adc6dfe 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -42,9 +42,9 @@ jobs: uses: actions/upload-artifact@v2 with: name: Test report - path: build/reports/tests/test + path: sdk/build/reports/tests/test - name: Upload JAR output uses: actions/upload-artifact@v2 with: name: Package - path: build/libs + path: sdk/build/libs From aca60f7065a88a3e3af9eddd20a7de0b1fff03b7 Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Tue, 1 Feb 2022 12:27:59 -0800 Subject: [PATCH 8/8] Upload correct test report + output --- .github/workflows/build-validation.yml | 4 ++-- sdk/build.gradle | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index 7adc6dfe..c4c6ad6b 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -41,8 +41,8 @@ jobs: - name: Archive test report uses: actions/upload-artifact@v2 with: - name: Test report - path: sdk/build/reports/tests/test + name: Integration test report + path: sdk/build/reports/tests/integrationTest - name: Upload JAR output uses: actions/upload-artifact@v2 with: diff --git a/sdk/build.gradle b/sdk/build.gradle index 6f30bffa..588b6fe5 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -72,5 +72,6 @@ task integrationTest(type: Test) { } dependsOn build shouldRunAfter test + testLogging.showStandardStreams = true }