Skip to content

Commit ac1082e

Browse files
committed
chore(migration): support root centralized custom conformance migration
1 parent e0a10d8 commit ac1082e

2 files changed

Lines changed: 54 additions & 11 deletions

File tree

monorepo-migration/migrate.sh

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,64 @@ EOF
220220
COMMIT_COUNT=$((COMMIT_COUNT + 1))
221221
fi
222222

223-
# 6.4c Migrate Integration presubmit config if present
224-
if [ -f "$SOURCE_REPO_NAME/.kokoro/presubmit/integration.cfg" ]; then
225-
echo "Migrating integration.cfg to monorepo root .kokoro/presubmit/${SOURCE_REPO_NAME#java-}-integration.cfg..."
223+
# 6.4c Migrate Integration presubmit configurations if present
224+
if ls "$SOURCE_REPO_NAME/.kokoro/presubmit/integration"*.cfg >/dev/null 2>&1; then
226225
mkdir -p .kokoro/presubmit
227-
sed -e 's/value: "integration"/value: "integration-single"/' \
228-
-e 's/java8/java11/' \
229-
"$SOURCE_REPO_NAME/.kokoro/presubmit/integration.cfg" > ".kokoro/presubmit/${SOURCE_REPO_NAME#java-}-integration.cfg"
230-
231-
# Append BUILD_SUBDIR
232-
cat <<EOF >> ".kokoro/presubmit/${SOURCE_REPO_NAME#java-}-integration.cfg"
226+
for cfg_file in "$SOURCE_REPO_NAME/.kokoro/presubmit/integration"*.cfg; do
227+
if [ -f "$cfg_file" ]; then
228+
filename=$(basename "$cfg_file")
229+
new_filename="${filename/integration/${SOURCE_REPO_NAME#java-}-integration}"
230+
target_cfg=".kokoro/presubmit/${new_filename}"
231+
232+
echo "Migrating and adapting $filename to $target_cfg..."
233+
sed -e 's/value: "integration"/value: "integration-single"/' \
234+
-e 's/java8/java11/' \
235+
"$cfg_file" > "$target_cfg"
236+
237+
# Append BUILD_SUBDIR
238+
cat <<EOF >> "$target_cfg"
233239
234240
env_vars: {
235241
key: "BUILD_SUBDIR"
236242
value: "${SOURCE_REPO_NAME}"
237243
}
238244
EOF
239-
git add ".kokoro/presubmit/${SOURCE_REPO_NAME#java-}-integration.cfg"
240-
git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): migrate Integration presubmit config"
245+
git add "$target_cfg"
246+
fi
247+
done
248+
git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): migrate Integration presubmit configurations"
249+
COMMIT_COUNT=$((COMMIT_COUNT + 1))
250+
fi
251+
252+
# 6.4c(2) Migrate custom conformance execution script if present
253+
if [ -f "$SOURCE_REPO_NAME/.kokoro/conformance.sh" ]; then
254+
echo "Migrating conformance.sh to monorepo root .kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh..."
255+
mkdir -p .kokoro
256+
cp "$SOURCE_REPO_NAME/.kokoro/conformance.sh" ".kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh"
257+
258+
echo "Adapting conformance script paths and build scopes for monorepo root..."
259+
PL_MODULES="${SOURCE_REPO_NAME}"
260+
if [ -n "${PRE_INSTALL_DEPS}" ]; then
261+
PL_MODULES="${PL_MODULES},${PRE_INSTALL_DEPS}"
262+
fi
263+
sed -i.bak "s|mvn install|mvn install -pl ${PL_MODULES} -am|" ".kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh"
264+
sed -i.bak "s|cd test-proxy|cd ${SOURCE_REPO_NAME}/test-proxy|" ".kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh"
265+
sed -i.bak "s|-jar test-proxy/target/|-jar ${SOURCE_REPO_NAME}/test-proxy/target/|" ".kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh"
266+
sed -i.bak "s|kill \${proxyPID}|kill \${proxyPID} \&\& sleep 5|" ".kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh"
267+
sed -i.bak "s|../../test-proxy/known_failures.txt|../../\${SOURCE_REPO_NAME}/test-proxy/known_failures.txt|" ".kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh"
268+
rm -f ".kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh.bak"
269+
270+
if [ -f "${SOURCE_REPO_NAME}/test-proxy/pom.xml" ]; then
271+
echo "Fixing protoc-gen-grpc-java version in test-proxy/pom.xml for Apple Silicon (osx-aarch_64) support..."
272+
sed -i.bak "s|1.24.0:exe:\${os.detected.classifier}|1.62.2:exe:\${os.detected.classifier}|" "${SOURCE_REPO_NAME}/test-proxy/pom.xml"
273+
rm -f "${SOURCE_REPO_NAME}/test-proxy/pom.xml.bak"
274+
git add "${SOURCE_REPO_NAME}/test-proxy/pom.xml"
275+
git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): fix protoc-gen-grpc-java version for Apple Silicon support"
276+
COMMIT_COUNT=$((COMMIT_COUNT + 1))
277+
fi
278+
279+
git add ".kokoro/${SOURCE_REPO_NAME#java-}-conformance.sh"
280+
git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): migrate and adapt conformance execution script"
241281
COMMIT_COUNT=$((COMMIT_COUNT + 1))
242282
fi
243283

monorepo-migration/transform_workflow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ def transform(content, lib_name):
128128
line = line.replace('" >> $GITHUB_ENV', ' -P !java17" >> $GITHUB_ENV')
129129
if 'build.bat' in line:
130130
line = line.replace('build.bat', 'build.sh')
131+
if '.kokoro/conformance.sh' in line:
132+
short_name = lib_name.replace('java-', '')
133+
line = line.replace('.kokoro/conformance.sh', f'.kokoro/{short_name}-conformance.sh')
131134

132135
new_lines.append(line)
133136
return "\n".join(new_lines)

0 commit comments

Comments
 (0)