Skip to contentSkip to conversation

CI: re-work / extend artifacts collection

PATCH In review Jan Beulich 2 participants 5 messages May 11 – May 12

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/2 CI: re-work Xen artifacts collection

There's no need to do this separately from three places. Once moved to the bottom of the script, the need for this to be a function also disappears.

While there also make sure xen-syms is collected. This is rather more useful for analysis of possible problems than its stripped counterpart.

automation/scripts/build +11 -19
@@ -44,30 +44,15 @@ cp xen/.config xen-config
 # Directory for the artefacts to be dumped into
 mkdir -p binaries
 
-collect_xen_artefacts()
-{
-    local f
-
-    for f in xen/xen xen/xen.efi; do
-        if [[ -f $f ]]; then
-            cp $f binaries/
-        fi
-    done
-}
-
 if [[ "${CPPCHECK}" == "y" ]] && [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
     # Cppcheck analysis invokes Xen-only build
     xen/scripts/xen-analysis.py --run-cppcheck --cppcheck-misra -- -j$(nproc)
 
     # Preserve artefacts
-    collect_xen_artefacts
     cp xen/cppcheck-report/xen-cppcheck.txt xen-cppcheck.txt
 elif [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
     # Xen-only build
     make -j$(nproc) xen
-
-    # Preserve artefacts
-    collect_xen_artefacts
 else
     # Full build.  Figure out our ./configure options
     cfgargs=("--prefix=/usr")
@@ -108,9 +93,16 @@ else
     make -j$(nproc) dist
 
     # Preserve artefacts
-    # Note: Some smoke tests depending on finding binaries/xen on a full build
-    # even though dist/ contains everything, while some containers don't even
-    # build Xen
     (cd dist/install; find | cpio -R 0:0 -o -H newc | gzip) > binaries/xen-tools.cpio.gz
-    collect_xen_artefacts
 fi
+
+# Preserve Xen artefacts
+#
+# Note: Some smoke tests depend on finding binaries/xen on a full build
+# even though dist/ contains everything, while some containers don't even
+# build Xen.
+for f in xen/xen xen/xen-syms xen/xen.efi; do
+    if [[ -f $f ]]; then
+        cp $f binaries/
+    fi
+done
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] CI: re-work Xen artifacts collection

Quoted 7 lines · Jan Beulich

There's no need to do this separately from three places. Once moved to the bottom of the script, the need for this to be a function also disappears.

While there also make sure xen-syms is collected. This is rather more useful for analysis of possible problems than its stripped counterpart.

Quoted 55 lines
automation/scripts/build +11 -19
@@ -44,30 +44,15 @@ cp xen/.config xen-config
 # Directory for the artefacts to be dumped into
 mkdir -p binaries
 
-collect_xen_artefacts()
-{
-    local f
-
-    for f in xen/xen xen/xen.efi; do
-        if [[ -f $f ]]; then
-            cp $f binaries/
-        fi
-    done
-}
-
 if [[ "${CPPCHECK}" == "y" ]] && [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
     # Cppcheck analysis invokes Xen-only build
     xen/scripts/xen-analysis.py --run-cppcheck --cppcheck-misra -- -j$(nproc)
 
     # Preserve artefacts
-    collect_xen_artefacts
     cp xen/cppcheck-report/xen-cppcheck.txt xen-cppcheck.txt
 elif [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
     # Xen-only build
     make -j$(nproc) xen
-
-    # Preserve artefacts
-    collect_xen_artefacts
 else
     # Full build.  Figure out our ./configure options
     cfgargs=("--prefix=/usr")
@@ -108,9 +93,16 @@ else
     make -j$(nproc) dist
 
     # Preserve artefacts
-    # Note: Some smoke tests depending on finding binaries/xen on a full build
-    # even though dist/ contains everything, while some containers don't even
-    # build Xen
     (cd dist/install; find | cpio -R 0:0 -o -H newc | gzip) > binaries/xen-tools.cpio.gz
-    collect_xen_artefacts
 fi
+
+# Preserve Xen artefacts
+#
+# Note: Some smoke tests depend on finding binaries/xen on a full build
+# even though dist/ contains everything, while some containers don't even
+# build Xen.
+for f in xen/xen xen/xen-syms xen/xen.efi; do
+    if [[ -f $f ]]; then
+        cp $f binaries/
+    fi
+done
#3 lore raw

PATCH v2 2/2 CI: collect certain intermediate files as artifacts

In reply to Jan Beulich

When one of the linking passes fails, additional intermediate files are still in place. Having them available for analysis of the underlying problem can be pretty helpful. Collect some into a new intermediates/ directory. (Nothing new will be collected if linking succeeds.)

As the script is run with -e passed to bash, defer exit if the main "make" (or substituent script thereof) failed. This way more artifacts are collected, potentially making it easier to analyze the failure.

---
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2515787945
(with PPC forced to invoke the new logic, hence respective failures there)
---
v2: Different approach.

automation/gitlab-ci/build.yaml +1 -0
@@ -6,6 +6,7 @@
   artifacts:
     paths:
       - binaries/
+      - intermediates/
       - xen-config
       - xen-cppcheck.txt
       - '*.log'
automation/scripts/build +18 -7
@@ -37,22 +37,24 @@ else
     make -j$(nproc) -C xen olddefconfig
 fi
 
-# Save the config file before building because build failure causes the script
-# to exit early -- bash is invoked with -e.
+# Save the config file before building, just in case.
 cp xen/.config xen-config
 
-# Directory for the artefacts to be dumped into
-mkdir -p binaries
+# Directories for artefacts to be dumped into
+mkdir -p binaries intermediates
+
+# Script exit status, to be overridden by the main make's status below.
+ret=0
 
 if [[ "${CPPCHECK}" == "y" ]] && [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
     # Cppcheck analysis invokes Xen-only build
-    xen/scripts/xen-analysis.py --run-cppcheck --cppcheck-misra -- -j$(nproc)
+    xen/scripts/xen-analysis.py --run-cppcheck --cppcheck-misra -- -j$(nproc) || ret=$?
 
     # Preserve artefacts
     cp xen/cppcheck-report/xen-cppcheck.txt xen-cppcheck.txt
 elif [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
     # Xen-only build
-    make -j$(nproc) xen
+    make -j$(nproc) xen || ret=$?
 else
     # Full build.  Figure out our ./configure options
     cfgargs=("--prefix=/usr")
@@ -90,7 +92,7 @@ else
     fi
 
     ./configure "${cfgargs[@]}"
-    make -j$(nproc) dist
+    make -j$(nproc) dist || ret=$?
 
     # Preserve artefacts
     (cd dist/install; find | cpio -R 0:0 -o -H newc | gzip) > binaries/xen-tools.cpio.gz
@@ -106,3 +108,12 @@ for f in xen/xen xen/xen-syms xen/xen.ef
         cp $f binaries/
     fi
 done
+
+# Preserve Xen intermediate files.  Some may be there only upon build failure.
+for f in xen/.xen-syms.* xen/.xen.efi.*; do
+    if [[ -f $f ]]; then
+        cp $f intermediates/
+    fi
+done
+
+exit $ret
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] CI: collect certain intermediate files as artifacts

Quoted 10 lines · Jan Beulich

When one of the linking passes fails, additional intermediate files are still in place. Having them available for analysis of the underlying problem can be pretty helpful. Collect some into a new intermediates/ directory. (Nothing new will be collected if linking succeeds.)

As the script is run with -e passed to bash, defer exit if the main "make" (or substituent script thereof) failed. This way more artifacts are collected, potentially making it easier to analyze the failure.

Quoted 72 lines

---
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2515787945
(with PPC forced to invoke the new logic, hence respective failures there)
---
v2: Different approach.

automation/gitlab-ci/build.yaml +1 -0
@@ -6,6 +6,7 @@
   artifacts:
     paths:
       - binaries/
+      - intermediates/
       - xen-config
       - xen-cppcheck.txt
       - '*.log'
automation/scripts/build +18 -7
@@ -37,22 +37,24 @@ else
     make -j$(nproc) -C xen olddefconfig
 fi
 
-# Save the config file before building because build failure causes the script
-# to exit early -- bash is invoked with -e.
+# Save the config file before building, just in case.
 cp xen/.config xen-config
 
-# Directory for the artefacts to be dumped into
-mkdir -p binaries
+# Directories for artefacts to be dumped into
+mkdir -p binaries intermediates
+
+# Script exit status, to be overridden by the main make's status below.
+ret=0
 
 if [[ "${CPPCHECK}" == "y" ]] && [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
     # Cppcheck analysis invokes Xen-only build
-    xen/scripts/xen-analysis.py --run-cppcheck --cppcheck-misra -- -j$(nproc)
+    xen/scripts/xen-analysis.py --run-cppcheck --cppcheck-misra -- -j$(nproc) || ret=$?
 
     # Preserve artefacts
     cp xen/cppcheck-report/xen-cppcheck.txt xen-cppcheck.txt
 elif [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
     # Xen-only build
-    make -j$(nproc) xen
+    make -j$(nproc) xen || ret=$?
 else
     # Full build.  Figure out our ./configure options
     cfgargs=("--prefix=/usr")
@@ -90,7 +92,7 @@ else
     fi
 
     ./configure "${cfgargs[@]}"
-    make -j$(nproc) dist
+    make -j$(nproc) dist || ret=$?
 
     # Preserve artefacts
     (cd dist/install; find | cpio -R 0:0 -o -H newc | gzip) > binaries/xen-tools.cpio.gz
@@ -106,3 +108,12 @@ for f in xen/xen xen/xen-syms xen/xen.ef
         cp $f binaries/
     fi
 done
+
+# Preserve Xen intermediate files.  Some may be there only upon build failure.
+for f in xen/.xen-syms.* xen/.xen.efi.*; do
+    if [[ -f $f ]]; then
+        cp $f intermediates/
+    fi
+done
+
+exit $ret