ci: Provide the logs as artifacts

If something goes wrong, it's good to have a way to see where it failed,
so let's provide the logs as artifacts.

While we're at it, also dump /proc/cpuinfo in the Fedora KVM job
as this might contain valuable information about the KVM environment.

Message-Id: <20230403093255.45104-1-thuth@redhat.com>
Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a999f64..c1defd0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,7 +4,20 @@
  - dnf update -y
  - dnf install -y make python
 
+.intree_template:
+ artifacts:
+  expire_in: 2 days
+  paths:
+   - logs
+
+.outoftree_template:
+ artifacts:
+  expire_in: 2 days
+  paths:
+   - build/logs
+
 build-aarch64:
+ extends: .intree_template
  script:
  - dnf install -y qemu-system-aarch64 gcc-aarch64-linux-gnu
  - ./configure --arch=aarch64 --cross-prefix=aarch64-linux-gnu-
@@ -35,6 +48,7 @@
  - if grep -q FAIL results.txt ; then exit 1 ; fi
 
 build-arm:
+ extends: .outoftree_template
  script:
  - dnf install -y qemu-system-arm gcc-arm-linux-gnu
  - mkdir build
@@ -49,6 +63,7 @@
  - if grep -q FAIL results.txt ; then exit 1 ; fi
 
 build-ppc64be:
+ extends: .outoftree_template
  script:
  - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu
  - mkdir build
@@ -62,6 +77,7 @@
  - if grep -q FAIL results.txt ; then exit 1 ; fi
 
 build-ppc64le:
+ extends: .intree_template
  script:
  - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu
  - ./configure --arch=ppc64 --endian=little --cross-prefix=powerpc64-linux-gnu-
@@ -73,6 +89,7 @@
  - if grep -q FAIL results.txt ; then exit 1 ; fi
 
 build-s390x:
+ extends: .outoftree_template
  script:
  - dnf install -y qemu-system-s390x gcc-s390x-linux-gnu
  - mkdir build
@@ -109,6 +126,7 @@
  - if grep -q FAIL results.txt ; then exit 1 ; fi
 
 build-x86_64:
+ extends: .intree_template
  script:
  - dnf install -y qemu-system-x86 gcc
  - ./configure --arch=x86_64
@@ -147,6 +165,7 @@
  - if grep -q FAIL results.txt ; then exit 1 ; fi
 
 build-i386:
+ extends: .outoftree_template
  script:
  - dnf install -y qemu-system-x86 gcc
  - mkdir build
@@ -180,6 +199,7 @@
  - if grep -q FAIL results.txt ; then exit 1 ; fi
 
 build-clang:
+ extends: .intree_template
  script:
  - dnf install -y qemu-system-x86 clang
  - ./configure --arch=x86_64 --cc=clang
@@ -218,6 +238,7 @@
  - grep -q PASS results.txt && ! grep -q FAIL results.txt
 
 build-centos7:
+ extends: .outoftree_template
  image: centos:7
  before_script:
  - yum update -y
@@ -266,6 +287,7 @@
  <<: *cirrus_build_job_definition
 
 s390x-kvm:
+ extends: .intree_template
  before_script: []
  tags:
   - s390x-z15-vm
diff --git a/ci/cirrus-ci-fedora.yml b/ci/cirrus-ci-fedora.yml
index d6070f7..918c9a3 100644
--- a/ci/cirrus-ci-fedora.yml
+++ b/ci/cirrus-ci-fedora.yml
@@ -13,6 +13,8 @@
     - git fetch origin "@CI_COMMIT_REF_NAME@"
     - git reset --hard "@CI_COMMIT_SHA@"
   script:
+    - uname -r
+    - sed -n "/processor.*:.0/,/^$/p" /proc/cpuinfo
     - mkdir build
     - cd build
     - ../configure
@@ -70,3 +72,7 @@
         xsave
         | tee results.txt
     - grep -q PASS results.txt && ! grep -q FAIL results.txt
+  on_failure:
+    log_artifacts:
+      path: build/logs/*.log
+      type: text/plain
diff --git a/ci/cirrus-ci-macos-i386.yml b/ci/cirrus-ci-macos-i386.yml
index ed580e6..45d1b71 100644
--- a/ci/cirrus-ci-macos-i386.yml
+++ b/ci/cirrus-ci-macos-i386.yml
@@ -35,3 +35,7 @@
          vmexit_tscdeadline_immed
          | tee results.txt
     - grep -q PASS results.txt && ! grep -q FAIL results.txt
+  on_failure:
+    log_artifacts:
+      path: build/logs/*.log
+      type: text/plain
diff --git a/ci/cirrus-ci-macos-x86-64.yml b/ci/cirrus-ci-macos-x86-64.yml
index 861caa1..8ee6fb7 100644
--- a/ci/cirrus-ci-macos-x86-64.yml
+++ b/ci/cirrus-ci-macos-x86-64.yml
@@ -39,3 +39,7 @@
          vmexit_tscdeadline_immed
          | tee results.txt
     - grep -q PASS results.txt && ! grep -q FAIL results.txt
+  on_failure:
+    log_artifacts:
+      path: build/logs/*.log
+      type: text/plain