Commit 3fbac8fc83 for qemu.org

commit 3fbac8fc83ed1c73c968fd5f068acf1c840c369e
Author: Daniel P. Berrangé <berrange@redhat.com>
Date:   Wed Jun 24 13:46:56 2026 +0100

    gitlab: pull before_script logic into .base_meson_job_template

    This ensures that all jobs have the $JOBS env set and capture the
    packages.txt content (where available) in their logs, and all use
    the job section headers.

    Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
    Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
    Link: https://lore.kernel.org/qemu-devel/20260624124657.2725376-6-berrange@redhat.com
    Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>

diff --git a/.gitlab-ci.d/base.yml b/.gitlab-ci.d/base.yml
index 366e654bcb..fa0ca94048 100644
--- a/.gitlab-ci.d/base.yml
+++ b/.gitlab-ci.d/base.yml
@@ -148,6 +148,15 @@ variables:
       - build/meson-logs
     reports:
       junit: build/meson-logs/*.junit.xml
+  before_script:
+    - source scripts/ci/gitlab-ci-section
+    - section_start setup "Pre-script setup"
+    - JOBS=$(expr $(nproc) + 1)
+    # Prevent logs (if any) from prior build job artifacts
+    # from being duplicated in the new job artifacts
+    - rm -f build/meson-logs/*
+    - test -f /packages.txt && cat /packages.txt
+    - section_end setup

 .base_meson_ccache_job_template:
   extends: .base_meson_job_template
diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml
index 8dfd17a0b5..11d7a75667 100644
--- a/.gitlab-ci.d/buildtest-template.yml
+++ b/.gitlab-ci.d/buildtest-template.yml
@@ -3,12 +3,6 @@
   extends: .base_meson_ccache_job_template
   stage: build
   image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
-  before_script:
-    - source scripts/ci/gitlab-ci-section
-    - section_start setup "Pre-script setup"
-    - JOBS=$(expr $(nproc) + 1)
-    - cat /packages.txt
-    - section_end setup
   script:
     - !reference [.base_meson_ccache_job_template, script]
     - du -sh .git
@@ -74,11 +68,6 @@

 .native_test_job_template:
   extends: .common_test_job_template
-  before_script:
-    # Prevent logs from the build job that run earlier
-    # from being duplicated in the test job artifacts
-    - rm -f build/meson-logs/*
-

 .functional_test_job_template:
   extends: .common_test_job_template
@@ -96,27 +85,18 @@
       - build/tests/functional/*/*/*.log
     reports:
       junit: build/meson-logs/*.junit.xml
-  before_script:
-    - export QEMU_TEST_ALLOW_UNTRUSTED_CODE=1
-    - export QEMU_TEST_CACHE_DIR=${CI_PROJECT_DIR}/functional-cache
-    # Prevent logs from the build job that run earlier
-    # from being duplicated in the test job artifacts
-    - rm -f build/meson-logs/*
   after_script:
     - cd build
     - du -chs ${CI_PROJECT_DIR}/*-cache
   variables:
     QEMU_JOB_FUNCTIONAL: 1
+    QEMU_TEST_ALLOW_UNTRUSTED_CODE: 1
+    QEMU_TEST_CACHE_DIR: ${CI_PROJECT_DIR}/functional-cache

 .wasm_build_job_template:
   extends: .base_meson_job_template
   stage: build
   image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
-  before_script:
-    - source scripts/ci/gitlab-ci-section
-    - section_start setup "Pre-script setup"
-    - JOBS=$(expr $(nproc) + 1)
-    - section_end setup
   script:
     - du -sh .git
     - mkdir build
diff --git a/.gitlab-ci.d/crossbuild-template.yml b/.gitlab-ci.d/crossbuild-template.yml
index aadae26844..94423814a7 100644
--- a/.gitlab-ci.d/crossbuild-template.yml
+++ b/.gitlab-ci.d/crossbuild-template.yml
@@ -3,12 +3,6 @@
   stage: build
   image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
   timeout: 80m
-  before_script:
-    - source scripts/ci/gitlab-ci-section
-    - section_start setup "Pre-script setup"
-    - JOBS=$(expr $(nproc) + 1)
-    - cat /packages.txt
-    - section_end setup
   script:
     - !reference [.base_meson_ccache_job_template, script]
     - mkdir build
@@ -48,9 +42,6 @@
   stage: build
   image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
   timeout: 60m
-  before_script:
-    - source scripts/ci/gitlab-ci-section
-    - JOBS=$(expr $(nproc) + 1)
   script:
     - !reference [.base_meson_ccache_job_template, script]
     - mkdir build
@@ -73,9 +64,6 @@
   extends: .base_meson_ccache_job_template
   stage: build
   image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
-  before_script:
-    - source scripts/ci/gitlab-ci-section
-    - JOBS=$(expr $(nproc) + 1)
   script:
     - !reference [.base_meson_ccache_job_template, script]
     - mkdir build