Skip to content
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

chore: create shared dependencies tag for library gen image #3378

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,31 @@ timeout: 7200s # 2 hours
substitutions:
_IMAGE_NAME: "us-docker.pkg.dev/java-hermetic-build-prod/private-resources/java-library-generation"
_GAPIC_GENERATOR_JAVA_VERSION: '2.50.1-SNAPSHOT' # {x-version-update:gapic-generator-java:current}
_SHARED_DEPENDENCIES_VERSION: '3.40.1-SNAPSHOT' # {x-version-update:google-cloud-shared-dependencies:current}
_SHA_IMAGE_ID: "${_IMAGE_NAME}:${COMMIT_SHA}"
_LATEST_IMAGE_ID: "${_IMAGE_NAME}:latest"
_VERSIONED_IMAGE_ID: "${_IMAGE_NAME}:${_GAPIC_GENERATOR_JAVA_VERSION}"
_GENERATOR_VERSIONED_IMAGE_ID: "${_IMAGE_NAME}:${_GAPIC_GENERATOR_JAVA_VERSION}"
_SHARED_DEPENDENCIES_VERSIONED_IMAGE_ID: "${_IMAGE_NAME}:${_SHARED_DEPENDENCIES_VERSION}"
steps:
# Library generation build
- name: gcr.io/cloud-builders/docker
args: [
"build",
"-t", "${_SHA_IMAGE_ID}",
"-t", "${_LATEST_IMAGE_ID}",
"-t", "${_VERSIONED_IMAGE_ID}",
"--file", ".cloudbuild/library_generation/library_generation.Dockerfile", "."]
id: library-generation-build
waitFor: ["-"]
env:
- 'DOCKER_BUILDKIT=1'
# Library generation build
- name: gcr.io/cloud-builders/docker
args: [
"build",
"-t", "${_SHA_IMAGE_ID}",
"-t", "${_LATEST_IMAGE_ID}",
"-t", "${_GENERATOR_VERSIONED_IMAGE_ID}",
"-t", "${_SHARED_DEPENDENCIES_VERSIONED_IMAGE_ID}",
"--file", ".cloudbuild/library_generation/library_generation.Dockerfile", "."]
id: library-generation-build
waitFor: ["-"]
env:
- 'DOCKER_BUILDKIT=1'

options:
logging: CLOUD_LOGGING_ONLY

images:
- ${_SHA_IMAGE_ID}
- ${_LATEST_IMAGE_ID}
- ${_VERSIONED_IMAGE_ID}
- ${_SHA_IMAGE_ID}
- ${_LATEST_IMAGE_ID}
- ${_GENERATOR_VERSIONED_IMAGE_ID}
- ${_SHARED_DEPENDENCIES_VERSIONED_IMAGE_ID}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ timeout: 7200s # 2 hours
substitutions:
_IMAGE_NAME: "gcr.io/cloud-devrel-public-resources/java-library-generation"
_GAPIC_GENERATOR_JAVA_VERSION: '2.50.1-SNAPSHOT' # {x-version-update:gapic-generator-java:current}
_SHARED_DEPENDENCIES_VERSION: '3.40.1-SNAPSHOT' # {x-version-update:google-cloud-shared-dependencies:current}
_SHA_IMAGE_ID: "${_IMAGE_NAME}:${COMMIT_SHA}"
_LATEST_IMAGE_ID: "${_IMAGE_NAME}:latest"
_VERSIONED_IMAGE_ID: "${_IMAGE_NAME}:${_GAPIC_GENERATOR_JAVA_VERSION}"
_GENERATOR_VERSIONED_IMAGE_ID: "${_IMAGE_NAME}:${_GAPIC_GENERATOR_JAVA_VERSION}"
_SHARED_DEPENDENCIES_VERSIONED_IMAGE_ID: "${_IMAGE_NAME}:${_SHARED_DEPENDENCIES_VERSION}"
steps:
# Library generation build
- name: gcr.io/cloud-builders/docker
args: [
"build",
"-t", "${_SHA_IMAGE_ID}",
"-t", "${_LATEST_IMAGE_ID}",
"-t", "${_VERSIONED_IMAGE_ID}",
"-t", "${_GENERATOR_VERSIONED_IMAGE_ID}",
"-t", "${_SHARED_DEPENDENCIES_VERSIONED_IMAGE_ID}",
"--file", ".cloudbuild/library_generation/library_generation.Dockerfile", "."]
id: library-generation-build
waitFor: ["-"]
Expand All @@ -39,4 +42,5 @@ options:
images:
- ${_SHA_IMAGE_ID}
- ${_LATEST_IMAGE_ID}
- ${_VERSIONED_IMAGE_ID}
- ${_GENERATOR_VERSIONED_IMAGE_ID}
- ${_SHARED_DEPENDENCIES_VERSIONED_IMAGE_ID}
7 changes: 6 additions & 1 deletion .github/scripts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ inputs:
required: true
image_tag:
description: the tag of hermetic build image
required: true
generator_version:
description: the version of gapic-generator-java
required: false
token:
description: Personal Access Token
Expand Down Expand Up @@ -72,9 +75,11 @@ runs:
bash hermetic_library_generation.sh \
--target_branch "${BASE_REF}" \
--current_branch "${HEAD_REF}" \
--image_tag "${IMAGE_TAG}"
--image_tag "${IMAGE_TAG}" \
--generator_version "${GENERATOR_VERSION}"
env:
BASE_REF: ${{ inputs.base_ref }}
HEAD_REF: ${{ inputs.head_ref }}
IMAGE_TAG: ${{ inputs.image_tag }}
GENERATOR_VERSION: ${{ inputs.generator_version }}
GH_TOKEN: ${{ inputs.token }}
20 changes: 13 additions & 7 deletions .github/scripts/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ 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. [optional] image_tag, the tag of gcr.io/cloud-devrel-public-resources/java-library-generation.
# 4. [optional] generation_config, the path to the generation configuration,
# 3. image_tag, the tag of gcr.io/cloud-devrel-public-resources/java-library-generation.
# 4.
# 5. [optional] generation_config, the path to the generation configuration,
# the default value is generation_config.yaml in the repository root.
while [[ $# -gt 0 ]]; do
key="$1"
Expand All @@ -40,6 +41,10 @@ case "${key}" in
image_tag="$2"
shift
;;
--generator_version)
generator_version="$2"
shift
;;
--generation_config)
generation_config="$2"
shift
Expand All @@ -62,15 +67,16 @@ 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}"
fi

if [ -z "${image_tag}" ]; then
image_tag=$(grep "gapic_generator_version" "${generation_config}" | cut -d ':' -f 2 | xargs)
fi

workspace_name="/workspace"
baseline_generation_config="baseline_generation_config.yaml"
message="chore: generate libraries at $(date)"
Expand Down Expand Up @@ -102,7 +108,7 @@ docker run \
-u "$(id -u):$(id -g)" \
-v "$(pwd):${workspace_name}" \
-v "${api_def_dir}:${workspace_name}/googleapis" \
-e GENERATOR_VERSION="${image_tag}" \
-e GENERATOR_VERSION="${generator_version}" \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \
--generation-config-path="${workspace_name}/${generation_config}" \
--library-names="${changed_libraries}" \
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/hermetic_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ jobs:
shell: bash
run: |
GENERATOR_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -pl gapic-generator-java)
SHARED_DEPENDENCIES_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -pl java-shared-dependencies)
echo "GENERATOR_VERSION=${GENERATOR_VERSION}" >> "$GITHUB_ENV"
echo "SHARED_DEPENDENCIES_VERSION=${SHARED_DEPENDENCIES_VERSION}" >> "$GITHUB_ENV"
docker build \
-f .cloudbuild/library_generation/library_generation.Dockerfile \
-t gcr.io/cloud-devrel-public-resources/java-library-generation:"${GENERATOR_VERSION}" \
-t gcr.io/cloud-devrel-public-resources/java-library-generation:"${SHARED_DEPENDENCIES_VERSION}" \
.
- uses: ./.github/scripts
if: env.SHOULD_RUN == 'true'
with:
base_ref: ${{ github.base_ref }}
head_ref: ${{ github.head_ref }}
image_tag: ${{ env.GENERATOR_VERSION }}
image_tag: ${{ env.SHARED_DEPENDENCIES_VERSION }}
generator_version: ${{ env.GENERATOR_VERSION }}
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,15 @@
{
"customType": "regex",
"fileMatch": [
"^.github/workflows/unmanaged_dependency_check.yaml$"
],
"matchStrings": [
"uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v(?<currentValue>.+?)\\n"
],
"depNameTemplate": "com.google.cloud:sdk-platform-java-config",
"datasourceTemplate": "maven"
},
{
"fileMatch": [
"^.github/workflows/unmanaged_dependency_check.yaml$",
"^.github/workflows/hermetic_library_generation.yaml$"
],
"matchStrings": [
"uses: googleapis/sdk-platform-java/.github/scripts@v(?<currentValue>.+?)\\n"
"uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v(?<currentValue>.+?)\\n",
"uses: googleapis/sdk-platform-java/.github/scripts@google-cloud-shared-dependencies/v(?<currentValue>.+?)\\n",
"IMAGE_TAG: (?<currentValue>.+?)\\n"
],
"depNameTemplate": "com.google.api:gapic-generator-java",
"depNameTemplate": "com.google.cloud:sdk-platform-java-config",
"datasourceTemplate": "maven"
}
],
Expand Down Expand Up @@ -114,13 +107,6 @@
"^com.fasterxml.jackson.core"
],
"groupName": "jackson dependencies"
},
{
"matchPackagePatterns": [
"^com.google.api:gapic-generator-java",
"^com.google.cloud:sdk-platform-java-config"
],
"groupName": "SDK platform Java dependencies"
}
],
"semanticCommits": true,
Expand Down
Loading