From 969f9a15f682188a3cbb75a02c44fb0d3c0d2f95 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Wed, 3 Apr 2024 18:07:46 +0100 Subject: [PATCH] Build HIL in CI prior to running them (#1388) * xtask: allow building hil tests * check hil tests build in CI --- .github/workflows/ci.yml | 17 ++++++++--------- xtask/src/lib.rs | 10 +++++----- xtask/src/main.rs | 9 ++++----- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb52b76a9..7825ffb2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -307,14 +307,6 @@ jobs: - name: rustfmt (examples) run: cargo fmt --all --manifest-path=examples/Cargo.toml -- --check - # -------------------------------------------------------------------------- - # NOTE: - # - # This is (hopefully) a temporary workaround to allow us to run HIL tests - # in merge queue, but not in pull requests. For more information see: - # - # https://github.com/esp-rs/esp-hal/issues/1328 - riscv-hil: name: HIL Test | ${{ matrix.soc }} runs-on: ubuntu-latest @@ -325,4 +317,11 @@ jobs: soc: [esp32c3, esp32c6, esp32h2] steps: - - run: echo "HIL tests are not run in pull requests!" + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@v1 + with: + target: riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf,riscv32imafc-unknown-none-elf + toolchain: nightly + components: rust-src + - uses: Swatinem/rust-cache@v2 + - run: cargo xtask build-examples hil-test ${{ matrix.soc }} diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index ba144bfda..3e3448ff9 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -23,6 +23,7 @@ pub enum Package { EspLpHal, EspRiscvRt, Examples, + HilTest, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Display, EnumIter, ValueEnum, serde::Serialize)] @@ -246,12 +247,11 @@ pub fn build_example( log::info!(" Features: {}", example.features().join(",")); } - let bin = if example - .example_path() - .strip_prefix(package_path)? - .starts_with("src/bin") - { + let package = example.example_path().strip_prefix(package_path)?; + let bin = if package.starts_with("src/bin") { format!("--bin={}", example.name()) + } else if package.starts_with("tests") { + format!("--test={}", example.name()) } else { format!("--example={}", example.name()) }; diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 597d4f053..7007eb9db 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -212,11 +212,10 @@ fn build_examples(workspace: &Path, mut args: BuildExamplesArgs) -> Result<()> { // Absolute path of the package's root: let package_path = xtask::windows_safe_path(&workspace.join(args.package.to_string())); - // Absolute path to the directory containing the examples: - let example_path = if args.package == Package::Examples { - package_path.join("src").join("bin") - } else { - package_path.join("examples") + let example_path = match args.package { + Package::Examples => package_path.join("src").join("bin"), + Package::HilTest => package_path.join("tests"), + _ => package_path.join("examples"), }; // Determine the appropriate build target for the given package and chip: