Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions .github/actions/codegen_drift/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: 'Codegen drift check'
description: >
Runs a Justfile codegen recipe and reports a warning - without failing the
build - when the committed output differs from what the recipe produces.
Runs a Justfile codegen recipe and fails the job when the committed output
differs from what the recipe produces. The job is deliberately not a
required status check, so drift is visible on the PR without blocking a
contributor who lacks the local toolchain from merging.

inputs:
recipe:
Expand All @@ -13,25 +15,11 @@ inputs:
label:
description: 'Human readable name of the generated artefact'
required: true
just-version:
description: 'Version of just to install'
default: '1.57.0'

runs:
using: "composite"
steps:

- name: Install just
shell: bash
env:
JUST_VERSION: ${{ inputs.just-version }}
run: |
# The edgetx-dev image ships wget but not curl.
wget -qO- \
"https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
| tar xz -C /usr/local/bin just
just --version

- name: Allow git to read the workspace
shell: bash
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
Expand Down Expand Up @@ -60,8 +48,9 @@ runs:
RECIPE: ${{ inputs.recipe }}
LABEL: ${{ inputs.label }}
run: |
# Deliberately non-failing. Contributors without the local toolchain must
# not be blocked; this only surfaces that the committed files have drifted.
# This job is not a required status check (see description above), so
# failing here surfaces real drift on the PR without blocking a
# contributor who lacks the local toolchain from merging.
# Word splitting on PATHS is intentional - it may hold several pathspecs.
# shellcheck disable=SC2086
changed=$(git status --porcelain -- ${PATHS})
Expand All @@ -70,13 +59,13 @@ runs:
exit 0
fi

echo "::warning::${LABEL} is out of date. Run 'just ${RECIPE}' and commit the result."
echo "::error::${LABEL} is out of date. Run 'just ${RECIPE}' and commit the result."

# A full regeneration diff can run to megabytes (the fonts are the worst
# case), so truncate well inside the 1 MiB step summary limit. Truncation
# uses bash substring expansion rather than `head`: piping into `head`
# would SIGPIPE the producer once it closed the pipe, and under `pipefail`
# that exits 141 - failing a step that must never fail.
# that would clobber the exit 1 below with a 141.
# shellcheck disable=SC2086
diff=$(git diff -- ${PATHS} || true)
truncated="${diff:0:60000}"
Expand All @@ -85,7 +74,7 @@ runs:
fi

{
echo "### :warning: ${LABEL} is out of date"
echo "### :x: ${LABEL} is out of date"
echo
echo "The committed files differ from what \`just ${RECIPE}\` produces in"
echo "\`ghcr.io/edgetx/edgetx-dev:latest\`. Run \`just ${RECIPE}\` and commit the result."
Expand All @@ -102,3 +91,5 @@ runs:
echo
echo "</details>"
} >> "$GITHUB_STEP_SUMMARY"

exit 1
43 changes: 36 additions & 7 deletions .github/workflows/codegen_drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ on:
- 'fw.json'
- 'web/scripts/gen-radios-json.js'
- 'web/public/radios.json'
# simulator string list
- 'radio/src/translations/simstr.m4'
- 'radio/src/translations/string_list.h'
- 'radio/src/translations/sim_string_list.h'
pull_request:
paths: *trigger-paths
workflow_dispatch:

# These jobs only ever report - they must never block a contributor who does not
# have the local toolchain, so nothing here fails on drift.
# These jobs fail on drift so it's visible on the PR, but none of them are
# configured as required status checks - a contributor without the local
# toolchain can still merge.
permissions:
contents: read
pull-requests: read
Expand All @@ -59,6 +64,7 @@ jobs:
fonts: ${{ steps.filter.outputs.fonts }}
yaml: ${{ steps.filter.outputs.yaml }}
radios: ${{ steps.filter.outputs.radios }}
simstr: ${{ steps.filter.outputs.simstr }}
steps:
- name: Check out the repo
uses: actions/checkout@v7
Expand All @@ -74,7 +80,7 @@ jobs:
- name: Check the recipes this workflow calls still resolve
run: |
just --list >/dev/null
for recipe in cfn-sort gen-fonts gen-yaml gen-radios; do
for recipe in cfn-sort gen-fonts gen-yaml gen-radios gen-simstr; do
just --show "${recipe}" >/dev/null
done

Expand Down Expand Up @@ -120,6 +126,12 @@ jobs:
- 'radio/src/boards/hw_defs/**'
- 'web/scripts/gen-radios-json.js'
- 'web/public/radios.json'
simstr:
- '.github/workflows/codegen_drift.yml'
- '.github/actions/codegen_drift/action.yml'
- 'radio/src/translations/simstr.m4'
- 'radio/src/translations/string_list.h'
- 'radio/src/translations/sim_string_list.h'

cfn-sort:
name: Custom function sort order
Expand All @@ -140,7 +152,6 @@ jobs:
- name: Check for drift
uses: ./.github/actions/codegen_drift
with:
just-version: ${{ env.JUST_VERSION }}
recipe: cfn-sort
paths: radio/src/cfn_sort.cpp
label: Custom function sort order
Expand All @@ -164,7 +175,6 @@ jobs:
- name: Check for drift
uses: ./.github/actions/codegen_drift
with:
just-version: ${{ env.JUST_VERSION }}
recipe: gen-fonts
paths: radio/src/fonts/lvgl
label: LVGL fonts
Expand All @@ -188,7 +198,6 @@ jobs:
- name: Check for drift
uses: ./.github/actions/codegen_drift
with:
just-version: ${{ env.JUST_VERSION }}
recipe: gen-yaml
paths: radio/src/storage/yaml
label: YAML parsers
Expand All @@ -210,7 +219,27 @@ jobs:
- name: Check for drift
uses: ./.github/actions/codegen_drift
with:
just-version: ${{ env.JUST_VERSION }}
recipe: gen-radios
paths: web/public/radios.json
label: Web simulator radio list

simstr:
name: Simulator string list
needs: changes
if: needs.changes.outputs.simstr == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 10
container:
image: ghcr.io/edgetx/edgetx-dev:latest
volumes:
- ${{ github.workspace }}:/src
steps:
- name: Check out the repo
uses: actions/checkout@v7

- name: Check for drift
uses: ./.github/actions/codegen_drift
with:
recipe: gen-simstr
paths: radio/src/translations/sim_string_list.h
label: Simulator string list
17 changes: 14 additions & 3 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ gen-yaml FLAVOR='':
gen-radios:
node web/scripts/gen-radios-json.js

[doc('Regenerate the YAML parsers, LVGL fonts, cfn sort order and radio list')]
# Needs: m4.
[doc('Regenerate the simulator string list (radio/src/translations/sim_string_list.h)')]
[group('codegen')]
codegen: gen-fonts cfn-sort gen-yaml gen-radios
gen-simstr:
m4 radio/src/translations/simstr.m4 radio/src/translations/string_list.h > radio/src/translations/sim_string_list.h

[doc('Regenerate the YAML parsers, LVGL fonts, cfn sort order, radio list and simulator string list')]
[group('codegen')]
codegen: gen-fonts cfn-sort gen-yaml gen-radios gen-simstr

[doc('Regenerate the LVGL fonts in the dev container')]
[group('codegen (docker)')]
Expand All @@ -72,6 +78,11 @@ docker-gen-yaml FLAVOR='':
docker-gen-radios:
{{ _docker }} node web/scripts/gen-radios-json.js

[doc('Regenerate the simulator string list in the dev container')]
[group('codegen (docker)')]
docker-gen-simstr:
{{ _docker }} m4 radio/src/translations/simstr.m4 radio/src/translations/string_list.h > radio/src/translations/sim_string_list.h

[doc('Regenerate everything in the dev container')]
[group('codegen (docker)')]
docker-codegen: docker-gen-fonts docker-cfn-sort docker-gen-yaml docker-gen-radios
docker-codegen: docker-gen-fonts docker-cfn-sort docker-gen-yaml docker-gen-radios docker-gen-simstr