mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -09:00
defconfigs are very unlikely to successfully build on a small runner because they build a kernel (and often a toolchain). They're also likely to benefit a lot from the additional parallelism on larger runners. For now, always build them on large runners. There may be some for which even the large runners don't have sufficient disk space or memory, but we'll solve that when it happens. Signed-off-by: Arnout Vandecappelle <arnout@rnout.be> Signed-off-by: Romain Naour <romain.naour@smile.fr>
153 lines
4.7 KiB
Bash
Executable File
153 lines
4.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
set -o pipefail
|
|
|
|
main() {
|
|
local template="${1}"
|
|
|
|
preamble "${template}"
|
|
gen_tests
|
|
}
|
|
|
|
preamble() {
|
|
local template="${1}"
|
|
|
|
cat - "${template}" <<-_EOF_
|
|
# This file is generated; do not edit!
|
|
# Builds appear on https://gitlab.com/buildroot.org/buildroot/pipelines
|
|
|
|
image: ${CI_JOB_IMAGE}
|
|
|
|
_EOF_
|
|
}
|
|
|
|
gen_tests() {
|
|
local -a basics defconfigs runtimes
|
|
local do_basics do_defconfigs do_runtime do_testpkg
|
|
local defconfigs_ext cfg runner tst
|
|
|
|
basics=( check-package check-symbol DEVELOPERS package symbol )
|
|
|
|
defconfigs=( $(cd configs; LC_ALL=C ls -1 *_defconfig) )
|
|
|
|
runtimes=( $(./support/testing/run-tests -l 2>&1 \
|
|
| sed -r -e '/^test_run \((.*)\).*/!d; s//\1/' \
|
|
| LC_ALL=C sort)
|
|
)
|
|
|
|
if [ -n "${CI_COMMIT_TAG}" ]; then
|
|
# When a tag is added to the Buildroot git tree, we want
|
|
# to run the runtime tests and only test Qemu defconfigs.
|
|
defconfigs=( $(cd configs; LC_ALL=C ls -1 qemu_*_defconfig) )
|
|
do_basics=true
|
|
do_defconfigs=base
|
|
do_runtime=true
|
|
elif [ -n "${BR_SCHEDULE_JOBS}" ]; then
|
|
case "${BR_SCHEDULE_JOBS}" in
|
|
(basic)
|
|
do_basics=true
|
|
do_defconfigs=check
|
|
defconfigs_ext=_check
|
|
;;
|
|
(defconfig)
|
|
do_defconfigs=base
|
|
;;
|
|
(runtime)
|
|
do_runtime=true
|
|
;;
|
|
esac
|
|
else
|
|
case "${CI_COMMIT_REF_NAME}" in
|
|
(*-basics)
|
|
do_basics=true
|
|
do_defconfigs=check
|
|
defconfigs_ext=_check
|
|
;;
|
|
(*-defconfigs)
|
|
do_defconfigs=base
|
|
;;
|
|
(*-defconfigs-*)
|
|
pattern=$(echo ${CI_COMMIT_REF_NAME} | sed 's%^.*-defconfigs-\(.*\)%\1%')
|
|
defconfigs=( $(cd configs; LC_ALL=C ls -1 | grep ^${pattern}) )
|
|
do_defconfigs=base
|
|
;;
|
|
(*-*_defconfig)
|
|
defconfigs=( "${CI_COMMIT_REF_NAME##*-}" )
|
|
do_defconfigs=base
|
|
;;
|
|
(*-runtime-tests)
|
|
do_runtime=true
|
|
;;
|
|
(*-tests.*)
|
|
runtimes=( $(./support/testing/run-tests -l 2>&1 \
|
|
| sed -r -e '/^test_run \((.*)\).*/!d; s//\1/' \
|
|
| LC_ALL=C sort \
|
|
| grep "^${CI_COMMIT_REF_NAME##*-}")
|
|
)
|
|
do_runtime=true
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# Retrieve defconfig for test-pkg from the git commit message (if any)
|
|
if grep -q -E '^test-pkg config:$' <<<"${CI_COMMIT_DESCRIPTION}"; then
|
|
sed -r -n -e '/^test-pkg config:$/{:a;n;s/^ +//;p;ba;}' \
|
|
<<<"${CI_COMMIT_DESCRIPTION}" \
|
|
>defconfig.frag
|
|
if [ ! -s defconfig.frag ]; then
|
|
printf "Empty configuration fragment.\n" >&2; exit 1
|
|
fi
|
|
# Use --all since we expect the user having already pre-tested the
|
|
# new package with the default subset of toolchains.
|
|
./utils/test-pkg \
|
|
--all --prepare-only \
|
|
--config-snippet defconfig.frag \
|
|
--build-dir br-test-pkg >&2
|
|
do_testpkg=( $(ls -1 br-test-pkg/*/.config 2>/dev/null |xargs -r dirname ) )
|
|
if [ "${#do_testpkg[@]}" -eq 0 ]; then
|
|
printf "Configuration fragment enables no test.\n" >&2; exit 1
|
|
fi
|
|
fi
|
|
|
|
# If nothing else, at least do the basics to generate a valid pipeline
|
|
if [ -z "${do_defconfigs}" \
|
|
-a -z "${do_runtime}" \
|
|
-a -z "${do_testpkg}" \
|
|
]
|
|
then
|
|
do_basics=true
|
|
fi
|
|
|
|
if ${do_basics:-false}; then
|
|
for tst in "${basics[@]}"; do
|
|
printf 'check-%s: { extends: .check-%s_base }\n' "${tst}" "${tst}"
|
|
done
|
|
fi
|
|
|
|
if [ -n "${do_defconfigs}" ]; then
|
|
for cfg in "${defconfigs[@]}"; do
|
|
printf '%s%s: { extends: [ .defconfig_%s, .runner-large ] }\n' \
|
|
"${cfg}" "${defconfigs_ext}" "${do_defconfigs}"
|
|
done
|
|
fi
|
|
|
|
if ${do_runtime:-false}; then
|
|
printf 'runtime_test_download: { extends: .runtime_test_download }\n'
|
|
for test in "${runtimes[@]}"; do
|
|
test_file=$(echo "${test}" | tr '.' '/' | sed 's%\(.*/test_[^/]*\)/.*test_run$%support/testing/\1.py%g')
|
|
test_name=$(echo "${test}" | sed 's/.test_run$//g' | sed 's/.*\.//')
|
|
runner=$(grep -w -B 1 "${test_name}" "${test_file}" | head -1 | sed -n 's/^.*# gitlab-runner: \(.*\)/\1/p' ) || true
|
|
if [ -z "${runner}" ]; then
|
|
runner="small"
|
|
fi
|
|
printf '%s: { extends: [ .runtime_test_base, .runner-%s ]}\n' "${test}" "${runner}"
|
|
done
|
|
fi
|
|
|
|
if [ -n "${do_testpkg}" ]; then
|
|
printf '%s: { extends: .test_pkg }\n' "${do_testpkg[@]}"
|
|
fi
|
|
}
|
|
|
|
main "${@}"
|