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.

144 lines
5.2 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/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" -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. 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: Install & 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 -Ev '/files/|/src/' | 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 "===+ Install: $PKG"
  92. ./scripts/feeds install "$PKG"
  93. echo_blue "===+ Download: $PKG"
  94. make "package/$PKG/download" V=s
  95. echo_blue "===+ Check package: $PKG"
  96. make "package/$PKG/check" V=s 2>&1 | tee logtmp
  97. RET=${PIPESTATUS[0]}
  98. if [ $RET -ne 0 ]; then
  99. echo_red "=> Package check failed: $RET)"
  100. exit $RET
  101. fi
  102. badhash_msg="HASH does not match "
  103. badhash_msg+="|HASH uses deprecated hash,"
  104. badhash_msg+="|HASH is missing,"
  105. if grep -qE "$badhash_msg" logtmp; then
  106. echo_red "=> Package HASH check failed"
  107. exit 1
  108. fi
  109. echo_green "=> Package check OK"
  110. done
  111. for PKG in $PKGS ; do
  112. echo_blue "===+ Building: $PKG"
  113. make "package/$PKG/compile" -j3 V=s
  114. done
  115. - store_artifacts:
  116. path: ~/build_dir/logs
  117. - store_artifacts:
  118. path: ~/build_dir/bin
  119. workflows:
  120. version: 2
  121. buildpr:
  122. jobs:
  123. - build:
  124. filters:
  125. branches:
  126. ignore: master