37fba2f4ecc95129807efeae02baabbef83d97b9
[openwrt/staging/dedeckeh.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: Fix permission
61 run: |
62 chown -R buildbot:buildbot openwrt
63
64 - name: Initialization environment
65 run: |
66 TARGET=$(echo ${{ matrix.target }} | cut -d "/" -f 1)
67 SUBTARGET=$(echo ${{ matrix.target }} | cut -d "/" -f 2)
68 echo "TARGET=$TARGET" >> "$GITHUB_ENV"
69 echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
70
71 - name: Update & Install feeds
72 shell: su buildbot -c "sh -e {0}"
73 working-directory: openwrt
74 run: |
75 ./scripts/feeds update -a
76 ./scripts/feeds install -a
77
78 - name: Parse toolchain file
79 working-directory: openwrt
80 run: |
81 TOOLCHAIN_FILE=$(curl "https://downloads.cdn.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" \
82 | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
83
84 echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
85
86 - name: Download external toolchain
87 shell: su buildbot -c "sh -e {0}"
88 working-directory: openwrt
89 run: |
90 wget -O - https://downloads.cdn.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${TOOLCHAIN_FILE}.tar.xz \
91 | tar --xz -xf -
92
93 - name: Configure external toolchain
94 shell: su buildbot -c "sh -e {0}"
95 working-directory: openwrt
96 run: |
97 ./scripts/ext-toolchain.sh \
98 --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
99 --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
100
101 make defconfig
102
103 - name: Show configuration
104 shell: su buildbot -c "sh -e {0}"
105 working-directory: openwrt
106 run: ./scripts/diffconfig.sh
107
108 - name: Build tools
109 shell: su buildbot -c "sh -e {0}"
110 working-directory: openwrt
111 run: make tools/install -j$(nproc) BUILD_LOG=1
112
113 - name: Build toolchain
114 shell: su buildbot -c "sh -e {0}"
115 working-directory: openwrt
116 run: make toolchain/install -j$(nproc) BUILD_LOG=1
117
118 - name: Build Kernel
119 shell: su buildbot -c "sh -e {0}"
120 working-directory: openwrt
121 run: make target/compile -j$(nproc) BUILD_LOG=1
122
123 - name: Upload logs
124 if: failure()
125 uses: actions/upload-artifact@v2
126 with:
127 name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs
128 path: "openwrt/logs"