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