You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
5.1 KiB

  1. version: 2.0
  2. jobs:
  3. build:
  4. docker:
  5. - image: docker.io/openwrtorg/packages-cci:v1.0.1
  6. environment:
  7. - SDK_BASE_URL: "https://downloads.openwrt.org/snapshots/targets/ar71xx/generic"
  8. - SDK_FILE: "openwrt-sdk-ar71xx-generic_gcc-7.4.0_musl.Linux-x86_64.tar.xz"
  9. - BRANCH: "master"
  10. steps:
  11. - checkout:
  12. path: ~/openwrt_packages
  13. - run:
  14. name: Check changes / verify commits
  15. working_directory: ~/openwrt_packages
  16. command: |
  17. cat >> $BASH_ENV <<EOF
  18. echo_red() { printf "\033[1;31m\$*\033[m\n"; }
  19. echo_green() { printf "\033[1;32m\$*\033[m\n"; }
  20. echo_blue() { printf "\033[1;34m\$*\033[m\n"; }
  21. EOF
  22. source $BASH_ENV
  23. RET=0
  24. for commit in $(git rev-list HEAD ^origin/$BRANCH); do
  25. echo_blue "=== Checking commit '$commit'"
  26. if git show --format='%P' -s $commit | grep -qF ' '; then
  27. echo_red "Pull request should not include merge commits"
  28. RET=1
  29. fi
  30. author="$(git show -s --format=%aN $commit)"
  31. if echo $author | grep -q '\S\+\s\+\S\+'; then
  32. echo_green "Author name ($author) seems ok"
  33. else
  34. echo_red "Author name ($author) need to be your real name 'firstname lastname'"
  35. RET=1
  36. fi
  37. subject="$(git show -s --format=%s $commit)"
  38. if echo "$subject" | grep -q -e '^[0-9A-Za-z,+/_-]\+: ' -e '^Revert '; then
  39. echo_green "Commit subject line seems ok ($subject)"
  40. else
  41. echo_red "Commit subject line MUST start with '<package name>: ' ($subject)"
  42. RET=1
  43. fi
  44. body="$(git show -s --format=%b $commit)"
  45. sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
  46. if echo "$body" | grep -qF "$sob"; then
  47. echo_green "Signed-off-by match author"
  48. else
  49. echo_red "Signed-off-by is missing or doesn't match author (should be '$sob')"
  50. RET=1
  51. fi
  52. done
  53. exit $RET
  54. - run:
  55. name: Download the SDK
  56. working_directory: ~/sdk
  57. command: |
  58. curl "$SDK_BASE_URL/sha256sums" -sS -o sha256sums
  59. curl "$SDK_BASE_URL/sha256sums.asc" -sS -o sha256sums.asc
  60. gpg --with-fingerprint --verify sha256sums.asc sha256sums
  61. curl "$SDK_BASE_URL/$SDK_FILE" -sS -o "$SDK_FILE"
  62. sha256sum -c --ignore-missing sha256sums
  63. - run:
  64. name: Prepare build_dir
  65. working_directory: ~/build_dir
  66. command: |
  67. tar Jxf ~/sdk/$SDK_FILE --strip=1
  68. cat > feeds.conf <<EOF
  69. src-git base https://github.com/openwrt/openwrt.git;$BRANCH
  70. src-link packages $HOME/openwrt_packages
  71. src-git luci https://github.com/openwrt/luci.git;$BRANCH
  72. EOF
  73. cat feeds.conf
  74. ./scripts/feeds update -a > /dev/null
  75. ./scripts/feeds install -a > /dev/null
  76. make defconfig > /dev/null
  77. # enable BUILD_LOG
  78. sed -i 's/# CONFIG_BUILD_LOG is not set/CONFIG_BUILD_LOG=y/' .config
  79. - run:
  80. name: Download source, check package, compile
  81. working_directory: ~/build_dir
  82. command: |
  83. set +o pipefail
  84. PKGS=$(cd ~/openwrt_packages; git diff --diff-filter=d --name-only "origin/$BRANCH..." | grep 'Makefile$' | grep -v '/files/' | awk -F/ '{ print $(NF-1) }')
  85. if [ -z "$PKGS" ] ; then
  86. echo_blue "WARNING: No new or modified packages found!"
  87. exit 0
  88. fi
  89. echo_blue "=== Found new/modified packages: $PKGS"
  90. for PKG in $PKGS ; do
  91. echo_blue "===+ Download: $PKG"
  92. make "package/$PKG/download" V=s
  93. echo_blue "===+ Check package: $PKG"
  94. make "package/$PKG/check" V=s 2>&1 | tee logtmp
  95. RET=${PIPESTATUS[0]}
  96. if [ $RET -ne 0 ]; then
  97. echo_red "=> Package check failed: $RET)"
  98. exit $RET
  99. fi
  100. badhash_msg="HASH does not match "
  101. badhash_msg+="|HASH uses deprecated hash,"
  102. badhash_msg+="|HASH is missing,"
  103. if grep -qE "$badhash_msg" logtmp; then
  104. echo_red "=> Package HASH check failed"
  105. exit 1
  106. fi
  107. echo_green "=> Package check OK"
  108. done
  109. for PKG in $PKGS ; do
  110. echo_blue "===+ Building: $PKG"
  111. make "package/$PKG/compile" -j3 V=s
  112. done
  113. - store_artifacts:
  114. path: ~/build_dir/logs
  115. - store_artifacts:
  116. path: ~/build_dir/bin
  117. workflows:
  118. version: 2
  119. buildpr:
  120. jobs:
  121. - build:
  122. filters:
  123. branches:
  124. ignore: master