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.

142 lines
5.1 KiB

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