CI: fix matching for openwrt release branch for container selection
[openwrt/openwrt.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=${{ github.ref_name }}
48 elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
49 CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
50 fi
51 elif [ ${{ github.ref_type }} == "tag" ]; then
52 if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
53 CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
54 fi
55 fi
56 echo "Tools container to use tools:$CONTAINER_TAG"
57 echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
58
59 check-patch:
60 name: Check Kernel patches
61 needs: setup_build
62 runs-on: ubuntu-latest
63
64 container: ghcr.io/${{ needs.setup_build.outputs.owner_lc }}/tools:${{ needs.setup_build.outputs.container_tag }}
65
66 permissions:
67 contents: read
68 packages: read
69
70 steps:
71 - name: Checkout master directory
72 uses: actions/checkout@v3
73 with:
74 path: openwrt
75
76 - name: Fix permission
77 run: |
78 chown -R buildbot:buildbot openwrt
79
80 - name: Initialization environment
81 run: |
82 TARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 1)
83 SUBTARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 2)
84 echo "TARGET=$TARGET" >> "$GITHUB_ENV"
85 echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
86
87 - name: Extract prebuilt tools
88 shell: su buildbot -c "sh -e {0}"
89 working-directory: openwrt
90 run: ./scripts/ext-tools.sh --tools /tools.tar
91
92 - name: Configure testing kernel
93 if: inputs.testing == true
94 shell: su buildbot -c "sh -e {0}"
95 working-directory: openwrt
96 run: |
97 echo CONFIG_TESTING_KERNEL=y >> .config
98
99 - name: Configure system
100 shell: su buildbot -c "sh -e {0}"
101 working-directory: openwrt
102 run: |
103 echo CONFIG_ALL_KMODS=y >> .config
104 echo CONFIG_DEVEL=y >> .config
105 echo CONFIG_AUTOREMOVE=y >> .config
106 echo CONFIG_CCACHE=y >> .config
107
108 echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config
109 echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config
110
111 make defconfig
112
113 - name: Build tools
114 shell: su buildbot -c "sh -e {0}"
115 working-directory: openwrt
116 run: make tools/quilt/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
117
118 - name: Refresh Kernel patches
119 shell: su buildbot -c "sh -e {0}"
120 working-directory: openwrt
121 run: |
122 make target/linux/refresh V=s
123
124 . .github/workflows/scripts/ci_helpers.sh
125
126 if git diff --name-only --exit-code; then
127 success "Kernel patches for ${{ env.TARGET }}/${{ env.SUBTARGET }} seems ok"
128 else
129 err "Kernel patches for ${{ env.TARGET }}/${{ env.SUBTARGET }} require refresh. (run 'make target/linux/refresh' and force push this pr)"
130 exit 1
131 fi