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
25 changes: 25 additions & 0 deletions .github/workflows/zephyr-autogen-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,41 @@ jobs:
echo "changed=true" >> "$GITHUB_OUTPUT"
git status --short -- 'ports/zephyr-cp/boards/**/autogen_board_info.toml'
fi
- name: Find existing open autogen PR
id: pr
env:
GH_TOKEN: ${{ github.token }}
run: |
pr=$(gh pr list --state open --head zephyr-autogen-board-info --json number --jq '.[0].number // empty')
echo "number=$pr" >> "$GITHUB_OUTPUT"
if [ -n "$pr" ]; then
echo "Found existing open autogen PR #$pr; will push to it."
fi
- name: Delete stale autogen branch
# A new pull request cannot be created from a head branch that already
# had one. If the previous autogen PR was closed without merging, the
# branch lingers on; delete it so create-pull-request can start over.
if: steps.diff.outputs.changed == 'true' && steps.pr.outputs.number == ''
run: |
if git ls-remote --heads origin zephyr-autogen-board-info | grep -q zephyr-autogen-board-info; then
git push origin --delete zephyr-autogen-board-info
fi
- name: Create PR
if: steps.diff.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v8
with:
add-paths: ports/zephyr-cp/boards/**/autogen_board_info.toml
commit-message: Regenerate zephyr-cp autogen_board_info.toml files
title: Regenerate zephyr-cp autogenerated board info
# create-pull-request pushes to the branch of an existing open PR,
# so a still-open autogen PR is updated in place instead of spawning
# a second one.
body: |
The `autogen_board_info.toml` files changed after building all zephyr-cp
boards on `main`. Created by the "Update Zephyr autogenerated files"
workflow.

Based on commit: ${{ github.sha }}
Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
branch: zephyr-autogen-board-info
delete-branch: true
10 changes: 8 additions & 2 deletions ports/zephyr-cp/cptools/build_circuitpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,19 @@ def determine_enabled_modules(board_info, portdir, srcdir):
enabled_modules.add("ssl")
module_reasons["ssl"] = "Zephyr networking enabled"

for port_module in (portdir / "bindings").iterdir():
# Iterate the shared-bindings directory in a stable (sorted) order. Several
# modules can enable the same reverse dependency, and the "reason" comment
# recorded in autogen_board_info.toml belongs to whichever module enabled it
# first. Directory iteration order is filesystem dependent (it differs
# between machines and CI runners), so an unsorted walk made the generated
# comments - and therefore the committed toml files - change between builds.
for port_module in sorted((portdir / "bindings").iterdir(), key=lambda x: x.name):
if not board_info.get(port_module.name, False):
continue
enabled_modules.add(port_module.name)
module_reasons[port_module.name] = f"Zephyr board has {port_module.name}"

for shared_module in (srcdir / "shared-bindings").iterdir():
for shared_module in sorted((srcdir / "shared-bindings").iterdir(), key=lambda x: x.name):
if not board_info.get(shared_module.name, False) or not shared_module.glob("*.c"):
continue
enabled_modules.add(shared_module.name)
Expand Down
Loading