Skip to content

Commit 91fa7be

Browse files
authored
chore: update hermetic library generation workflow (#10693)
* chore: update generation workflow * update workflow * update new client creation workflow * add base branch * use shell script * generalize repo name * add script to update googleapis commit * update comments * update workflow file * update image tag * try to fix workflow error * change comment * update comment * refactor according to code review * restore change * update branch
1 parent 61aa5c2 commit 91fa7be

7 files changed

Lines changed: 273 additions & 175 deletions

.github/workflows/generate-from-configuration.yaml

Lines changed: 0 additions & 113 deletions
This file was deleted.

.github/workflows/generate_new_client_hermetic_build.yaml

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Generate new GAPIC client library (Hermetic Build)
22
on:
33
workflow_dispatch:
4-
# some inputs are ommited due to limit of 10 input arguments
4+
# some inputs are omitted due to limit of 10 input arguments
55
inputs:
66
api_shortname:
77
required: true
@@ -53,7 +53,7 @@ jobs:
5353
generate:
5454
runs-on: ubuntu-22.04
5555
steps:
56-
- uses: actions/checkout@v3
56+
- uses: actions/checkout@v4
5757
- uses: actions/setup-python@v4
5858
with:
5959
python-version: '3.9'
@@ -78,36 +78,6 @@ jobs:
7878
API_DESCRIPTION: ${{ github.event.inputs.api_description }}
7979
LIBRARY_NAME: ${{ github.event.inputs.library_name }}
8080
DISTRIBUTION_NAME: ${{ github.event.inputs.distribution_name }}
81-
- name: setup docker environment
82-
shell: bash
83-
run: |
84-
set -x
85-
# we create a volume pointing to `pwd` (google-cloud-java) that will
86-
# be referenced by the container and its children
87-
if [[ $(docker volume inspect repo-google-cloud-java) != '[]' ]]; then
88-
docker volume rm repo-google-cloud-java
89-
fi
90-
docker volume create --name "repo-google-cloud-java" --opt "type=none" --opt "device=$(pwd)" --opt "o=bind"
91-
- name: generate from configuration
92-
id: generation
93-
shell: bash
94-
run: |
95-
set -x
96-
repo_volumes="-v repo-google-cloud-java:/workspace/google-cloud-java"
97-
echo "::set-output name=repo_volumes::${repo_volumes}"
98-
docker run --rm \
99-
${repo_volumes} \
100-
-v /tmp:/tmp \
101-
-v /var/run/docker.sock:/var/run/docker.sock \
102-
-e "RUNNING_IN_DOCKER=true" \
103-
-e "REPO_BINDING_VOLUMES=${repo_volumes}" \
104-
gcr.io/cloud-devrel-public-resources/java-library-generation:latest \
105-
python /src/generate_repo.py generate \
106-
--generation-config-yaml=/workspace/google-cloud-java/generation_config.yaml \
107-
--repository-path=/workspace/google-cloud-java \
108-
--target-library-names=${API_SHORTNAME}
109-
env:
110-
API_SHORTNAME: ${{ github.event.inputs.api_shortname }}
11181
- name: Push to branch and create PR
11282
run: |
11383
set -x
@@ -133,19 +103,6 @@ jobs:
133103
134104
\`\`\`
135105
python generation/new_client_hermetic_build/add-new-client-config.py add-new-client ${GENERATION_ARGUMENTS}
136-
137-
docker run --rm \\
138-
${DOCKER_VOLUMES} \\
139-
-v /tmp:/tmp \\
140-
-v /var/run/docker.sock:/var/run/docker.sock \\
141-
-e \"RUNNING_IN_DOCKER=true\" \\
142-
-e \"REPO_BINDING_VOLUMES=${DOCKER_VOLUMES}\" \\
143-
gcr.io/cloud-devrel-public-resources/java-library-generation:latest \\
144-
python /src/generate_repo.py generate \\
145-
--generation-config-yaml=/workspace/google-cloud-java/generation_config.yaml \\
146-
--repository-path=/workspace/google-cloud-java \\
147-
--target-library-names=${API_SHORTNAME}
148-
149106
\`\`\`"
150107
gh pr create --title "${commit_message}" --label "owlbot:run" --head "${branch_name}" --body "${pr_body}"
151108
env:
@@ -154,4 +111,3 @@ jobs:
154111
GENERATION_ARGUMENTS: ${{ steps.config_generation.outputs.new_library_args }}
155112
DOCKER_VOLUMES: ${{ steps.generation.outputs.repo_volumes }}
156113
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
157-

.github/workflows/generated_files_sync.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
# Github action job to test core java library features on
14+
# GitHub action job to test core java library features on
1515
# downstream client libraries before they are released.
1616
on:
1717
push:
@@ -20,7 +20,7 @@ on:
2020
pull_request:
2121
name: generation diff
2222
env:
23-
library_generation_image_tag: latest
23+
library_generation_image_tag: 2.39.0
2424
repo_volumes: "-v repo-google-cloud-java:/workspace/google-cloud-java"
2525
jobs:
2626
root-pom:
Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# GitHub action job to test core java library features on
15+
# downstream client libraries before they are released.
116
name: Hermetic library generation upon generation config change through pull requests
217
on:
318
pull_request:
4-
types:
5-
- synchronize
619
paths:
7-
- generation_config.yaml
20+
- "generation_config.yaml"
21+
822
jobs:
923
library_generation:
1024
runs-on: ubuntu-latest
1125
env:
12-
library_generation_image_tag: latest
13-
repo_volumes: "-v repo-google-cloud-java:/workspace/google-cloud-java"
26+
library_generation_image_tag: 2.39.0
1427
steps:
1528
- uses: actions/checkout@v4
1629
with:
17-
ref: ${{ github.head_ref }}
18-
- name: get baseline generation config
19-
uses: actions/checkout@v4
20-
with:
21-
ref: ${{ github.base_ref }}
22-
path: baseline
23-
sparse-checkout: generation_config.yaml
24-
- name: diff
30+
fetch-depth: 0
31+
- name: Generate changed libraries
2532
shell: bash
2633
run: |
27-
diff generation_config.yaml baseline/generation_config.yaml
34+
set -x
35+
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
36+
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
37+
bash generation/hermetic_library_generation.sh \
38+
--target_branch ${{ github.base_ref }} \
39+
--current_branch ${{ github.head_ref }} \
40+
--image_tag "${library_generation_image_tag}"
41+
env:
42+
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# GitHub action job to test core java library features on
15+
# downstream client libraries before they are released.
16+
name: Update googleapis commit
17+
on:
18+
schedule:
19+
- cron: '* 2 * * *'
20+
workflow_dispatch:
21+
22+
23+
jobs:
24+
update-googleapis-commit:
25+
runs-on: ubuntu-22.04
26+
env:
27+
# the branch into which the pull request is merged
28+
base_branch: main
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Update googleapis commit to latest
32+
shell: bash
33+
run: |
34+
set -x
35+
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
36+
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
37+
bash generation/update_googleapis_commit.sh \
38+
--base_branch "${base_branch}"\
39+
--repo ${{ github.repository }}
40+
env:
41+
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}

0 commit comments

Comments
 (0)