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: always fully generate the repo if it is a non-monorepo or contains common protos #3162

Merged
merged 8 commits into from
Sep 4, 2024
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 9 additions & 10 deletions .github/scripts/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,14 @@ fi

image_tag=local
workspace_name="/workspace"
docker_file="library_generation.Dockerfile"
baseline_generation_config="baseline_generation_config.yaml"
message="chore: generate libraries at $(date)"

git checkout "${target_branch}"
git checkout "${current_branch}"
# if the last commit doesn't contain changes to generation configuration
# or Dockerfile, do not generate again as the result will be the same.
change_of_last_commit="$(git diff-tree --no-commit-id --name-only HEAD~1..HEAD -r)"
if [[ ! ("${change_of_last_commit}" == *"${generation_config}"* || "${change_of_last_commit}" == *"${docker_file}"*) ]]; then
echo "The last commit doesn't contain any changes to the generation_config.yaml or Dockerfile, skipping the whole generation process." || true
exit 0
fi

# copy generation configuration from target branch to current branch.
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}"

generator_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -pl gapic-generator-java)
echo "Local generator version: ${generator_version}"
Expand All @@ -94,10 +91,12 @@ docker run \
-v "$(pwd):${workspace_name}" \
-v "$HOME"/.m2:/home/.m2 \
-e GENERATOR_VERSION="${generator_version}" \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}"
gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \
--baseline-generation-config-path="${workspace_name}/${baseline_generation_config}" \
--current-generation-config-path="${workspace_name}/${generation_config}"

# commit the change to the pull request.
rm -rdf output googleapis
rm -rdf output googleapis "${baseline_generation_config}"
git add --all -- ':!pr_description.txt'
changed_files=$(git diff --cached --name-only)
if [[ "${changed_files}" == "" ]]; then
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/hermetic_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ name: Hermetic library generation upon generation config change through pull req
on:
pull_request:

env:
REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
jobs:
library_generation:
# skip pull requests come from a forked repository
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -31,6 +32,10 @@ jobs:
shell: bash
run: |
set -x
if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then
echo "This PR comes from a fork. Skip library generation."
exit 0
fi
[ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com"
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
bash .github/scripts/hermetic_library_generation.sh \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/config_change.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/config_change.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface AdviceOrBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/annotations.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public final class AnnotationsProto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public final class AuthProto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface AuthProviderOrBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface AuthRequirementOrBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface AuthenticationOrBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/auth.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface AuthenticationRuleOrBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/backend.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/backend.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface BackendOrBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/backend.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public final class BackendProto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/backend.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/backend.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface BackendRuleOrBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/billing.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/billing.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface BillingOrBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/billing.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public final class BillingProto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/config_change.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/client.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/client.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/client.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/client.proto

// Protobuf Java Version: 3.25.3
// Protobuf Java Version: 3.25.4
package com.google.api;

public interface ClientLibrarySettingsOrBuilder
Expand Down
Loading
Loading