Skip to content

Commit 6eec68f

Browse files
authored
Merge branch 'main' into test_librariangen_change
2 parents ddc305b + c86b4ea commit 6eec68f

File tree

9 files changed

+109
-26
lines changed

9 files changed

+109
-26
lines changed

.github/workflows/ci.yaml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ on:
33
branches:
44
- main
55
pull_request:
6-
paths-ignore:
7-
- 'internal/librariangen/**'
86
name: ci
97
jobs:
8+
changes:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
should_run: ${{ steps.filter.outputs.should_run }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
15+
id: filter
16+
with:
17+
filters: |
18+
should_run:
19+
- '!internal/librariangen/**'
1020
build:
21+
needs: changes
22+
if: needs.changes.outputs.should_run == 'true'
1123
runs-on: ubuntu-22.04
1224
strategy:
1325
matrix:
@@ -61,6 +73,8 @@ jobs:
6173
./gradlew clean build publishToMavenLocal sourcesJar allJars
6274
popd
6375
build-java-21:
76+
needs: changes
77+
if: needs.changes.outputs.should_run == 'true'
6478
name: "build(21) except self-service clients"
6579
# Support for Java 21 is available for all use cases except self-service clients.
6680
runs-on: ubuntu-22.04
@@ -94,6 +108,8 @@ jobs:
94108
run: |
95109
bazelisk --batch test //test/integration/...
96110
build-java-25:
111+
needs: changes
112+
if: needs.changes.outputs.should_run == 'true'
97113
name: "build(25) except self-service clients"
98114
# Support for Java 25 is available for all use cases except self-service clients.
99115
runs-on: ubuntu-22.04
@@ -128,6 +144,8 @@ jobs:
128144
run: |
129145
bazelisk --batch test //test/integration/... --jvmopt=-Dcom.google.testing.junit.runner.shouldInstallTestSecurityManager=false
130146
build-java8-except-gapic-generator-java:
147+
needs: changes
148+
if: needs.changes.outputs.should_run == 'true'
131149
name: "build(8) except for gapic-generator-java"
132150
runs-on: ubuntu-22.04
133151
steps:
@@ -174,6 +192,8 @@ jobs:
174192
GOOGLE_SDK_JAVA_LOGGING: true
175193

176194
build-java8-gapic-generator-java:
195+
needs: changes
196+
if: needs.changes.outputs.should_run == 'true'
177197
name: "build(8) for gapic-generator-java"
178198
runs-on: ubuntu-22.04
179199
steps:
@@ -221,6 +241,8 @@ jobs:
221241
popd
222242
223243
lint:
244+
needs: changes
245+
if: needs.changes.outputs.should_run == 'true'
224246
runs-on: ubuntu-22.04
225247
steps:
226248
- uses: actions/checkout@v4
@@ -235,6 +257,8 @@ jobs:
235257
run: mvn -B -ntp fmt:check
236258

237259
compatibility:
260+
needs: changes
261+
if: needs.changes.outputs.should_run == 'true'
238262
runs-on: ubuntu-22.04
239263
steps:
240264
- uses: actions/checkout@v4
@@ -250,6 +274,8 @@ jobs:
250274
run: mvn package clirr:check -DskipTests -Dfmt.skip
251275

252276
build-java8-showcase:
277+
needs: changes
278+
if: needs.changes.outputs.should_run == 'true'
253279
name: "build(8) for showcase"
254280
runs-on: ubuntu-22.04
255281
steps:
@@ -306,6 +332,8 @@ jobs:
306332
--batch-mode \
307333
--no-transfer-progress
308334
showcase:
335+
needs: changes
336+
if: needs.changes.outputs.should_run == 'true'
309337
runs-on: ubuntu-22.04
310338
strategy:
311339
matrix:
@@ -376,7 +404,8 @@ jobs:
376404
--no-transfer-progress
377405
378406
showcase-clirr:
379-
if: ${{ github.base_ref != '' }} # Only execute on pull_request trigger event
407+
needs: changes
408+
if: ${{ github.base_ref != '' && needs.changes.outputs.should_run == 'true' }}
380409
runs-on: ubuntu-22.04
381410
steps:
382411
- name: Checkout @ target branch
@@ -407,6 +436,8 @@ jobs:
407436
mvn clirr:check -B -ntp -Dclirr.skip=false -DcomparisonVersion=$SHOWCASE_CLIENT_VERSION
408437
409438
gapic-generator-java-bom:
439+
needs: changes
440+
if: needs.changes.outputs.should_run == 'true'
410441
runs-on: ubuntu-22.04
411442
steps:
412443
- uses: actions/checkout@v4
@@ -424,6 +455,8 @@ jobs:
424455
bom-path: gapic-generator-java-bom/pom.xml
425456

426457
unmanaged_dependency_check:
458+
needs: changes
459+
if: needs.changes.outputs.should_run == 'true'
427460
runs-on: ubuntu-22.04
428461
steps:
429462
- uses: actions/checkout@v4
@@ -447,6 +480,8 @@ jobs:
447480
bom-path: gapic-generator-java-bom/pom.xml
448481

449482
dependency_analyzer_unit_test:
483+
needs: changes
484+
if: needs.changes.outputs.should_run == 'true'
450485
runs-on: ubuntu-22.04
451486
steps:
452487
- uses: actions/checkout@v4
@@ -460,4 +495,4 @@ jobs:
460495
- name: Unit Tests
461496
run: |
462497
mvn test --batch-mode --no-transfer-progress
463-
working-directory: java-shared-dependencies/dependency-analyzer
498+
working-directory: java-shared-dependencies/dependency-analyzer

.github/workflows/dependency_compatibility_test.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
pull_request:
55
branches:
66
- 'main'
7-
paths-ignore:
8-
- 'internal/librariangen/**'
97
workflow_dispatch:
108
inputs:
119
dependencies-list:
@@ -17,7 +15,21 @@ on:
1715
default: ''
1816

1917
jobs:
18+
changes:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
should_run: ${{ steps.filter.outputs.should_run }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
25+
id: filter
26+
with:
27+
filters: |
28+
should_run:
29+
- '!internal/librariangen/**'
2030
dependency-compatibility-test:
31+
needs: changes
32+
if: needs.changes.outputs.should_run == 'true'
2133
runs-on: ubuntu-latest
2234
permissions:
2335
contents: read
@@ -75,4 +87,4 @@ jobs:
7587
else
7688
../.github/scripts/test_dependency_compatibility.sh -f ../dependencies.txt
7789
fi
78-
working-directory: java-showcase
90+
working-directory: java-showcase

.github/workflows/hermetic_library_generation.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
name: Hermetic library generation upon generation config change through pull requests
1717
on:
1818
pull_request:
19-
paths-ignore:
20-
- 'internal/librariangen/**'
2119

2220
env:
2321
REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}

.github/workflows/java_compatibility_check.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@
1515
# downstream client libraries before they are released.
1616
on:
1717
pull_request:
18-
paths-ignore:
19-
- 'internal/librariangen/**'
2018
name: Java 8 compatibility check
2119
jobs:
20+
changes:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
should_run: ${{ steps.filter.outputs.should_run }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
27+
id: filter
28+
with:
29+
filters: |
30+
should_run:
31+
- '!internal/librariangen/**'
2232
java8-compatibility-check:
33+
needs: changes
34+
if: needs.changes.outputs.should_run == 'true'
2335
runs-on: ubuntu-latest
2436
steps:
2537
- uses: actions/checkout@v4
@@ -45,4 +57,4 @@ jobs:
4557
exit 1
4658
fi
4759
done
48-
echo "All class files are compatible with Java 8."
60+
echo "All class files are compatible with Java 8."

.github/workflows/sonar.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@ on:
55
- main
66
pull_request:
77
types: [opened, synchronize, reopened]
8-
paths-ignore:
9-
- 'internal/librariangen/**'
108
jobs:
9+
changes:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
should_run: ${{ steps.filter.outputs.should_run }}
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
16+
id: filter
17+
with:
18+
filters: |
19+
should_run:
20+
- '!internal/librariangen/**'
1121
build:
22+
needs: changes
23+
if: needs.changes.outputs.should_run == 'true'
1224
name: Build
1325
runs-on: ubuntu-22.04
1426
steps:
@@ -78,4 +90,4 @@ jobs:
7890
-Dsonar.projectKey=googleapis_gapic-generator-java_integration_tests \
7991
-Dsonar.organization=googleapis \
8092
-Dsonar.host.url=https://sonarcloud.io \
81-
-Dsonar.projectName=java_showcase_integration_tests
93+
-Dsonar.projectName=java_showcase_integration_tests

.github/workflows/verify_library_generation.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
on:
22
pull_request:
3-
paths-ignore:
4-
- 'internal/librariangen/**'
53

64
name: verify_library_generation
75
jobs:

internal/librariangen/generate/generator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ import (
2727

2828
"cloud.google.com/java/internal/librariangen/bazel"
2929
"cloud.google.com/java/internal/librariangen/execv"
30+
"cloud.google.com/java/internal/librariangen/message"
3031
"cloud.google.com/java/internal/librariangen/protoc"
31-
"cloud.google.com/java/internal/librariangen/request"
3232
)
3333

3434
// Test substitution vars.
3535
var (
3636
bazelParse = bazel.Parse
3737
execvRun = execv.Run
38-
requestParse = request.ParseLibrary
38+
requestParse = message.ParseLibrary
3939
protocBuild = protoc.Build
4040
)
4141

@@ -113,7 +113,7 @@ func Generate(ctx context.Context, cfg *Config) error {
113113
// invokeProtoc handles the protoc GAPIC generation logic for the 'generate' CLI command.
114114
// It reads a request file, and for each API specified, it invokes protoc
115115
// to generate the client library. It returns the module path and the path to the service YAML.
116-
func invokeProtoc(ctx context.Context, cfg *Config, generateReq *request.Library) error {
116+
func invokeProtoc(ctx context.Context, cfg *Config, generateReq *message.Library) error {
117117
for _, api := range generateReq.APIs {
118118
apiServiceDir := filepath.Join(cfg.SourceDir, api.Path)
119119
slog.Info("processing api", "service_dir", apiServiceDir)
@@ -135,7 +135,7 @@ func invokeProtoc(ctx context.Context, cfg *Config, generateReq *request.Library
135135
// readGenerateReq reads generate-request.json from the librarian-tool input directory.
136136
// The request file tells librariangen which library and APIs to generate.
137137
// It is prepared by the Librarian tool and mounted at /librarian.
138-
func readGenerateReq(librarianDir string) (*request.Library, error) {
138+
func readGenerateReq(librarianDir string) (*message.Library, error) {
139139
reqPath := filepath.Join(librarianDir, "generate-request.json")
140140
slog.Debug("librariangen: reading generate request", "path", reqPath)
141141

@@ -264,4 +264,4 @@ func unzip(src, dest string) error {
264264
}
265265
}
266266
return nil
267-
}
267+
}
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,30 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package request
15+
// Package message defines data types which the Librarian CLI and language
16+
// containers exchange.
17+
// There shouldn't be CLI-specific data type or language container-specific
18+
// data types in this package.
19+
// TODO(b/447404382): Move this package to the https://github.com/googleapis/librarian
20+
// GitHub repository once the interface is finalized.
21+
package message
1622

1723
import (
1824
"encoding/json"
1925
"fmt"
2026
"os"
2127
)
2228

29+
// ReleaseInitRequest is the structure of the release-init-request.json file.
30+
type ReleaseInitRequest struct {
31+
Libraries []*Library `json:"libraries"`
32+
}
33+
34+
// ReleaseInitResponse is the structure of the release-init-response.json file.
35+
type ReleaseInitResponse struct {
36+
Error string `json:"error,omitempty"`
37+
}
38+
2339
// Library is the combination of all the fields used by CLI requests and responses.
2440
// Each CLI command has its own request/response type, but they all use Library.
2541
type Library struct {
@@ -75,4 +91,4 @@ func ParseLibrary(path string) (*Library, error) {
7591
}
7692

7793
return &req, nil
78-
}
94+
}

internal/librariangen/request/request_test.go renamed to internal/librariangen/message/message_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package request
15+
package message
1616

1717
import (
1818
"os"
@@ -95,4 +95,4 @@ func TestParseLibrary_FileNotFound(t *testing.T) {
9595
if err == nil {
9696
t.Error("Parse() expected error for non-existent file, got nil")
9797
}
98-
}
98+
}

0 commit comments

Comments
 (0)