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.

123 lines
4.5 KiB

  1. version: 2.0
  2. jobs:
  3. build:
  4. docker:
  5. - image: docker.io/champtar/openwrtpackagesci@sha256:96ef72edc70cba371ea5676fba15ee25b3a94f538f648a27454b699edce61da0
  6. environment:
  7. - SDK_BASE_URL: "https://downloads.openwrt.org/snapshots/targets/ar71xx/generic"
  8. - SDK_FILE: "openwrt-sdk-ar71xx-generic_gcc-7.3.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. # enable BUILD_LOG
  75. sed -i '1s/^/config BUILD_LOG\n\tbool\n\tdefault y\n\n/' Config-build.in
  76. ./scripts/feeds update -a > /dev/null
  77. ./scripts/feeds install -a > /dev/null
  78. make defconfig > /dev/null
  79. - run:
  80. name: Download source/check/compile
  81. working_directory: ~/build_dir
  82. command: |
  83. PKGS=$(cd ~/openwrt_packages; git diff --diff-filter=d --name-only "origin/$BRANCH..." | grep 'Makefile$' | grep -v '/files/' | awk -F/ '{ print $(NF-1) }')
  84. if [ -z "$PKGS" ] ; then
  85. echo_blue "WARNING: No new or modified packages found!"
  86. exit 0
  87. fi
  88. echo_blue "=== Found new/modified packages: $PKGS"
  89. for PKG in $PKGS ; do
  90. echo_blue "===+ Download/check: $PKG"
  91. make "package/$PKG/download" V=s
  92. make "package/$PKG/check" V=s
  93. done
  94. for PKG in $PKGS ; do
  95. echo_blue "===+ Building: $PKG"
  96. make "package/$PKG/compile" -j3 V=s
  97. done
  98. - store_artifacts:
  99. path: ~/build_dir/logs
  100. - store_artifacts:
  101. path: ~/build_dir/bin
  102. workflows:
  103. version: 2
  104. buildpr:
  105. jobs:
  106. - build:
  107. filters:
  108. branches:
  109. ignore: master