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# If we run in the fork (not from mesa or Marge-bot), reuse mainline kernel and rootfs, if exist. 7_check_artifact_path() { 8 _url="https://${1}/${2}" 9 if curl -s -o /dev/null -I -L -f --retry 4 --retry-delay 15 "${_url}"; then 10 echo -n "${_url}" 11 fi 12} 13 14get_path_to_artifact() { 15 _mainline_artifact="$(_check_artifact_path ${BASE_SYSTEM_MAINLINE_HOST_PATH} ${1})" 16 if [ -n "${_mainline_artifact}" ]; then 17 echo -n "${_mainline_artifact}" 18 return 19 fi 20 _fork_artifact="$(_check_artifact_path ${BASE_SYSTEM_FORK_HOST_PATH} ${1})" 21 if [ -n "${_fork_artifact}" ]; then 22 echo -n "${_fork_artifact}" 23 return 24 fi 25 set +x 26 error "Sorry, I couldn't find a viable built path for ${1} in either mainline or a fork." >&2 27 echo "" >&2 28 echo "If you're working on CI, this probably means that you're missing a dependency:" >&2 29 echo "this job ran ahead of the job which was supposed to upload that artifact." >&2 30 echo "" >&2 31 echo "If you aren't working on CI, please ping @mesa/ci-helpers to see if we can help." >&2 32 echo "" >&2 33 echo "This job is going to fail, because I can't find the resources I need. Sorry." >&2 34 set -x 35 exit 1 36} 37 38. "${SCRIPTS_DIR}/setup-test-env.sh" 39 40section_start prepare_rootfs "Preparing root filesystem" 41 42set -ex 43 44section_switch rootfs "Assembling root filesystem" 45ROOTFS_URL="$(get_path_to_artifact lava-rootfs.tar.zst)" 46[ $? != 1 ] || exit 1 47 48rm -rf results 49mkdir -p results/job-rootfs-overlay/ 50 51artifacts/ci-common/export-gitlab-job-env-for-dut.sh \ 52 > results/job-rootfs-overlay/set-job-env-vars.sh 53cp artifacts/ci-common/init-*.sh results/job-rootfs-overlay/ 54cp "$SCRIPTS_DIR"/setup-test-env.sh results/job-rootfs-overlay/ 55 56tar zcf job-rootfs-overlay.tar.gz -C results/job-rootfs-overlay/ . 57s3_upload job-rootfs-overlay.tar.gz "https://${JOB_ARTIFACTS_BASE}" 58 59# Prepare env vars for upload. 60section_switch variables "Environment variables passed through to device:" 61cat results/job-rootfs-overlay/set-job-env-vars.sh 62 63section_switch lava_submit "Submitting job for scheduling" 64 65touch results/lava.log 66tail -f results/lava.log & 67PYTHONPATH=artifacts/ artifacts/lava/lava_job_submitter.py \ 68 --farm "${FARM}" \ 69 --device-type "${DEVICE_TYPE}" \ 70 --boot-method "${BOOT_METHOD}" \ 71 --job-timeout-min $((CI_JOB_TIMEOUT/60 - 5)) \ 72 --dump-yaml \ 73 --pipeline-info "$CI_JOB_NAME: $CI_PIPELINE_URL on $CI_COMMIT_REF_NAME ${CI_NODE_INDEX}/${CI_NODE_TOTAL}" \ 74 --rootfs-url "${ROOTFS_URL}" \ 75 --kernel-url-prefix "https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}" \ 76 --kernel-external "${EXTERNAL_KERNEL_TAG}" \ 77 --first-stage-init artifacts/ci-common/init-stage1.sh \ 78 --dtb-filename "${DTB}" \ 79 --jwt-file "${S3_JWT_FILE}" \ 80 --kernel-image-name "${KERNEL_IMAGE_NAME}" \ 81 --kernel-image-type "${KERNEL_IMAGE_TYPE}" \ 82 --visibility-group "${VISIBILITY_GROUP}" \ 83 --lava-tags "${LAVA_TAGS}" \ 84 --mesa-job-name "$CI_JOB_NAME" \ 85 --structured-log-file "results/lava_job_detail.json" \ 86 --ssh-client-image "${LAVA_SSH_CLIENT_IMAGE}" \ 87 --project-name "${CI_PROJECT_NAME}" \ 88 --starting-section "${CURRENT_SECTION}" \ 89 --job-submitted-at "${CI_JOB_STARTED_AT}" \ 90 - append-overlay \ 91 --name=kernel-build \ 92 --url="${FDO_HTTP_CACHE_URI:-}https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/kernel-files.tar.zst" \ 93 --compression=zstd \ 94 --path="${CI_PROJECT_DIR}" \ 95 --format=tar \ 96 - append-overlay \ 97 --name=job-overlay \ 98 --url="https://${JOB_ROOTFS_OVERLAY_PATH}" \ 99 --compression=gz \ 100 --path="/" \ 101 --format=tar \ 102 - submit \ 103 >> results/lava.log 104