ci: simplify workflows; default to all repeater targets

- filter-build.yml: with no explicit targets input, build every repeater
  target this branch defines (build.sh list, case-insensitive 'repeater'
  match) instead of falling back to the FIRMWARE_TARGETS repo variable,
  so the variable is no longer needed and stable publishes the full
  repeater set like dev. Explicit input still validates with the
  unknown-name warning.
- filter-build.yml: drop the dead 'Clear stale artifacts' step (fresh
  runner, no out/ can exist) and trim release needs/if: validate-targets
  is required transitively through build, and a skipped build skips the
  release anyway, so the skip re-check is redundant.
- sync-upstream.yml: the two near-identical conflict-issue scripts
  (~50 lines each) become calls to a new composite action
  .github/actions/open-conflict-issue; one authoritative copy of the
  marker/search/update-or-create/setFailed logic.
- sync-upstream.yml: 'Configure Git' is two git config lines, not a
  github-script step spawning git in a loop.

Verified: all YAML parses; simulated target selection against
build.sh list resolves 155 repeater targets with no non-repeater
leakage and a working explicit-input path.
This commit is contained in:
Jason Huebert committed 2026-10-08 11:15:47 -05:00
1 parent 6d51726193
commit 605fd54a3a
3 files changed
+115 -120

No files matched your search

@@ -0,0 +1,70 @@
name: Open conflict issue
description: >-
Create or update the merge-conflict issue for a failed sync (dev merge or
stable promotion), then fail the run. Conflict details come from a
workspace file written by the step that detected the conflict.
inputs:
marker:
description: Unique text marker used to find an already-open issue
required: true
files-file:
description: Workspace file holding the conflicted paths, one per line
required: true
title:
description: Issue title
required: true
intro:
description: First body paragraph (before the file list)
required: true
closing:
description: Final body paragraph (how to resolve)
required: true
failure-message:
description: Message used to fail the run
required: true
runs:
using: composite
steps:
- name: Create or update issue
uses: actions/github-script@v8
# inputs ride env, never string interpolation: issue text must stay data
env:
CONFLICT_MARKER: ${{ inputs.marker }}
CONFLICT_FILES_FILE: ${{ inputs.files-file }}
CONFLICT_TITLE: ${{ inputs.title }}
CONFLICT_INTRO: ${{ inputs.intro }}
CONFLICT_CLOSING: ${{ inputs.closing }}
CONFLICT_FAILURE: ${{ inputs.failure-message }}
with:
script: |
const fs = require('fs');
const files = fs.readFileSync(process.env.CONFLICT_FILES_FILE, 'utf8').trim() || '(none listed)';
const body = [
process.env.CONFLICT_MARKER,
process.env.CONFLICT_INTRO,
'',
'**Conflicted files:**',
'',
...files.split('\n').map((f) => '- ' + f),
'',
process.env.CONFLICT_CLOSING,
].join('\n');
const res = await github.rest.search.issuesAndPullRequests({
q: 'repo:' + context.repo.owner + '/' + context.repo.repo + ' is:issue is:open "' + process.env.CONFLICT_MARKER + '" in:body',
});
const payload = {
owner: context.repo.owner,
repo: context.repo.repo,
title: process.env.CONFLICT_TITLE,
body,
};
if (res.data.total_count > 0) {
await github.rest.issues.update({ ...payload, issue_number: res.data.items[0].number });
} else {
await github.rest.issues.create(payload);
}
// a conflict is a failure like any other, not a warning; this step
// is also where the conflicted step leaves the job failing
core.setFailed(process.env.CONFLICT_FAILURE);
+28 -35
View File
@@ -9,7 +9,7 @@ on:
type: string
default: dev
targets:
description: Comma- or newline-separated build targets (defaults to the FIRMWARE_TARGETS repo variable)
description: Comma- or newline-separated build targets (defaults to every repeater target this branch defines)
required: false
type: string
default: ""
@@ -39,7 +39,7 @@ on:
- dev
- stable
targets:
description: Comma- or newline-separated build targets (defaults to the FIRMWARE_TARGETS repo variable)
description: Comma- or newline-separated build targets (defaults to every repeater target this branch defines)
required: false
type: string
default: ""
@@ -259,42 +259,40 @@ jobs:
uses: actions/github-script@v8
env:
TARGETS_INPUT: ${{ inputs.targets }}
FIRMWARE_TARGETS: ${{ vars.FIRMWARE_TARGETS }}
with:
script: |
const { execFileSync } = require('child_process');
// resolve targets: explicit input, else FIRMWARE_TARGETS repo
// variable (both via env: an input containing a quote must stay data)
const input = (process.env.TARGETS_INPUT || process.env.FIRMWARE_TARGETS || '').trim();
if (!input) {
core.setFailed("No targets: set the FIRMWARE_TARGETS repo variable or pass the 'targets' input");
return;
}
// known targets come from platformio.ini via build.sh
// build.sh uses bash arrays; /bin/sh is not a contract
const known = new Set(
execFileSync('bash', ['build.sh', 'list'], { encoding: 'utf8' })
.split(/\r?\n/).map((s) => s.trim()),
);
const known = execFileSync('bash', ['build.sh', 'list'], { encoding: 'utf8' })
.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
// 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
const selected = [];
for (const target of new Set(input.split(/[\s,]+/).filter(Boolean))) {
if (known.has(target)) {
selected.push(target);
} else {
core.warning(`unknown build target '${target}' - skipped (not in this branch's platformio.ini)`);
// 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.length === 0) {
core.setFailed('No known build targets: every entry in the target list is unknown to this branch');
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));
core.setOutput('targets', JSON.stringify([...selected]));
build:
name: Build ${{ matrix.target }}
@@ -322,13 +320,6 @@ jobs:
- name: Setup Build Environment
uses: ./.github/actions/setup-build-environment
- name: Clear stale artifacts
# a previous run's output must never be mistaken for this run's
uses: actions/github-script@v8
with:
script: |
require('fs').rmSync('out', { recursive: true, force: true });
- name: Build Firmware
uses: actions/github-script@v8
env:
@@ -408,8 +399,10 @@ jobs:
release:
name: Create Release
needs: [version, validate-targets, build]
if: inputs.create_release && needs.version.outputs.skip != 'true'
# validate-targets rides in through build's own needs; a skipped build
# (nothing to release) skips this job the same way
needs: [version, build]
if: inputs.create_release
runs-on: ubuntu-latest
# only this job writes; build and test jobs stay at contents: read
permissions:
+17 -85
View File
@@ -53,17 +53,9 @@ jobs:
fetch-depth: 0
- name: Configure Git
uses: actions/github-script@v8
with:
script: |
const { spawnSync } = require('child_process');
for (const [key, value] of [
['user.name', 'github-actions[bot]'],
['user.email', '41898282+github-actions[bot]@users.noreply.github.com'],
]) {
const r = spawnSync('git', ['config', key, value], { encoding: 'utf8' });
if (r.status !== 0) throw new Error(`git config ${key} failed: ${(r.stderr || '').trim()}`);
}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Fast-forward fork dev and main to upstream
uses: actions/github-script@v8
@@ -132,44 +124,14 @@ jobs:
- name: Open merge-conflict issue
if: steps.merge.outputs.conflict == 'true'
uses: actions/github-script@v8
uses: ./.github/actions/open-conflict-issue
with:
script: |
const fs = require('fs');
const marker = '[filter-sync-conflict]';
const files = fs.readFileSync('conflicted-files.txt', 'utf8').trim() || '(none listed)';
const body = [
marker,
'Automatic merge of `dev` into `repeater-filter` failed with conflicts.',
'',
'**Conflicted files:**',
'',
...files.split('\n').map((f) => '- ' + f),
'',
'Resolve the conflicts locally, push the merge, then close this issue.',
].join('\n');
const res = await github.rest.search.issuesAndPullRequests({
q: 'repo:' + context.repo.owner + '/' + context.repo.repo + ' is:issue is:open "' + marker + '" in:body',
});
if (res.data.total_count > 0) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: res.data.items[0].number,
title: 'Upstream merge conflict in repeater-filter',
body,
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Upstream merge conflict in repeater-filter',
body,
});
}
// a conflict is a failure like any other, not a warning; the issue
// step is also where the merge step leaves the job failing
core.setFailed('Upstream merge conflict in repeater-filter; resolve locally, push the merge, then close this issue.');
marker: '[filter-sync-conflict]'
files-file: conflicted-files.txt
title: Upstream merge conflict in repeater-filter
intro: 'Automatic merge of `dev` into `repeater-filter` failed with conflicts.'
closing: 'Resolve the conflicts locally, push the merge, then close this issue.'
failure-message: 'Upstream merge conflict in repeater-filter; resolve locally, push the merge, then close this issue.'
- name: Setup Build Environment
# the promotion gate runs the native suites, and this runner has no
@@ -308,44 +270,14 @@ jobs:
- name: Open stable-sync conflict issue
if: steps.stable.outputs.conflict == 'true'
uses: actions/github-script@v8
uses: ./.github/actions/open-conflict-issue
with:
script: |
const fs = require('fs');
const marker = '[filter-sync-conflict-stable]';
const files = fs.readFileSync('stable-conflicted-files.txt', 'utf8').trim() || '(none listed)';
const body = [
marker,
'Promoting `repeater-filter-stable` (merge of `main` and/or cherry-picks from `repeater-filter`) failed with conflicts. Stable was not changed.',
'',
'**Conflicted files:**',
'',
...files.split('\n').map((f) => '- ' + f),
'',
'Resolve the conflicts locally, push the branch, then close this issue.',
].join('\n');
const res = await github.rest.search.issuesAndPullRequests({
q: 'repo:' + context.repo.owner + '/' + context.repo.repo + ' is:issue is:open "' + marker + '" in:body',
});
if (res.data.total_count > 0) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: res.data.items[0].number,
title: 'Upstream sync conflict in repeater-filter-stable',
body,
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Upstream sync conflict in repeater-filter-stable',
body,
});
}
// a conflict is a failure like any other, not a warning: the stable
// step reports it via its output, this step raises the failure
core.setFailed('Upstream sync conflict in repeater-filter-stable; resolve locally, push the branch, then close this issue.');
marker: '[filter-sync-conflict-stable]'
files-file: stable-conflicted-files.txt
title: Upstream sync conflict in repeater-filter-stable
intro: 'Promoting `repeater-filter-stable` (merge of `main` and/or cherry-picks from `repeater-filter`) failed with conflicts. Stable was not changed.'
closing: 'Resolve the conflicts locally, push the branch, then close this issue.'
failure-message: 'Upstream sync conflict in repeater-filter-stable; resolve locally, push the branch, then close this issue.'
build-dev:
name: Build firmware (dev)