From 1810451e1ed01329c4af9ea0247672818ba7ac0f Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Thu, 2 May 2024 15:25:50 +0000 Subject: [PATCH 1/3] chore: skip library generation tests after merging a pull request (#2712) In this PR: - Skip running library generation test after merging a pull request. Related error: ``` Run set -ex set -ex git checkout "${base_ref}" git checkout "${head_ref}" changed_directories="$(git diff --name-only ${base_ref} ${head_ref})" if [[ ${changed_directories} =~ "library_generation/" ]]; then echo "should_run=true" >> $GITHUB_OUTPUT else echo "should_run=false" >> $GITHUB_OUTPUT fi shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0} env: base_ref: head_ref: + git checkout '' fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths ``` Full log: https://github.com/googleapis/sdk-platform-java/actions/runs/8913958564/job/24480528068 --- .github/workflows/verify_library_generation.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/verify_library_generation.yaml b/.github/workflows/verify_library_generation.yaml index 8feec8a9d6..8f2520c858 100644 --- a/.github/workflows/verify_library_generation.yaml +++ b/.github/workflows/verify_library_generation.yaml @@ -3,7 +3,8 @@ on: branches: - main pull_request: - + # do not run this workflow when merging the pull request. + types: [opened, reopened, edited, synchronize] workflow_dispatch: name: verify_library_generation jobs: From 3ab0aa3313ae223d0dd16d1bdfffe51e137f5ac6 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Thu, 2 May 2024 16:16:08 +0000 Subject: [PATCH 2/3] chore: remove test output (#2713) In this PR: - Remove test output directory. --- library_generation/test/integration_tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library_generation/test/integration_tests.py b/library_generation/test/integration_tests.py index e3f950300e..47ad22b6dc 100644 --- a/library_generation/test/integration_tests.py +++ b/library_generation/test/integration_tests.py @@ -190,8 +190,7 @@ def __build_image(cls, docker_file: str, cwd: str): @classmethod def __remove_generated_files(cls): - # uncomment this line when the generated files don't owned by root. - # shutil.rmtree(f"{output_dir}", ignore_errors=True) + shutil.rmtree(f"{output_dir}", ignore_errors=True) if os.path.isdir(f"{golden_dir}"): shutil.rmtree(f"{golden_dir}") From 5d4567f883b1e29cd5f299d392c5a809b451aa18 Mon Sep 17 00:00:00 2001 From: Alice <65933803+alicejli@users.noreply.github.com> Date: Thu, 2 May 2024 13:14:28 -0400 Subject: [PATCH 3/3] chore: fix verify_library_generation.yaml for forks (#2716) PRs opened by renovate-bot are failing `verify_library_generation` because renovate-bot opens PRs from a fork rather than main. For instance https://github.com/googleapis/sdk-platform-java/pull/2657 is failing: ``` env: base_ref: main head_ref: renovate/markupsafe-2.x + git checkout main Previous HEAD position was d84e6072d Merge 645951c0497bf9cdb42e6323cd90a08d77a1926a into 766646a9e0bed6c8e804eb1e6ab4d[13](https://github.com/googleapis/sdk-platform-java/actions/runs/8914757209/job/24482995077?pr=2657#step:3:13)3d1465dca Switched to a new branch 'main' branch 'main' set up to track 'origin/main'. + git checkout renovate/markupsafe-2.x error: pathspec 'renovate/markupsafe-2.x' did not match any file(s) known to git ``` This updates the yaml file to explicitly fetch specific branches which should fix the issue. --------- Co-authored-by: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> --- .github/workflows/verify_library_generation.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify_library_generation.yaml b/.github/workflows/verify_library_generation.yaml index 8f2520c858..51c276504d 100644 --- a/.github/workflows/verify_library_generation.yaml +++ b/.github/workflows/verify_library_generation.yaml @@ -21,8 +21,10 @@ jobs: shell: bash run: | set -ex - git checkout "${base_ref}" - git checkout "${head_ref}" + git checkout "${base_ref}" # Checkout a detached head, and then fetch the base ref to populate the detached head. + git fetch --no-tags --prune origin +${base_ref}:refs/remotes/origin/${base_ref} + git checkout "${head_ref}" # Checkout a detached head, and then fetch the head ref to populate the detached head. + git fetch --no-tags --prune origin +${head_ref}:refs/remotes/origin/${head_ref} changed_directories="$(git diff --name-only ${base_ref} ${head_ref})" if [[ ${changed_directories} =~ "library_generation/" ]]; then echo "should_run=true" >> $GITHUB_OUTPUT