Skip to content

Commit

Permalink
chore: parse image tag from generation config (#10956)
Browse files Browse the repository at this point in the history
* chore: parse image tag from generation config

* update renovate config
  • Loading branch information
JoeWang1127 committed Jun 12, 2024
1 parent 9e124ee commit bda6bb5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
13 changes: 3 additions & 10 deletions .github/scripts/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ set -e
# The parameters of this script is:
# 1. target_branch, the branch into which the pull request is merged.
# 2. current_branch, the branch with which the pull request is associated.
# 3. image_tag, the tag of gcr.io/cloud-devrel-public-resources/java-library-generation.
# 3. [optional] generation_config, the path to the generation configuration,
# the default value is generation_config.yaml in the repository root.
while [[ $# -gt 0 ]]; do
Expand All @@ -35,10 +34,6 @@ case "${key}" in
current_branch="$2"
shift
;;
--image_tag)
image_tag="$2"
shift
;;
--generation_config)
generation_config="$2"
shift
Expand All @@ -61,11 +56,6 @@ if [ -z "${current_branch}" ]; then
exit 1
fi

if [ -z "${image_tag}" ]; then
echo "missing required argument --image_tag"
exit 1
fi

if [ -z "${generation_config}" ]; then
generation_config=generation_config.yaml
echo "Use default generation config: ${generation_config}"
Expand All @@ -88,6 +78,9 @@ fi
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}"
config_diff=$(diff "${generation_config}" "${baseline_generation_config}" || true)

# parse image tag from the generation configuration.
image_tag=$(grep "gapic_generator_version" "${generation_config}" | cut -d ':' -f 2 | xargs)

# run hermetic code generation docker image.
docker run \
--rm \
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/hermetic_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
# skip pull requests come from a forked repository
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
env:
library_generation_image_tag: 2.41.0
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -37,8 +35,7 @@ jobs:
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
bash .github/scripts/hermetic_library_generation.sh \
--target_branch "${base_ref}" \
--current_branch "${head_ref}" \
--image_tag "${library_generation_image_tag}"
--current_branch "${head_ref}"
env:
base_ref: ${{ github.base_ref }}
head_ref: ${{ github.head_ref }}
Expand Down
16 changes: 1 addition & 15 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
".kokoro/nightly/graalvm-sub-jobs/native*/common.cfg",
".kokoro/presubmit/graalvm-native*.cfg",
"owl-bot-postprocessor/synthtool/gcp/templates/java-library/.kokoro/presubmit/graalvm-native*.cfg",
"generation_config.yaml",
".github/workflows/ci.yaml",
".github/workflows/generated_files_sync.yaml",
".github/workflows/hermetic_library_generation.yaml",
".github/workflows/unmanaged_dependency_check.yaml"
],
"regexManagers": [
Expand Down Expand Up @@ -57,22 +55,10 @@
"depNameTemplate": "com.google.cloud:libraries-bom",
"datasourceTemplate": "maven"
},
{
"fileMatch": [
"generation_config.yaml"
],
"matchStrings": [
"libraries_bom_version\\s*:\\s*(?<currentValue>.*?)\\n"
],
"depNameTemplate": "com.google.cloud:libraries-bom",
"datasourceTemplate": "maven"
},
{
"fileMatch": [
".github/workflows/ci.yaml",
".github/workflows/generated_files_sync.yaml",
".github/workflows/hermetic_library_generation.yaml",
".github/workflows/unmanaged_dependency_check.yaml"
".github/workflows/generated_files_sync.yaml"
],
"matchStrings": [
"library_generation_image_tag\\s*:\\s*(?<currentValue>.*?)\\n"
Expand Down

0 comments on commit bda6bb5

Please sign in to comment.