Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions images/build-e2e/lib/linux/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ cd $targetFolder/bin
cd ..
init_line=$(grep -n '<?xml version="1.0" encoding="UTF-8"?>' results/e2e.results | awk '{split($0,n,":"); print n[1]}')
if ! command -v xsltproc &>/dev/null
then
sudo yum install -y xsltproc || echo "Warning: Failed to install xsltproc"
then
sudo yum install -y xsltproc || sudo yum install -y --nogpgcheck xsltproc || echo "Warning: Failed to install xsltproc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we want to have a non signed package installed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are waiting for pre release RHEL to confirm if recent non signed packages is a mistake.

This is just a workaround, but probably we will refuse this change

fi
Comment on lines +66 to +68
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Install the correct package; avoid sudo hangs; gate --nogpgcheck behind an opt‑in.

On RHEL, the xsltproc binary is provided by the libxslt package. yum install xsltproc commonly fails with “No match”. Also, sudo may not exist or can hang awaiting a TTY. Finally, installing with --nogpgcheck should be opt‑in to reduce supply‑chain risk.

Apply this diff to harden installation:

-then
-  sudo yum install -y xsltproc || sudo yum install -y --nogpgcheck xsltproc || echo "Warning: Failed to install xsltproc"
-fi
+then
+  # Choose package manager
+  PM=""
+  if command -v dnf &>/dev/null; then PM="dnf"; elif command -v yum &>/dev/null; then PM="yum"; fi
+  # Prefer running without sudo if already root; use non‑interactive sudo if available
+  SUDO=""
+  if [ "$EUID" -ne 0 ] && command -v sudo &>/dev/null; then SUDO="sudo -n"; fi
+  if [ -n "$PM" ]; then
+    # xsltproc is provided by libxslt on RHEL/Fedora
+    if ! $SUDO $PM -y install libxslt; then
+      if [ "${CRC_ALLOW_UNSIGNED:=}" = "1" ]; then
+        $SUDO $PM -y --nogpgcheck install libxslt || echo "Warning: Failed to install libxslt/xsltproc." >&2
+      else
+        echo "Warning: xsltproc missing and unsigned packages not allowed (set CRC_ALLOW_UNSIGNED=1 to allow pre-release unsigned install)." >&2
+      fi
+    fi
+  else
+    echo "Warning: No supported package manager found to install xsltproc." >&2
+  fi
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
then
sudo yum install -y xsltproc || sudo yum install -y --nogpgcheck xsltproc || echo "Warning: Failed to install xsltproc"
fi
then
# Choose package manager
PM=""
if command -v dnf &>/dev/null; then PM="dnf"; elif command -v yum &>/dev/null; then PM="yum"; fi
# Prefer running without sudo if already root; use non‑interactive sudo if available
SUDO=""
if [ "$EUID" -ne 0 ] && command -v sudo &>/dev/null; then SUDO="sudo -n"; fi
if [ -n "$PM" ]; then
# xsltproc is provided by libxslt on RHEL/Fedora
if ! $SUDO $PM -y install libxslt; then
if [ "${CRC_ALLOW_UNSIGNED:=}" = "1" ]; then
$SUDO $PM -y --nogpgcheck install libxslt || echo "Warning: Failed to install libxslt/xsltproc." >&2
else
echo "Warning: xsltproc missing and unsigned packages not allowed (set CRC_ALLOW_UNSIGNED=1 to allow pre-release unsigned install)." >&2
fi
fi
else
echo "Warning: No supported package manager found to install xsltproc." >&2
fi
fi


if command -v xsltproc &>/dev/null
then
tail -n +$init_line results/e2e.results | xsltproc filter.xsl - > results/$junitFilename
else
tail -n +$init_line results/e2e.results > results/$junitFilename
fi
Comment on lines +70 to 75
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Emit valid JUnit XML when xsltproc is unavailable.

Writing a raw tail into an .xml file produces invalid JUnit and can break report consumers. Generate a minimal, valid JUnit report embedding raw output in a failure message.

-if command -v xsltproc &>/dev/null
-then
-  tail -n +$init_line results/e2e.results | xsltproc filter.xsl - > results/$junitFilename
-else
-  tail -n +$init_line results/e2e.results > results/$junitFilename
-fi
+if command -v xsltproc &>/dev/null
+then
+  tail -n +${init_line:-1} "results/e2e.results" | xsltproc "filter.xsl" - > "results/$junitFilename"
+else
+  {
+    echo '<?xml version="1.0" encoding="UTF-8"?>'
+    echo '<testsuite name="crc-e2e" tests="1" failures="1">'
+    echo '  <testcase classname="crc.e2e" name="xsltproc-missing">'
+    echo '    <failure message="xsltproc not available; emitting raw results">'
+    echo '<![CDATA['
+    tail -n +${init_line:-1} "results/e2e.results"
+    echo ']]>'
+    echo '    </failure>'
+    echo '  </testcase>'
+    echo '</testsuite>'
+  } > "results/$junitFilename"
+fi
🤖 Prompt for AI Agents
In images/build-e2e/lib/linux/run.sh around lines 70 to 75, when xsltproc is
missing the script currently writes raw tail output to results/$junitFilename
which is not valid JUnit XML; instead capture the tail output into a variable or
temp file, ensure results/ exists, and write a minimal valid JUnit XML file that
wraps the raw output (escaped or inside a CDATA) as the failure message—e.g.,
create a testsuite with tests="1" failures="1" and a single testcase whose
<failure> element contains the raw log, then write that XML to
results/$junitFilename so report consumers receive valid JUnit even without
xsltproc.

tail -n +$init_line results/e2e.results | xsltproc filter.xsl - > results/$junitFilename

# Copy logs and diagnose
cp -r bin/out/test-results/* results
Loading