Skip to content

Commit b2fbe03

Browse files
authored
fix(build): update surefire report processing to handle time format (#2962)
* fix(build): update surefire report processing to handle time format and skip on errors Modify sed command to properly handle time format in test reports and add skipSurefireReport configuration to prevent build failures when encountering parsing issues * check import jsonschema * use python * use python3 * disable cache * fixed the dockerfile
1 parent e44aaad commit b2fbe03

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

plugins/core-plugin/src/main/resources/Dockerfile-template-yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ COPY --from=python-base /root/.apache_beam/cache /root/.apache_beam/cache
8181
# Copy licenses
8282
COPY --from=python-base /usr/licenses/ /usr/licenses/
8383

84+
# Test jsonschema
85+
RUN python -c "import jsonschema"
86+
8487
WORKDIR /template
8588

8689
ENTRYPOINT ${entryPoint}

plugins/templates-maven-plugin/src/main/java/com/google/cloud/teleport/plugin/maven/TemplatesStageMojo.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ private void stageYamlUsingDockerfile(
10851085

10861086
File cloudbuildFile = File.createTempFile("cloudbuild", ".yaml");
10871087
try (FileWriter writer = new FileWriter(cloudbuildFile)) {
1088-
String cacheFolder = imagePathTag.substring(0, imagePathTag.lastIndexOf('/')) + "/cache";
1088+
// String cacheFolder = imagePathTag.substring(0, imagePathTag.lastIndexOf('/')) + "/cache";
10891089
String tarPath = "/workspace/" + yamlTemplateName + ".tar\n";
10901090
writer.write(
10911091
"steps:\n"
@@ -1097,12 +1097,12 @@ private void stageYamlUsingDockerfile(
10971097
+ " - --dockerfile="
10981098
+ dockerfile
10991099
+ "\n"
1100-
+ " - --cache=true\n"
1101-
+ " - --cache-ttl=6h\n"
1102-
+ " - --compressed-caching=false\n"
1103-
+ " - --cache-copy-layers=true\n"
1104-
+ " - --cache-repo="
1105-
+ cacheFolder
1100+
// + " - --cache=true\n"
1101+
// + " - --cache-ttl=6h\n"
1102+
// + " - --compressed-caching=false\n"
1103+
// + " - --cache-copy-layers=true\n"
1104+
// + " - --cache-repo="
1105+
// + cacheFolder
11061106
+ (generateSBOM
11071107
? "\n"
11081108
+ " - --no-push\n"
@@ -1159,7 +1159,7 @@ private void stagePythonUsingDockerfile(
11591159

11601160
File cloudbuildFile = File.createTempFile("cloudbuild", ".yaml");
11611161
try (FileWriter writer = new FileWriter(cloudbuildFile)) {
1162-
String cacheFolder = imagePathTag.substring(0, imagePathTag.lastIndexOf('/')) + "/cache";
1162+
// String cacheFolder = imagePathTag.substring(0, imagePathTag.lastIndexOf('/')) + "/cache";
11631163
String tarPath = "/workspace/" + containerName + ".tar\n";
11641164
writer.write(
11651165
"steps:\n"
@@ -1168,12 +1168,12 @@ private void stagePythonUsingDockerfile(
11681168
+ " - --destination="
11691169
+ imagePathTag
11701170
+ "\n"
1171-
+ " - --cache=true\n"
1172-
+ " - --cache-ttl=6h\n"
1173-
+ " - --compressed-caching=false\n"
1174-
+ " - --cache-copy-layers=true\n"
1175-
+ " - --cache-repo="
1176-
+ cacheFolder
1171+
// + " - --cache=true\n"
1172+
// + " - --cache-ttl=6h\n"
1173+
// + " - --compressed-caching=false\n"
1174+
// + " - --cache-copy-layers=true\n"
1175+
// + " - --cache-repo="
1176+
// + cacheFolder
11771177
+ (generateSBOM
11781178
? "\n"
11791179
+ " - --no-push\n"
@@ -1310,7 +1310,7 @@ private void stageXlangUsingDockerfile(
13101310
File cloudbuildFile = File.createTempFile("cloudbuild", ".yaml");
13111311
String tarPath = "/workspace/" + containerName + ".tar\n";
13121312
try (FileWriter writer = new FileWriter(cloudbuildFile)) {
1313-
String cacheFolder = imagePathTag.substring(0, imagePathTag.lastIndexOf('/')) + "/cache";
1313+
// String cacheFolder = imagePathTag.substring(0, imagePathTag.lastIndexOf('/')) + "/cache";
13141314
writer.write(
13151315
"steps:\n"
13161316
+ "- name: gcr.io/kaniko-project/executor\n"
@@ -1321,12 +1321,12 @@ private void stageXlangUsingDockerfile(
13211321
+ " - --dockerfile="
13221322
+ dockerfile
13231323
+ "\n"
1324-
+ " - --cache=true\n"
1325-
+ " - --cache-ttl=6h\n"
1326-
+ " - --compressed-caching=false\n"
1327-
+ " - --cache-copy-layers=true\n"
1328-
+ " - --cache-repo="
1329-
+ cacheFolder
1324+
// + " - --cache=true\n"
1325+
// + " - --cache-ttl=6h\n"
1326+
// + " - --compressed-caching=false\n"
1327+
// + " - --cache-copy-layers=true\n"
1328+
// + " - --cache-repo="
1329+
// + cacheFolder
13301330
+ (generateSBOM
13311331
? "\n"
13321332
+ " - --no-push\n"

pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@
531531
<executable>bash</executable>
532532
<arguments>
533533
<argument>-c</argument>
534-
<argument>find . -name "TEST-*.xml" -path "*/target/surefire-reports/*" -exec sed -i.bak 's/time="\([0-9]*\),\([0-9]*\.*[0-9]*\)"/time="\1\2"/g' {} \;</argument>
534+
<argument>find . -name "TEST-*.xml" -path "*/target/surefire-reports/*" -exec sed -E -i.bak -e ':a' -e 's/(time="[^\"]*),/\1/g' -e 'ta' {} \; || true</argument>
535535
</arguments>
536536
</configuration>
537537
</execution>
@@ -559,6 +559,10 @@
559559
<goals>
560560
<goal>report-only</goal>
561561
</goals>
562+
<configuration>
563+
<!-- If report generation encounters parsing issues, skip to avoid failing the build -->
564+
<skipSurefireReport>true</skipSurefireReport>
565+
</configuration>
562566
</execution>
563567
</executions>
564568
</plugin>

0 commit comments

Comments
 (0)