Uh oh!
There was an error while loading. Please reload this page.
ci: Self-built toolchains, git-based versioning, and automated SDK/firmware releases - #14
Conversation
- Switch Dockerfile to a multi-stage build that compiles riscv-gnu-toolchain from source and reuses it in the ci/develop targets - Update docker-image.yml to build/push per-arch digests for librmcs-ci and librmcs-develop, then publish multi-arch manifests - Simplify firmware/.clangd thanks to the stable in-image toolchain layout, and add .dockerignore to trim build context
Caution Review failedThe pull request is closed. Walkthrough本次变更新增并重构了多阶段容器构建与发布管道、引入自动版本生成脚本、添加专用 SDK/固件 构建 Dockerfile,并在固件与主机 CMake 中暴露版本与调整打包流程。 Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub Actions
participant WF as docker-image.yml
participant Buildx as Docker Buildx
participant Registry as Container Registry
participant Artifacts as Artifact Storage
GH->>WF: 触发(push/merge)
WF->>WF: Free disk space
WF->>Buildx: Build & push CI (target=ci, platforms, push-by-digest)
Buildx->>Registry: 推送 CI 镜像层
Buildx-->>WF: 输出 CI digest
WF->>Artifacts: 上传 CI digest artifact
WF->>Buildx: Build & push Develop (target=develop, push-by-digest)
Buildx->>Registry: 推送 Develop 镜像层
Buildx-->>WF: 输出 Develop digest
WF->>Artifacts: 上传 Develop digest artifact
WF->>Artifacts: 下载 CI digest -> ci/
WF->>Artifacts: 下载 Develop digest -> develop/
WF->>Buildx: Create CI manifest list (ci/)
Buildx->>Registry: 推送 CI manifest list
WF->>Buildx: Create Develop manifest list (develop/)
Buildx->>Registry: 推送 Develop manifest list
WF->>Buildx: Inspect final CI & Develop images
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
Dockerfile (2)
84-90: ARM GNU工具链下载缺少完整性校验当前代码直接下载并解压 ARM GNU工具链,缺少完整性校验会产生供应链风险。ARM 官方在 Arm Developer 下载页面提供
.sha256asc校验文件,建议引入 SHA256 校验并在校验失败时中止构建。校验实现示例
+ARG ARM_GNU_TOOLCHAIN_SHA256 RUN VERSION=15.2.rel1 \ && wget https://developer.arm.com/-/media/Files/downloads/gnu/${VERSION}/binrel/arm-gnu-toolchain-${VERSION}-${TARGETARCH_UNAME}-arm-none-eabi.tar.xz \ -O arm-gnu-toolchain.tar.xz \ + && echo "${ARM_GNU_TOOLCHAIN_SHA256} arm-gnu-toolchain.tar.xz" | sha256sum -c - \ && tar -xvf arm-gnu-toolchain.tar.xz -C /opt/ \
27-77: Dockerfile${VAR/old/new}替换依赖 BuildKit,在常规构建中可能不工作
ARG TARGETARCH_UNAME=${TARGETARCH/amd64/x86_64}这种参数展开语法需要启用 BuildKit(如docker buildx或DOCKER_BUILDKIT=1),以及声明正确的 frontend(如# syntax=docker/dockerfile:1)。如果构建环境未启用 BuildKit,变量会解析为空或被当作字面值,导致后续路径失效。为提高可移植性和兼容性,建议在
RUN中用显式的case映射替代:🛠️ 修正示例
-ARG TARGETARCH_UNAME=${TARGETARCH/amd64/x86_64}-ARG TARGETARCH_UNAME=${TARGETARCH_UNAME/arm64/aarch64}+ARG TARGETARCH_UNAME ... -RUN apt-get update \+RUN case "$TARGETARCH" in \+ amd64) TARGETARCH_UNAME=x86_64 ;; \+ arm64) TARGETARCH_UNAME=aarch64 ;; \+ *) echo "Unsupported TARGETARCH=$TARGETARCH" >&2; exit 1 ;; \+ esac \+ && apt-get update \
🤖 Fix all issues with AI agents
In @.scripts/generate_version:
- Line 1: The shebang in .scripts/generate_version is using an incorrect
hardcoded path (/bin/python3); update the script's shebang line so it uses the
environment lookup (/usr/bin/env python3) to ensure portability across
distributions — edit the first line of .scripts/generate_version to replace the
current shebang with the env-based one.
- Around line 71-80: The function format_version mutates the input release list
by doing release[-1] += 1 which causes side effects if the caller reuses the
same version tuple; to fix, do not modify release in place — make a shallow copy
(e.g., release_copy = list(release) or similar), increment the last element on
that copy, and use the copy when building trailing/version strings (update
references to release in format_version to use the copied list instead of
mutating the original release variable).
🧹 Nitpick comments (2)
.github/workflows/docker-image.yml (1)
37-51: 建议将 Free disk space 步骤提前到 Buildx 之前该动作会清理 Docker 镜像/缓存,放在 Buildx 初始化后可能影响 builder 与缓存命中;建议先清理再 setup Buildx。
🔧 调整顺序示例
- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v3-- - name: Free disk space- uses: BRAINSia/free-disk-space@v2- with:- tool-cache: false- mandb: true- android: true- dotnet: true- haskell: true- large-packages: true- docker-images: true- swap-storage: false+ - name: Free disk space+ uses: BRAINSia/free-disk-space@v2+ with:+ tool-cache: false+ mandb: true+ android: true+ dotnet: true+ haskell: true+ large-packages: true+ docker-images: true+ swap-storage: false++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v3Dockerfile (1)
16-21: 建议固定 riscv-gnu-toolchain 版本并核对 GCC 15.1 要求当前直接拉取最新 HEAD 会导致构建不可复现,且工具链版本可能漂移。建议通过 tag/commit 固定版本,并在需要时显式校验 GCC 版本。
Based on learnings, 固件构建要求 GCC 15.1,请确认所固定的提交满足该要求。♻️ 固定版本示例
+ARG RISCV_GNU_TOOLCHAIN_REF=<pin>-RUN git clone --depth 1 https://github.com/riscv-collab/riscv-gnu-toolchain \+RUN git clone https://github.com/riscv-collab/riscv-gnu-toolchain \ && cd /src/riscv-gnu-toolchain \ + && git checkout "${RISCV_GNU_TOOLCHAIN_REF}" \ && git submodule update --init --depth 1 binutils newlib gcc gdb \
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Add .scripts/generate_version to emit semver and Debian-friendly versions via git describe - Update host/firmware CMake to derive LIBRMCS_PROJECT_VERSION and expose LIBRMCS_PROJECT_VERSION_STRING - Stamp firmware USB product string and align CPack Debian packaging (headers install + versioned file names)
- Add release-package.yml to build SDK .deb (multi-arch) + optional source zip, and create a tag-triggered GitHub pre-release with uploaded artifacts - Introduce Dockerfile.build_sdk and Dockerfile.build_firmware to package SDK/firmware from qzhhhi/librmcs-ci with versioned outputs - Update host/CMakePresets.json with linux-debug/linux-release presets for the packaging builds
ci(release): Build and publish Docker-packaged artifacts
build(version): Generate versions from git tags
ci(docker): Self-build RISC-V toolchain for CI images
Pull Request 摘要
概述
本 PR 引入 CI/打包、基于 Git 的版本生成、自编译 RISC-V 工具链与多架构镜像发布流程,增加用于生成 SDK/固件的专用 Docker 构建文件,并将版本信息贯穿至固件 USB 描述符与 Debian 打包文件名,支持标签触发的预发布自动化流程。
主要改动
一、版本生成与暴露
二、CI / 打包与发布
三、Docker 与工具链
四、固件与源码调整
五、构建预设与安装/打包
技术亮点
兼容性与注意点