aboutsummaryrefslogtreecommitdiff
path: root/.circleci/config.yml
blob: 8a8bef1c5a94bfa152056a0c964a0ab6bbc5231d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
version: 2.0
jobs:
  build:
    docker:
      - image: docker.io/openwrtorg/packages-cci:v1.0.1
    environment:
      - SDK_BASE_URL: "https://downloads.openwrt.org/snapshots/targets/ar71xx/generic"
      - SDK_FILE: "openwrt-sdk-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64.tar.xz"
      - BRANCH: "master"
    steps:
      - checkout:
          path: ~/openwrt_packages

      - run:
          name: Check changes / verify commits
          working_directory: ~/openwrt_packages
          command: |
             cat >> $BASH_ENV <<EOF
             echo_red()   { printf "\033[1;31m\$*\033[m\n"; }
             echo_green() { printf "\033[1;32m\$*\033[m\n"; }
             echo_blue()  { printf "\033[1;34m\$*\033[m\n"; }
             EOF
             source $BASH_ENV

             RET=0
             for commit in $(git rev-list HEAD ^origin/$BRANCH); do
               echo_blue "=== Checking commit '$commit'"
               if git show --format='%P' -s $commit | grep -qF ' '; then
                 echo_red "Pull request should not include merge commits"
                 RET=1
               fi

               author="$(git show -s --format=%aN $commit)"
               if echo $author | grep -q '\S\+\s\+\S\+'; then
                 echo_green "Author name ($author) seems ok"
               else
                 echo_red "Author name ($author) need to be your real name 'firstname lastname'"
                 RET=1
               fi

               subject="$(git show -s --format=%s $commit)"
               if echo "$subject" | grep -q -e '^[0-9A-Za-z,/_-]\+: ' -e '^Revert '; then
                 echo_green "Commit subject line seems ok ($subject)"
               else
                 echo_red "Commit subject line MUST start with '<package name>: ' ($subject)"
                 RET=1
               fi

               body="$(git show -s --format=%b $commit)"
               sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
               if echo "$body" | grep -qF "$sob"; then
                 echo_green "Signed-off-by match author"
               else
                 echo_red "Signed-off-by is missing or doesn't match author (should be '$sob')"
                 RET=1
               fi
             done

             exit $RET

      - run:
          name: Download the SDK
          working_directory: ~/sdk
          command: |
             curl "$SDK_BASE_URL/sha256sums" -sS -o sha256sums
             curl "$SDK_BASE_URL/sha256sums.asc" -sS -o sha256sums.asc
             gpg --with-fingerprint --verify sha256sums.asc sha256sums
             curl "$SDK_BASE_URL/$SDK_FILE" -sS -o "$SDK_FILE"
             sha256sum -c --ignore-missing sha256sums

      - run:
          name: Prepare build_dir
          working_directory: ~/build_dir
          command: |
             tar Jxf ~/sdk/$SDK_FILE --strip=1
             cat > feeds.conf <<EOF
             src-git base https://github.com/openwrt/openwrt.git;$BRANCH
             src-link packages $HOME/openwrt_packages
             src-git luci https://github.com/openwrt/luci.git;$BRANCH
             EOF
             cat feeds.conf
             # enable BUILD_LOG
             sed -i '1s/^/config BUILD_LOG\n\tbool\n\tdefault y\n\n/' Config-build.in
             ./scripts/feeds update -a > /dev/null
             ./scripts/feeds install -a > /dev/null
             make defconfig > /dev/null

      - run:
          name: Download source/check/compile
          working_directory: ~/build_dir
          command: |
             set +o pipefail
             PKGS=$(cd ~/openwrt_packages; git diff --diff-filter=d --name-only "origin/$BRANCH..." | grep 'Makefile$' | grep -v '/files/' | awk -F/ '{ print $(NF-1) }')
             if [ -z "$PKGS" ] ; then
                 echo_blue "WARNING: No new or modified packages found!"
                 exit 0
             fi

             echo_blue "=== Found new/modified packages: $PKGS"
             for PKG in $PKGS ; do
                 echo_blue "===+ Download/check: $PKG"
                 make "package/$PKG/download" V=s
                 make "package/$PKG/check" V=s
             done

             for PKG in $PKGS ; do
                 echo_blue "===+ Building: $PKG"
                 make "package/$PKG/compile" -j3 V=s
             done

      - store_artifacts:
          path: ~/build_dir/logs

      - store_artifacts:
          path: ~/build_dir/bin

workflows:
  version: 2
  buildpr:
    jobs:
      - build:
          filters:
            branches:
              ignore: master