projects/linux·blob master · refs

98 lines · 3.3 KiB

1#!/usr/bin/env bash
2# SPDX-License-Identifier: MIT
3# shellcheck disable=SC2086 # we want word splitting
4# shellcheck disable=SC1091 # paths only become valid at runtime
5
6# shellcheck disable=SC1090
7source "${FDO_CI_BASH_HELPERS}"
8
9fdo_log_section_start_collapsed prepare_rootfs "Preparing root filesystem"
10
11set -ex
12
13# If we run in the fork (not from mesa or Marge-bot), reuse mainline kernel and rootfs, if exist.
14ROOTFS_URL="$(fdo_find_s3_path "$LAVA_ROOTFS_PATH")" ||
15{
16 set +x
17 fdo_log_section_error "Sorry, I couldn't find a viable built path for ${LAVA_ROOTFS_PATH} in either mainline or a fork." >&2
18 echo "" >&2
19 echo "If you're working on CI, this probably means that you're missing a dependency:" >&2
20 echo "this job ran ahead of the job which was supposed to upload that artifact." >&2
21 echo "" >&2
22 echo "If you aren't working on CI, please ping @mesa/ci-helpers to see if we can help." >&2
23 echo "" >&2
24 echo "This job is going to fail, because I can't find the resources I need. Sorry." >&2
25 set -x
26 exit 1
27}
28
29rm -rf results
30mkdir results
31
32fdo_filter_env_vars > dut-env-vars.sh
33# Set SCRIPTS_DIR to point to the Mesa install we download for the DUT
34echo "export SCRIPTS_DIR='$CI_PROJECT_DIR/install'" >> dut-env-vars.sh
35
36fdo_log_section_end prepare_rootfs
37
38# Prepare env vars for upload.
39fdo_log_section_start_collapsed variables "Environment variables passed through to device:"
40cat dut-env-vars.sh
41fdo_log_section_end variables
42
43fdo_log_section_start_collapsed lava_submit "Submitting job for scheduling"
44
45touch results/lava.log
46tail -f results/lava.log &
47# Ensure that we are printing the commands that are being executed,
48# making it easier to debug the job in case it fails.
49set -x
50
51# List of optional overlays
52LAVA_EXTRA_OVERLAYS=()
53if [ -n "${LAVA_FIRMWARE:-}" ]; then
54 for fw in $LAVA_FIRMWARE; do
55 LAVA_EXTRA_OVERLAYS+=(
56 - append-overlay
57 --name=linux-firmware
58 --url="https://${S3_BASE_PATH}/${FIRMWARE_REPO}/${fw}-${FIRMWARE_TAG}.tar"
59 --path="/"
60 --format=tar
61 )
62 done
63fi
64LAVA_EXTRA_OVERLAYS+=(
65 - append-overlay \
66 --name=kernel-build \
67 --url="${FDO_HTTP_CACHE_URI:-}https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/kernel-files.tar.zst" \
68 --compression=zstd \
69 --path="${CI_PROJECT_DIR}" \
70 --format=tar \
71)
72
73lava-job-submitter \
74 --farm "${FARM}" \
75 --device-type "${DEVICE_TYPE}" \
76 --boot-method "${BOOT_METHOD}" \
77 --job-timeout-min $((CI_JOB_TIMEOUT/60 - 5)) \
78 --dump-yaml \
79 --pipeline-info "$CI_JOB_NAME: $CI_PIPELINE_URL on $CI_COMMIT_REF_NAME ${CI_NODE_INDEX}/${CI_NODE_TOTAL}" \
80 --rootfs-url "${ROOTFS_URL}" \
81 --kernel-url-prefix "https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}" \
82 --dtb-filename "${DTB}" \
83 --env-file dut-env-vars.sh \
84 --jwt-file "${S3_JWT_FILE}" \
85 --kernel-image-name "${KERNEL_IMAGE_NAME}" \
86 --kernel-image-type "${KERNEL_IMAGE_TYPE}" \
87 --visibility-group "${VISIBILITY_GROUP}" \
88 --lava-tags "${LAVA_TAGS}" \
89 --mesa-job-name "$CI_JOB_NAME" \
90 --structured-log-file "results/lava_job_detail.json" \
91 --ssh-client-image "${LAVA_SSH_CLIENT_IMAGE}" \
92 --project-dir "${CI_PROJECT_DIR}" \
93 --project-name "${CI_PROJECT_NAME}" \
94 --starting-section lava_submit \
95 --job-submitted-at "${CI_JOB_STARTED_AT}" \
96 "${LAVA_EXTRA_OVERLAYS[@]}" \
97 - submit \
98 >> results/lava.log