From e62627175ad5f2419bc071ace512fb2012068e61 Mon Sep 17 00:00:00 2001 From: Shinku <17696928+Shinku-Chen@users.noreply.github.com> Date: Fri, 28 Aug 2026 17:03:32 +0800 Subject: [PATCH] ci: split PR checks into static and firmware workflows Split the old ci.yml into two focused workflows so the ESP-IDF firmware build only runs when the change actually touches firmware. - static-checks.yml: repository/host checks on every PR, push to main, and manual dispatch. - firmware-checks.yml: ESP-IDF build with paths-ignore for docs/**, plays/**, skills/**, and *.md so documentation-only changes skip the firmware build. assets/** is intentionally not ignored (may embed fonts/images/audio). - Update CI-validation.md (+ zh_CN) to describe the two workflows, the path filtering, and the required-check compatibility caveat. --- .../workflows/{ci.yml => firmware-checks.yml} | 28 ++++++-------- .github/workflows/static-checks.yml | 30 +++++++++++++++ docs/development/CI-validation.md | 38 ++++++++++++++++--- docs/development/CI-validation.zh_CN.md | 30 ++++++++++++--- 4 files changed, 100 insertions(+), 26 deletions(-) rename .github/workflows/{ci.yml => firmware-checks.yml} (70%) create mode 100644 .github/workflows/static-checks.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/firmware-checks.yml similarity index 70% rename from .github/workflows/ci.yml rename to .github/workflows/firmware-checks.yml index ab6441f..05dbe8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/firmware-checks.yml @@ -1,34 +1,30 @@ -name: Pull request checks +name: Firmware checks on: pull_request: + paths-ignore: + - "docs/**" + - "plays/**" + - "skills/**" + - "*.md" push: branches: - main + paths-ignore: + - "docs/**" + - "plays/**" + - "skills/**" + - "*.md" workflow_dispatch: permissions: contents: read concurrency: - group: ci-${{ github.ref }} + group: firmware-${{ github.ref }} cancel-in-progress: true jobs: - static: - name: Repository and host checks - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - - - name: Install verified actionlint - run: | - actionlint_bin="$(./tools/install-actionlint.sh "$RUNNER_TEMP/actionlint")" - echo "ACTIONLINT_BIN=${actionlint_bin}" >> "$GITHUB_ENV" - - - name: Validate repository and run host tests - run: ./tools/validate.sh --static - firmware: name: ESP-IDF 5.5.3 firmware runs-on: ubuntu-latest diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml new file mode 100644 index 0000000..3cd3389 --- /dev/null +++ b/.github/workflows/static-checks.yml @@ -0,0 +1,30 @@ +name: Static checks + +on: + pull_request: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: static-${{ github.ref }} + cancel-in-progress: true + +jobs: + static: + name: Repository and host checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + + - name: Install verified actionlint + run: | + actionlint_bin="$(./tools/install-actionlint.sh "$RUNNER_TEMP/actionlint")" + echo "ACTIONLINT_BIN=${actionlint_bin}" >> "$GITHUB_ENV" + + - name: Validate repository and run host tests + run: ./tools/validate.sh --static diff --git a/docs/development/CI-validation.md b/docs/development/CI-validation.md index 6319121..b68a7a5 100644 --- a/docs/development/CI-validation.md +++ b/docs/development/CI-validation.md @@ -4,14 +4,42 @@ # Pull Request Validation -`.github/workflows/ci.yml` runs for pull requests, pushes to `main`, and manual dispatch. Local development and CI share `tools/validate.sh`. +Two workflows validate pull requests: `.github/workflows/static-checks.yml` and +`.github/workflows/firmware-checks.yml`. Both run for pull requests, pushes to +`main`, and manual dispatch; local development and CI share `tools/validate.sh`. -## Jobs +## Workflows -- **Repository and host checks:** validates English-default bilingual Markdown, relative links, full-SHA Actions, issue forms, the dependency lock, conflict markers, and likely sensitive data; then runs `actionlint` and host tests. -- **ESP-IDF 5.5.3 firmware:** runs `./tools/validate.sh --firmware` for ESP32-C3 in a fresh isolated build/configuration directory, verifies the build and merged `0x0` image contents/offsets, and retains the artifact for seven days. +- **Static checks** (`static-checks.yml`): validates English-default bilingual + Markdown, relative links, full-SHA Actions, issue forms, the dependency lock, + conflict markers, and likely sensitive data; then runs `actionlint` and host + tests. It runs on every pull request. +- **Firmware checks** (`firmware-checks.yml`): runs + `./tools/validate.sh --firmware` for ESP32-C3 in a fresh isolated + build/configuration directory, verifies the build and the merged `0x0` image + contents/offsets, and retains the artifact for seven days. -The workflow has only `contents: read` and uses no repository secrets, so it can validate fork pull requests. Every GitHub Action is pinned to a full commit SHA. +## Path filtering + +`firmware-checks.yml` ignores paths that cannot affect the firmware build: +`docs/**`, `plays/**`, `skills/**`, and `*.md`. A documentation-only pull request +therefore runs the static checks but skips the firmware build. `assets/**` is +intentionally **not** ignored: `assets/` holds reusable fonts, images, music, and +sound effects that may be embedded into the firmware, so any asset change must +trigger the firmware build. + +## Path filtering vs required checks + +A path-filtered workflow that is skipped produces no check run for that job. If +the firmware job is ever configured as a **required** status check, a +documentation-only pull request would have no firmware check to satisfy and could +block merging. Keep this in mind before marking the firmware job required; if it +is required, the path filter must be revisited (for example, split the job into a +documentation-only pass/fail stub, or use a single unconditional workflow). + +Both workflows have only `contents: read` and use no repository secrets, so they +can validate fork pull requests. Every GitHub Action is pinned to a full commit +SHA. ## Reproduce locally diff --git a/docs/development/CI-validation.zh_CN.md b/docs/development/CI-validation.zh_CN.md index 05f1681..b885c07 100644 --- a/docs/development/CI-validation.zh_CN.md +++ b/docs/development/CI-validation.zh_CN.md @@ -4,14 +4,34 @@ # PR 自动验证(CI Validation) -`.github/workflows/ci.yml` 在 Pull Request、`main` push 和手动触发时运行,与本地共用 `tools/validate.sh`。 +两个工作流验证 PR:`.github/workflows/static-checks.yml` 与 +`.github/workflows/firmware-checks.yml`。两者都在 Pull Request、`main` push 和手动触发时运行, +与本地共用 `tools/validate.sh`。 -## Jobs +## 工作流 -- **Repository and host checks**:校验 Markdown 相对链接、GitHub Action 完整 SHA、Issue Form 基本结构、依赖锁文件、冲突标记和疑似敏感信息;随后运行 `actionlint` 与 host tests。 -- **ESP-IDF 5.5.3 firmware**:在全新隔离的构建/配置目录中,使用 ESP-IDF 5.5.3 / ESP32-C3 运行 `./tools/validate.sh --firmware`,验证编译、0x0 合并固件及其中三个映像的偏移和内容,并保留 7 天 Actions artifact。 +- **Static checks**(`static-checks.yml`):校验英文默认双语 Markdown、相对链接、GitHub Action + 完整 SHA、Issue Form 基本结构、依赖锁文件、冲突标记和疑似敏感信息;随后运行 `actionlint` 与 + host tests。它在每个 pull request 上运行。 +- **Firmware checks**(`firmware-checks.yml`):在全新隔离的构建/配置目录中,使用 ESP-IDF 5.5.3 / + ESP32-C3 运行 `./tools/validate.sh --firmware`,验证编译、0x0 合并固件的偏移与内容,并保留 7 天 + Actions artifact。 -工作流只有 `contents: read` 权限,不使用仓库 secrets,因此可以安全验证来自 fork 的 PR。所有 GitHub Actions 固定到完整 commit SHA;升级时必须核对官方版本、更新 SHA 注释并运行 `actionlint`。 +## 路径过滤 + +`firmware-checks.yml` 忽略不会影响固件构建的路径:`docs/**`、`plays/**`、`skills/**` 与 `*.md`。 +因此纯文档的 pull request 只跑 static checks、跳过固件构建。`assets/**` **故意不**忽略:`assets/` +存放可复用的字体、图片、音乐与音效,未来可能被嵌入固件,因此任何资源变更都必须触发固件构建。 + +## 路径过滤与 required check 的兼容性 + +被路径过滤跳过的 workflow 不会为那个 job 产生 check run。若未来把 firmware job 设为 **required** +状态检查,纯文档的 pull request 将没有 firmware check 可满足,从而可能阻塞合并。在把 firmware job +设为 required 之前请谨记这一点;若确需 required,必须重新审视路径过滤(例如把 job 拆出一个 +文档专用的 pass/fail 桩,或改用单一无条件 workflow)。 + +两个工作流都只有 `contents: read` 权限、不使用仓库 secrets,因此可以安全验证来自 fork 的 PR。 +所有 GitHub Actions 固定到完整 commit SHA;升级时必须核对官方版本、更新 SHA 注释并运行 `actionlint`。 ## 本地复现