Skip to content

Commit

Permalink
Build HIL in CI prior to running them (#1388)
Browse files Browse the repository at this point in the history
* xtask: allow building hil tests

* check hil tests build in CI
  • Loading branch information
MabezDev authored Apr 3, 2024
1 parent 13c8117 commit 969f9a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
10 changes: 5 additions & 5 deletions xtask/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum Package {
EspLpHal,
EspRiscvRt,
Examples,
HilTest,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Display, EnumIter, ValueEnum, serde::Serialize)]
Expand Down Expand Up @@ -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())
};
Expand Down
9 changes: 4 additions & 5 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 969f9a1

Please sign in to comment.