addedb91fed74f9e20c926ed560b8b45b69968ff
[openwrt/staging/hauke.git] / .github / workflows / kernel.yml
1 name: Build Kernel
2
3 on:
4 pull_request:
5 paths:
6 - '.github/workflows/kernel.yml'
7 - 'include/kernel-*'
8 - 'package/kernel/**'
9 - 'target/linux/generic/**'
10 jobs:
11 determine_targets:
12 name: Set targets
13 runs-on: ubuntu-latest
14 outputs:
15 target: ${{ steps.find_targets.outputs.target }}
16
17 steps:
18 - name: Checkout
19 uses: actions/checkout@v2
20
21 - name: Set targets
22 id: find_targets
23 run: |
24 export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \
25 | sort -u -t '/' -k1,1 \
26 | awk '{ print $1 }')"
27
28 JSON='['
29 FIRST=1
30 for TARGET in $TARGETS; do
31 [[ $FIRST -ne 1 ]] && JSON="$JSON"','
32 JSON="$JSON"'"'"${TARGET}"'"'
33 FIRST=0
34 done
35 JSON="$JSON"']'
36
37 echo -e "\n---- targets ----\n"
38 echo "$JSON"
39 echo -e "\n---- targets ----\n"
40
41 echo "::set-output name=target::$JSON"
42
43 build:
44 name: Build Kernel with external toolchain
45 needs: determine_targets
46 runs-on: ubuntu-latest
47 strategy:
48 fail-fast: False
49 matrix:
50 target: ${{fromJson(needs.determine_targets.outputs.target)}}
51
52 container: registry.gitlab.com/openwrt/buildbot/buildworker-3.4.1
53
54 steps:
55 - name: Checkout master directory
56 uses: actions/checkout@v2
57 with:
58 path: openwrt
59
60 - name: Checkout packages feed
61 uses: actions/checkout@v2
62 with:
63 repository: openwrt/packages
64 path: openwrt/feeds/packages
65
66 - name: Checkout luci feed
67 uses: actions/checkout@v2
68 with:
69 repository: openwrt/luci
70 path: openwrt/feeds/luci
71
72 - name: Checkout routing feed
73 uses: actions/checkout@v2
74 with:
75 repository: openwrt/routing
76 path: openwrt/feeds/routing
77
78 - name: Checkout telephony feed
79 uses: actions/checkout@v2
80 with:
81 repository: openwrt/telephony
82 path: openwrt/feeds/telephony
83
84 - name: Fix permission
85 run: |
86 chown -R buildbot:buildbot openwrt
87
88 - name: Initialization environment
89 run: |
90 TARGET=$(echo ${{ matrix.target }} | cut -d "/" -f 1)
91 SUBTARGET=$(echo ${{ matrix.target }} | cut -d "/" -f 2)
92 echo "TARGET=$TARGET" >> "$GITHUB_ENV"
93 echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
94
95 - name: Update & Install feeds
96 shell: su buildbot -c "sh -e {0}"
97 working-directory: openwrt
98 run: |
99 ./scripts/feeds update -a
100 ./scripts/feeds install -a
101
102 - name: Parse toolchain file
103 working-directory: openwrt
104 run: |
105 TOOLCHAIN_FILE=$(curl "https://downloads.cdn.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" \
106 | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
107
108 echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
109
110 - name: Download external toolchain
111 shell: su buildbot -c "sh -e {0}"
112 working-directory: openwrt
113 run: |
114 wget -O - https://downloads.cdn.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${TOOLCHAIN_FILE}.tar.xz \
115 | tar --xz -xf -
116
117 - name: Configure external toolchain
118 shell: su buildbot -c "sh -e {0}"
119 working-directory: openwrt
120 run: |
121 ./scripts/ext-toolchain.sh \
122 --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
123 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
124
125 make defconfig
126
127 - name: Show configuration
128 shell: su buildbot -c "sh -e {0}"
129 working-directory: openwrt
130 run: ./scripts/diffconfig.sh
131
132 - name: Build tools
133 shell: su buildbot -c "sh -e {0}"
134 working-directory: openwrt
135 run: make tools/install -j$(nproc) BUILD_LOG=1
136
137 - name: Build toolchain
138 shell: su buildbot -c "sh -e {0}"
139 working-directory: openwrt
140 run: make toolchain/install -j$(nproc) BUILD_LOG=1
141
142 - name: Build Kernel
143 shell: su buildbot -c "sh -e {0}"
144 working-directory: openwrt
145 run: make target/compile -j$(nproc) BUILD_LOG=1
146
147 - name: Upload logs
148 if: failure()
149 uses: actions/upload-artifact@v2
150 with:
151 name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs
152 path: "openwrt/logs"