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.

173 lines
6.4 KiB

  1. version: 2.0
  2. jobs:
  3. build:
  4. docker:
  5. - image: docker.io/openwrtorg/packages-cci:v1.0.5
  6. environment:
  7. - SDK_HOST: "downloads.openwrt.org"
  8. - SDK_PATH: "snapshots/targets/ath79/generic"
  9. - SDK_FILE: "openwrt-sdk-ath79-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" -fs -o sha256sums.asc || true
  61. curl "https://$SDK_HOST/$SDK_PATH/sha256sums.sig" -fs -o sha256sums.sig || true
  62. if [ ! -f sha256sums.asc ] && [ ! -f sha256sums.sig ]; then
  63. echo_red "Missing sha256sums signature files"
  64. exit 1
  65. fi
  66. [ ! -f sha256sums.asc ] || gpg --with-fingerprint --verify sha256sums.asc sha256sums
  67. if [ -f sha256sums.sig ]; then
  68. VERIFIED=
  69. for KEY in ~/usign/*; do
  70. echo "Trying $KEY..."
  71. if signify-openbsd -V -q -p "$KEY" -x sha256sums.sig -m sha256sums; then
  72. echo "...verified"
  73. VERIFIED=1
  74. break
  75. fi
  76. done
  77. if [ -z "$VERIFIED" ]; then
  78. echo_red "Could not verify usign signature"
  79. exit 1
  80. fi
  81. fi
  82. rsync -av "$SDK_HOST::downloads/$SDK_PATH/$SDK_FILE" .
  83. sha256sum -c --ignore-missing sha256sums
  84. - run:
  85. name: Prepare build_dir
  86. working_directory: ~/build_dir
  87. command: |
  88. tar Jxf ~/sdk/$SDK_FILE --strip=1
  89. touch .config
  90. make prepare-tmpinfo scripts/config/conf
  91. ./scripts/config/conf --defconfig=.config Config.in
  92. make prereq
  93. rm .config
  94. cat > feeds.conf <<EOF
  95. src-git base https://github.com/openwrt/openwrt.git;$BRANCH
  96. src-link packages $HOME/openwrt_packages
  97. src-git luci https://github.com/openwrt/luci.git;$BRANCH
  98. EOF
  99. cat feeds.conf
  100. ./scripts/feeds update -a > /dev/null
  101. make defconfig > /dev/null
  102. # enable BUILD_LOG
  103. sed -i 's/# CONFIG_BUILD_LOG is not set/CONFIG_BUILD_LOG=y/' .config
  104. - run:
  105. name: Install & download source, check package, compile
  106. working_directory: ~/build_dir
  107. command: |
  108. set +o pipefail
  109. PKGS=$(cd ~/openwrt_packages; git diff --diff-filter=d --name-only "origin/$BRANCH..." | grep 'Makefile$' | grep -Ev '/files/|/src/' | awk -F/ '{ print $(NF-1) }')
  110. if [ -z "$PKGS" ] ; then
  111. echo_blue "WARNING: No new or modified packages found!"
  112. exit 0
  113. fi
  114. echo_blue "=== Found new/modified packages: $PKGS"
  115. for PKG in $PKGS ; do
  116. echo_blue "===+ Install: $PKG"
  117. ./scripts/feeds install "$PKG"
  118. echo_blue "===+ Download: $PKG"
  119. make "package/$PKG/download" V=s
  120. echo_blue "===+ Check package: $PKG"
  121. make "package/$PKG/check" V=s 2>&1 | tee logtmp
  122. RET=${PIPESTATUS[0]}
  123. if [ $RET -ne 0 ]; then
  124. echo_red "=> Package check failed: $RET)"
  125. exit $RET
  126. fi
  127. badhash_msg="HASH does not match "
  128. badhash_msg+="|HASH uses deprecated hash,"
  129. badhash_msg+="|HASH is missing,"
  130. if grep -qE "$badhash_msg" logtmp; then
  131. echo_red "=> Package HASH check failed"
  132. exit 1
  133. fi
  134. echo_green "=> Package check OK"
  135. done
  136. for PKG in $PKGS ; do
  137. echo_blue "===+ Building: $PKG"
  138. make "package/$PKG/compile" -j3 V=s || {
  139. RET=$?
  140. echo_red "===+ Building: $PKG failed, rebuilding with -j1 for human readable error log"
  141. make "package/$PKG/compile" -j1 V=s; exit $RET
  142. }
  143. done
  144. - store_artifacts:
  145. path: ~/build_dir/logs
  146. - store_artifacts:
  147. path: ~/build_dir/bin
  148. workflows:
  149. version: 2
  150. buildpr:
  151. jobs:
  152. - build:
  153. filters:
  154. branches:
  155. ignore: master