ci: cut releases in CI without building firmware

The 155-target build matrix cost 6-7 runner hours per release and got
Actions disabled on the fork. Firmware is now built and uploaded locally
(scripts/local-release-build.sh); CI keeps only the parts that are cheap
and need to be centralized.

- filter-build.yml: drop the validate-targets and build jobs and the
  targets input; keep the version job (tag scheme and change gate are
  unchanged) and create the release with no assets — the local script
  fills the assets in afterwards
- sync-upstream.yml: same two calls, retitled Create release; the
  force_build input now means create-the-release, not build
- AGENTS.md: describe the new split and where the stack-usage gate lives

Also disabled the upstream firmware-builder workflows at the fork level
(Actions settings, no file changes, so weekly upstream syncs cannot
conflict): build-{companion,repeater,room-server}-firmwares,
firmware-builder, and pr-build-check, which built firmware on every
push to main/dev — i.e. on every weekly sync.
This commit is contained in:
Jason Huebert committed 2026-10-09 12:38:55 -05:00
1 parent 7afc0ee6b8
commit ddaa76e2e7
3 files changed
+30 -205

No files matched your search

+10 -191
View File
@@ -1,4 +1,4 @@
name: Filter Firmware Build
name: Filter Release
on:
workflow_call:
@@ -8,23 +8,18 @@ on:
required: false
type: string
default: dev
targets:
description: Comma- or newline-separated build targets (defaults to every repeater target this branch defines)
required: false
type: string
default: ""
branch:
description: Branch to build (defaults to the channel's branch)
description: Branch to release (defaults to the channel's branch)
required: false
type: string
default: ""
create_release:
description: Attach the built firmware to a release
description: Create the release
required: false
type: boolean
default: true
force_build:
description: Build even if nothing changed since the last release of this channel
description: Create the release even if nothing changed since the last one of this channel
required: false
type: boolean
default: false
@@ -38,23 +33,18 @@ on:
options:
- dev
- stable
targets:
description: Comma- or newline-separated build targets (defaults to every repeater target this branch defines)
required: false
type: string
default: ""
branch:
description: Branch to build (defaults to the channel's branch)
description: Branch to release (defaults to the channel's branch)
required: false
type: string
default: ""
create_release:
description: Attach the built firmware to a release
description: Create the release
required: false
type: boolean
default: true
force_build:
description: Build even if nothing changed since the last release of this channel
description: Create the release even if nothing changed since the last one of this channel
required: false
type: boolean
default: true
@@ -235,187 +225,16 @@ jobs:
// the exact revision everything below was derived from and built at
core.setOutput('source_sha', git('rev-parse', 'HEAD').trim());
validate-targets:
name: Validate build targets
needs: version
if: needs.version.outputs.skip != 'true'
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.validate.outputs.targets }}
steps:
- name: Clone Repo
uses: actions/checkout@v6
with:
# the revision the release names, not the branch tip: the target list
# must describe the same tree the firmware is built from
ref: ${{ needs.version.outputs.source_sha }}
- name: Setup Build Environment
uses: ./.github/actions/setup-build-environment
- name: Validate Build Targets
id: validate
uses: actions/github-script@v8
env:
TARGETS_INPUT: ${{ inputs.targets }}
with:
script: |
const { execFileSync } = require('child_process');
// known targets come from platformio.ini via build.sh
// build.sh uses bash arrays; /bin/sh is not a contract
const known = execFileSync('bash', ['build.sh', 'list'], { encoding: 'utf8' })
.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
// explicit input wins (via env: an input containing a quote must
// stay data); otherwise every repeater firmware this branch defines
const input = (process.env.TARGETS_INPUT || '').trim();
const selected = new Set();
if (input) {
for (const target of input.split(/[\s,]+/).filter(Boolean)) {
if (known.includes(target)) {
selected.add(target);
} else {
// warn and skip unknown names instead of failing: a target can
// be valid on the dev branch but not yet on stable's upstream base
core.warning(`unknown build target '${target}' - skipped (not in this branch's platformio.ini)`);
}
}
} else {
for (const target of known) {
if (/repeater/i.test(target)) selected.add(target);
}
}
if (selected.size === 0) {
core.setFailed("No known build targets: pass the 'targets' input, or this branch defines no repeater firmware");
return;
}
core.setOutput('targets', JSON.stringify([...selected]));
build:
name: Build ${{ matrix.target }}
needs: [version, validate-targets]
if: needs.version.outputs.skip != 'true'
runs-on: ubuntu-latest
# Dev publishes what built; a board that failed is visible as a red matrix
# job in the run. Stable does NOT skip failures: a stable release is
# what users install, so any requested board failing must block it.
continue-on-error: ${{ inputs.channel != 'stable' }}
strategy:
matrix:
target: ${{ fromJson(needs.validate-targets.outputs.targets) }}
fail-fast: false
steps:
- name: Clone Repo
uses: actions/checkout@v6
with:
# pinned, like the target list: if the branch moved after version
# selection, the release body and the tag would all name
# a revision this job never built
ref: ${{ needs.version.outputs.source_sha }}
- name: Setup Build Environment
uses: ./.github/actions/setup-build-environment
- name: Build Firmware
uses: actions/github-script@v8
env:
FIRMWARE_VERSION: ${{ needs.version.outputs.firmware_version }}
TARGET: ${{ matrix.target }}
# metadata-only (emits .su files next to the objects; codegen is
# unchanged) — consumed by the stack usage check below
PLATFORMIO_BUILD_FLAGS: -fstack-usage
with:
script: |
const { spawnSync } = require('child_process');
const target = process.env.TARGET;
const r = spawnSync('bash', ['build.sh', 'build-firmware', target], { stdio: 'inherit' });
if (r.error) throw r.error;
if (r.status !== 0) throw new Error(`build.sh build-firmware ${target} exited with status ${r.status}`);
- name: Stack usage check
# One big stack scratch array in boot- or loop-path code brick-reboots
# every repeater flashed with the release (2026-10: an 8.5 KB scratch
# in FilterRules::load overflowed the 4 KB nRF52 / 8 KB ESP32 loop
# task stacks at boot). The compiler's own accounting catches that
# class on every target we publish; the binary is unaffected.
uses: actions/github-script@v8
env:
TARGET: ${{ matrix.target }}
STACK_FRAME_LIMIT: 2048
with:
script: |
const fs = require('fs');
const path = require('path');
const limit = parseInt(process.env.STACK_FRAME_LIMIT, 10);
const suDir = path.join('.pio', 'build', process.env.TARGET);
// repo code only: src/ and examples/. Vendored crypto (lib/ed25519) and
// libdeps libraries carry frames above the limit that ship today and are
// not what this repo edits; gating them would train everyone to ignore
// the check. The frames this repo owns are the ones it can break.
const suFiles = [];
const walk = (dir) => {
if (!fs.existsSync(dir)) return;
for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
const p = path.join(dir, ent.name);
if (ent.isDirectory()) walk(p);
else if (p.endsWith('.su')) suFiles.push(p);
}
};
walk(path.join(suDir, 'src'));
walk(path.join(suDir, 'examples'));
if (suFiles.length === 0) {
core.setFailed(`ERROR: no .su files under ${suDir} — the build did not run with -fstack-usage, check is blind`);
return;
}
// .su lines are "file:line:col:function\tbytes\ttype"
const offenders = [];
for (const f of suFiles) {
for (const line of fs.readFileSync(f, 'utf8').split('\n')) {
if (!line.trim()) continue;
const [loc, size] = line.split('\t');
if (parseInt(size, 10) >= limit) offenders.push(`${size} B ${loc}`);
}
}
if (offenders.length > 0) {
core.setFailed(`ERROR: stack frames >= ${limit} B (loop task is 4 KB on nRF52, 8 KB on ESP32):\n${offenders.join('\n')}`);
return;
}
core.info(`OK: ${suFiles.length} translation units, no stack frame >= ${limit} B`);
- name: Upload Workflow Artifacts
uses: actions/upload-artifact@v7
with:
# channel prefix keeps the two concurrently-built channels' artifacts
# from colliding in the shared artifact store
name: "firmware-${{ inputs.channel }}-${{ matrix.target }}"
path: out
if-no-files-found: error
release:
name: Create Release
# validate-targets rides in through build's own needs; a skipped build
# (nothing to release) skips this job the same way
needs: [version, build]
needs: [version]
if: inputs.create_release
runs-on: ubuntu-latest
# only this job writes; build and test jobs stay at contents: read
# only this job writes; the version job stays at contents: read
permissions:
contents: write
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v8
with:
pattern: "firmware-${{ inputs.channel }}-*"
merge-multiple: true
path: out
- name: Create Release
uses: softprops/action-gh-release@v3
with:
@@ -425,6 +244,6 @@ jobs:
prerelease: ${{ inputs.channel != 'stable' }}
make_latest: ${{ inputs.channel == 'stable' && 'true' || 'false' }}
# release notes are written by hand after the release is created
# firmware assets are built and uploaded locally (scripts/local-release-build.sh)
body: "Built from commit `${{ needs.version.outputs.source_sha }}`."
files: out/*
target_commitish: ${{ needs.version.outputs.source_sha }}
+9 -7
View File
@@ -6,7 +6,7 @@ on:
workflow_dispatch:
inputs:
force_build:
description: Build firmware even if upstream is unchanged
description: Create the release even if upstream is unchanged
required: false
type: boolean
default: false
@@ -39,9 +39,11 @@ jobs:
sync:
name: Sync upstream and filter branches
runs-on: ubuntu-latest
# dev is built when the integration branch moved; stable only when it was
# promoted (building the channel that did not move would re-tag a release
# for no reason) — outputs map straight from the steps that did the work
# dev gets a release when the integration branch moved; stable only when it
# was promoted (re-releasing the channel that did not move would re-tag a
# release for no reason) — outputs map straight from the steps that did the
# work. Firmware itself is built and uploaded locally
# (scripts/local-release-build.sh); CI only cuts the tag and release.
outputs:
dev_changed: ${{ steps.merge.outputs.merged }}
stable_changed: ${{ steps.stable.outputs.pushed }}
@@ -280,7 +282,7 @@ jobs:
failure-message: 'Upstream sync conflict in repeater-filter-stable; resolve locally, push the branch, then close this issue.'
build-dev:
name: Build firmware (dev)
name: Create release (dev)
needs: sync
if: needs.sync.outputs.dev_changed == 'true' || inputs.force_build == true
uses: ./.github/workflows/filter-build.yml
@@ -290,9 +292,9 @@ jobs:
force_build: ${{ inputs.force_build == true }}
build-stable:
name: Build firmware (stable)
name: Create release (stable)
needs: sync
# stable is built only when it was deliberately promoted; it never needs
# stable is released only when it was deliberately promoted; it never needs
# force_build because the promotion step is the only way it gets triggered
if: needs.sync.outputs.stable_changed == 'true'
uses: ./.github/workflows/filter-build.yml
+11 -7
View File
@@ -98,11 +98,14 @@ family** before calling persistence work done: `Xiao_S3_WIO_repeater`,
`RAK_4631_repeater` (nRF52), `PicoW_repeater`, `wio-e5_repeater` — host-native
tests cannot catch a platform-specific API difference, and one did (the nRF52
file type has no default constructor).
`.github/workflows/filter-build.yml` builds release channels (dev →
`repeater-filter`, stable → `repeater-filter-stable`); `sync-upstream.yml` merges
upstream weekly and promotes stable only on explicit dispatch. Upstream's own
docs live in `docs/` (MeshCore protocol/CLI generally) — not fork-filter
documentation.
`.github/workflows/filter-build.yml` cuts release channels (dev →
`repeater-filter`, stable → `repeater-filter-stable`) — tag + release object
only; the firmware assets are built locally with
`scripts/local-release-build.sh` and uploaded to the release with `gh`
(CI no longer builds firmware — the 155-target runner fan-out got Actions
shut down). `sync-upstream.yml` merges upstream weekly and promotes stable
only on explicit dispatch. Upstream's own docs live in `docs/` (MeshCore
protocol/CLI generally) — not fork-filter documentation.
## Branch model
@@ -255,8 +258,9 @@ FILTER.md:
crash-loops every repeater flashed with the release (2026-10: ~8.5 KB of
scratch in `FilterRules::load()` did exactly that). Measure frames with
`PLATFORMIO_BUILD_FLAGS=-fstack-usage pio run -e <env>` before committing
large local arrays; `filter-build.yml` fails any release target whose
`src/`/`examples/` code holds a frame >= 2 KB — keep new frames well
large local arrays; the stack gate in `scripts/local-release-build.sh`
fails any release target whose `src/`/`examples/` code holds a frame
>= 2 KB (formerly a filter-build.yml CI check) — keep new frames well
under it.
- Pure refactors keep both suites green **unchanged** — the suites (295 filter,
82 fleet, 44 battery) are the safety net that proves no behavior slipped.