bc39eb359c55b429b7a50917b8c07fd0be054a06
[openwrt/staging/stintel.git] / .github / workflows / kernel.yml
1 name: Build Kernel
2
3 on:
4 pull_request:
5 paths:
6 - '.github/workflows/check-kernel-patches.yml'
7 - '.github/workflows/build.yml'
8 - '.github/workflows/kernel.yml'
9 - 'include/kernel*'
10 - 'package/kernel/**'
11 - 'target/linux/generic/**'
12 push:
13 paths:
14 - '.github/workflows/check-kernel-patches.yml'
15 - '.github/workflows/build.yml'
16 - '.github/workflows/kernel.yml'
17 - 'include/kernel*'
18 - 'package/kernel/**'
19 - 'target/linux/**'
20
21 permissions:
22 contents: read
23
24 concurrency:
25 group: ${{ github.workflow }}-${{ github.ref }}
26 cancel-in-progress: ${{ github.event_name == 'pull_request' }}
27
28 jobs:
29 determine_targets:
30 name: Set targets
31 runs-on: ubuntu-latest
32 outputs:
33 targets_subtargets: ${{ steps.find_targets.outputs.targets_subtargets }}
34 targets: ${{ steps.find_targets.outputs.targets }}
35
36 steps:
37 - name: Checkout
38 uses: actions/checkout@v3
39 with:
40 fetch-depth: 2
41
42 - name: Get changed files
43 id: changed-files
44 uses: tj-actions/changed-files@v35
45 with:
46 since_last_remote_commit: true
47
48 - name: Set targets
49 id: find_targets
50 run: |
51 export TARGETS_SUBTARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \
52 | sort -u -t '/' -k1 \
53 | awk '{ print $1 }')"
54
55 export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null \
56 | sort -u -t '/' -k1,1 \
57 | awk '{ print $1 }')"
58
59 JSON_TARGETS_SUBTARGETS='['
60 FIRST=1
61 for TARGET in $TARGETS_SUBTARGETS; do
62 if echo ${{ steps.changed-files.outputs.all_changed_files }} | grep -q target/linux/generic ||
63 echo ${{ steps.changed-files.outputs.all_changed_files }} | grep -q $(echo $TARGET | cut -d "/" -f 1); then
64 [[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"','
65 JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"'"'"${TARGET}"'"'
66 FIRST=0
67 fi
68 done
69 JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"']'
70
71 JSON_TARGETS='['
72 FIRST=1
73 for TARGET in $TARGETS; do
74 if echo ${{ steps.changed-files.outputs.all_changed_files }} | grep -q target/linux/generic ||
75 echo ${{ steps.changed-files.outputs.all_changed_files }} | grep -q $(echo $TARGET | cut -d "/" -f 1); then
76 [[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"','
77 JSON_TARGETS="$JSON_TARGETS"'"'"${TARGET}"'"'
78 FIRST=0
79 fi
80 done
81 JSON_TARGETS="$JSON_TARGETS"']'
82
83 echo -e "\n---- targets to build ----\n"
84 echo "$JSON_TARGETS_SUBTARGETS"
85 echo -e "\n---- targets to build ----\n"
86
87 echo -e "\n---- targets to check patch ----\n"
88 echo "$JSON_TARGETS"
89 echo -e "\n---- targets to check patch ----\n"
90
91 echo "targets_subtargets=$JSON_TARGETS_SUBTARGETS" >> $GITHUB_OUTPUT
92 echo "targets=$JSON_TARGETS" >> $GITHUB_OUTPUT
93
94 build:
95 name: Build Kernel with external toolchain
96 needs: determine_targets
97 permissions:
98 contents: read
99 packages: read
100 strategy:
101 fail-fast: False
102 matrix:
103 target: ${{fromJson(needs.determine_targets.outputs.targets_subtargets)}}
104 uses: ./.github/workflows/build.yml
105 with:
106 target: ${{ matrix.target }}
107 build_kernel: true
108 build_all_kmods: true
109
110 check-kernel-patches:
111 name: Check Kernel patches
112 needs: determine_targets
113 permissions:
114 contents: read
115 packages: read
116 strategy:
117 fail-fast: False
118 matrix:
119 target: ${{fromJson(needs.determine_targets.outputs.targets)}}
120 uses: ./.github/workflows/check-kernel-patches.yml
121 with:
122 target: ${{ matrix.target }}
123