ci/lava: Use init-stage1 from Mesa build instead of inlining it

We can use the init-stage1 script from the Mesa build artifacts instead of
keeping a copy in the lava-trigger container and inlining it into the
LAVA job definition.

v2 (Guilherme)
* Source the `init-stage1.sh` file instead of executing it
* Avoid hardcoding the run_steps asserts, check only the core parts

Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
Co-authored-by: Guilherme Gallo <guilherme.gallo@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36549>
This commit is contained in:
Valentine Burley 2025-08-01 11:39:27 +02:00 committed by Marge Bot
parent be15208cda
commit 9c49138b1a
11 changed files with 34 additions and 34 deletions

View file

@ -3,10 +3,6 @@
# Very early init, used to make sure devices and network are set up and
# reachable.
# When changing this file, you need to bump the following
# .gitlab-ci/image-tags.yml tags:
# ALPINE_X86_64_LAVA_TRIGGER_TAG
set -ex
cd /
@ -21,7 +17,14 @@ mkdir -p /dev/shm
findmnt --mountpoint /dev/shm || mount -t tmpfs -o noexec,nodev,nosuid tmpfs /dev/shm
findmnt --mountpoint /tmp || mount -t tmpfs tmpfs /tmp
echo "nameserver 8.8.8.8" > /etc/resolv.conf
# For the vmware farm, change the nameserver as 8.8.8.8 is off limit.
# This is temporary and will be reverted once the farm is moved.
if [ "${FARM:-}" = "vmware" ]; then
echo "nameserver 192.19.189.10" > /etc/resolv.conf
else
echo "nameserver 8.8.8.8" > /etc/resolv.conf
fi
[ -z "$NFS_SERVER_IP" ] || echo "$NFS_SERVER_IP caching-proxy" >> /etc/hosts
# Set the time so we can validate certificates before we fetch anything;

View file

@ -35,7 +35,6 @@ pip3 install --break-system-packages -r bin/ci/requirements-lava.txt
cp -Rp .gitlab-ci/lava /
cp -Rp .gitlab-ci/bin/structured_logger.py /lava
cp -Rp .gitlab-ci/common/init-stage1.sh /lava
. .gitlab-ci/container/container_pre_build.sh

View file

@ -30,7 +30,7 @@ variables:
ALPINE_X86_64_BUILD_TAG: "20250722-libwayland"
ALPINE_X86_64_LAVA_SSH_TAG: "20250423-rootfs"
ALPINE_X86_64_LAVA_TRIGGER_TAG: "20250804-logger"
ALPINE_X86_64_LAVA_TRIGGER_TAG: "20250804-init"
FEDORA_X86_64_BUILD_TAG: "20250722-libwayland"

View file

@ -126,7 +126,6 @@ PYTHONPATH=/ /lava/lava_job_submitter.py \
--rootfs-url "${ROOTFS_URL}" \
--kernel-url-prefix "${KERNEL_IMAGE_BASE}/${DEBIAN_ARCH}" \
--dtb-filename "${DTB}" \
--first-stage-init /lava/init-stage1.sh \
--env-file dut-env-vars.sh \
--jwt-file "${S3_JWT_FILE}" \
--kernel-image-name "${KERNEL_IMAGE_NAME}" \

View file

@ -407,7 +407,6 @@ class LAVAJobSubmitter(PathResolver):
shell_prompt: str = "lava-shell:"
dtb_filename: str = None
dump_yaml: bool = False # Whether to dump the YAML payload to stdout
first_stage_init: str = None
env_file: pathlib.Path = None
jwt_file: pathlib.Path = None
kernel_image_name: str = None

View file

@ -88,8 +88,8 @@ actions:
run:
steps:
- |-
echo test FASTBOOT
echo ZWNobyB0ZXN0IEZBU1RCT09U | base64 -d >> /set-job-env-vars.sh
FARM=test_farm . /test_dir/install/common/init-stage1.sh
echo RkFSTT10ZXN0X2Zhcm0gL3Rlc3RfZGlyL2luc3RhbGwvY29tbW9uL2luaXQtc3RhZ2UxLnNo | base64 -d >> /set-job-env-vars.sh
export CURRENT_SECTION=dut_boot
- export -p > /dut-env-vars.sh
- test:

View file

@ -84,8 +84,9 @@ actions:
format: Lava-Test Test Definition 1.0
run:
steps:
- echo test FASTBOOT
- echo ZWNobyB0ZXN0IEZBU1RCT09U | base64 -d >> /set-job-env-vars.sh
- FARM=test_farm . /test_dir/install/common/init-stage1.sh
- echo RkFSTT10ZXN0X2Zhcm0gL3Rlc3RfZGlyL2luc3RhbGwvY29tbW9uL2luaXQtc3RhZ2UxLnNo
| base64 -d >> /set-job-env-vars.sh
- export CURRENT_SECTION=dut_boot
- set -e
- echo Could not find jwt file, disabling S3 requests...

View file

@ -59,8 +59,8 @@ actions:
run:
steps:
- |-
echo test UBOOT
echo ZWNobyB0ZXN0IFVCT09U | base64 -d >> /set-job-env-vars.sh
FARM=test_farm . /test_dir/install/common/init-stage1.sh
echo RkFSTT10ZXN0X2Zhcm0gL3Rlc3RfZGlyL2luc3RhbGwvY29tbW9uL2luaXQtc3RhZ2UxLnNo | base64 -d >> /set-job-env-vars.sh
export CURRENT_SECTION=dut_boot
- export -p > /dut-env-vars.sh
- test:

View file

@ -57,8 +57,9 @@ actions:
format: Lava-Test Test Definition 1.0
run:
steps:
- echo test UBOOT
- echo ZWNobyB0ZXN0IFVCT09U | base64 -d >> /set-job-env-vars.sh
- FARM=test_farm . /test_dir/install/common/init-stage1.sh
- echo RkFSTT10ZXN0X2Zhcm0gL3Rlc3RfZGlyL2luc3RhbGwvY29tbW9uL2luaXQtc3RhZ2UxLnNo
| base64 -d >> /set-job-env-vars.sh
- export CURRENT_SECTION=dut_boot
- set -e
- echo Could not find jwt file, disabling S3 requests...

View file

@ -60,7 +60,6 @@ def job_submitter_factory(mode: Literal["UBOOT", "FASTBOOT"], shell_file):
device_type=device_type,
farm="test_farm",
dtb_filename="my_dtb_filename",
first_stage_init=shell_file,
env_file=shell_file,
job_timeout_min=job_timeout_min,
mesa_job_name=mesa_job_name,
@ -108,8 +107,9 @@ def test_generate_lava_job_definition_sanity(
# Do not actually connect to the LAVA server
mock_lava_proxy.return_value = mock_proxy
init_script_content = f"echo test {mode}"
job_submitter = job_submitter_factory(mode, shell_file(init_script_content))
farm_env = "FARM=test_farm"
init_script = "/install/common/init-stage1.sh"
job_submitter = job_submitter_factory(mode, shell_file(init_script))
job_definition = LAVAJobDefinition(job_submitter).generate_lava_job_definition()
# Load the YAML output and check that it contains the expected keys and values
@ -184,7 +184,8 @@ def test_generate_lava_job_definition_sanity(
"test",
]
)
assert init_script_content in run_steps
assert farm_env in run_steps
assert init_script in run_steps
# use yaml files from tests/data/ to test the job definition generation
@ -210,8 +211,8 @@ def test_lava_job_definition(
# Load the YAML output and check that it contains the expected keys and values
expected_job_dict = load_yaml_file(f"{mode}_force_uart={force_uart}_job_definition.yaml")
init_script_content = f"echo test {mode}"
job_submitter = job_submitter_factory(mode, shell_file(init_script_content))
init_script = f"FARM=test_farm /test_dir/install/common/init-stage1.sh"
job_submitter = job_submitter_factory(mode, shell_file(init_script))
job_definition = LAVAJobDefinition(job_submitter).generate_lava_job_definition()
job_dict = yaml.load(job_definition)

View file

@ -253,20 +253,17 @@ class LAVAJobDefinition:
return steps
def init_stage1_steps(self) -> list[str]:
run_steps = []
# job execution script:
# - inline .gitlab-ci/common/init-stage1.sh
# - source .gitlab-ci/common/init-stage1.sh
# - fetch and unpack per-pipeline build artifacts from build job
# - fetch, unpack and encode per-job env from lava-submit.sh
# - inline and encode per-job env from lava-submit.sh
# - exec .gitlab-ci/common/init-stage2.sh
with open(self.job_submitter.first_stage_init, "r") as init_sh:
# For vmware farm, patch nameserver as 8.8.8.8 is off limit.
# This is temporary and will be reverted once the farm is moved.
if self.job_submitter.mesa_job_name.startswith("vmware-"):
run_steps += [x.rstrip().replace("nameserver 8.8.8.8", "nameserver 192.19.189.10") for x in init_sh if not x.startswith("#") and x.rstrip()]
else:
run_steps += [x.rstrip() for x in init_sh if not x.startswith("#") and x.rstrip()]
run_steps = [
f"FARM={self.job_submitter.farm} "
# We need to source the init-stage1.sh script, so that the environment
# variables including PWD are set in the current shell.
f". {self.job_submitter.project_dir}/install/common/init-stage1.sh"
]
# We cannot distribute the Adreno 660 shader firmware inside rootfs,
# since the license isn't bundled inside the repository