-
Notifications
You must be signed in to change notification settings - Fork 1.1k
185 lines (174 loc) · 6.98 KB
/
generated_files_sync.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# GitHub action job to test core java library features on
# downstream client libraries before they are released.
on:
push:
branches:
- main
pull_request:
name: generation diff
env:
library_generation_image_tag: 2.48.0
jobs:
root-pom:
# root pom.xml does not have diff from generated one
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate root pom.xml file
shell: bash
run: |
docker run \
--rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/workspace" \
--entrypoint python \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${library_generation_image_tag}" \
/src/cli/generate_monorepo_root_pom.py \
generate \
--repository-path=/workspace
- name: Fail if there's any difference
run: git --no-pager diff --exit-code
gapic-bom:
# gapic-libraries-bom does not have diff from generated one
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate gapic-libraries-bom/pom.xml
shell: bash
run: |
docker run \
--rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/workspace" \
--entrypoint python \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${library_generation_image_tag}" \
/src/cli/generate_monorepo_gapic_bom.py \
generate \
--repository-path=/workspace \
--versions-file=/workspace/versions.txt
- name: Fail if there's any difference
run: git --no-pager diff --exit-code
owlbot-py:
# applying templated owlbot.py config doesn't create a diff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate owlbot.py files
run: |
bash generation/update_owlbot_postprocessor_config.sh
- name: Fail if there's any difference (To fix, run generation/update_owlbot_postprocessor_config.sh)
run: git --no-pager diff --exit-code
owlbot-yaml:
# Each module's .Owlbot-hermetic.yaml config is configured according to set_owlbot_config.sh
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check if .Owlbot-hermetic.yaml files are correctly configured
run: |
bash generation/set_owlbot_config.sh
- name: Fail if there's any difference (To fix, run generation/set_owlbot_config.sh)
run: git --no-pager diff --exit-code
gitignore_correctness:
# Generated files should not match .gitignore
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: checking any files matching gitignore
# By default, GitHub Actions's bash has '-e' option to fail immediately
# upon non-zero exit code. Not using it here to catch the exit code 1.
shell: /usr/bin/bash --noprofile --norc -o pipefail {0}
run: |
find . -type f -name '*.java' -not -path './.git/*' \
|git check-ignore --no-index --verbose --stdin
# https://git-scm.com/docs/git-check-ignore returns 1 when there's no
# matching files with the gitignore file.
# "--no-index" is needed to check against tracked files.
if [ "$?" == 1 ]; then
echo "No matching files. Good."
exit 0
else
echo "There are gitignore matching files. Please adjust .gitignore."
exit 1
fi
generate-readme:
# Ensure generate-readme.py runs fine
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
# These parameters should match ones in readme.yaml
with:
python-version: '3.11'
architecture: 'x64'
- run: python3 -m pip install --require-hashes -r .github/requirements.txt
- run: python3 generate-readme.py
group_id_check_for_maps_libraries:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Maps modules
run: |
IncludedNonCloudModules=$(find java-maps-* -name 'pom.xml' \
|sed -e 's|/pom.xml$||' |xargs |sed -e 's/ /,/g')
echo "Included modules: ${IncludedNonCloudModules}"
mvn -B -V -ntp install --also-make --projects "${IncludedNonCloudModules}" \
-DskipTests -Dclirr.skip
- name: Ensure Maps libraries have com.google.maps group IDs
run: |
for POM in $(find java-maps-* -name 'pom.xml'); do
group_id=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.groupId}' \
--projects $POM 2>/dev/null )
echo "${group_id}" |grep -q com.google.maps
# 0 if match; otherwise 1
match=$?
if [ "${match}" == "1" ]; then
echo "Unexpected group ID '${group_id}' found in ${POM}"
exit 1
fi
echo "Passed ${POM}"
done
echo "All group IDs start with com.google.maps. Good."
package_name_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ensure no new invalid package name in Java files
shell: bash
run: |
# grep returns "1" (error) when no output
set +e
echo "Finding files matching '*main/java/google/*.java'"
# In past, we published Java classes with wrong package names (google.)
# due to improper java_package field in proto files (https://protobuf.dev/programming-guides/proto3/#options).
# This check excludes these existing files.
# java/com/google : This is the standard package
# samples : Samples are not shipped as a library
# grafeas : java-grafeas is known to have special package name
# cloud-build v2 : java_package was not configured when we published
# the Cloud Build V2 client library
# the rest : the same as above
invalid_files=$(find . -name '*.java' \
|grep --invert-match 'java/com/google' \
|grep --invert-match samples \
|grep --invert-match grafeas \
|grep --invert-match 'cloud-build.*v2' \
|grep --invert-match 'google/monitoring/v3/DroppedLabelsOuterClass.java' \
|grep --invert-match 'google/cloud/policytroubleshooter/v1/Explanations.java')
if [ -n "${invalid_files}" ]; then
echo "New invalid package name found. Check the files: ${invalid_files}"
exit 1
fi
echo "No new invalid package names in Java files"