fix: correct patch strip level for out-of-tree build #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Validate Drivers | |
| on: | |
| push: | |
| branches: ['v5.4', 'v5.15', 'v6.1', 'v6.6', 'v6.12'] | |
| workflow_dispatch: | |
| concurrency: | |
| group: build-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| kv: ${{ steps.m.outputs.kv }} | |
| major: ${{ steps.m.outputs.major }} | |
| steps: | |
| - id: m | |
| run: | | |
| REF="${GITHUB_REF_NAME}" | |
| [[ "$REF" == */merge ]] && REF="${{ github.head_ref }}" | |
| KV="${REF#v}" | |
| echo "kv=${KV}" >> "$GITHUB_OUTPUT" | |
| echo "major=${KV%%.*}" >> "$GITHUB_OUTPUT" | |
| validate-patches: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download kernel ${{ needs.setup.outputs.kv }} | |
| run: | | |
| KV="${{ needs.setup.outputs.kv }}" | |
| MAJ="${{ needs.setup.outputs.major }}" | |
| curl -fSL --retry 3 -o /tmp/linux.tar.xz \ | |
| "https://cdn.kernel.org/pub/linux/kernel/v${MAJ}.x/linux-${KV}.tar.xz" | |
| mkdir -p /tmp/linux-src | |
| tar xf /tmp/linux.tar.xz -C /tmp/linux-src --strip-components=1 | |
| - name: Dry-run patches against kernel source | |
| run: | | |
| cd /tmp/linux-src | |
| ERRORS=0 | |
| for pf in "$GITHUB_WORKSPACE/patches"/*.patch; do | |
| [ -f "$pf" ] || continue | |
| name=$(basename "$pf") | |
| if head -1 "$pf" | grep -q "No changes"; then | |
| echo "⊘ $name: no changes needed" | |
| continue | |
| fi | |
| echo "→ Testing: $name ($(wc -l < "$pf") lines)" | |
| if patch --dry-run -p1 < "$pf"; then | |
| echo "✓ $name applies cleanly" | |
| else | |
| echo "✗ $name FAILED" | |
| ERRORS=$((ERRORS + 1)) | |
| fi | |
| done | |
| exit $ERRORS | |
| build-out-of-tree: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install deps | |
| run: sudo apt-get update -qq && sudo apt-get install -y -qq build-essential libelf-dev bc flex bison | |
| - name: Download kernel ${{ needs.setup.outputs.kv }} | |
| run: | | |
| KV="${{ needs.setup.outputs.kv }}" | |
| MAJ="${{ needs.setup.outputs.major }}" | |
| curl -fSL --retry 3 -o /tmp/linux.tar.xz \ | |
| "https://cdn.kernel.org/pub/linux/kernel/v${MAJ}.x/linux-${KV}.tar.xz" | |
| tar xf /tmp/linux.tar.xz -C /tmp --strip-components=1 | |
| - name: Minimal kernel config + vmlinux | |
| run: | | |
| cd /tmp | |
| make tinyconfig | |
| cat >> .config <<'EOF' | |
| CONFIG_64BIT=y | |
| CONFIG_MODULES=y | |
| CONFIG_MODULE_UNLOAD=y | |
| CONFIG_USB=y | |
| CONFIG_USB_SUPPORT=y | |
| CONFIG_USB_COMMON=y | |
| CONFIG_USB_ARCH_HAS_HCD=y | |
| CONFIG_NET=y | |
| CONFIG_INET=y | |
| CONFIG_TTY=y | |
| CONFIG_PRINTK=y | |
| CONFIG_PROC_FS=y | |
| CONFIG_SYSFS=y | |
| CONFIG_DEVTMPFS=y | |
| CONFIG_GENERIC_ALLOCATOR=y | |
| CONFIG_CRC32=y | |
| CONFIG_CRC_CCITT=y | |
| CONFIG_CRC16=y | |
| CONFIG_USB_SERIAL=m | |
| CONFIG_USB_SERIAL_WWAN=m | |
| CONFIG_USB_SERIAL_OPTION=m | |
| CONFIG_USB_NET_DRIVERS=m | |
| CONFIG_USB_ACM=m | |
| CONFIG_WWAN_CORE=m | |
| CONFIG_WWAN=y | |
| EOF | |
| make olddefconfig 2>&1 | tail -3 | |
| make vmlinux -j$(nproc) HOSTCFLAGS="-Wno-error" 2>&1 | tail -5 | |
| make modules_prepare -j$(nproc) HOSTCFLAGS="-Wno-error" 2>&1 | tail -5 | |
| - name: Build out-of-tree with Makefile | |
| run: | | |
| make KDIR=/tmp 2>&1 | tee /tmp/build.log || true | |
| echo "=== Build log tail ===" | |
| tail -30 /tmp/build.log | |
| - name: Verify modules | |
| run: | | |
| ERRORS=0 | |
| for mod in option.ko usb_wwan.ko qmi_wwan.ko; do | |
| found=$(find build/ -name "$mod" -print -quit 2>/dev/null) | |
| if [ -n "$found" ]; then | |
| echo "✓ $mod" | |
| else | |
| echo "✗ $mod NOT found" | |
| ERRORS=$((ERRORS + 1)) | |
| fi | |
| done | |
| if grep -E 'error:' /tmp/build.log | grep -qv 'warning'; then | |
| echo "✗ Compilation errors:" | |
| grep -E 'error:' /tmp/build.log | head -10 | |
| ERRORS=$((ERRORS + 1)) | |
| fi | |
| exit $ERRORS | |
| summary: | |
| needs: [setup, validate-patches, build-out-of-tree] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: | | |
| echo "## kernel ${{ needs.setup.outputs.kv }}" | |
| echo "patches: ${{ needs.validate-patches.result }}" | |
| echo "build: ${{ needs.build-out-of-tree.result }}" | |
| [ "${{ needs.validate-patches.result }}" = "success" ] && \ | |
| [ "${{ needs.build-out-of-tree.result }}" = "success" ] || exit 1 |