Skip to content

Commit 4f7fe0c

Browse files
YunchuWangJoshVanL
authored andcommitted
enhance proto generation (microsoft#207)
1 parent fb9c30d commit 4f7fe0c

File tree

10 files changed

+787
-19
lines changed

10 files changed

+787
-19
lines changed

.github/workflows/build-validation.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v2
23-
with:
24-
submodules: true
2523

2624
- name: Set up JDK 11
2725
uses: actions/setup-java@v2
@@ -58,13 +56,13 @@ jobs:
5856
run: ./gradlew integrationTest
5957

6058
- name: Archive test report
61-
uses: actions/upload-artifact@v2
59+
uses: actions/upload-artifact@v4
6260
with:
6361
name: Integration test report
6462
path: client/build/reports/tests/integrationTest
6563

6664
- name: Upload JAR output
67-
uses: actions/upload-artifact@v2
65+
uses: actions/upload-artifact@v4
6866
with:
6967
name: Package
7068
path: client/build/libs
@@ -76,8 +74,6 @@ jobs:
7674

7775
steps:
7876
- uses: actions/checkout@v2
79-
with:
80-
submodules: true
8177

8278
- name: Set up JDK 8
8379
uses: actions/setup-java@v2
@@ -89,7 +85,7 @@ jobs:
8985
uses: gradle/gradle-build-action@v2
9086

9187
- name: Publish to local
92-
run: ./gradlew publishToMavenLocal -x sign
88+
run: ./gradlew publishToMavenLocal
9389

9490
- name: Build azure functions sample
9591
run: ./gradlew azureFunctionsPackage
@@ -105,7 +101,7 @@ jobs:
105101
arguments: endToEndTest
106102

107103
- name: Archive test report
108-
uses: actions/upload-artifact@v2
104+
uses: actions/upload-artifact@v4
109105
with:
110106
name: Integration test report
111107
path: client/build/reports/tests/endToEndTest
@@ -117,8 +113,6 @@ jobs:
117113

118114
steps:
119115
- uses: actions/checkout@v2
120-
with:
121-
submodules: true
122116

123117
- name: Set up JDK 8
124118
uses: actions/setup-java@v2
@@ -146,7 +140,7 @@ jobs:
146140
arguments: sampleTest
147141

148142
- name: Archive test report
149-
uses: actions/upload-artifact@v2
143+
uses: actions/upload-artifact@v4
150144
with:
151145
name: Integration test report
152146
path: client/build/reports/tests/endToEndTest

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## placeholder
2+
* Add automatic proto file download and commit hash tracking during build ([#207](https://github.com/microsoft/durabletask-java/pull/207))
23
* Fix infinite loop when use continueasnew after wait external event ([#183](https://github.com/microsoft/durabletask-java/pull/183))
34
* Fix the issue "Deserialize Exception got swallowed when use anyOf with external event." ([#185](https://github.com/microsoft/durabletask-java/pull/185))
45

azdevops-pipeline/build-release-artifacts.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pool:
1010

1111
steps:
1212
- checkout: self
13-
submodules: true
1413

1514
- task: Gradle@3
1615
inputs:

client/build.gradle

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def jacksonVersion = '2.15.3'
1717
// When build on local, you need to set this value to your local jdk11 directory.
1818
// Java11 is used to compile and run all the tests.
1919
// Example for Windows: C:/Program Files/Java/openjdk-11.0.12_7/
20-
def PATH_TO_TEST_JAVA_RUNTIME = "$System.env.JDK_11"
20+
def PATH_TO_TEST_JAVA_RUNTIME = System.env.JDK_11 ?: System.getProperty("java.home")
2121

2222
dependencies {
2323

@@ -49,20 +49,44 @@ compileTestJava {
4949
options.forkOptions.executable = "${PATH_TO_TEST_JAVA_RUNTIME}/bin/javac"
5050
}
5151

52+
task downloadProtoFiles {
53+
ext.branch = project.hasProperty('protoBranch') ? project.protoBranch : 'main'
54+
55+
doLast {
56+
def protoDir = file("${rootProject.projectDir}/internal/durabletask-protobuf/protos")
57+
protoDir.mkdirs()
58+
59+
// Download the proto file
60+
new URL("https://raw.githubusercontent.com/microsoft/durabletask-protobuf/${ext.branch}/protos/orchestrator_service.proto")
61+
.withInputStream { i ->
62+
new File(protoDir, 'orchestrator_service.proto').withOutputStream { it << i }
63+
}
64+
65+
// Get and save the commit hash
66+
def commitHashFile = new File("${rootProject.projectDir}/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH")
67+
def commitApiUrl = new URL("https://api.github.com/repos/microsoft/durabletask-protobuf/commits?path=protos/orchestrator_service.proto&sha=${ext.branch}&per_page=1")
68+
def connection = commitApiUrl.openConnection()
69+
connection.setRequestProperty('Accept', 'application/vnd.github.v3+json')
70+
def commitHash = new groovy.json.JsonSlurper().parse(connection.inputStream)[0].sha
71+
commitHashFile.text = commitHash
72+
}
73+
}
74+
5275
protobuf {
5376
protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
5477
plugins {
5578
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
5679
}
5780
generateProtoTasks {
5881
all()*.plugins { grpc {} }
82+
all()*.dependsOn downloadProtoFiles
5983
}
6084
}
6185

6286
sourceSets {
6387
main {
6488
proto {
65-
srcDir '../submodules/durabletask-protobuf/protos'
89+
srcDir '../internal/durabletask-protobuf/protos'
6690
}
6791
java {
6892
srcDirs 'build/generated/source/proto/main/grpc'

eng/templates/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ jobs:
1111

1212
steps:
1313
- checkout: self
14-
submodules: true
1514

1615
- task: Gradle@3
1716
inputs:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4792f47019ab2b3e9ea979fb4af72427a4144c51
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Durable Task Protobuf Files
2+
3+
This directory contains the protocol buffer definitions used by the Durable Task Framework Java SDK. The files in this directory are automatically downloaded and updated during the build process from the [microsoft/durabletask-protobuf](https://github.com/microsoft/durabletask-protobuf) repository.
4+
5+
## Directory Structure
6+
7+
- `protos/` - Contains the downloaded proto files
8+
- `PROTO_SOURCE_COMMIT_HASH` - Contains the commit hash of the latest proto file version
9+
10+
## Auto-Update Process
11+
12+
The proto files are automatically downloaded and updated when running Gradle builds. This is handled by the `downloadProtoFiles` task in the `client/build.gradle` file. The task:
13+
14+
1. Downloads the latest version of `orchestrator_service.proto`
15+
2. Saves the current commit hash for tracking purposes
16+
3. Updates these files before proto compilation begins
17+
18+
## Manual Update
19+
20+
If you need to manually update the proto files, you can run:
21+
22+
```bash
23+
./gradlew downloadProtoFiles -PprotoBranch=<branch-name>
24+
```

0 commit comments

Comments
 (0)