Skip to content
Open
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
137 changes: 0 additions & 137 deletions .github/actions/build-tests/action.yml

This file was deleted.

21 changes: 19 additions & 2 deletions .github/actions/setup-nightly/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ description: Install the repo-wide pinned Rust nightly toolchain, with an option

inputs:
targets:
description: Comma-separated list of target triples to install.
description: >-
Comma-separated list of target triples to install, or "all" for every RISC-V
triple in chips.json.
required: false
default: ""
components:
Expand All @@ -24,10 +26,25 @@ runs:
shell: bash
run: echo "nightly=nightly" >> "$GITHUB_OUTPUT"

- id: targets
shell: bash
run: |
if [ '${{ inputs.targets }}' = all ]; then
# Order-preserving dedupe, so the triple list reads the same as
# chips.json rather than being alphabetised.
VALUE=$(jq -r '
[.[] | select(.arch == "riscv") | ."rust-target"]
| reduce .[] as $t ([]; if index($t) then . else . + [$t] end)
| join(",")' .github/chips.json)
else
VALUE='${{ inputs.targets }}'
fi
echo "value=$VALUE" >> "$GITHUB_OUTPUT"

- uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ steps.version.outputs.nightly }}
targets: ${{ inputs.targets }}
targets: ${{ steps.targets.outputs.value }}
components: ${{ inputs.components }}

# xtask docs/doc-tests call `cargo +nightly`; make that name resolve to the pin.
Expand Down
126 changes: 126 additions & 0 deletions .github/actions/setup-toolchains/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Setup toolchains
description: >-
Install the repo-wide pinned Rust toolchains for Xtensa and/or RISC-V targets.

inputs:
channel:
description: 'Which pin to install: "current" or "msrv".'
required: false
default: current
current-xtensa-version:
description: Xtensa Rust release for the "current" channel.
required: false
default: "1.97.0.0"
xtensa:
description: When "true", install the Xtensa toolchain.
required: false
default: "false"
xtensa-buildtargets:
description: Comma-separated SoCs to build the Xtensa toolchain for. Defaults to every Xtensa chip in chips.json.
required: false
default: ""
xtensa-default:
description: When "true", make the Xtensa toolchain the rustup default.
required: false
default: "false"
riscv:
description: When "true", install the RISC-V toolchain.
required: false
default: "false"
riscv-targets:
description: '"all" for every RISC-V triple in chips.json, "none" for a host-only toolchain, or an explicit comma-separated list.'
required: false
default: all
riscv-extra-targets:
description: Comma-separated extra triples to append to the RISC-V toolchain.
required: false
default: ""
riscv-components:
description: >-
Comma-separated components for the RISC-V toolchain.
required: false
default: rust-src

outputs:
xtensa-version:
description: The Xtensa toolchain version for the selected channel.
value: ${{ steps.pins.outputs.xtensa-version }}
riscv-toolchain:
description: The rustup channel used for the RISC-V toolchain.
value: ${{ steps.pins.outputs.riscv-toolchain }}

runs:
using: composite
steps:
# Pins for the two channels CI exercises. api-baseline-generation.yml pins
# the current Xtensa version inline as well, since it runs against trees
# that may not contain this action.
- id: pins
shell: bash
run: |
case '${{ inputs.channel }}' in
current)
echo "xtensa-version=${{ inputs.current-xtensa-version }}" >> "$GITHUB_OUTPUT"
echo "riscv-toolchain=stable" >> "$GITHUB_OUTPUT"
;;
msrv)
# The first `rust-version` in the file is the one in `[package]`.
MSRV=$(sed -n 's/^rust-version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' esp-hal/Cargo.toml | head -n1)
if [ -z "$MSRV" ]; then
echo "::error::Could not read rust-version from esp-hal/Cargo.toml"
exit 1
fi
echo "Resolved MSRV: $MSRV"
# espup resolves this three-component prefix to the newest 1.x.y.* release.
echo "xtensa-version=$MSRV" >> "$GITHUB_OUTPUT"
echo "riscv-toolchain=$MSRV" >> "$GITHUB_OUTPUT"
;;
*)
echo "::error::Unknown channel '${{ inputs.channel }}'; expected 'current' or 'msrv'"
exit 1
;;
esac

# Chip-derived defaults, so adding a chip to chips.json does not require
# touching any workflow.
- id: chips
shell: bash
run: |
BUILDTARGETS='${{ inputs.xtensa-buildtargets }}'
if [ -z "$BUILDTARGETS" ]; then
BUILDTARGETS=$(jq -r '[.[] | select(.arch == "xtensa") | .soc] | join(",")' .github/chips.json)
fi
echo "buildtargets=$BUILDTARGETS" >> "$GITHUB_OUTPUT"

case '${{ inputs.riscv-targets }}' in
all)
# Order-preserving dedupe, so the triple list reads the same as
# chips.json rather than being alphabetised.
TARGETS=$(jq -r '
[.[] | select(.arch == "riscv") | ."rust-target"]
| reduce .[] as $t ([]; if index($t) then . else . + [$t] end)
| join(",")' .github/chips.json)
;;
none) TARGETS="" ;;
*) TARGETS='${{ inputs.riscv-targets }}' ;;
esac

EXTRA='${{ inputs.riscv-extra-targets }}'
if [ -n "$EXTRA" ]; then
TARGETS="${TARGETS:+$TARGETS,}$EXTRA"
fi
echo "targets=$TARGETS" >> "$GITHUB_OUTPUT"

- if: inputs.xtensa == 'true'
uses: esp-rs/xtensa-toolchain@v1.6
with:
buildtargets: ${{ steps.chips.outputs.buildtargets }}
default: ${{ inputs.xtensa-default }}
version: ${{ steps.pins.outputs.xtensa-version }}

- if: inputs.riscv == 'true'
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ steps.pins.outputs.riscv-toolchain }}
targets: ${{ steps.chips.outputs.targets }}
components: ${{ inputs.riscv-components }}
13 changes: 13 additions & 0 deletions .github/chips.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{ "soc": "esp32", "arch": "xtensa", "rust-target": "xtensa-esp32-none-elf", "ci-toolchain": "esp", "hil-runner": "esp32-jtag" },
{ "soc": "esp32s2", "arch": "xtensa", "rust-target": "xtensa-esp32s2-none-elf", "ci-toolchain": "esp", "hil-runner": "esp32s2-jtag" },
{ "soc": "esp32s3", "arch": "xtensa", "rust-target": "xtensa-esp32s3-none-elf", "ci-toolchain": "esp", "quick": true, "hil-runner": "esp32s3-usb", "hil-radio-runner": "esp32s3-radio" },
{ "soc": "esp32c2", "arch": "riscv", "rust-target": "riscv32imc-unknown-none-elf", "ci-toolchain": "esp", "hil-runner": "esp32c2-jtag" },
{ "soc": "esp32c3", "arch": "riscv", "rust-target": "riscv32imc-unknown-none-elf", "ci-toolchain": "esp", "hil-runner": "esp32c3-usb" },
{ "soc": "esp32c5", "arch": "riscv", "rust-target": "riscv32imac-unknown-none-elf", "ci-toolchain": "stable", "hil-runner": "esp32c5-usb" },
{ "soc": "esp32c6", "arch": "riscv", "rust-target": "riscv32imac-unknown-none-elf", "ci-toolchain": "stable", "quick": true, "hil-runner": "esp32c6-usb", "hil-radio-runner": "esp32c6-radio" },
{ "soc": "esp32c61", "arch": "riscv", "rust-target": "riscv32imac-unknown-none-elf", "ci-toolchain": "stable", "hil-runner": "esp32c61-usb" },
{ "soc": "esp32h2", "arch": "riscv", "rust-target": "riscv32imac-unknown-none-elf", "ci-toolchain": "stable", "hil-runner": "esp32h2-usb" },
{ "soc": "esp32p4", "arch": "riscv", "rust-target": "riscv32imafc-unknown-none-elf", "ci-toolchain": "stable", "hil-runner": "esp32p4" },
{ "soc": "esp32s31", "arch": "riscv", "rust-target": "riscv32imafc-unknown-none-elf", "ci-toolchain": "stable", "hil-runner": "esp32s31-jtag" }
]
5 changes: 3 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# esp-hal agent instructions

Bare-metal `no_std` Rust HAL for Espressif SoCs. MSRV: **1.95.0** (source: `MSRV` env in `.github/workflows/ci.yml`).
Bare-metal `no_std` Rust HAL for Espressif SoCs. MSRV: see `rust-version` in `esp-hal/Cargo.toml`.

## Chip reference

Expand Down Expand Up @@ -128,5 +128,6 @@ Prefer these over `#[cfg(feature = "esp32c3")]` where possible.
- `documentation/API-DOC-RULES.md` — API / rustdoc writing rules (STE, EMoS, item docs)
- `documentation/CONTRIBUTING.md` — contribution workflow
- `xtask/README.md` — metadata annotations and xtask usage
- `.github/workflows/ci.yml` — CI steps and MSRV
- `.github/workflows/ci.yml` — CI steps
- `.github/chips.json` — chip list CI builds from (arch, rust target, CI build group, HIL runner labels)
- `esp-metadata/devices/*.toml` — per-chip peripheral definitions
26 changes: 11 additions & 15 deletions .github/scripts/hil-gate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const RUN_TESTS_STEP = "Run Tests";

function isHilRunMatrixJob(name) {
// Matches "hil-run (…)" but not "hil-run-radio (…)".
return /^hil-run \(/i.test(String(name || ""));
return /(?:^|\/\s*)hil-run \(/i.test(String(name || ""));
}

function classifyMatrixJob(job) {
Expand All @@ -14,21 +14,13 @@ function classifyMatrixJob(job) {

const conclusion = runTests.conclusion;
if (conclusion === "skipped") {
// A successful job intentionally skipped this chip because it had no ELFs.
// An unsuccessful job skipped this step because an earlier step failed.
// The guard step skips a chip that produced no ELFs. A job that failed, was
// cancelled or timed out leaves the same skipped step behind, so only a
// successful job means "not tested".
if (job.conclusion === "success") {
return { kind: "skipped" };
}
if (
job.conclusion === "failure" ||
job.conclusion === "cancelled" ||
job.conclusion === null
) {
return { kind: "failed" };
}
return {
error: `job "${job.name}" has skipped "${RUN_TESTS_STEP}" step and unexpected conclusion: ${job.conclusion}`,
};
return { kind: "failed" };
}
if (conclusion === "success") {
return { kind: "passed" };
Expand Down Expand Up @@ -75,8 +67,12 @@ async function listWorkflowRunJobs(github, context) {
page,
});

jobs.push(...(data.jobs || []));
if (jobs.length >= data.total_count) {
const page_jobs = data.jobs || [];
jobs.push(...page_jobs);
// An empty page ends the walk even when total_count claims more: the count
// can drift while the run is still going, and trusting it alone spins here
// until the job times out.
if (page_jobs.length === 0 || jobs.length >= data.total_count) {
break;
}
page += 1;
Expand Down
Loading
Loading