CI: build: add support for per branch tools container
[openwrt/staging/stintel.git] / .github / workflows / check-kernel-patches.yml
1 name: Refresh kernel for target
2
3 on:
4 workflow_call:
5 inputs:
6 target:
7 required: true
8 type: string
9 testing:
10 type: boolean
11
12 permissions:
13 contents: read
14
15 jobs:
16 setup_build:
17 name: Setup build
18 runs-on: ubuntu-latest
19 outputs:
20 owner_lc: ${{ steps.lower_owner.outputs.owner_lc }}
21 container_tag: ${{ steps.determine_tools_container.outputs.container_tag }}
22
23 steps:
24 - name: Set lower case owner name
25 id: lower_owner
26 run: |
27 OWNER_LC=$(echo "${{ github.repository_owner }}" \
28 | tr '[:upper:]' '[:lower:]')
29 echo "owner_lc=$OWNER_LC" >> $GITHUB_OUTPUT
30
31 # Per branch tools container tag
32 # By default stick to latest
33 # For official test targetting openwrt stable branch
34 # Get the branch or parse the tag and push dedicated tools containers
35 # For local test to use the correct container for stable release testing
36 # you need to use for the branch name a prefix of openwrt-[0-9][0-9].[0-9][0-9]-
37 - name: Determine tools container tag
38 id: determine_tools_container
39 run: |
40 CONTAINER_TAG=latest
41 if [ -n "${{ github.base_ref }}" ]; then
42 if echo "${{ github.base_ref }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
43 CONTAINER_TAG="${{ github.base_ref }}"
44 fi
45 elif [ ${{ github.ref_type }} == "branch" ]; then
46 if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
47 CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
48 fi
49 elif [ ${{ github.ref_type }} == "tag" ]; then
50 if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
51 CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
52 fi
53 fi
54 echo "Tools container to use tools:$CONTAINER_TAG"
55 echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
56
57 check-patch:
58 name: Check Kernel patches
59 needs: setup_build
60 runs-on: ubuntu-latest
61
62 container: ghcr.io/${{ needs.setup_build.outputs.owner_lc }}/tools:${{ needs.setup_build.outputs.container_tag }}
63
64 permissions:
65 contents: read
66 packages: read
67
68 steps:
69 - name: Checkout master directory
70 uses: actions/checkout@v3
71 with:
72 path: openwrt
73
74 - name: Fix permission
75 run: |
76 chown -R buildbot:buildbot openwrt
77
78 - name: Initialization environment
79 run: |
80 TARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 1)
81 SUBTARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 2)
82 echo "TARGET=$TARGET" >> "$GITHUB_ENV"
83 echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
84
85 - name: Extract prebuilt tools
86 shell: su buildbot -c "sh -e {0}"
87 working-directory: openwrt
88 run: ./scripts/ext-tools.sh --tools /tools.tar
89
90 - name: Configure testing kernel
91 if: inputs.testing == true
92 shell: su buildbot -c "sh -e {0}"
93 working-directory: openwrt
94 run: |
95 echo CONFIG_TESTING_KERNEL=y >> .config
96
97 - name: Configure system
98 shell: su buildbot -c "sh -e {0}"
99 working-directory: openwrt
100 run: |
101 echo CONFIG_ALL_KMODS=y >> .config
102 echo CONFIG_DEVEL=y >> .config
103 echo CONFIG_AUTOREMOVE=y >> .config
104 echo CONFIG_CCACHE=y >> .config
105
106 echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config
107 echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config
108
109 make defconfig
110
111 - name: Build tools
112 shell: su buildbot -c "sh -e {0}"
113 working-directory: openwrt
114 run: make tools/quilt/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
115
116 - name: Refresh Kernel patches
117 shell: su buildbot -c "sh -e {0}"
118 working-directory: openwrt
119 run: |
120 make target/linux/refresh V=s
121
122 . .github/workflows/scripts/ci_helpers.sh
123
124 if git diff --name-only --exit-code; then
125 success "Kernel patches for ${{ env.TARGET }}/${{ env.SUBTARGET }} seems ok"
126 else
127 err "Kernel patches for ${{ env.TARGET }}/${{ env.SUBTARGET }} require refresh. (run 'make target/linux/refresh' and force push this pr)"
128 exit 1
129 fi