From bebda8098511d7f042a201823ed4b46425492d75 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Sun, 8 Nov 2026 13:40:50 +0800 Subject: [PATCH] Let the 24.10 lane pin an explicit kernel version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改动:kernel_version 输入对两个 lane 都生效,新增 sdk/arch 过滤(setup job 生成矩阵),限定过滤时跳过发布以免冲掉其它架构的包。 原因:24.10 的点版本内核与分支 HEAD 不一致,BTF 必须按用户实际 uname -r 构建,否则发出的 BTF 对不上任何一台常规设备。 --- .github/workflows/build.yml | 49 +++++++++++++++++++++++-------------- scripts/gen-matrix.py | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 18 deletions(-) create mode 100755 scripts/gen-matrix.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a705c7..a03ec6c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,15 @@ on: workflow_dispatch: inputs: kernel_version: - description: '25.12 影子内核版本覆盖(留空跟 SDK 走,如 6.12.112)' + description: '影子内核版本覆盖,两个 lane 都生效(留空跟 SDK 走,如 6.6.144 / 6.12.112)' + required: false + default: '' + sdk: + description: '只跑某个 SDK(24.10 / 25.12,留空全跑)' + required: false + default: '' + arch: + description: '只跑某个架构(如 x86_64,留空全跑)' required: false default: '' # quarterly safety net; kernel BTF only changes when the SDK kernel bumps @@ -12,33 +20,37 @@ on: - cron: '0 4 1 */3 *' jobs: + # 手动指定 sdk/arch 时只生成需要的组合:job 级 if 拿不到 matrix,只能先把 + # 组合算出来再交给 fromJSON。 + setup: + runs-on: ubuntu-22.04 + outputs: + matrix: ${{ steps.gen.outputs.matrix }} + steps: + - uses: actions/checkout@v7 + - id: gen + env: + WANT_SDK: ${{ inputs.sdk }} + WANT_ARCH: ${{ inputs.arch }} + run: python3 scripts/gen-matrix.py >> "$GITHUB_OUTPUT" + build: + needs: setup runs-on: ubuntu-22.04 timeout-minutes: 120 strategy: fail-fast: false - matrix: - arch: - - aarch64_cortex-a53 - - aarch64_cortex-a72 - - aarch64_generic - - arm_cortex-a7_neon-vfpv4 - - arm_cortex-a9_neon - - i386_pentium4 - - mips_24kc - - mipsel_24kc - - x86_64 - sdk: - - "24.10" - - "25.12" + matrix: ${{ fromJSON(needs.setup.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v7 # SDK 镜像的内核版本按架构分别重建,x86_64 等常落后;有输入时按输入编 + # 24.10 的点版本内核与分支 HEAD 不一致(例如 24.10.8 是 6.6.144, + # 分支已经到 6.6.159),BTF 必须按用户实际 uname -r 编,所以两个 lane 都支持覆盖。 - name: Pin shadow kernel version - if: matrix.sdk == '25.12' && inputs.kernel_version != '' + if: inputs.kernel_version != '' env: KERNEL_VERSION: ${{ inputs.kernel_version }} run: | @@ -94,8 +106,9 @@ jobs: release: needs: build - # 非 main 分支的试跑只出 artifact,不覆盖最新发布 - if: github.ref == 'refs/heads/main' + # 只出 artifact 的场景:非 main 分支试跑、以及手动限定 sdk/arch 的单点构建。 + # 发布用 removeArtifacts 全量替换,单点构建一旦发布会把其它架构的包冲掉。 + if: github.ref == 'refs/heads/main' && inputs.sdk == '' && inputs.arch == '' runs-on: ubuntu-22.04 permissions: contents: write diff --git a/scripts/gen-matrix.py b/scripts/gen-matrix.py new file mode 100755 index 0000000..d1eb4d4 --- /dev/null +++ b/scripts/gen-matrix.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +"""Print the (sdk, arch) build matrix as `matrix={json}` for $GITHUB_OUTPUT. + +24.10 的点版本内核与分支 HEAD 不一致(例如 24.10.8 是 6.6.144,分支已到 6.6.159), +所以按需只编某一份,避免每次都排 18 个组合。 +""" +import json +import os +import sys + +ARCHES = [ + "aarch64_cortex-a53", + "aarch64_cortex-a72", + "aarch64_generic", + "arm_cortex-a7_neon-vfpv4", + "arm_cortex-a9_neon", + "i386_pentium4", + "mips_24kc", + "mipsel_24kc", + "x86_64", +] +SDKS = ["24.10", "25.12"] + + +def main() -> int: + want_sdk = os.environ.get("WANT_SDK", "").strip() + want_arch = os.environ.get("WANT_ARCH", "").strip() + if want_sdk and want_sdk not in SDKS: + print(f"unknown sdk: {want_sdk}", file=sys.stderr) + return 2 + if want_arch and want_arch not in ARCHES: + print(f"unknown arch: {want_arch}", file=sys.stderr) + return 2 + include = [ + {"sdk": sdk, "arch": arch} + for sdk in SDKS + if not want_sdk or sdk == want_sdk + for arch in ARCHES + if not want_arch or arch == want_arch + ] + print("matrix=" + json.dumps({"include": include})) + return 0 + + +if __name__ == "__main__": + sys.exit(main())