generate-gitlab-ci-yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. set -e
  3. set -o pipefail
  4. main() {
  5. local template="${1}"
  6. preamble "${template}"
  7. gen_defconfigs
  8. ./support/testing/run-tests -l 2>&1 \
  9. | sed -r -e '/^test_run \((.*)\).*/!d; s//\1: { extends: .runtime_test }/' \
  10. | LC_ALL=C sort
  11. }
  12. preamble() {
  13. local template="${1}"
  14. cat - "${template}" <<-_EOF_
  15. # This file is generated; do not edit!
  16. # Builds appear on https://gitlab.com/buildroot.org/buildroot/pipelines
  17. image: ${CI_JOB_IMAGE}
  18. _EOF_
  19. }
  20. gen_defconfigs() {
  21. local -a defconfigs
  22. local build_defconfigs cfg
  23. defconfigs=( $(cd configs; LC_ALL=C ls -1 *_defconfig) )
  24. build_defconfigs=false
  25. if [ -n "${CI_COMMIT_TAG}" ]; then
  26. # For tags, create a pipeline.
  27. build_defconfigs=true
  28. fi
  29. if [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
  30. # For pipeline created by using a trigger token.
  31. build_defconfigs=true
  32. fi
  33. case "${CI_COMMIT_REF_NAME}" in
  34. # For the branch or tag name named *-defconfigs, create a pipeline.
  35. (*-defconfigs) build_defconfigs=true;;
  36. esac
  37. for cfg in "${defconfigs[@]}"; do
  38. printf '%s_check: { extends: .defconfig_check }\n' "${cfg}"
  39. if ${build_defconfigs}; then
  40. printf '%s: { extends: .defconfig }\n' "${cfg}"
  41. fi
  42. done
  43. }
  44. main "${@}"