Skip to content

Commit 7a8e684

Browse files
authored
Improve CONTRIBUTING guide and streamline local dev requirements (#2871)
- Cleaned up `CONTRIBUTING.md`: - Lowered minimum JDK from 23 down to 21 - Explained how to test against an external Temporal service - Renamed the `USE_DOCKER_SERVICE` environment variable to `USE_EXTERNAL_SERVICE` because the external service no longer requires Docker - Trimmed the JDK requirements in `temporal-sdk/build.gradle`: `virtualThreadTests`, `jackson3Tests`, and `newJavaTests` no longer hardcode JDK 17/21 launchers. Locally, a single JDK 21+ install is enough. - Updated `mise.toml` to pin `temurin-21` (down from `temurin-23`)
1 parent 1386d4b commit 7a8e684

12 files changed

Lines changed: 66 additions & 79 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ jobs:
3232
- name: Run unit tests (Java 23)
3333
env:
3434
USER: unittest
35-
USE_DOCKER_SERVICE: false
35+
USE_EXTERNAL_SERVICE: false
3636
run: ./gradlew --no-daemon test -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest -PtestJavaVersion=23
3737

3838
- name: Run independent resource tuner test
3939
env:
4040
USER: unittest
41-
USE_DOCKER_SERVICE: false
41+
USE_EXTERNAL_SERVICE: false
4242
run: ./gradlew --no-daemon temporal-sdk:testResourceIndependent -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest -PtestJavaVersion=23
4343

4444
- name: Run Spring Boot 3 compatibility tests
4545
env:
4646
USER: unittest
47-
USE_DOCKER_SERVICE: false
47+
USE_EXTERNAL_SERVICE: false
4848
run: ./gradlew --no-daemon :temporal-spring-boot-autoconfigure:test -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest -P springBoot3Test -PtestJavaVersion=23
4949

5050
- name: Run Spring Boot 4 compatibility tests
5151
env:
5252
USER: unittest
53-
USE_DOCKER_SERVICE: false
53+
USE_EXTERNAL_SERVICE: false
5454
run: ./gradlew --no-daemon :temporal-spring-boot-autoconfigure:test -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest -P springBoot4Test -PtestJavaVersion=23
5555

5656
- name: Publish Test Report
@@ -125,20 +125,20 @@ jobs:
125125
env:
126126
USER: unittest
127127
TEMPORAL_SERVICE_ADDRESS: localhost:7233
128-
USE_DOCKER_SERVICE: true
128+
USE_EXTERNAL_SERVICE: true
129129
run: ./gradlew --no-daemon test -x spotlessCheck -x spotlessApply -x spotlessJava -PtestJavaVersion=11
130130

131131
- name: Run Jackson 3 converter tests (Java 17)
132132
env:
133133
USER: unittest
134-
USE_DOCKER_SERVICE: false
134+
USE_EXTERNAL_SERVICE: false
135135
run: ./gradlew --no-daemon :temporal-sdk:jackson3Tests -x spotlessCheck -x spotlessApply -x spotlessJava -PtestJavaVersion=17
136136

137137
- name: Run virtual thread tests (Java 21)
138138
env:
139139
USER: unittest
140140
TEMPORAL_SERVICE_ADDRESS: localhost:7233
141-
USE_DOCKER_SERVICE: true
141+
USE_EXTERNAL_SERVICE: true
142142
run: ./gradlew --no-daemon :temporal-sdk:virtualThreadTests -x spotlessCheck -x spotlessApply -x spotlessJava -PtestJavaVersion=21
143143

144144
- name: Publish Test Report

CONTRIBUTING.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ before we can merge in any of your changes
88

99
## Development Environment
1010

11-
- Java 23+
12-
- Docker to run Temporal Server
11+
- **Java 21+** is required to run Gradle, compile the project, and run all tests locally.
12+
- Some optional tests also require the [Temporal CLI](https://docs.temporal.io/cli#installation).
13+
14+
If you're using Apple Silicon, see the [note on Rosetta](#note-on-rosetta).
15+
1316

1417
## Build
1518

@@ -41,26 +44,32 @@ fatal: No names found, cannot describe anything.
4144
This can be done resolved by running `git fetch --tags` on your branch. Note, make sure your fork has tags copied from
4245
the main repo.
4346

44-
## Test and Build
47+
## Testing
4548

46-
Run a local temporal server with the [temporal CLI](https://docs.temporal.io/cli#installation):
49+
Run tests:
4750

4851
```bash
49-
temporal server start-dev
52+
./gradlew test
5053
```
5154

52-
(If this does not work, see instructions for running the Temporal Server at https://github.com/temporalio/temporal/blob/master/README.md.)
53-
54-
Then run all the tests with:
55+
Run a single test or group of tests:
5556

5657
```bash
57-
./gradlew test
58+
./gradlew :temporal-sdk:test --offline --tests "io.temporal.activity.ActivityPauseTest"
59+
./gradlew :temporal-sdk:test --offline --tests "io.temporal.workflow.*"
5860
```
5961

60-
Build with:
62+
By default, integration tests run against the built-in time-skipping test server. Some tests require features that the built-in server doesn't support; those tests will be skipped. To run the skipped tests:
6163

64+
1. Install the [temporal CLI](https://docs.temporal.io/cli#installation), which comes with a built-in dev server.
65+
2. Find the flags that the dev server will need to run the tests by grepping for `temporal server` in [./github/workflows/ci.yml](./github/workflows/ci.yml).
66+
3. Start the server:
67+
```bash
68+
temporal server start-dev --YOUR-FLAGS-HERE
69+
```
70+
4. Set the `USE_EXTERNAL_SERVICE` environment variable and run the tests:
6271
```bash
63-
./gradlew build
72+
USE_EXTERNAL_SERVICE=true ./gradlew test
6473
```
6574

6675
## Note on Rosetta

mise.toml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
1-
# TIP
2-
#
3-
# For the best SDK development experience, make to hava all of the following
4-
# JDKs installed on your machine (`mise install java@[version]`):
5-
# - `java@temurin-11`
6-
# - `java@temurin-17`
7-
# - `java@temurin-23`
8-
#
9-
# Java 21+ is required for anything that requires gradle.
10-
#
11-
# If you find out that gradle isn't automatically picking it up older JDKs as
12-
# toolchains, see https://mise.jdx.dev/lang/java.html#gradle-toolchains-detection.
13-
141
[tools]
15-
java = "temurin-23"
2+
java = "temurin-21"

temporal-sdk/build.gradle

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ testing {
184184
targets {
185185
all {
186186
testTask.configure {
187-
javaLauncher = javaToolchains.launcherFor {
188-
languageVersion = JavaLanguageVersion.of(17)
187+
if (project.hasProperty("testJavaVersion")) {
188+
javaLauncher = javaToolchains.launcherFor {
189+
languageVersion = JavaLanguageVersion.of(project.property("testJavaVersion") as int)
190+
}
189191
}
190192
shouldRunAfter(test)
191193
}
@@ -194,20 +196,24 @@ testing {
194196
}
195197

196198
// Unlike virtualThreadTests, jackson3Tests source directly imports Jackson 3 types
197-
// and java17 classes, so the compile task also needs a Java 17 compiler (not just
199+
// and java17 classes, so the compile task also needs a Java 17+ compiler (not just
198200
// the test launcher).
199201
tasks.named('compileJackson3TestsJava') {
200-
javaCompiler = javaToolchains.compilerFor {
201-
languageVersion = JavaLanguageVersion.of(17)
202+
if (project.hasProperty("testJavaVersion")) {
203+
javaCompiler = javaToolchains.compilerFor {
204+
languageVersion = JavaLanguageVersion.of(project.property("testJavaVersion") as int)
205+
}
202206
}
203207
}
204208

205209
virtualThreadTests(JvmTestSuite) {
206210
targets {
207211
all {
208212
testTask.configure {
209-
javaLauncher = javaToolchains.launcherFor {
210-
languageVersion = JavaLanguageVersion.of(21)
213+
if (project.hasProperty("testJavaVersion")) {
214+
javaLauncher = javaToolchains.launcherFor {
215+
languageVersion = JavaLanguageVersion.of(project.property("testJavaVersion") as int)
216+
}
211217
}
212218
shouldRunAfter(test)
213219
}
@@ -230,8 +236,10 @@ testing {
230236
targets {
231237
all {
232238
testTask.configure {
233-
javaLauncher = javaToolchains.launcherFor {
234-
languageVersion = JavaLanguageVersion.of(21)
239+
if (project.hasProperty("testJavaVersion")) {
240+
javaLauncher = javaToolchains.launcherFor {
241+
languageVersion = JavaLanguageVersion.of(project.property("testJavaVersion") as int)
242+
}
235243
}
236244
environment("USE_VIRTUAL_THREADS", "false")
237245
}

temporal-sdk/src/test/java/io/temporal/worker/StickyWorkerTest.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,15 @@
4646
import org.junit.Rule;
4747
import org.junit.Test;
4848
import org.junit.rules.TestName;
49-
import org.junit.runner.RunWith;
50-
import org.junit.runners.Parameterized;
5149
import org.slf4j.Logger;
5250
import org.slf4j.LoggerFactory;
5351

54-
@RunWith(Parameterized.class)
5552
public class StickyWorkerTest {
5653

57-
private static final boolean useDockerService =
58-
Boolean.parseBoolean(System.getenv("USE_DOCKER_SERVICE"));
54+
private static final boolean useExternalService =
55+
Boolean.parseBoolean(System.getenv("USE_EXTERNAL_SERVICE"));
5956
private static final String serviceAddress = System.getenv("TEMPORAL_SERVICE_ADDRESS");
6057

61-
@Parameterized.Parameter public boolean useExternalService;
62-
63-
@Parameterized.Parameters(name = "{1}")
64-
public static Object[] data() {
65-
if (!useDockerService) {
66-
return new Object[][] {{false, "TestService"}};
67-
} else {
68-
return new Object[][] {{true, "Docker"}};
69-
}
70-
}
71-
72-
@Parameterized.Parameter(1)
73-
public String testType;
74-
7558
@Rule public TestName testName = new TestName();
7659

7760
private Scope metricsScope;

temporal-sdk/src/test/java/io/temporal/workerFactory/WorkerFactoryTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121

2222
public class WorkerFactoryTests {
2323

24-
private static final boolean useDockerService =
25-
Boolean.parseBoolean(System.getenv("USE_DOCKER_SERVICE"));
24+
private static final boolean useExternalService =
25+
Boolean.parseBoolean(System.getenv("USE_EXTERNAL_SERVICE"));
2626
private static final String serviceAddress = System.getenv("TEMPORAL_SERVICE_ADDRESS");
2727

2828
@BeforeClass
2929
public static void beforeClass() {
30-
Assume.assumeTrue(useDockerService);
30+
Assume.assumeTrue(useExternalService);
3131
}
3232

3333
private WorkflowServiceStubs service;

temporal-spring-boot-autoconfigure/src/test/java/io/temporal/spring/boot/autoconfigure/WorkerVersioningTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public class WorkerVersioningTest {
3636
@Autowired WorkflowClient workflowClient;
3737

3838
@BeforeAll
39-
static void checkDockerService() {
40-
String useDocker = System.getenv("USE_DOCKER_SERVICE");
39+
static void checkExternalService() {
40+
String useExternal = System.getenv("USE_EXTERNAL_SERVICE");
4141
Assumptions.assumeTrue(
42-
useDocker != null && useDocker.equalsIgnoreCase("true"),
43-
"Skipping tests because USE_DOCKER_SERVICE is not set");
42+
useExternal != null && useExternal.equalsIgnoreCase("true"),
43+
"Skipping tests because USE_EXTERNAL_SERVICE is not set");
4444
}
4545

4646
@BeforeEach

temporal-testing/src/main/java/io/temporal/internal/docker/RegisterTestNamespace.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
/** Waits for local service to become available and registers UnitTest namespace. */
1414
public class RegisterTestNamespace {
1515
public static final String NAMESPACE = "UnitTest";
16-
private static final boolean useDockerService =
17-
Boolean.parseBoolean(System.getenv("USE_DOCKER_SERVICE"));
16+
private static final boolean useExternalService =
17+
Boolean.parseBoolean(System.getenv("USE_EXTERNAL_SERVICE"));
1818
private static final String serviceAddress = System.getenv("TEMPORAL_SERVICE_ADDRESS");
1919

2020
public static void main(String[] args) throws InterruptedException {
21-
if (!useDockerService) {
21+
if (!useExternalService) {
2222
return;
2323
}
2424

temporal-testing/src/main/java/io/temporal/testing/internal/ExternalServiceTestConfigurator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
import io.temporal.testing.TestWorkflowRule;
66

77
public class ExternalServiceTestConfigurator {
8-
private static boolean USE_DOCKER_SERVICE =
9-
EnvironmentVariableUtils.readBooleanFlag("USE_DOCKER_SERVICE");
8+
private static boolean USE_EXTERNAL_SERVICE =
9+
EnvironmentVariableUtils.readBooleanFlag("USE_EXTERNAL_SERVICE");
1010
private static String TEMPORAL_SERVICE_ADDRESS =
1111
EnvironmentVariableUtils.readString("TEMPORAL_SERVICE_ADDRESS");
1212
private static boolean USE_VIRTUAL_THREADS =
1313
EnvironmentVariableUtils.readBooleanFlag("USE_VIRTUAL_THREADS");
1414

1515
public static boolean isUseExternalService() {
16-
return USE_DOCKER_SERVICE;
16+
return USE_EXTERNAL_SERVICE;
1717
}
1818

1919
public static boolean isUseVirtualThreads() {
2020
return USE_VIRTUAL_THREADS;
2121
}
2222

2323
public static String getTemporalServiceAddress() {
24-
return USE_DOCKER_SERVICE
24+
return USE_EXTERNAL_SERVICE
2525
? (TEMPORAL_SERVICE_ADDRESS != null ? TEMPORAL_SERVICE_ADDRESS : "127.0.0.1:7233")
2626
: null;
2727
}
2828

2929
public static TestWorkflowRule.Builder configure(TestWorkflowRule.Builder testWorkflowRule) {
30-
if (USE_DOCKER_SERVICE) {
30+
if (USE_EXTERNAL_SERVICE) {
3131
testWorkflowRule.setUseExternalService(true);
3232
if (TEMPORAL_SERVICE_ADDRESS != null) {
3333
testWorkflowRule.setTarget(TEMPORAL_SERVICE_ADDRESS);
@@ -38,7 +38,7 @@ public static TestWorkflowRule.Builder configure(TestWorkflowRule.Builder testWo
3838

3939
public static TestEnvironmentOptions.Builder configure(
4040
TestEnvironmentOptions.Builder testEnvironmentOptions) {
41-
if (USE_DOCKER_SERVICE) {
41+
if (USE_EXTERNAL_SERVICE) {
4242
testEnvironmentOptions.setUseExternalService(true);
4343
if (TEMPORAL_SERVICE_ADDRESS != null) {
4444
testEnvironmentOptions.setTarget(TEMPORAL_SERVICE_ADDRESS);

temporal-testing/src/main/java/io/temporal/testing/internal/SDKTestWorkflowRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class SDKTestWorkflowRule implements TestRule {
6464
"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
6565
// Enable to regenerate JsonFiles used for replay testing.
6666
public static final boolean REGENERATE_JSON_FILES = false;
67-
// Only enable when USE_DOCKER_SERVICE is true
67+
// Only enable when USE_EXTERNAL_SERVICE is true
6868
public static final boolean useExternalService =
6969
ExternalServiceTestConfigurator.isUseExternalService();
7070
public static final boolean USE_VIRTUAL_THREADS =

0 commit comments

Comments
 (0)