-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: generate_library.sh
with postprocessing
#1951
Merged
diegomarquezp
merged 203 commits into
main
from
feat/generate-aiplatform-with-postprocessing
Oct 31, 2023
Merged
Changes from all commits
Commits
Show all changes
203 commits
Select commit
Hold shift + click to select a range
53abd0e
feat: add
JoeWang1127 434cbfc
generate gapic and proto folder
JoeWang1127 5825bcc
refactor utilities
JoeWang1127 c39cbea
add an action to verify
JoeWang1127 10a1c6d
checkout googleapis-gen
JoeWang1127 cca6770
setup repo name
JoeWang1127 89bbedc
add commit hash of googleapis-gen
JoeWang1127 3e85e33
change secret
JoeWang1127 fdf9260
change token
JoeWang1127 f3b60a6
change to git clone
JoeWang1127 1b4746d
change user name
JoeWang1127 2856709
add input list
JoeWang1127 81cbdc2
include resources folder in main
JoeWang1127 d733c5a
remove grpc version in `*ServiceGrpc.java`
JoeWang1127 92660ff
change destination path
JoeWang1127 07f3ea6
compare generation result with googleapis-gen
JoeWang1127 49542f7
fix type in diff command
JoeWang1127 d7b3752
checkout repo using checkout action
JoeWang1127 0c8aa78
checkout repos as nested repo
JoeWang1127 3d612f8
sparse checkout googleapis
JoeWang1127 280a571
Revert "sparse checkout googleapis"
JoeWang1127 d375848
change library
JoeWang1127 734e1eb
change step name
JoeWang1127 9a5a7cd
add a readme
JoeWang1127 35ad197
make grpc version optional
JoeWang1127 8477b74
make protobuf version optional
JoeWang1127 5eb0223
checkout master branch, rather than a commit hash
JoeWang1127 b12f99e
allow snapshot version of generator
JoeWang1127 e893df3
download snapshot of generator parent pom
JoeWang1127 a7d8a55
update README
JoeWang1127 2a9f8a8
download generator and grpc using mvn
JoeWang1127 51beff7
change error message
JoeWang1127 f7e4b72
add maven central mirror
JoeWang1127 32463da
add comments in utilities
JoeWang1127 b58a802
add comments
JoeWang1127 d7dcdca
add an integration test
JoeWang1127 4e525a6
fail fast if no file is found
JoeWang1127 64ee89e
do not delete google/
JoeWang1127 56e418a
Merge branch 'main' into feat/generate-aiplatform-without-postprocessing
JoeWang1127 a056ae1
get protobuf version from WORKSPACE
JoeWang1127 7ef8278
add instructions on download `google/` from googleapis
JoeWang1127 4f0ef4a
add comments
JoeWang1127 5805e84
update description of `destination_path`
JoeWang1127 880c27b
update comments
JoeWang1127 a5fe171
download dependencies using `curl`
JoeWang1127 f6c5784
increase download time
JoeWang1127 5d16f16
remove comment
JoeWang1127 4f5689a
add samples directory in readme
JoeWang1127 b38f907
remove prerequisite about `proto_path`
JoeWang1127 1648254
add explanation in prerequisite
JoeWang1127 b896cad
add example to generate showcase
JoeWang1127 f7cb5f7
add a comment
JoeWang1127 68beeb9
wip adaptations
diegomarquezp 44dedad
add owlbot.py template
diegomarquezp 17d8e55
run owlbot docker image
diegomarquezp 4c63bfd
fix consolidate config
diegomarquezp 4966605
move owlbot call to its own function
diegomarquezp c4a67e3
move postprocessing logic
diegomarquezp b60860d
prepare integration test for gh workflow
diegomarquezp 808a281
fix local dev script
diegomarquezp fc7db26
Merge remote-tracking branch 'origin/main' into feat/generate-aiplatf…
diegomarquezp 7af9688
post-merge fixes
diegomarquezp 6d1b82e
fix test script and IT
diegomarquezp 563f088
fix parent poms
diegomarquezp a37a630
start fixing samples problem
diegomarquezp 8359fe8
fix samples folder transfer
diegomarquezp 797c3c4
cleanup, prepare IT workflow
diegomarquezp d9ac0f3
cleanup ii, sparse clone monorepo
diegomarquezp beb60c0
delete preserve script
diegomarquezp 589eb2a
clean unnecessary lines
diegomarquezp 3425fa1
Merge branch 'main' into feat/generate-aiplatform-with-postprocessing
diegomarquezp 16c9c79
infer owlbot sha
diegomarquezp e7b7a89
Merge remote-tracking branch 'refs/remotes/origin/feat/generate-aipla…
diegomarquezp 1f92d42
add template file
diegomarquezp 2a4552c
remove newline from owlbot template
diegomarquezp c5ad849
chore: newline correction
diegomarquezp 18ee764
use stderr for error messages
diegomarquezp b71fa8a
fix script documentation
diegomarquezp 7169e88
function comments
diegomarquezp 8ac66d3
quoting variables
diegomarquezp 759d175
format constant
diegomarquezp 8f88198
fix sparse checkout of monorepo
diegomarquezp 50ea3d6
include location to googleapis sparse clone
diegomarquezp 45391fa
remove unnecessary parent pom setting
diegomarquezp a33e8f6
remove consolidate_config.sh
diegomarquezp b6959e0
exclude changelog and owlbot copy files from diff check
diegomarquezp a5563fe
Merge remote-tracking branch 'origin/main' into feat/generate-aiplatf…
diegomarquezp bbf4ad4
fixes after merge
diegomarquezp 2661ae0
include .github in monorepo sparse clone
diegomarquezp dc90843
restore `set_parent_pom.sh`
diegomarquezp 5ca4077
restore `consolidate_config.sh`
diegomarquezp dc20ccf
correct parameter resolution
diegomarquezp bd4032b
use separate variable for version
diegomarquezp 645920b
postprocessing to use separate versions
diegomarquezp fd2add0
Merge remote-tracking branch 'origin/main' into feat/generate-aiplatf…
diegomarquezp eb630d6
Merge remote-tracking branch 'origin/main' into feat/generate-aiplatf…
diegomarquezp 6c74dd1
remove old IT file
diegomarquezp f4aeec1
post-merge fixes
diegomarquezp 51c0cce
enable post-processing by default
diegomarquezp 15776eb
Merge remote-tracking branch 'origin/main' into feat/generate-aiplatf…
diegomarquezp 4d47b5b
post-merge fixes
diegomarquezp bf59555
post-merge fixes
diegomarquezp 8501e6a
Merge remote-tracking branch 'refs/remotes/origin/feat/generate-aipla…
diegomarquezp ff56f8f
post merge fixes
diegomarquezp 0e235ff
add script to compare poms
diegomarquezp 949e03a
Merge remote-tracking branch 'origin/main' into feat/generate-aiplatf…
diegomarquezp 26724b9
post-merge fixes
diegomarquezp cb79e4e
post-merge fixes ii
diegomarquezp d4db01c
fix pom comparison
diegomarquezp 965ae63
include pre-existing poms before running owlbot
diegomarquezp 206d193
change owlbot-staging suffix folder to run owlbot.py
diegomarquezp 43c3295
fix newline removal in owlbot.py
diegomarquezp 4a7a766
split git diff command
diegomarquezp d61f635
enable tests for HW libraries
diegomarquezp 4656c8c
generate all hw libs except bigtable
diegomarquezp 89767f9
all libraries passing
diegomarquezp 6957092
fix unit tests
diegomarquezp 0c67ea2
repo metadata json logic cleanup
diegomarquezp b3169c3
remove new library scripts
diegomarquezp 85e7ef9
fix googleapis-gen tests
diegomarquezp beef5fa
fix post-processing it
diegomarquezp a2ac324
magic empty commit
diegomarquezp 457b140
Merge remote-tracking branch 'origin/main' into feat/generate-aiplatf…
diegomarquezp 946ebc5
correct conflict string
diegomarquezp b3379b9
use os agnostic string replacement
diegomarquezp 0c17333
comments and cleanup on postprocessing
diegomarquezp 0127e7f
cleanup of IT
diegomarquezp 4943488
temp: use custom gapic library name
diegomarquezp 79d9d4b
use owl-bot-copy
diegomarquezp 71b6e57
remove api_version logic
diegomarquezp b3ac7a6
remove custom_gapic_name in favor of owl-bot-copy
diegomarquezp 68b975a
remove unnecessary new library flag
diegomarquezp 84fdb5b
fix folder name test
diegomarquezp fb83971
remove unnecessary util function
diegomarquezp 26cb59b
remove unnecessary utils script dir var
diegomarquezp fd25987
rename postprocessing folder, apply_current_versions comment
diegomarquezp 36d440b
fix postprocessing comments
diegomarquezp a242fcd
correct popd folder name to its variable name
diegomarquezp 2a04035
unnecessary sed command
diegomarquezp 8cb7551
skip generation if more versions coming
diegomarquezp 38e7573
Merge remote-tracking branch 'origin/main' into feat/generate-aiplatf…
diegomarquezp 8b3a7e6
do not stage previous versions in owl-bot-staging
diegomarquezp a35f7b0
do not use custom repo metadatas
diegomarquezp 1f15c84
reset workspace folder
diegomarquezp 59ebdfb
remove unnecessary owlbot yaml copy
diegomarquezp e3fe861
modify readme
diegomarquezp 5f5897c
expand README instructions
diegomarquezp 25358e1
examples for both pre and post processing
diegomarquezp d03aad6
exclude new library owlbot.py template
diegomarquezp 0f3ce9e
do not process HW libraries
diegomarquezp aef4f06
success message, folder navigation fix
diegomarquezp 9477110
set git author
diegomarquezp bd3b673
add docker to workflow
diegomarquezp 025305c
lint fix
diegomarquezp 61bce33
custom docker step for macos
diegomarquezp 5f5e001
do not postprocess showcase
diegomarquezp 1a833e5
os-dependent pom comparison
diegomarquezp f0b5190
add python to workflow
diegomarquezp 6ae705c
explicit python version
diegomarquezp 0ffb4c5
add debugging output for compare_poms
diegomarquezp 24b0fe2
correct xargs for macos
diegomarquezp 08b9afb
remove debug checkpoints
diegomarquezp 8deeebc
clean compare_poms.py
diegomarquezp 01de512
concise else logic
diegomarquezp 14fd3af
infer destination_path
diegomarquezp 55a22b9
add generation times
diegomarquezp e10d1eb
remove unused transport and include_samples from postprocessing
diegomarquezp a97158a
use versions.txt at root of owlbot postprocessor fs
diegomarquezp c549cd5
modify success message
diegomarquezp e94cd56
remove unused version processing script
diegomarquezp b8226dc
remove owlbot_sha and repo_metadata args
diegomarquezp 1c7e5c7
use built-in docker images
diegomarquezp 9d12336
manual install of docker ii
diegomarquezp d01736a
manual install of docker iii
diegomarquezp f355551
manual install of docker iv
diegomarquezp 6b9bb19
manual install of docker v
diegomarquezp 7a9bd74
manual install of docker vi
diegomarquezp fa3f64d
manual install of docker vii
diegomarquezp a84eb2b
manual install of docker viii
diegomarquezp 955ed0d
manual install of docker ix
diegomarquezp 5886739
versions.txt as an argument
diegomarquezp bdee6d7
fix exit code in time tracking
diegomarquezp a5b991e
fix readme
diegomarquezp d418a9c
remove unused options
diegomarquezp e896c1c
fix macos docker install
diegomarquezp 8862348
do not use cask to install docker
diegomarquezp 7464c0e
test custom user id in docker run
diegomarquezp d1bc3f9
correct time tracking entry
diegomarquezp a2a4ef9
change postprocessing file structture
diegomarquezp fdcfb1e
move helper postprocess funcs to utilities.sh
diegomarquezp 21e4e85
add unit tests for postprocess utils
diegomarquezp 17436eb
remove repository_path
diegomarquezp 086f95f
fix workspace creation logic
diegomarquezp 3d216d2
fix readme
diegomarquezp 338767e
transfer from workspace to destination path
diegomarquezp 30a1ffc
include folder structure for p.p. libs in readme
diegomarquezp 9228814
omit pre-processed folders
diegomarquezp a60d3b0
omit package-info.java
diegomarquezp fcfd510
fix documentation argument order
diegomarquezp 45cb355
fix preparation of copy-code source folder
diegomarquezp 7ab4545
add unit test for copy_directory_if_exists
diegomarquezp 09128a4
fix wrong args to cp
diegomarquezp 173bf3a
change test monorepo folder names
diegomarquezp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/bash | ||
# | ||
# Main functions to interact with owlbot post-processor and postprocessing | ||
# scripts | ||
|
||
|
||
# Runs the owlbot post-processor docker image. The resulting post-processed | ||
# library gets stored in `${output_folder}/workspace` | ||
# Arguments | ||
# 1 - workspace: the location of the grpc,proto and gapic libraries to be | ||
# processed | ||
# 2 - scripts_root: location of the generation scripts | ||
# 3 - destination_path: used to transfer the raw grpc, proto and gapic libraries | ||
# 4 - proto_path: googleapis path of the library. This is used to prepare the | ||
# folder structure to run `owlbot-cli copy-code` | ||
# 5 - versions_file: path to file containing versions to be applied to the poms | ||
# 6 - output_folder: main workspace of the generation process | ||
|
||
workspace=$1 | ||
scripts_root=$2 | ||
destination_path=$3 | ||
proto_path=$4 | ||
versions_file=$5 | ||
output_folder=$6 | ||
|
||
source "${scripts_root}"/utilities.sh | ||
|
||
repository_root=$(echo "${destination_path}" | cut -d/ -f1) | ||
repo_metadata_json_path=$(get_repo_metadata_json "${destination_path}" "${output_folder}") | ||
owlbot_sha=$(get_owlbot_sha "${output_folder}" "${repository_root}") | ||
|
||
# read or infer owlbot sha | ||
|
||
cp "${repo_metadata_json_path}" "${workspace}"/.repo-metadata.json | ||
|
||
# call owl-bot-copy | ||
owlbot_staging_folder="${workspace}/owl-bot-staging" | ||
mkdir -p "${owlbot_staging_folder}" | ||
owlbot_postprocessor_image="gcr.io/cloud-devrel-public-resources/owlbot-java@sha256:${owlbot_sha}" | ||
|
||
|
||
|
||
# copy existing pom, owlbot and version files if the source of truth repo is present | ||
# pre-processed folders are ommited | ||
if [[ -d "${output_folder}/${destination_path}" ]]; then | ||
rsync -avm \ | ||
--include='*/' \ | ||
--include='*.xml' \ | ||
--include='owlbot.py' \ | ||
--include='.OwlBot.yaml' \ | ||
--exclude='*' \ | ||
"${output_folder}/${destination_path}/" \ | ||
"${workspace}" | ||
fi | ||
|
||
echo 'Running owl-bot-copy' | ||
pre_processed_libs_folder="${output_folder}/pre-processed" | ||
# By default (thanks to generation templates), .OwlBot.yaml `deep-copy` section | ||
# references a wildcard pattern matching a folder | ||
# ending with `-java` at the leaf of proto_path. | ||
mkdir -p "${pre_processed_libs_folder}/${proto_path}/generated-java" | ||
folder_name=$(extract_folder_name "${destination_path}") | ||
copy_directory_if_exists "${output_folder}/${destination_path}/proto-${folder_name}" \ | ||
"${pre_processed_libs_folder}/${proto_path}/generated-java/proto-google-cloud-${folder_name}" | ||
copy_directory_if_exists "${output_folder}/${destination_path}/grpc-${folder_name}" \ | ||
"${pre_processed_libs_folder}/${proto_path}/generated-java/grpc-google-cloud-${folder_name}" | ||
copy_directory_if_exists "${output_folder}/${destination_path}/gapic-${folder_name}" \ | ||
"${pre_processed_libs_folder}/${proto_path}/generated-java/gapic-google-cloud-${folder_name}" | ||
copy_directory_if_exists "${output_folder}/${destination_path}/samples" \ | ||
"${pre_processed_libs_folder}/${proto_path}/generated-java/samples" | ||
pushd "${pre_processed_libs_folder}" | ||
# create an empty repository so owl-bot-copy can process this as a repo | ||
# (cannot process non-git-repositories) | ||
git init | ||
git commit --allow-empty -m 'empty commit' | ||
popd # pre_processed_libs_folder | ||
|
||
docker run --rm \ | ||
--user $(id -u):$(id -g) \ | ||
-v "${workspace}:/repo" \ | ||
-v "${pre_processed_libs_folder}:/pre-processed-libraries" \ | ||
-w /repo \ | ||
--env HOME=/tmp \ | ||
gcr.io/cloud-devrel-public-resources/owlbot-cli:latest \ | ||
copy-code \ | ||
--source-repo-commit-hash=none \ | ||
--source-repo=/pre-processed-libraries \ | ||
--config-file=.OwlBot.yaml | ||
|
||
|
||
echo 'running owl-bot post-processor' | ||
versions_file_arg="" | ||
if [ -f "${versions_file}" ];then | ||
versions_file_arg="-v ${versions_file}:/versions.txt" | ||
fi | ||
# run the postprocessor | ||
docker run --rm \ | ||
-v "${workspace}:/workspace" \ | ||
${versions_file_arg} \ | ||
--user $(id -u):$(id -g) \ | ||
"${owlbot_postprocessor_image}" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK to make it required for now since it's only for existing libraries. For new client libraries, I'm assuming we have to generate versions.txt first before calling this script? Is it generated by new client library script currently? cc @JoeWang1127
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blakeli0 the version of a new library defaults to
0.0.1-SNAPSHOT
.example PR
The new library script applies current versions but this is for other referenced artifacts such as
google-cloud-java
(example)I think we still need a versions file for referenced artifacts other than the library being generated when dealing with a new monorepo library