Files
buildroot/support/scripts/generate-gitlab-ci-yml
Yann E. MORIN 6bc09ae38f gitlab-ci: handle the basic tests in script
Note that those tests were so far ignored only when requesting a single
defconfig build, or a single runtime test build; everything else
was trigerring thoses tests.

However, it feels more natural that they are also ignored when all
defconfigs build. or all runtime tests, are explictly requested.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Romain Naour <romain.naour@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Reviewed-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2020-09-09 09:25:52 +02:00

113 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
set -o pipefail
main() {
local template="${1}"
preamble "${template}"
gen_basics
gen_defconfigs
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_basics() {
local tst
# Skip basic tests when explicitly building defconfigs or runtime tests
case "${CI_COMMIT_REF_NAME}" in
(*-defconfigs) return;;
(*-*_defconfig) return;;
(*-runtime-tests) return;;
(*-tests.*) return;;
esac
for tst in DEVELOPERS flake8 package; do
printf 'check-%s: { extends: .check-%s_base }\n' "${tst}" "${tst}"
done
}
gen_defconfigs() {
local -a defconfigs
local build_defconfigs cfg
defconfigs=( $(cd configs; LC_ALL=C ls -1 *_defconfig) )
build_defconfigs=false
if [ -n "${CI_COMMIT_TAG}" ]; then
# For tags, create a pipeline.
build_defconfigs=true
fi
if [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
# For pipeline created by using a trigger token.
build_defconfigs=true
fi
case "${CI_COMMIT_REF_NAME}" in
# For the branch or tag name named *-defconfigs, create a pipeline.
(*-defconfigs)
build_defconfigs=true
;;
(*-*_defconfig)
defconfigs=( "${CI_COMMIT_REF_NAME##*-}" )
build_defconfigs=true
;;
esac
for cfg in "${defconfigs[@]}"; do
if ${build_defconfigs}; then
printf '%s: { extends: .defconfig_base }\n' "${cfg}"
else
printf '%s_check: { extends: .defconfig_check }\n' "${cfg}"
fi
done
}
gen_tests() {
local -a tests
local run_tests tst
tests=( $(./support/testing/run-tests -l 2>&1 \
| sed -r -e '/^test_run \((.*)\).*/!d; s//\1/'\
| LC_ALL=C sort)
)
run_tests=false
if [ -n "${CI_COMMIT_TAG}" ]; then
# For tags, create a pipeline.
run_tests=true
fi
if [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
# For pipeline created by using a trigger token.
run_tests=true
fi
case "${CI_COMMIT_REF_NAME}" in
# For the branch or tag name named *-runtime-tests, create a pipeline.
(*-runtime-tests)
run_tests=true
;;
(*-tests.*)
tests=( "${CI_COMMIT_REF_NAME##*-}" )
run_tests=true
;;
esac
if ${run_tests}; then
printf '%s: { extends: .runtime_test_base }\n' "${tests[@]}"
fi
}
main "${@}"