Skip to content

Commit 5015778

Browse files
diegomarquezplqiu96
authored andcommitted
chore: use library_name to compute destination folder of generate_repo (#2489)
fixes #2494
1 parent 18f07ea commit 5015778

File tree

7 files changed

+39
-24
lines changed

7 files changed

+39
-24
lines changed

library_generation/generate_composed_library.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def generate_composed_library(
8181
library_path=library_path,
8282
)
8383
service_version = gapic.proto_path.split("/")[-1]
84-
temp_destination_path = f"java-{library.api_shortname}-{service_version}"
84+
temp_destination_path = (
85+
f"java-{util.get_library_name(library)}-{service_version}"
86+
)
8587
effective_arguments = __construct_effective_arg(
8688
base_arguments=base_arguments,
8789
gapic=gapic,

library_generation/owlbot/bin/entrypoint.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ fi
4646

4747

4848
# Runs template and etc in current working directory
49-
monorepo=$1
5049

5150
# apply repo templates
5251
echo "Rendering templates"
@@ -56,8 +55,11 @@ python3 "${scripts_root}/owlbot/src/apply_repo_templates.py" "${configuration_ya
5655
echo "Retrieving files from owl-bot-staging directory..."
5756
if [ -f "owlbot.py" ]
5857
then
58+
# we use an empty synthtool folder to prevent cached templates from being used
59+
export SYNTHTOOL_TEMPLATES=$(mktemp -d)
5960
# defaults to run owlbot.py
6061
python3 owlbot.py
62+
export SYNTHTOOL_TEMPLATES=""
6163
fi
6264
echo "...done"
6365

library_generation/owlbot/src/apply_repo_templates.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from library_generation.model.generation_config import from_yaml
1414

1515
script_dir = os.path.dirname(os.path.realpath(__file__))
16-
repo_templates_path = os.path.join(script_dir, "..", "templates", "java_library")
16+
repo_templates_path = os.path.normpath(os.path.join(script_dir, "..", "templates"))
1717

1818

1919
def apply_repo_templates(configuration_yaml_path: str, monorepo: bool) -> None:

library_generation/postprocess_library.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# different logic
2323
# 8 - configuration_yaml_path: path to the configuration yaml containing library
2424
# generation information for this library
25-
set -eo pipefail
25+
set -exo pipefail
2626
scripts_root=$(dirname "$(readlink -f "$0")")
2727

2828
postprocessing_target=$1

library_generation/setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
"templates/*.j2",
1717
"gapic-generator-java-wrapper",
1818
"requirements.*",
19-
"owlbot/src/requirements.*",
2019
"owlbot/bin/*.sh",
21-
"owlbot/templates/**/*.j2",
20+
"owlbot/templates/clirr/*.j2",
21+
"owlbot/templates/poms/*.j2",
22+
"owlbot/templates/java_library/**/*",
2223
],
2324
},
2425
)

library_generation/test/integration_tests.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from library_generation.model.generation_config import from_yaml
2828
from library_generation.test.compare_poms import compare_xml
2929
from library_generation.utilities import get_library_name
30+
from library_generation.utilities import sh_util as shell_call
3031

3132
config_name = "generation_config.yaml"
3233
script_dir = os.path.dirname(os.path.realpath(__file__))
@@ -37,6 +38,7 @@
3738
golden_dir = f"{config_dir}/golden"
3839
repo_prefix = "https://github.com/googleapis"
3940
committish_list = ["chore/test-hermetic-build"] # google-cloud-java
41+
output_folder = shell_call("get_output_folder")
4042

4143

4244
class IntegrationTest(unittest.TestCase):
@@ -46,7 +48,7 @@ def test_generate_repo(self):
4648
config_files = self.__get_config_files(config_dir)
4749
i = 0
4850
for repo, config_file in config_files.items():
49-
repo_dest = f"{golden_dir}/{repo}"
51+
repo_dest = f"{output_folder}/{repo}"
5052
self.__pull_repo_to(Path(repo_dest), repo, committish_list[i])
5153
library_names = self.__get_library_names_from_config(config_file)
5254
# prepare golden files
@@ -62,9 +64,10 @@ def test_generate_repo(self):
6264
# compare result
6365
for library_name in library_names:
6466
print(
67+
f"Generation finished. Will now compare "
68+
f"the expected library in {golden_dir}/{library_name}, "
69+
f"with the actual library in {repo_dest}/{library_name}. "
6570
f"Compare generation result: "
66-
f"expected library in {golden_dir}/{library_name}, "
67-
f"actual library in {repo_dest}/{library_name}."
6871
)
6972
compare_result = dircmp(
7073
f"{golden_dir}/{library_name}",

library_generation/test/resources/integration/google-cloud-java/generation_config.yaml

+22-15
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,26 @@ libraries:
2525
GAPICs:
2626
- proto_path: google/cloud/apigeeconnect/v1
2727

28-
- api_shortname: cloudasset
29-
name_pretty: Cloud Asset Inventory
30-
product_documentation: "https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview"
31-
api_description: "provides inventory services based on a time series database. This database keeps a five week history of Google Cloud asset metadata. The Cloud Asset Inventory export service allows you to export all asset metadata at a certain timestamp or export event change history during a timeframe."
32-
library_name: "asset"
33-
client_documentation: "https://cloud.google.com/java/docs/reference/google-cloud-asset/latest/overview"
34-
distribution_name: "com.google.cloud:google-cloud-asset"
35-
release_level: "stable"
36-
issue_tracker: "https://issuetracker.google.com/issues/new?component=187210&template=0"
37-
api_reference: "https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview"
28+
- api_shortname: alloydb
29+
name_pretty: AlloyDB
30+
product_documentation: https://cloud.google.com/alloydb/
31+
api_description: AlloyDB is a fully managed, PostgreSQL-compatible database service
32+
with industry-leading performance, availability, and scale.
33+
rest_documentation: https://cloud.google.com/alloydb/docs/reference/rest
34+
GAPICs:
35+
- proto_path: google/cloud/alloydb/v1
36+
- proto_path: google/cloud/alloydb/v1alpha
37+
- proto_path: google/cloud/alloydb/v1beta
38+
39+
- api_shortname: alloydb
40+
name_pretty: AlloyDB connectors
41+
product_documentation: https://cloud.google.com/alloydb/docs
42+
api_description: AlloyDB is a fully-managed, PostgreSQL-compatible database for
43+
demanding transactional workloads. It provides enterprise-grade performance and
44+
availability while maintaining 100% compatibility with open-source PostgreSQL.
45+
library_name: alloydb-connectors
46+
rest_documentation: https://cloud.google.com/alloydb/docs/reference/rest
3847
GAPICs:
39-
- proto_path: google/cloud/asset/v1
40-
- proto_path: google/cloud/asset/v1p1beta1
41-
- proto_path: google/cloud/asset/v1p2beta1
42-
- proto_path: google/cloud/asset/v1p5beta1
43-
- proto_path: google/cloud/asset/v1p7beta1
48+
- proto_path: google/cloud/alloydb/connectors/v1
49+
- proto_path: google/cloud/alloydb/connectors/v1alpha
50+
- proto_path: google/cloud/alloydb/connectors/v1beta

0 commit comments

Comments
 (0)