Skip to content

Commit f060a34

Browse files
authored
Merge branch 'main' into owl-bot-copy-java-common-protos
2 parents 862949c + 3c5284a commit f060a34

File tree

1,369 files changed

+6375
-4262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,369 files changed

+6375
-4262
lines changed

.github/snippet-bot.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ ignoreFiles:
44
- src/test/**
55
- test/**
66
- showcase/**
7+
- library_generation/owlbot/templates/java_library/samples/install-without-bom/pom.xml

.github/workflows/verify_library_generation.yaml

+37-28
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
java: [ 11 ]
16-
os: [ ubuntu-22.04, macos-12 ]
17-
post_processing: [ 'true', 'false' ]
18-
runs-on: ${{ matrix.os }}
16+
runs-on: ubuntu-22.04
1917
steps:
2018
- uses: actions/checkout@v3
2119
- uses: actions/setup-java@v3
@@ -44,36 +42,15 @@ jobs:
4442
set -ex
4543
pushd library_generation
4644
pip install -r requirements.in
45+
pip install .
4746
popd
48-
49-
- name: install utils (macos)
50-
if: matrix.os == 'macos-12'
51-
shell: bash
52-
run: |
53-
brew update --preinstall
54-
# we need the `realpath` command to be available
55-
brew install coreutils
56-
- name: install docker (ubuntu)
57-
if: matrix.os == 'ubuntu-22.04'
58-
shell: bash
59-
run: |
60-
set -x
61-
# install docker
62-
sudo apt install containerd -y
63-
sudo apt install -y docker.io docker-compose
64-
65-
# launch docker
66-
sudo systemctl start docker
6747
- name: Run integration tests
68-
# we don't run ITs with postprocessing on macos because one of its dependencies "synthtool" is designed to run on linux only
69-
if: matrix.os == 'ubuntu-22.04' || matrix.post_processing == 'false'
7048
shell: bash
7149
run: |
50+
set -x
7251
git config --global user.email "[email protected]"
7352
git config --global user.name "Github Workflow"
74-
library_generation/test/generate_library_integration_test.sh \
75-
--googleapis_gen_url https://cloud-java-bot:${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}@github.com/googleapis/googleapis-gen.git \
76-
--enable_postprocessing "${{ matrix.post_processing }}"
53+
python -m unittest library_generation/test/integration_tests.py
7754
unit_tests:
7855
strategy:
7956
matrix:
@@ -98,6 +75,21 @@ jobs:
9875
pushd library_generation
9976
pip install -r requirements.in
10077
popd
78+
- name: install synthtool
79+
shell: bash
80+
run: |
81+
set -ex
82+
mkdir -p /tmp/synthtool
83+
pushd /tmp/synthtool
84+
if [ ! -d "synthtool" ]; then
85+
git clone https://github.com/googleapis/synthtool.git
86+
fi
87+
pushd "synthtool"
88+
89+
git reset --hard origin/no-java-templates
90+
91+
python3 -m pip install -e .
92+
python3 -m pip install -r requirements.in
10193
- name: Run shell unit tests
10294
run: |
10395
set -x
@@ -106,7 +98,7 @@ jobs:
10698
run: |
10799
set -x
108100
python -m unittest library_generation/test/unit_tests.py
109-
lint:
101+
lint-shell:
110102
runs-on: ubuntu-22.04
111103
steps:
112104
- uses: actions/checkout@v3
@@ -116,3 +108,20 @@ jobs:
116108
scandir: 'library_generation'
117109
format: tty
118110
severity: error
111+
lint-python:
112+
runs-on: ubuntu-22.04
113+
steps:
114+
- uses: actions/checkout@v3
115+
- name: install python dependencies
116+
shell: bash
117+
run: |
118+
set -ex
119+
pushd library_generation
120+
pip install -r requirements.in
121+
popd
122+
- name: Lint
123+
shell: bash
124+
run: |
125+
# exclude generated golden files
126+
# exclude owlbot until further refaction
127+
black --check library_generation --exclude "(library_generation/test/resources/goldens)"

.gitignore

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ target/
1919

2020
# Python
2121
**/__pycache__/
22+
.venv
2223

2324
# library generation
24-
output/
25-
library_generation/output/
26-
showcase/scripts/output/
25+
**/output/
26+
**/googleapis
27+
library_generation/test/**/golden*/
28+
library_generation/test/resources/test_repo_level_postprocess/
29+
**/*egg-info/
30+
**/build/

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/CommentComposer.java

+13-10
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,23 @@
1919
import com.google.api.generator.engine.ast.LineComment;
2020
import com.google.api.generator.engine.ast.Statement;
2121
import java.util.Arrays;
22+
import java.util.Calendar;
2223
import java.util.List;
2324

2425
public class CommentComposer {
2526
private static final String APACHE_LICENSE_STRING =
26-
"Copyright 2023 Google LLC\n\n"
27-
+ "Licensed under the Apache License, Version 2.0 (the \"License\");\n"
28-
+ "you may not use this file except in compliance with the License.\n"
29-
+ "You may obtain a copy of the License at\n\n"
30-
+ " https://www.apache.org/licenses/LICENSE-2.0\n\n"
31-
+ "Unless required by applicable law or agreed to in writing, software\n"
32-
+ "distributed under the License is distributed on an \"AS IS\" BASIS,\n"
33-
+ "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
34-
+ "See the License for the specific language governing permissions and\n"
35-
+ "limitations under the License.";
27+
String.format(
28+
"Copyright %s Google LLC\n\n"
29+
+ "Licensed under the Apache License, Version 2.0 (the \"License\");\n"
30+
+ "you may not use this file except in compliance with the License.\n"
31+
+ "You may obtain a copy of the License at\n\n"
32+
+ " https://www.apache.org/licenses/LICENSE-2.0\n\n"
33+
+ "Unless required by applicable law or agreed to in writing, software\n"
34+
+ "distributed under the License is distributed on an \"AS IS\" BASIS,\n"
35+
+ "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
36+
+ "See the License for the specific language governing permissions and\n"
37+
+ "limitations under the License.",
38+
Calendar.getInstance().get(Calendar.YEAR));
3639

3740
private static final String AUTO_GENERATED_CLASS_DISCLAIMER_STRING =
3841
"AUTO-GENERATED DOCUMENTATION AND CLASS.";

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceSettingsClassComposer.java

-8
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,6 @@ private List<MethodDefinition> createDefaultGetterMethods(Service service, TypeS
430430
"defaultApiClientHeaderProviderBuilder",
431431
TypeNode.withReference(
432432
ConcreteReference.withClazz(ApiClientHeaderProvider.Builder.class)))
433-
.setAnnotations(
434-
Arrays.asList(
435-
AnnotationNode.builder()
436-
.setType(FIXED_TYPESTORE.get("BetaApi"))
437-
.setDescription(
438-
"The surface for customizing headers is not stable yet and may"
439-
+ " change in the future.")
440-
.build()))
441433
.build());
442434
return javaMethods;
443435
}

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java

-8
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,7 @@ protected MethodDefinition createApiClientHeaderProviderBuilderMethod(
370370
.setReturnType(returnType)
371371
.build();
372372

373-
AnnotationNode annotation =
374-
AnnotationNode.builder()
375-
.setType(FIXED_TYPESTORE.get("BetaApi"))
376-
.setDescription(
377-
"The surface for customizing headers is not stable yet and may change in the"
378-
+ " future.")
379-
.build();
380373
return MethodDefinition.builder()
381-
.setAnnotations(Arrays.asList(annotation))
382374
.setScope(ScopeNode.PUBLIC)
383375
.setIsStatic(true)
384376
.setReturnType(returnType)

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposerTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,6 @@ public void createSimpleMessage_containsMessagesEnumsAndResourceName() {
568568
"EchoRequest.newBuilder().setName("
569569
+ "FoobarName.ofProjectFoobarName(\"[PROJECT]\", \"[FOOBAR]\").toString())"
570570
+ ".setParent(FoobarName.ofProjectFoobarName(\"[PROJECT]\", \"[FOOBAR]\").toString())"
571-
+ ".setRequestId(\"requestId693933066\")"
572-
+ ".setSecondRequestId(\"secondRequestId344404470\")"
573-
+ ".setThirdRequestId(true)"
574-
+ ".setFourthRequestId(\"fourthRequestId-2116417776\")"
575-
+ ".setFifthRequestId(\"fifthRequestId959024147\")"
576-
+ ".setSixthRequestId(\"sixthRequestId1005218260\")"
577571
+ ".setSeverity(Severity.forNumber(0))"
578572
+ ".setFoobar(Foobar.newBuilder().build()).build()",
579573
writerVisitor.write());

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/goldens/ComposerPostProcOnFooBar.golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Google LLC
2+
* Copyright 2024 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposerTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,14 @@ public void generateGrpcServiceStubClass_createBatchingCallable() {
8282
Assert.assertGoldenClass(this.getClass(), clazz, "GrpcLoggingStub.golden");
8383
Assert.assertEmptySamples(clazz.samples());
8484
}
85+
86+
@Test
87+
public void generateGrpcServiceStubClass_autopopulateField() {
88+
GapicContext context = GrpcTestProtoLoader.instance().parseAutoPopulateFieldTesting();
89+
Service service = context.services().get(0);
90+
GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, service);
91+
92+
Assert.assertGoldenClass(this.getClass(), clazz, "GrpcAutoPopulateFieldStub.golden");
93+
Assert.assertEmptySamples(clazz.samples());
94+
}
8595
}

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/DeprecatedServiceSettings.golden

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.google.testdata.v1;
22

33
import com.google.api.core.ApiFunction;
4-
import com.google.api.core.BetaApi;
54
import com.google.api.gax.core.GoogleCredentialsProvider;
65
import com.google.api.gax.core.InstantiatingExecutorProvider;
76
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
@@ -109,7 +108,6 @@ public class DeprecatedServiceSettings extends ClientSettings<DeprecatedServiceS
109108
return DeprecatedServiceStubSettings.defaultTransportChannelProvider();
110109
}
111110

112-
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
113111
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
114112
return DeprecatedServiceStubSettings.defaultApiClientHeaderProviderBuilder();
115113
}

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/DeprecatedServiceStubSettings.golden

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.google.testdata.v1.stub;
22

33
import com.google.api.core.ApiFunction;
4-
import com.google.api.core.BetaApi;
54
import com.google.api.gax.core.GaxProperties;
65
import com.google.api.gax.core.GoogleCredentialsProvider;
76
import com.google.api.gax.core.InstantiatingExecutorProvider;
@@ -148,7 +147,6 @@ public class DeprecatedServiceStubSettings extends StubSettings<DeprecatedServic
148147
return defaultGrpcTransportProviderBuilder().build();
149148
}
150149

151-
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
152150
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
153151
return ApiClientHeaderProvider.newBuilder()
154152
.setGeneratedLibToken(

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/EchoClient.golden

+1-47
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,6 @@ public class EchoClient implements BackgroundResource {
517517
* EchoRequest.newBuilder()
518518
* .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
519519
* .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
520-
* .setRequestId("requestId693933066")
521-
* .setSecondRequestId("secondRequestId344404470")
522-
* .setThirdRequestId(true)
523-
* .setFourthRequestId("fourthRequestId-2116417776")
524-
* .setFifthRequestId("fifthRequestId959024147")
525-
* .setSixthRequestId("sixthRequestId1005218260")
526520
* .setSeverity(Severity.forNumber(0))
527521
* .setFoobar(Foobar.newBuilder().build())
528522
* .build();
@@ -552,12 +546,6 @@ public class EchoClient implements BackgroundResource {
552546
* EchoRequest.newBuilder()
553547
* .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
554548
* .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
555-
* .setRequestId("requestId693933066")
556-
* .setSecondRequestId("secondRequestId344404470")
557-
* .setThirdRequestId(true)
558-
* .setFourthRequestId("fourthRequestId-2116417776")
559-
* .setFifthRequestId("fifthRequestId959024147")
560-
* .setSixthRequestId("sixthRequestId1005218260")
561549
* .setSeverity(Severity.forNumber(0))
562550
* .setFoobar(Foobar.newBuilder().build())
563551
* .build();
@@ -583,11 +571,7 @@ public class EchoClient implements BackgroundResource {
583571
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
584572
* try (EchoClient echoClient = EchoClient.create()) {
585573
* ExpandRequest request =
586-
* ExpandRequest.newBuilder()
587-
* .setContent("content951530617")
588-
* .setInfo("info3237038")
589-
* .setRequestId("requestId693933066")
590-
* .build();
574+
* ExpandRequest.newBuilder().setContent("content951530617").setInfo("info3237038").build();
591575
* ServerStream<EchoResponse> stream = echoClient.expandCallable().call(request);
592576
* for (EchoResponse response : stream) {
593577
* // Do something when a response is received.
@@ -633,12 +617,6 @@ public class EchoClient implements BackgroundResource {
633617
* EchoRequest.newBuilder()
634618
* .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
635619
* .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
636-
* .setRequestId("requestId693933066")
637-
* .setSecondRequestId("secondRequestId344404470")
638-
* .setThirdRequestId(true)
639-
* .setFourthRequestId("fourthRequestId-2116417776")
640-
* .setFifthRequestId("fifthRequestId959024147")
641-
* .setSixthRequestId("sixthRequestId1005218260")
642620
* .setSeverity(Severity.forNumber(0))
643621
* .setFoobar(Foobar.newBuilder().build())
644622
* .build();
@@ -666,12 +644,6 @@ public class EchoClient implements BackgroundResource {
666644
* EchoRequest.newBuilder()
667645
* .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
668646
* .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
669-
* .setRequestId("requestId693933066")
670-
* .setSecondRequestId("secondRequestId344404470")
671-
* .setThirdRequestId(true)
672-
* .setFourthRequestId("fourthRequestId-2116417776")
673-
* .setFifthRequestId("fifthRequestId959024147")
674-
* .setSixthRequestId("sixthRequestId1005218260")
675647
* .setSeverity(Severity.forNumber(0))
676648
* .setFoobar(Foobar.newBuilder().build())
677649
* .build();
@@ -702,12 +674,6 @@ public class EchoClient implements BackgroundResource {
702674
* EchoRequest.newBuilder()
703675
* .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
704676
* .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
705-
* .setRequestId("requestId693933066")
706-
* .setSecondRequestId("secondRequestId344404470")
707-
* .setThirdRequestId(true)
708-
* .setFourthRequestId("fourthRequestId-2116417776")
709-
* .setFifthRequestId("fifthRequestId959024147")
710-
* .setSixthRequestId("sixthRequestId1005218260")
711677
* .setSeverity(Severity.forNumber(0))
712678
* .setFoobar(Foobar.newBuilder().build())
713679
* .build();
@@ -1116,12 +1082,6 @@ public class EchoClient implements BackgroundResource {
11161082
* EchoRequest.newBuilder()
11171083
* .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
11181084
* .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
1119-
* .setRequestId("requestId693933066")
1120-
* .setSecondRequestId("secondRequestId344404470")
1121-
* .setThirdRequestId(true)
1122-
* .setFourthRequestId("fourthRequestId-2116417776")
1123-
* .setFifthRequestId("fifthRequestId959024147")
1124-
* .setSixthRequestId("sixthRequestId1005218260")
11251085
* .setSeverity(Severity.forNumber(0))
11261086
* .setFoobar(Foobar.newBuilder().build())
11271087
* .build();
@@ -1151,12 +1111,6 @@ public class EchoClient implements BackgroundResource {
11511111
* EchoRequest.newBuilder()
11521112
* .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
11531113
* .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
1154-
* .setRequestId("requestId693933066")
1155-
* .setSecondRequestId("secondRequestId344404470")
1156-
* .setThirdRequestId(true)
1157-
* .setFourthRequestId("fourthRequestId-2116417776")
1158-
* .setFifthRequestId("fifthRequestId959024147")
1159-
* .setSixthRequestId("sixthRequestId1005218260")
11601114
* .setSeverity(Severity.forNumber(0))
11611115
* .setFoobar(Foobar.newBuilder().build())
11621116
* .build();

0 commit comments

Comments
 (0)