From face142d24a547882c393ac7b73d08955fcd48e8 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Fri, 24 Jan 2025 14:31:12 +0000 Subject: [PATCH 01/61] Documents --- docs/Diagram.drawio.svg | 296 ++++++++++++++++++++++++++++++++++++++++ examples/README.md | 63 +++++++++ 2 files changed, 359 insertions(+) create mode 100644 docs/Diagram.drawio.svg create mode 100644 examples/README.md diff --git a/docs/Diagram.drawio.svg b/docs/Diagram.drawio.svg new file mode 100644 index 00000000..bd47b55c --- /dev/null +++ b/docs/Diagram.drawio.svg @@ -0,0 +1,296 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + Pull Request + +
+
+
+
+ + Pull Request + +
+
+ + + + + + + + +
+
+
+ Trigger +
+ Hardware Independent +
+ host tests +
+
+
+
+ + Trigger... + +
+
+ + + + + + + + + + +
+
+
+ Self Hosted Runner +
+
+
+
+ + Self Hosted Runner + +
+
+ + + + + + + + +
+
+
+ RodBot +
+
+
+
+ + RodBot + +
+
+ + + + +
+
+
+ Integration Tests +
+
+
+
+ + Integration Tests + +
+
+ + + + + + +
+
+
+ Example Tests +
+
+
+
+ + Example Tests + +
+
+ + + + +
+
+
+ ci.yaml +
+
+
+
+ + ci.yaml + +
+
+ + + + +
+
+
+ tests.yaml +
+
+
+
+ + tests.yaml + +
+
+ + + + +
+
+
+ + Cloud + +
+ + Runner + +
+
+
+
+
+ + Cloud... + +
+
+ + + + + + + +
+
+
+ Self Hosted Runner +
+
+
+
+ + Self Hosted Runner + +
+
+ + + + +
+
+
+ HIL Bench +
+
+
+
+ + HIL Be... + +
+
+ + + + + + +
+
+
+ + USB + +
+
+
+
+ + USB + +
+
+ + + + + + +
+
+
+ + USB + +
+
+
+
+ + USB + +
+
+
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000..c1a5ce02 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,63 @@ +# Examples + +## Summary + +Within this directory we have numerous examples showing how to get started using Trouble in your projects. We also test these examples using Automated CI. More information on this can be found below: + +## Examples + +Within this examples directory we have the following structure: + +```bash +tree -L 1 +. +├── README.md +├── apache-nimble +├── apps +├── esp32 +├── nrf-sdc +├── rp-pico-2-w +├── rp-pico-w +├── serial-hci +``` + +The `apps` folder contains the functionality that is used in every example across the multiple platforms. This crate is then pulled into each example and can be run by simply flashing the code onto the devices using `cargo run` within each of the project directories. + +The hardware for which each example uses is listed below: + +- **[apache-nimble](./apache-nimble/Cargo.toml)**: +- **[esp32](./esp32/Cargo.toml)**: [ESP-Rust-Board](https://github.com/esp-rs/esp-rust-board) +- **[rp-pico-2-w](./rp-pico-2-w/Cargo.toml)**: [Raspberry Pi Pico 2 W](https://thepihut.com/products/raspberry-pi-pico-2-w?variant=53727839027585&country=GB¤cy=GBP&utm_medium=product_sync&utm_source=google&utm_content=sag_organic&utm_campaign=sag_organic&gad_source=1&gclid=CjwKCAiAkc28BhB0EiwAM001TXNknX7fTXNwbaySLfbvbUJRaOgFseqj6RcDeu4Dd8RE64GgZ0imnxoCVVYQAvD_BwE) +- **[rp-pico-w](./rp-pico-w/Cargo.toml)**: [Raspberry Pico W](https://thepihut.com/products/raspberry-pi-pico-w) +- **[serial-hci](./serial-hci/Cargo.toml)**: Can be used with any Serial HCI, the following has been used: + - [Example 1]() + - [Example 2]() + - [Example 3]() + +## Tests + +### Hardware Indepedent Tests + +The Tests inside the [tests crate](./tests/Cargo.toml) are being ran inside the GitHub Actions Runner on a cloud host. The commands for this can be found [here](../ci.sh) and [here](../.github/workflows/ci.yaml). + +### Hardware in the Loop Tests + +The Tests inside the [tests crate](./tests/Cargo.toml) are also run using a `self-hosted` runner utilising the [Hil Bench](https://github.com/lulf/hilbench/tree/main). This works by using the [tests.yaml](../.github/workflows/tests.yaml) flow in which `example-tests` is used alongside integrations tests. + +The self hosted HIL Bench setup can be further understood using the following diagram: + +![HIL Bench Setup](../docs/Diagram.drawio.svg) + +[RodBot](https://github.com/ctron/rodbot) is used to setup the `tests` by using dedicated approvers to call the integration and example tests. + +## Integration tests + +In terms of integration tests these are defined in the [tests.yaml](../.github/workflows/tests.yaml) under `integration_tests` job. Which are running the tests in the [host crate](../host/tests/). These require the following hardware: + +These tests do not use the [hilbench](https://github.com/lulf/hilbench/tree/main) helper crate. + +## Example Tests + +The tests that use hardware are the [example tests](../examples/tests/tests/). These tests require the hilbench. + +The integration tests first work by downloading the artifacts which downloads the bins for each test. Then using the [config.json](../.ci/config.json) it selects the MCU to flash and run the tests on. Each time the tests are done on the Linux side with the examples being connected too. From 3b90c9415e8ee2afcbd37b1a83279a76c3bda8fc Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Fri, 24 Jan 2025 15:12:41 +0000 Subject: [PATCH 02/61] attempt at megalinter --- .github/workflows/.mega-linter.yaml | 204 ++++++++++++++++++++++++++++ .markdownlint.json | 4 + .mega-linter.yaml | 46 +++++++ 3 files changed, 254 insertions(+) create mode 100644 .github/workflows/.mega-linter.yaml create mode 100644 .markdownlint.json create mode 100644 .mega-linter.yaml diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml new file mode 100644 index 00000000..94fdb642 --- /dev/null +++ b/.github/workflows/.mega-linter.yaml @@ -0,0 +1,204 @@ +# MegaLinter GitHub Action configuration file +# More info at https://megalinter.io +--- +name: MegaLinter + +# Trigger mega-linter at every push. Action will also be visible from +# Pull Requests to main +on: + # Comment this line to trigger action only on pull-requests---------------------------------------------------------------- + # (not recommended if you don't pay for GH Actions) + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + workflow_call: + +# Comment env block if you do not want to apply fixes +env: + # Apply linter fixes configuration + # + # When active, APPLY_FIXES must also be defined as environment variable + # (in github/workflows/mega-linter.yml or other CI tool) + APPLY_FIXES: all + + # Decide which event triggers application of fixes in a commit or a PR + # (pull_request, push, all) + APPLY_FIXES_EVENT: pull_request + + # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) + # or posted in a PR (pull_request) + APPLY_FIXES_MODE: pull_request + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + megalinter: + name: MegaLinter + runs-on: ubuntu-latest + + # Give the default GITHUB_TOKEN write permission to commit and push, comment + # issues, and post new Pull Requests; remove the ones you do not need + permissions: + contents: write + issues: write + pull-requests: write + statuses: write + + steps: + # Git Checkout + - name: Checkout Code + uses: actions/checkout@v4 + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + + # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to + # improve performance + fetch-depth: 0 + + # MegaLinter + - name: MegaLinter + + # You can override MegaLinter flavor used to have faster performances + # More info at https://megalinter.io/latest/flavors/ + uses: oxsecurity/megalinter/flavors/rust@v8 + + id: ml + + # All available variables are described in documentation + # https://megalinter.io/latest/config-file/ + env: + # Validates all source when push on main, else just the git diff with + # main. Override with true if you always want to lint all sources + # + # To validate the entire codebase, set to: + # VALIDATE_ALL_CODEBASE: true + # + # To validate only diff with main, set to: + # VALIDATE_ALL_CODEBASE: >- + # ${{ + # github.event_name == 'push' && + # github.ref == 'refs/heads/main' + # }} + VALIDATE_ALL_CODEBASE: true + + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF + # .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY + + # Upload MegaLinter artifacts + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: MegaLinter reports + path: | + megalinter-reports + mega-linter.log + + # Create pull request if applicable + # (for now works only on PR from same repository, not from forks) + - name: Create Pull Request with applied fixes + uses: peter-evans/create-pull-request@v7 + id: cpr + if: >- + steps.ml.outputs.has_updated_sources == 1 && + ( + env.APPLY_FIXES_EVENT == 'all' || + env.APPLY_FIXES_EVENT == github.event_name + ) && + env.APPLY_FIXES_MODE == 'pull_request' && + ( + github.event_name == 'push' || + github.event.pull_request.head.repo.full_name == github.repository + ) && + !contains(github.event.head_commit.message, 'skip fix') + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + commit-message: "[MegaLinter] Apply linters automatic fixes" + title: "[MegaLinter] Apply linters automatic fixes" + labels: bot + branch: megalinter-fixes-${{ github.head_ref }} + body: | + MegaLinter has automatically applied linters fixes on this PR. + Please review the changes and merge if they are correct. + base: ${{ github.head_ref }} + + - name: Post PR Comment + if: >- + steps.ml.outputs.has_updated_sources == 1 && + ( + env.APPLY_FIXES_EVENT == 'all' || + env.APPLY_FIXES_EVENT == github.event_name + ) && + env.APPLY_FIXES_MODE == 'pull_request' && + ( + github.event_name == 'push' || + github.event.pull_request.head.repo.full_name == github.repository + ) && + !contains(github.event.head_commit.message, 'skip fix') + uses: marocchino/sticky-pull-request-comment@v2 + with: + message: | + MegaLinter has automatically applied linters fixes on this PR. + Please review the changes and merge if they are correct. + PR: ${{ steps.cpr.outputs.pull-request-url }} + hide_and_recreate: true + + - name: Fail if PR Created + run: | + if [ "${{ steps.cpr.outputs.pull-request-url }}" != "" ]; then + echo "A PR with formatting fixes has been created. Please merge it before proceeding." + exit 1 + fi +# Required due to Mega Linter not currently supporting Rust Format + cargo_fmt: + name: Cargo Formatter + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Rustfmt check on src + run: cargo fmt --manifest-path Cargo.toml -- --check + - name: Rustfmt check on utils + run: cargo fmt --manifest-path utils/Cargo.toml -- --check + - name: Rustfmt check on esp32 example + run: cargo fmt --manifest-path examples/esp32c3/Cargo.toml -- --check + - name: Rustfmt check on esp32 tests + run: cargo fmt --manifest-path tests/esp32c3/Cargo.toml -- --check + - name: Rustfmt check on pipico tests + run: cargo fmt --manifest-path tests/pipico/Cargo.toml -- --check + - name: Rustfmt check on stm32 tests + run: cargo fmt --manifest-path tests/stm32f072/Cargo.toml -- --check + + cargo_clippy: + name: Cargo Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Clippy check on esp32 example + run: | + cd examples/esp32c3 + cargo clippy -- -D warnings + - name: Clippy check on esp32 tests + run: | + cd tests/esp32c3/ + cargo clippy -- -D warnings + - name: Clippy on Pi Pico Tests + run: | + rustup target add thumbv6m-none-eabi + cd tests/pipico + cargo clippy -- -D warnings + - name: Clippy on STM32 Tests + run: | + rustup target add thumbv6m-none-eabi + cd tests/stm32f072 + cargo clippy -- -D warnings diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..ea9d8a14 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,4 @@ +{ + "default": true, + "line-length": false +} \ No newline at end of file diff --git a/.mega-linter.yaml b/.mega-linter.yaml new file mode 100644 index 00000000..644a793d --- /dev/null +++ b/.mega-linter.yaml @@ -0,0 +1,46 @@ +--- +# Configuration file for MegaLinter +# +# See all available variables at https://megalinter.io/latest/config-file/ and in +# linters documentation + +# all, none, or list of linter keys +APPLY_FIXES: all + +# If you use ENABLE variable, all other languages/formats/tooling-formats will +# be disabled by default +# ENABLE: + +# If you use ENABLE_LINTERS variable, all other linters will be disabled by default +ENABLE_LINTERS: + - ACTION_ACTIONLINT + - RUST_CLIPPY + - MARKDOWN_MARKDOWNLINT + - MARKDOWN_MARKDOWN_LINK_CHECK + - MARKDOWN_MARKDOWN_TABLE_FORMATTER + - YAML_YAMLLINT + - YAML_PRETTIER + - JSON_JSONLINT + - JSON_PRETTIER + - PYTHON_RUFF + - PYTHON_RUFF_FORMAT + +# DISABLE: + +SHOW_ELAPSED_TIME: true + +FILEIO_REPORTER: false + +# Uncomment if you want MegaLinter to detect errors but not block CI to pass +# DISABLE_ERRORS: true +GITHUB_COMMENT_REPORTER: true +GITHUB_STATUS_REPORTER: true +VALIDATE_ALL_CODEBASE: true +OUTPUT_DETAIL: detailed + +# Linter Configuration +MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdownlint.json + +RUST_CLIPPY_ARGUMENTS: + - --manifest-path + - host/Cargo.toml \ No newline at end of file From efd1683758d714417af88794e5e7cdaeec720095 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Fri, 24 Jan 2025 15:14:51 +0000 Subject: [PATCH 03/61] fixed formatting --- .github/workflows/.mega-linter.yaml | 41 +++-------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 94fdb642..e517a928 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -165,40 +165,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Rustfmt check on src - run: cargo fmt --manifest-path Cargo.toml -- --check - - name: Rustfmt check on utils - run: cargo fmt --manifest-path utils/Cargo.toml -- --check - - name: Rustfmt check on esp32 example - run: cargo fmt --manifest-path examples/esp32c3/Cargo.toml -- --check - - name: Rustfmt check on esp32 tests - run: cargo fmt --manifest-path tests/esp32c3/Cargo.toml -- --check - - name: Rustfmt check on pipico tests - run: cargo fmt --manifest-path tests/pipico/Cargo.toml -- --check - - name: Rustfmt check on stm32 tests - run: cargo fmt --manifest-path tests/stm32f072/Cargo.toml -- --check - - cargo_clippy: - name: Cargo Clippy - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Clippy check on esp32 example - run: | - cd examples/esp32c3 - cargo clippy -- -D warnings - - name: Clippy check on esp32 tests - run: | - cd tests/esp32c3/ - cargo clippy -- -D warnings - - name: Clippy on Pi Pico Tests - run: | - rustup target add thumbv6m-none-eabi - cd tests/pipico - cargo clippy -- -D warnings - - name: Clippy on STM32 Tests - run: | - rustup target add thumbv6m-none-eabi - cd tests/stm32f072 - cargo clippy -- -D warnings + - name: Rustfmt check on host + run: cargo fmt --manifest-path host/Cargo.toml -- --check + - name: Rustfmt check on host macros + run: cargo fmt --manifest-path host-macros/Cargo.toml -- --check From 2a038e78f7554c9567e4d40974bb0a12560ed263 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Fri, 24 Jan 2025 15:24:17 +0000 Subject: [PATCH 04/61] added crates checks --- .github/workflows/.mega-linter.yaml | 61 +++++++++++++++++++++++++++-- .mega-linter.yaml | 2 + 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index e517a928..acd50f56 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -67,7 +67,7 @@ jobs: # You can override MegaLinter flavor used to have faster performances # More info at https://megalinter.io/latest/flavors/ - uses: oxsecurity/megalinter/flavors/rust@v8 + uses: oxsecurity/megalinter/flavors/all id: ml @@ -159,8 +159,8 @@ jobs: exit 1 fi # Required due to Mega Linter not currently supporting Rust Format - cargo_fmt: - name: Cargo Formatter + cargo_fmt_library: + name: Cargo Formatter (Library) runs-on: ubuntu-latest steps: - name: Checkout code @@ -169,3 +169,58 @@ jobs: run: cargo fmt --manifest-path host/Cargo.toml -- --check - name: Rustfmt check on host macros run: cargo fmt --manifest-path host-macros/Cargo.toml -- --check + + cargo_clippy_library: + name: Cargo Clippy Host Macros + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Cargo Clippy check on host Macros + run: cargo clippy --manifest-path host-macros/Cargo.toml + + cargo_clippy_examples: + name: Cargo Clippy Examples + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Cargo Clippy check on apache-nimble + run: cargo clippy --manifest-path examples/apache-nimble/Cargo.toml + - name: Cargo Clippy apps + run: cargo clippy --manifest-path examples/apps/Cargo.toml + - name: Cargo Clippy esp32 + run: cargo clippy --manifest-path examples/esp32/Cargo.toml + - name: Cargo Clippy nrf-sdc + run: cargo clippy --manifest-path examples/nrf-sdc/Cargo.toml + - name: Cargo Clippy rp-pico-2-w + run: cargo clippy --manifest-path examples/rp-pico-2-w/Cargo.toml + - name: Cargo Clippy rp-pico-w + run: cargo clippy --manifest-path examples/rp-pico-w/Cargo.toml + - name: Cargo Clippy serial-hci + run: cargo clippy --manifest-path examples/serial-hci/Cargo.toml + - name: Cargo Clippy tests + run: cargo clippy --manifest-path examples/tests/Cargo.toml + + cargo_fmt_examples: + name: Cargo Formatter Examples + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Rustfmt check on apache-nimble + run: cargo fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check + - name: Rustfmt check on apps + run: cargo fmt --manifest-path examples/apps/Cargo.toml -- --check + - name: Rustfmt check on esp32 + run: cargo fmt --manifest-path examples/esp32/Cargo.toml -- --check + - name: Rustfmt check on nrf-sdc + run: cargo fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check + - name: Rustfmt check on rp-pico-2-w + run: cargo fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check + - name: Rustfmt check on rp-pico-w + run: cargo fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check + - name: Rustfmt check on serial-hci + run: cargo fmt --manifest-path examples/serial-hci/Cargo.toml -- --check + - name: Rustfmt check on tests + run: cargo fmt --manifest-path examples/tests/Cargo.toml -- --check \ No newline at end of file diff --git a/.mega-linter.yaml b/.mega-linter.yaml index 644a793d..8a57c2bb 100644 --- a/.mega-linter.yaml +++ b/.mega-linter.yaml @@ -24,6 +24,8 @@ ENABLE_LINTERS: - JSON_PRETTIER - PYTHON_RUFF - PYTHON_RUFF_FORMAT + - BASH_SHELLCHECK + - BASH_SHFMT # DISABLE: From 3e5037258f1f2919e3114bb36215335a0a2f0dc4 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Fri, 24 Jan 2025 15:27:01 +0000 Subject: [PATCH 05/61] updated uses tag --- .github/workflows/.mega-linter.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index acd50f56..44da20e0 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -67,7 +67,7 @@ jobs: # You can override MegaLinter flavor used to have faster performances # More info at https://megalinter.io/latest/flavors/ - uses: oxsecurity/megalinter/flavors/all + uses: oxsecurity/megalinter@v8 id: ml From 1ba9adfbf4322773fa3154c38ae73c5c9235d358 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Fri, 24 Jan 2025 15:34:42 +0000 Subject: [PATCH 06/61] need to investiaget lint checks --- .github/workflows/.mega-linter.yaml | 6 +++--- .mega-linter.yaml | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 44da20e0..71fe3428 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -166,9 +166,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Rustfmt check on host - run: cargo fmt --manifest-path host/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check - name: Rustfmt check on host macros - run: cargo fmt --manifest-path host-macros/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check cargo_clippy_library: name: Cargo Clippy Host Macros @@ -177,7 +177,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Cargo Clippy check on host Macros - run: cargo clippy --manifest-path host-macros/Cargo.toml + run: cargo clippy --manifest-path host-macros/Cargo.toml --all-features cargo_clippy_examples: name: Cargo Clippy Examples diff --git a/.mega-linter.yaml b/.mega-linter.yaml index 8a57c2bb..9fbf20ae 100644 --- a/.mega-linter.yaml +++ b/.mega-linter.yaml @@ -45,4 +45,6 @@ MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdownlint.json RUST_CLIPPY_ARGUMENTS: - --manifest-path - - host/Cargo.toml \ No newline at end of file + - host/Cargo.toml + - -- + - --all-features \ No newline at end of file From aab9ec874bc92c1526b4d89173078ca0bfca25db Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:09:20 +0000 Subject: [PATCH 07/61] rearranged commands --- .github/workflows/.mega-linter.yaml | 22 ++++++++++++---------- .mega-linter.yaml | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 71fe3428..f9a534f4 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -165,10 +165,12 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Install Toolchain + run: rustup toolchain install nightly-x86_64-unknown-linux-gnu - name: Rustfmt check on host - run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check - name: Rustfmt check on host macros - run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check cargo_clippy_library: name: Cargo Clippy Host Macros @@ -209,18 +211,18 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Rustfmt check on apache-nimble - run: cargo fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check - name: Rustfmt check on apps - run: cargo fmt --manifest-path examples/apps/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check - name: Rustfmt check on esp32 - run: cargo fmt --manifest-path examples/esp32/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check - name: Rustfmt check on nrf-sdc - run: cargo fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check - name: Rustfmt check on rp-pico-2-w - run: cargo fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check - name: Rustfmt check on rp-pico-w - run: cargo fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check - name: Rustfmt check on serial-hci - run: cargo fmt --manifest-path examples/serial-hci/Cargo.toml -- --check + run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check - name: Rustfmt check on tests - run: cargo fmt --manifest-path examples/tests/Cargo.toml -- --check \ No newline at end of file + run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check \ No newline at end of file diff --git a/.mega-linter.yaml b/.mega-linter.yaml index 9fbf20ae..f6b0ee93 100644 --- a/.mega-linter.yaml +++ b/.mega-linter.yaml @@ -44,7 +44,7 @@ OUTPUT_DETAIL: detailed MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdownlint.json RUST_CLIPPY_ARGUMENTS: + - -- - --manifest-path - host/Cargo.toml - - -- - --all-features \ No newline at end of file From a8048477ba72055998ba750d0611386653c6e7f2 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:14:34 +0000 Subject: [PATCH 08/61] added toolchains --- .github/workflows/.mega-linter.yaml | 56 ++++++++++++++++------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index f9a534f4..906b18d8 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -165,13 +165,42 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Install Toolchain - run: rustup toolchain install nightly-x86_64-unknown-linux-gnu + - name: Install Toolchains + run: | + rustup toolchain install nightly-x86_64-unknown-linux-gnu + rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - name: Rustfmt check on host run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check - name: Rustfmt check on host macros run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check + cargo_fmt_examples: + name: Cargo Formatter Examples + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Toolchains + run: | + rustup toolchain install nightly-x86_64-unknown-linux-gnu + rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt + - name: Rustfmt check on apache-nimble + run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check + - name: Rustfmt check on apps + run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check + - name: Rustfmt check on esp32 + run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check + - name: Rustfmt check on nrf-sdc + run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check + - name: Rustfmt check on rp-pico-2-w + run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check + - name: Rustfmt check on rp-pico-w + run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check + - name: Rustfmt check on serial-hci + run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check + - name: Rustfmt check on tests + run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check + cargo_clippy_library: name: Cargo Clippy Host Macros runs-on: ubuntu-latest @@ -204,25 +233,4 @@ jobs: - name: Cargo Clippy tests run: cargo clippy --manifest-path examples/tests/Cargo.toml - cargo_fmt_examples: - name: Cargo Formatter Examples - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Rustfmt check on apache-nimble - run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check - - name: Rustfmt check on apps - run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check - - name: Rustfmt check on esp32 - run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check - - name: Rustfmt check on nrf-sdc - run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check - - name: Rustfmt check on rp-pico-2-w - run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check - - name: Rustfmt check on rp-pico-w - run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check - - name: Rustfmt check on serial-hci - run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check - - name: Rustfmt check on tests - run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check \ No newline at end of file + \ No newline at end of file From c97ad797bad7590e768c056c2bb0a80b8c790df7 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:23:09 +0000 Subject: [PATCH 09/61] fixed python and markdown --- README.md | 3 +++ host/gen_config.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20f52b8d..7dde64c8 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,11 @@ See `examples` for example applications for different BLE controllers. * `serial-hci` which runs on std using a controller attached via a serial port (Such as [this Zephyr sample](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/bluetooth/hci_uart/README.html)). * `apache-nimble` which uses the controller from the [NimBLE stack](https://github.com/apache/mynewt-nimble) through high-level bindings from the [`apache-nimble`](https://github.com/benbrittain/apache-nimble-sys) crate. * `esp32` which uses the BLE controller in the [esp-hal](https://github.com/esp-rs/esp-hal). + + * `rp-pico-w` which uses the BLE controller in the [Raspberry Pi Pico W](https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html#raspberry-pi-pico-w). * `rp-pico-2-w` which uses the BLE controller in the [Raspberry Pi Pico 2 W](https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html#raspberry-pi-pico-2-w). + Since a lot of the examples demo the same BLE functionality, they only contain basic wiring specific to the BLE controller, and share the 'business logic' within the `examples/apps` folder. diff --git a/host/gen_config.py b/host/gen_config.py index 3a16efd5..5267eb4b 100644 --- a/host/gen_config.py +++ b/host/gen_config.py @@ -19,7 +19,7 @@ def feature(name, default, min=None, max=None, pow2=None, vals=None, factors=[]) for f in factors: if val*f <= max: vals.add(val*f) - if (pow2 == True or (isinstance(pow2, int) and val >= pow2)) and val > 0: + if (pow2 is True or (isinstance(pow2, int) and val >= pow2)) and val > 0: val *= 2 else: val += 1 From ab25ffd5025e845d2d245b41ec47220cffaa0132 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:24:17 +0000 Subject: [PATCH 10/61] fixed shell script --- ci.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci.sh b/ci.sh index f5361889..b499151d 100755 --- a/ci.sh +++ b/ci.sh @@ -3,9 +3,9 @@ set -eo pipefail if ! command -v cargo-batch &> /dev/null; then - mkdir -p $HOME/.cargo/bin - curl -L https://github.com/embassy-rs/cargo-batch/releases/download/batch-0.6.0/cargo-batch > $HOME/.cargo/bin/cargo-batch - chmod +x $HOME/.cargo/bin/cargo-batch + mkdir -p "$HOME"/.cargo/bin + curl -L https://github.com/embassy-rs/cargo-batch/releases/download/batch-0.6.0/cargo-batch > "$HOME"/.cargo/bin/cargo-batch + chmod +x "$HOME"/.cargo/bin/cargo-batch fi export RUSTFLAGS=-Dwarnings From 1d6995a907208c0742c267c8ad07a1e3b8d34bd1 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:25:57 +0000 Subject: [PATCH 11/61] bumped ci dependency --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 557c0ba4..e773a945 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: run: | sudo apt-get install --no-install-recommends libudev-dev - name: Set up cargo cache - uses: actions/cache@v3 + uses: actions/cache@v4.2.0 continue-on-error: true with: path: | From 908bfa03123bd9461050d25781d283ba338bcd36 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:34:07 +0000 Subject: [PATCH 12/61] Fixed YAML and added allow comments --- .github/workflows/.mega-linter.yaml | 2 -- .github/workflows/ci.yaml | 2 ++ .github/workflows/release_trouble_host.yaml | 7 ++++--- .github/workflows/release_trouble_host_macros.yaml | 4 +++- .github/workflows/rodbot.yaml | 5 +++-- .github/workflows/tests.yaml | 1 + .mega-linter.yaml | 5 ++++- .vscode/settings.json | 12 ++++++------ 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 906b18d8..df28f9d6 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -232,5 +232,3 @@ jobs: run: cargo clippy --manifest-path examples/serial-hci/Cargo.toml - name: Cargo Clippy tests run: cargo clippy --manifest-path examples/tests/Cargo.toml - - \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e773a945..4f32508e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,3 +1,5 @@ +--- + name: CI on: diff --git a/.github/workflows/release_trouble_host.yaml b/.github/workflows/release_trouble_host.yaml index 0bf6eebb..1662aeb9 100644 --- a/.github/workflows/release_trouble_host.yaml +++ b/.github/workflows/release_trouble_host.yaml @@ -1,4 +1,5 @@ -name: Trouble Host Release +--- +name: Trouble Host Release on: push: @@ -7,7 +8,7 @@ on: permissions: contents: write - + jobs: # Re Run the Checks build: @@ -18,7 +19,7 @@ jobs: run: | sudo apt-get install --no-install-recommends libudev-dev - name: Set up cargo cache - uses: actions/cache@v3 + uses: actions/cache@v4.2.0 continue-on-error: true with: path: | diff --git a/.github/workflows/release_trouble_host_macros.yaml b/.github/workflows/release_trouble_host_macros.yaml index 2080fcbb..f05e7072 100644 --- a/.github/workflows/release_trouble_host_macros.yaml +++ b/.github/workflows/release_trouble_host_macros.yaml @@ -1,3 +1,5 @@ +--- + name: Trouble Host macros Release on: @@ -18,7 +20,7 @@ jobs: run: | sudo apt-get install --no-install-recommends libudev-dev - name: Set up cargo cache - uses: actions/cache@v3 + uses: actions/cache@v4.2.0 continue-on-error: true with: path: | diff --git a/.github/workflows/rodbot.yaml b/.github/workflows/rodbot.yaml index 330285cd..8fa076a0 100644 --- a/.github/workflows/rodbot.yaml +++ b/.github/workflows/rodbot.yaml @@ -1,3 +1,4 @@ +--- name: rodbot on: @@ -13,8 +14,8 @@ jobs: steps: - run: | - echo $GITHUB_EVENT_PATH - cat $GITHUB_EVENT_PATH + echo $"GITHUB_EVENT_PATH" + cat $"GITHUB_EVENT_PATH" - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0f6e3cbb..0a898713 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,3 +1,4 @@ +--- name: Tests on: diff --git a/.mega-linter.yaml b/.mega-linter.yaml index f6b0ee93..2198c700 100644 --- a/.mega-linter.yaml +++ b/.mega-linter.yaml @@ -47,4 +47,7 @@ RUST_CLIPPY_ARGUMENTS: - -- - --manifest-path - host/Cargo.toml - - --all-features \ No newline at end of file + - --all-features + +JSON_JSONLINT_ARGUMENTS: +- --comments \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 40f3a478..3d2618c0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,11 +15,11 @@ "host-macros/Cargo.toml", "examples/apps/Cargo.toml", // uncomment the examples you want to explore below - // "examples/esp32/Cargo.toml", - // "examples/nrf-sdc/Cargo.toml", - // "examples/rp-pico-w/Cargo.toml", - // "examples/rp-pico-2-w/Cargo.toml", - // "examples/serial-hci/Cargo.toml", - // "examples/apache-nimble/Cargo.toml", + "examples/esp32/Cargo.toml", + "examples/nrf-sdc/Cargo.toml", + "examples/rp-pico-w/Cargo.toml", + "examples/rp-pico-2-w/Cargo.toml", + "examples/serial-hci/Cargo.toml", + "examples/apache-nimble/Cargo.toml", ] } \ No newline at end of file From a60ae92b742324e8a8e6191f080c5cdf157b99fa Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:44:17 +0000 Subject: [PATCH 13/61] yaml fixes --- .github/rodbot.yaml | 1 + .github/workflows/rodbot.yaml | 4 ++-- .github/workflows/tests.yaml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/rodbot.yaml b/.github/rodbot.yaml index 6ad3f6c1..81209275 100644 --- a/.github/rodbot.yaml +++ b/.github/rodbot.yaml @@ -1,3 +1,4 @@ +--- on: issue_comment: - if: diff --git a/.github/workflows/rodbot.yaml b/.github/workflows/rodbot.yaml index 8fa076a0..87f2e0bb 100644 --- a/.github/workflows/rodbot.yaml +++ b/.github/workflows/rodbot.yaml @@ -3,7 +3,7 @@ name: rodbot on: issue_comment: - types: [ "created" ] + types: ["created"] jobs: rodbot: @@ -18,7 +18,7 @@ jobs: cat $"GITHUB_EVENT_PATH" - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: ctron/rodbot-action@v0.1 with: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0a898713..23f42e55 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -23,7 +23,7 @@ jobs: run: | sudo apt-get install --no-install-recommends libudev-dev - name: Set up cargo cache - uses: actions/cache@v3 + uses: actions/cache@v4.2.0 continue-on-error: true with: path: | From 33aab517148844997ffa66051afae3d70f22564e Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:45:07 +0000 Subject: [PATCH 14/61] jsonlint removed trailing comma --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4dadd879..8d8a6339 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,7 +5,7 @@ "recommendations": [ "rust-lang.rust-analyzer", "tamasfe.even-better-toml", - "fill-labs.dependi", + "fill-labs.dependi" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] From ab6c3e38730eb4c9ebf60b84f73ba1d9abf250b2 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 11:46:22 +0000 Subject: [PATCH 15/61] removed trailing spaces --- .github/workflows/release_trouble_host.yaml | 6 +++--- .github/workflows/release_trouble_host_macros.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release_trouble_host.yaml b/.github/workflows/release_trouble_host.yaml index 1662aeb9..65c1f7b6 100644 --- a/.github/workflows/release_trouble_host.yaml +++ b/.github/workflows/release_trouble_host.yaml @@ -63,9 +63,9 @@ jobs: - name: Build project run: | - cd host + cd host cargo build --release - + - name: Create GitHub release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -81,7 +81,7 @@ jobs: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} # Publish to the main registry run: | - echo "Publishing to crates.io" + echo "Publishing to crates.io" cargo publish # To perform a dry run uncomment the following lines # run: | diff --git a/.github/workflows/release_trouble_host_macros.yaml b/.github/workflows/release_trouble_host_macros.yaml index f05e7072..a320a159 100644 --- a/.github/workflows/release_trouble_host_macros.yaml +++ b/.github/workflows/release_trouble_host_macros.yaml @@ -9,7 +9,7 @@ on: permissions: contents: write - + jobs: # Re Run the Checks build: @@ -66,7 +66,7 @@ jobs: run: | cd host-macros cargo build --release - + - name: Create GitHub release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -82,7 +82,7 @@ jobs: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} # Publish to the main registry run: | - echo "Publishing to crates.io" + echo "Publishing to crates.io" cargo publish # To perform a dry run uncomment the following lines # run: | From 82d774c96a749e84cf4885cb7373bfda1356dd5b Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 12:13:28 +0000 Subject: [PATCH 16/61] fixed globbing --- .github/workflows/tests.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 23f42e55..760abf28 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -62,7 +62,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | gh api --method POST -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ + -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/"${COMMIT}" \ -f "state=pending" -f "description=Running integration tests" -f "context=integration-tests" - name: Test env: @@ -78,7 +78,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | gh api --method POST -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ + -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/"${COMMIT}" \ -f "state=failure" -f "description=The integration tests failed" -f "context=integration-tests" - name: Update success status if: success() @@ -87,7 +87,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | gh api --method POST -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ + -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/"${COMMIT}" \ -f "state=success" -f "description=The integration tests succeeded!" -f "context=integration-tests" example-tests: @@ -108,7 +108,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | gh api --method POST -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ + -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/"${COMMIT}" \ -f "state=pending" -f "description=Running example tests" -f "context=example-tests" - uses: actions/download-artifact@v4 @@ -131,7 +131,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | gh api --method POST -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ + -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/"${COMMIT}" \ -f "state=failure" -f "description=The example tests failed" -f "context=example-tests" - name: Update success status if: success() @@ -140,5 +140,5 @@ jobs: GH_TOKEN: ${{ github.token }} run: | gh api --method POST -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ + -H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/"${COMMIT}" \ -f "state=success" -f "description=The example tests succeeded!" -f "context=example-tests" From e3dc4a9d431b5270bc5532865fe40b6d71976820 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 12:13:36 +0000 Subject: [PATCH 17/61] removed commas and extra spaces --- .vscode/settings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3d2618c0..9c5ed882 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ -{ +{ "[rust]": { "editor.formatOnSave": true, - "editor.formatOnSaveMode": "file", + "editor.formatOnSaveMode": "file" }, "[toml]": { "editor.formatOnSave": false @@ -15,7 +15,7 @@ "host-macros/Cargo.toml", "examples/apps/Cargo.toml", // uncomment the examples you want to explore below - "examples/esp32/Cargo.toml", + "examples/esp32/Cargo.toml", "examples/nrf-sdc/Cargo.toml", "examples/rp-pico-w/Cargo.toml", "examples/rp-pico-2-w/Cargo.toml", From b148e9753e641580196519a1e50721d8e60952e0 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 12:13:46 +0000 Subject: [PATCH 18/61] fixed markdown error --- examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index c1a5ce02..e04bc5e7 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,7 +4,7 @@ Within this directory we have numerous examples showing how to get started using Trouble in your projects. We also test these examples using Automated CI. More information on this can be found below: -## Examples +## Example Applications Within this examples directory we have the following structure: From 4b3095a397ddeddf4ae70f0b0984833abe447be2 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 12:21:20 +0000 Subject: [PATCH 19/61] ran cargo fmt on the codebase --- .../workflows/release_trouble_host_macros.yaml | 2 +- .../src/bin/ble_bas_peripheral.rs | 3 +-- examples/apps/src/ble_bas_peripheral.rs | 3 ++- examples/esp32/build.rs | 2 +- examples/esp32/src/bin/ble_bas_central.rs | 3 ++- examples/esp32/src/bin/ble_bas_peripheral.rs | 3 ++- examples/esp32/src/bin/ble_l2cap_central.rs | 3 ++- examples/esp32/src/bin/ble_l2cap_peripheral.rs | 3 ++- examples/rp-pico-w/build.rs | 2 +- examples/tests/src/probe/mod.rs | 8 +++----- examples/tests/tests/ble_l2cap_central.rs | 3 ++- examples/tests/tests/ble_l2cap_peripheral.rs | 3 ++- host/src/attribute.rs | 2 +- host/src/central.rs | 5 +++-- host/src/gatt.rs | 3 +-- host/src/lib.rs | 13 ++++++------- host/src/scan.rs | 18 +++++++----------- host/tests/common.rs | 3 ++- 18 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/release_trouble_host_macros.yaml b/.github/workflows/release_trouble_host_macros.yaml index a320a159..4843ab1b 100644 --- a/.github/workflows/release_trouble_host_macros.yaml +++ b/.github/workflows/release_trouble_host_macros.yaml @@ -82,7 +82,7 @@ jobs: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} # Publish to the main registry run: | - echo "Publishing to crates.io" + echo "Publishing to crates.io" cargo publish # To perform a dry run uncomment the following lines # run: | diff --git a/examples/apache-nimble/src/bin/ble_bas_peripheral.rs b/examples/apache-nimble/src/bin/ble_bas_peripheral.rs index 36ee65e7..5e56a9ff 100644 --- a/examples/apache-nimble/src/bin/ble_bas_peripheral.rs +++ b/examples/apache-nimble/src/bin/ble_bas_peripheral.rs @@ -1,8 +1,7 @@ #![no_main] #![no_std] -use apache_nimble::controller::NimbleController; -use apache_nimble::controller::NimbleControllerTask; +use apache_nimble::controller::{NimbleController, NimbleControllerTask}; use embassy_time::{Duration, Ticker, Timer}; use trouble_example_apps::ble_bas_peripheral; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/apps/src/ble_bas_peripheral.rs b/examples/apps/src/ble_bas_peripheral.rs index b3663b28..6d21f314 100644 --- a/examples/apps/src/ble_bas_peripheral.rs +++ b/examples/apps/src/ble_bas_peripheral.rs @@ -1,4 +1,5 @@ -use embassy_futures::{join::join, select::select}; +use embassy_futures::join::join; +use embassy_futures::select::select; use embassy_time::Timer; use trouble_host::prelude::*; diff --git a/examples/esp32/build.rs b/examples/esp32/build.rs index d1771291..5efe9c99 100644 --- a/examples/esp32/build.rs +++ b/examples/esp32/build.rs @@ -1,3 +1,3 @@ fn main() { println!("cargo:rustc-link-arg-bins=-Tlinkall.x"); -} \ No newline at end of file +} diff --git a/examples/esp32/src/bin/ble_bas_central.rs b/examples/esp32/src/bin/ble_bas_central.rs index cc016c95..11d16ab1 100644 --- a/examples/esp32/src/bin/ble_bas_central.rs +++ b/examples/esp32/src/bin/ble_bas_central.rs @@ -3,7 +3,8 @@ use bt_hci::controller::ExternalController; use embassy_executor::Spawner; -use esp_hal::{clock::CpuClock, timer::timg::TimerGroup}; +use esp_hal::clock::CpuClock; +use esp_hal::timer::timg::TimerGroup; use esp_wifi::ble::controller::BleConnector; use trouble_example_apps::ble_bas_central; use {esp_alloc as _, esp_backtrace as _}; diff --git a/examples/esp32/src/bin/ble_bas_peripheral.rs b/examples/esp32/src/bin/ble_bas_peripheral.rs index ded57aa5..ec9f41d6 100644 --- a/examples/esp32/src/bin/ble_bas_peripheral.rs +++ b/examples/esp32/src/bin/ble_bas_peripheral.rs @@ -3,7 +3,8 @@ use bt_hci::controller::ExternalController; use embassy_executor::Spawner; -use esp_hal::{clock::CpuClock, timer::timg::TimerGroup}; +use esp_hal::clock::CpuClock; +use esp_hal::timer::timg::TimerGroup; use esp_wifi::ble::controller::BleConnector; use trouble_example_apps::ble_bas_peripheral; use {esp_alloc as _, esp_backtrace as _}; diff --git a/examples/esp32/src/bin/ble_l2cap_central.rs b/examples/esp32/src/bin/ble_l2cap_central.rs index 03024fe3..b0a10d4d 100644 --- a/examples/esp32/src/bin/ble_l2cap_central.rs +++ b/examples/esp32/src/bin/ble_l2cap_central.rs @@ -3,7 +3,8 @@ use bt_hci::controller::ExternalController; use embassy_executor::Spawner; -use esp_hal::{clock::CpuClock, timer::timg::TimerGroup}; +use esp_hal::clock::CpuClock; +use esp_hal::timer::timg::TimerGroup; use esp_wifi::ble::controller::BleConnector; use trouble_example_apps::ble_l2cap_central; use {esp_alloc as _, esp_backtrace as _}; diff --git a/examples/esp32/src/bin/ble_l2cap_peripheral.rs b/examples/esp32/src/bin/ble_l2cap_peripheral.rs index 4a0d19e0..49002078 100644 --- a/examples/esp32/src/bin/ble_l2cap_peripheral.rs +++ b/examples/esp32/src/bin/ble_l2cap_peripheral.rs @@ -3,7 +3,8 @@ use bt_hci::controller::ExternalController; use embassy_executor::Spawner; -use esp_hal::{clock::CpuClock, timer::timg::TimerGroup}; +use esp_hal::clock::CpuClock; +use esp_hal::timer::timg::TimerGroup; use esp_wifi::ble::controller::BleConnector; use trouble_example_apps::ble_l2cap_peripheral; use {esp_alloc as _, esp_backtrace as _}; diff --git a/examples/rp-pico-w/build.rs b/examples/rp-pico-w/build.rs index ff241da0..00e2b38c 100644 --- a/examples/rp-pico-w/build.rs +++ b/examples/rp-pico-w/build.rs @@ -48,7 +48,7 @@ fn download_cyw43_firmware() { "43439A0_clm.bin", "LICENSE-permissive-binary-license-1.0.txt", "README.md", - ]; + ]; println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed={}", download_folder); diff --git a/examples/tests/src/probe/mod.rs b/examples/tests/src/probe/mod.rs index df369ad3..a9e4444a 100644 --- a/examples/tests/src/probe/mod.rs +++ b/examples/tests/src/probe/mod.rs @@ -1,13 +1,11 @@ use std::process::Stdio; -use tokio::io::AsyncBufReadExt; -use tokio::io::BufReader; + +use hilbench_agent::{ProbeConfig, Target}; +use tokio::io::{AsyncBufReadExt, BufReader}; use tokio::process::Command; use tokio::select; use tokio_util::sync::CancellationToken; -use hilbench_agent::ProbeConfig; -use hilbench_agent::Target; - pub fn init(config: ProbeConfig) { hilbench_agent::init(config); } diff --git a/examples/tests/tests/ble_l2cap_central.rs b/examples/tests/tests/ble_l2cap_central.rs index ccc620c8..f5adb463 100644 --- a/examples/tests/tests/ble_l2cap_central.rs +++ b/examples/tests/tests/ble_l2cap_central.rs @@ -1,5 +1,6 @@ -use futures::future::join; use std::time::Duration; + +use futures::future::join; use tokio::select; use trouble_example_tests::{serial, TestContext}; use trouble_host::prelude::*; diff --git a/examples/tests/tests/ble_l2cap_peripheral.rs b/examples/tests/tests/ble_l2cap_peripheral.rs index 4601c0bd..cb6a828f 100644 --- a/examples/tests/tests/ble_l2cap_peripheral.rs +++ b/examples/tests/tests/ble_l2cap_peripheral.rs @@ -1,5 +1,6 @@ -use futures::future::join; use std::time::Duration; + +use futures::future::join; use tokio::select; use trouble_example_tests::{serial, TestContext}; use trouble_host::prelude::*; diff --git a/host/src/attribute.rs b/host/src/attribute.rs index 2773ab7d..d740587f 100644 --- a/host/src/attribute.rs +++ b/host/src/attribute.rs @@ -7,6 +7,7 @@ use bt_hci::uuid::declarations::{CHARACTERISTIC, PRIMARY_SERVICE}; use bt_hci::uuid::descriptors::CLIENT_CHARACTERISTIC_CONFIGURATION; use embassy_sync::blocking_mutex::raw::RawMutex; use embassy_sync::blocking_mutex::Mutex; +use heapless::Vec; use crate::att::AttErrorCode; use crate::attribute_server::AttributeServer; @@ -15,7 +16,6 @@ use crate::prelude::Connection; use crate::types::gatt_traits::GattValue; pub use crate::types::uuid::Uuid; use crate::Error; -use heapless::Vec; /// Characteristic properties #[derive(Debug, Clone, Copy)] diff --git a/host/src/central.rs b/host/src/central.rs index 5c8ca412..20a2a81e 100644 --- a/host/src/central.rs +++ b/host/src/central.rs @@ -1,6 +1,4 @@ //! Functionality for the BLE central role. -use crate::connection::{ConnectConfig, Connection, PhySet}; -use crate::{BleHostError, Error, Stack}; use bt_hci::cmd::le::{LeAddDeviceToFilterAcceptList, LeClearFilterAcceptList, LeCreateConn, LeExtCreateConn}; use bt_hci::controller::{Controller, ControllerCmdAsync, ControllerCmdSync}; use bt_hci::param::{AddrKind, BdAddr, InitiatingPhy, LeConnRole, PhyParams}; @@ -8,6 +6,9 @@ use bt_hci::param::{AddrKind, BdAddr, InitiatingPhy, LeConnRole, PhyParams}; use bt_hci::param::{ConnHandleCompletedPackets, ControllerToHostFlowControl}; use embassy_futures::select::{select, Either}; +use crate::connection::{ConnectConfig, Connection, PhySet}; +use crate::{BleHostError, Error, Stack}; + /// A type implementing the BLE central role. pub struct Central<'stack, C> { pub(crate) stack: &'stack Stack<'stack, C>, diff --git a/host/src/gatt.rs b/host/src/gatt.rs index 804ca348..b9a92e61 100644 --- a/host/src/gatt.rs +++ b/host/src/gatt.rs @@ -8,8 +8,7 @@ use bt_hci::controller::Controller; use bt_hci::param::ConnHandle; use bt_hci::uuid::declarations::{CHARACTERISTIC, PRIMARY_SERVICE}; use bt_hci::uuid::descriptors::CLIENT_CHARACTERISTIC_CONFIGURATION; -use embassy_sync::blocking_mutex::raw::NoopRawMutex; -use embassy_sync::blocking_mutex::raw::RawMutex; +use embassy_sync::blocking_mutex::raw::{NoopRawMutex, RawMutex}; use embassy_sync::channel::{Channel, DynamicReceiver}; use embassy_sync::pubsub::{self, PubSubChannel, WaitResult}; use heapless::Vec; diff --git a/host/src/lib.rs b/host/src/lib.rs index 648312bd..c47496c3 100644 --- a/host/src/lib.rs +++ b/host/src/lib.rs @@ -15,6 +15,7 @@ use core::mem::MaybeUninit; use advertise::AdvertisementDataError; use bt_hci::cmd::status::ReadRssi; use bt_hci::cmd::{AsyncCmd, SyncCmd}; +use bt_hci::param::{AddrKind, BdAddr}; use bt_hci::FromHciBytesError; use crate::att::AttErrorCode; @@ -22,7 +23,6 @@ use crate::channel_manager::{ChannelStorage, PacketChannel}; use crate::connection_manager::{ConnectionStorage, EventChannel}; use crate::l2cap::sar::SarType; use crate::packet_pool::PacketPool; -use bt_hci::param::{AddrKind, BdAddr}; mod fmt; @@ -44,11 +44,10 @@ mod pdu; pub mod peripheral; pub mod types; -#[cfg(feature = "peripheral")] -use peripheral::*; - #[cfg(feature = "central")] use central::*; +#[cfg(feature = "peripheral")] +use peripheral::*; pub mod advertise; pub mod connection; @@ -66,7 +65,6 @@ use host::{AdvHandleState, BleHost, HostMetrics, Runner}; #[allow(missing_docs)] pub mod prelude { - pub use super::Host; pub use bt_hci::param::{AddrKind, BdAddr, LeConnRole as Role}; pub use bt_hci::uuid::*; #[cfg(feature = "derive")] @@ -75,7 +73,7 @@ pub mod prelude { pub use trouble_host_macros::*; pub use super::att::AttErrorCode; - pub use super::{BleHostError, Controller, Error, HostResources, Stack}; + pub use super::{BleHostError, Controller, Error, Host, HostResources, Stack}; #[cfg(feature = "peripheral")] pub use crate::advertise::*; #[cfg(feature = "gatt")] @@ -376,9 +374,10 @@ pub fn new< #[cfg(feature = "gatt")] let tx_pool = unsafe { core::mem::transmute::<&'resources dyn Pool, &'static dyn Pool>(tx_pool) }; + use bt_hci::param::ConnHandle; + use crate::l2cap::sar::AssembledPacket; use crate::types::l2cap::L2capHeader; - use bt_hci::param::ConnHandle; let connections: &mut [ConnectionStorage] = &mut *resources.connections.write([ConnectionStorage::DISCONNECTED; CONNS]); let connections: &'resources mut [ConnectionStorage] = unsafe { transmute_slice(connections) }; diff --git a/host/src/scan.rs b/host/src/scan.rs index a2e02b73..6d5f63ac 100644 --- a/host/src/scan.rs +++ b/host/src/scan.rs @@ -1,24 +1,20 @@ //! Scan config. -use crate::command::CommandState; -use crate::connection::ScanConfig; -use crate::host::ScanState; -use crate::BleHostError; -use crate::Error; -use bt_hci::cmd::le::LeSetScanParams; use bt_hci::cmd::le::{ LeAddDeviceToFilterAcceptList, LeClearFilterAcceptList, LeSetExtScanEnable, LeSetExtScanParams, LeSetScanEnable, + LeSetScanParams, }; use bt_hci::controller::{Controller, ControllerCmdSync}; use bt_hci::param::{AddrKind, FilterDuplicates, LeAdvReport, LeExtAdvReport, ScanningPhy}; use bt_hci::FromHciBytes; use embassy_futures::yield_now; use embassy_sync::blocking_mutex::raw::NoopRawMutex; -use embassy_sync::pipe::DynamicWriter; -use embassy_sync::pipe::{DynamicReader, Pipe}; -use embassy_time::with_deadline; -use embassy_time::Instant; +use embassy_sync::pipe::{DynamicReader, DynamicWriter, Pipe}; +use embassy_time::{with_deadline, Instant}; -use crate::Central; +use crate::command::CommandState; +use crate::connection::ScanConfig; +use crate::host::ScanState; +use crate::{BleHostError, Central, Error}; /// A scanner that wraps a central to provide additional functionality /// around BLE scanning. diff --git a/host/tests/common.rs b/host/tests/common.rs index 4004a754..e73572e0 100644 --- a/host/tests/common.rs +++ b/host/tests/common.rs @@ -1,8 +1,9 @@ +use std::path::PathBuf; + use bt_hci::controller::ExternalController; use bt_hci::transport::SerialTransport; use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embedded_io_adapters::tokio_1::FromTokio; -use std::path::PathBuf; use tokio::io::{ReadHalf, WriteHalf}; use tokio::time::Duration; use tokio_serial::{DataBits, Parity, SerialStream, StopBits}; From 1fcaf4f5a844b9286e6ab1e3d8fcecb67b44e3fe Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 12:23:49 +0000 Subject: [PATCH 20/61] commented out apache-nimble --- .github/workflows/.mega-linter.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index df28f9d6..a7b7c02e 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -216,8 +216,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Cargo Clippy check on apache-nimble - run: cargo clippy --manifest-path examples/apache-nimble/Cargo.toml + # - name: Cargo Clippy check on apache-nimble + # run: cargo clippy --manifest-path examples/apache-nimble/Cargo.toml - name: Cargo Clippy apps run: cargo clippy --manifest-path examples/apps/Cargo.toml - name: Cargo Clippy esp32 From c8a0dc90cf78b3860c05f5dfbbe320f7fff74098 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 12:24:38 +0000 Subject: [PATCH 21/61] removed trailing comma --- .vscode/settings.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9c5ed882..c46b5b15 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,11 +15,11 @@ "host-macros/Cargo.toml", "examples/apps/Cargo.toml", // uncomment the examples you want to explore below - "examples/esp32/Cargo.toml", - "examples/nrf-sdc/Cargo.toml", - "examples/rp-pico-w/Cargo.toml", - "examples/rp-pico-2-w/Cargo.toml", - "examples/serial-hci/Cargo.toml", - "examples/apache-nimble/Cargo.toml", + // "examples/esp32/Cargo.toml", + // "examples/nrf-sdc/Cargo.toml", + // "examples/rp-pico-w/Cargo.toml", + // "examples/rp-pico-2-w/Cargo.toml", + // "examples/serial-hci/Cargo.toml", + // "examples/apache-nimble/Cargo.toml" ] } \ No newline at end of file From b257627e2e0f4c1d9c6e069ef82ec7f0606451eb Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 12:27:57 +0000 Subject: [PATCH 22/61] removed esp32 from clippy --- .github/workflows/.mega-linter.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index a7b7c02e..2d4b3cfa 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -220,8 +220,8 @@ jobs: # run: cargo clippy --manifest-path examples/apache-nimble/Cargo.toml - name: Cargo Clippy apps run: cargo clippy --manifest-path examples/apps/Cargo.toml - - name: Cargo Clippy esp32 - run: cargo clippy --manifest-path examples/esp32/Cargo.toml + # - name: Cargo Clippy esp32 + # run: cargo clippy --manifest-path examples/esp32/Cargo.toml # Portable Atomic Error - name: Cargo Clippy nrf-sdc run: cargo clippy --manifest-path examples/nrf-sdc/Cargo.toml - name: Cargo Clippy rp-pico-2-w From ed713711e7872aa51ebcc46784d12dc6ebba5e46 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 12:31:47 +0000 Subject: [PATCH 23/61] made mega-linter match ci.sh --- .mega-linter.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mega-linter.yaml b/.mega-linter.yaml index 2198c700..e6a746d6 100644 --- a/.mega-linter.yaml +++ b/.mega-linter.yaml @@ -47,7 +47,8 @@ RUST_CLIPPY_ARGUMENTS: - -- - --manifest-path - host/Cargo.toml - - --all-features + - --features + - gatt,peripheral,central JSON_JSONLINT_ARGUMENTS: - --comments \ No newline at end of file From 0507242f2bf43efbf9df5d6ee27dfd6b7569a942 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 15:30:56 +0000 Subject: [PATCH 24/61] added megalinter fixes --- .ci/config.json | 2 +- .github/workflows/.mega-linter.yaml | 2 +- .github/workflows/ci.yaml | 1 - .github/workflows/release_trouble_host.yaml | 82 +++++++++--------- .../release_trouble_host_macros.yaml | 83 +++++++++---------- .gitignore | 3 +- .markdownlint.json | 6 +- .mega-linter.yaml | 2 +- .vscode/extensions.json | 22 ++--- .vscode/settings.json | 48 +++++------ ci.sh | 42 +++++----- examples/README.md | 6 +- 12 files changed, 149 insertions(+), 150 deletions(-) diff --git a/.ci/config.json b/.ci/config.json index efa33378..3ffb12ad 100644 --- a/.ci/config.json +++ b/.ci/config.json @@ -13,7 +13,7 @@ "probe": "303a:1001:60:55:F9:BF:A9:44", "labels": { "target": "esp32", - "board": "esp-rust-board" + "board": "esp-rust-board" } } ] diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 2d4b3cfa..20f11536 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -158,7 +158,7 @@ jobs: echo "A PR with formatting fixes has been created. Please merge it before proceeding." exit 1 fi -# Required due to Mega Linter not currently supporting Rust Format + # Required due to Mega Linter not currently supporting Rust Format cargo_fmt_library: name: Cargo Formatter (Library) runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4f32508e..470ee305 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,4 @@ --- - name: CI on: diff --git a/.github/workflows/release_trouble_host.yaml b/.github/workflows/release_trouble_host.yaml index 65c1f7b6..cf22f655 100644 --- a/.github/workflows/release_trouble_host.yaml +++ b/.github/workflows/release_trouble_host.yaml @@ -4,7 +4,7 @@ name: Trouble Host Release on: push: tags: - - 'trouble-host-v[0-9]+.[0-9]+.[0-9]+' + - "trouble-host-v[0-9]+.[0-9]+.[0-9]+" permissions: contents: write @@ -43,48 +43,48 @@ jobs: timeout-minutes: 10 if: github.ref == 'refs/heads/main' steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - name: Verify Version - run: | - TAG_VERSION=${GITHUB_REF#refs/tags/trouble-host-v} - CARGO_VERSION=$(grep '^version =' host/Cargo.toml | sed -E 's/version = "([^"]+)"/\1/') - if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then - echo "Version mismatch: tag is $TAG_VERSION but Cargo.toml is $CARGO_VERSION" - exit 1 # Exits with a non-zero status to fail the workflow - fi - shell: bash + - name: Verify Version + run: | + TAG_VERSION=${GITHUB_REF#refs/tags/trouble-host-v} + CARGO_VERSION=$(grep '^version =' host/Cargo.toml | sed -E 's/version = "([^"]+)"/\1/') + if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then + echo "Version mismatch: tag is $TAG_VERSION but Cargo.toml is $CARGO_VERSION" + exit 1 # Exits with a non-zero status to fail the workflow + fi + shell: bash - - name: Set up Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable - - name: Build project - run: | - cd host - cargo build --release + - name: Build project + run: | + cd host + cargo build --release - - name: Create GitHub release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.ref_name }} - run: | - gh release create "$tag" \ - --repo="$GITHUB_REPOSITORY" \ - --title="${GITHUB_REPOSITORY#*/} host v${tag#trouble-host-v}" \ - --generate-notes + - name: Create GitHub release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + run: | + gh release create "$tag" \ + --repo="$GITHUB_REPOSITORY" \ + --title="${GITHUB_REPOSITORY#*/} host v${tag#trouble-host-v}" \ + --generate-notes - - name: Publish to crates.io - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - # Publish to the main registry - run: | - echo "Publishing to crates.io" - cargo publish - # To perform a dry run uncomment the following lines - # run: | - # echo "Performing dry-run publish to crates.io" - # cd host - # cargo publish --dry-run + - name: Publish to crates.io + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + # Publish to the main registry + run: | + echo "Publishing to crates.io" + cargo publish + # To perform a dry run uncomment the following lines + # run: | + # echo "Performing dry-run publish to crates.io" + # cd host + # cargo publish --dry-run diff --git a/.github/workflows/release_trouble_host_macros.yaml b/.github/workflows/release_trouble_host_macros.yaml index 4843ab1b..551be443 100644 --- a/.github/workflows/release_trouble_host_macros.yaml +++ b/.github/workflows/release_trouble_host_macros.yaml @@ -1,11 +1,10 @@ --- - name: Trouble Host macros Release on: push: tags: - - 'trouble-host-macros-v[0-9]+.[0-9]+.[0-9]+' + - "trouble-host-macros-v[0-9]+.[0-9]+.[0-9]+" permissions: contents: write @@ -44,48 +43,48 @@ jobs: timeout-minutes: 10 if: github.ref == 'refs/heads/main' steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - name: Verify Version - run: | - TAG_VERSION=${GITHUB_REF#refs/tags/trouble-host-macros-v} - CARGO_VERSION=$(grep '^version =' host-macros/Cargo.toml | sed -E 's/version = "([^"]+)"/\1/') - if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then - echo "Version mismatch: tag is $TAG_VERSION but Cargo.toml is $CARGO_VERSION" - exit 1 # Exits with a non-zero status to fail the workflow - fi - shell: bash + - name: Verify Version + run: | + TAG_VERSION=${GITHUB_REF#refs/tags/trouble-host-macros-v} + CARGO_VERSION=$(grep '^version =' host-macros/Cargo.toml | sed -E 's/version = "([^"]+)"/\1/') + if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then + echo "Version mismatch: tag is $TAG_VERSION but Cargo.toml is $CARGO_VERSION" + exit 1 # Exits with a non-zero status to fail the workflow + fi + shell: bash - - name: Set up Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable - - name: Build project - run: | - cd host-macros - cargo build --release + - name: Build project + run: | + cd host-macros + cargo build --release - - name: Create GitHub release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.ref_name }} - run: | - gh release create "$tag" \ - --repo="$GITHUB_REPOSITORY" \ - --title="${GITHUB_REPOSITORY#*/} host macros v${tag#trouble-host-macros-v}" \ - --generate-notes + - name: Create GitHub release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + run: | + gh release create "$tag" \ + --repo="$GITHUB_REPOSITORY" \ + --title="${GITHUB_REPOSITORY#*/} host macros v${tag#trouble-host-macros-v}" \ + --generate-notes - - name: Publish to crates.io - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - # Publish to the main registry - run: | - echo "Publishing to crates.io" - cargo publish - # To perform a dry run uncomment the following lines - # run: | - # echo "Performing dry-run publish to crates.io" - # cd host-macros - # cargo publish --dry-run + - name: Publish to crates.io + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + # Publish to the main registry + run: | + echo "Publishing to crates.io" + cargo publish + # To perform a dry run uncomment the following lines + # run: | + # echo "Performing dry-run publish to crates.io" + # cd host-macros + # cargo publish --dry-run diff --git a/.gitignore b/.gitignore index 93871a3d..d4b4c1e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/target **/target_ci -Cargo.lock \ No newline at end of file +Cargo.lock +megalinter-reports/ \ No newline at end of file diff --git a/.markdownlint.json b/.markdownlint.json index ea9d8a14..984d3733 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,4 +1,4 @@ { - "default": true, - "line-length": false -} \ No newline at end of file + "default": true, + "line-length": false +} diff --git a/.mega-linter.yaml b/.mega-linter.yaml index e6a746d6..39d5a0cd 100644 --- a/.mega-linter.yaml +++ b/.mega-linter.yaml @@ -51,4 +51,4 @@ RUST_CLIPPY_ARGUMENTS: - gatt,peripheral,central JSON_JSONLINT_ARGUMENTS: -- --comments \ No newline at end of file + - --comments diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 8d8a6339..4b16fb23 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,12 +1,12 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. - // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp - // List of extensions which should be recommended for users of this workspace. - "recommendations": [ - "rust-lang.rust-analyzer", - "tamasfe.even-better-toml", - "fill-labs.dependi" - ], - // List of extensions recommended by VS Code that should not be recommended for users of this workspace. - "unwantedRecommendations": [] -} \ No newline at end of file + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml", + "fill-labs.dependi" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index c46b5b15..922b66c7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,25 +1,25 @@ { - "[rust]": { - "editor.formatOnSave": true, - "editor.formatOnSaveMode": "file" - }, - "[toml]": { - "editor.formatOnSave": false - }, - "[markdown]": { - "editor.formatOnSave": false - }, - "rust-analyzer.check.allTargets": false, - "rust-analyzer.linkedProjects": [ - "host/Cargo.toml", - "host-macros/Cargo.toml", - "examples/apps/Cargo.toml", - // uncomment the examples you want to explore below - // "examples/esp32/Cargo.toml", - // "examples/nrf-sdc/Cargo.toml", - // "examples/rp-pico-w/Cargo.toml", - // "examples/rp-pico-2-w/Cargo.toml", - // "examples/serial-hci/Cargo.toml", - // "examples/apache-nimble/Cargo.toml" - ] -} \ No newline at end of file + "[rust]": { + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "file" + }, + "[toml]": { + "editor.formatOnSave": false + }, + "[markdown]": { + "editor.formatOnSave": false + }, + "rust-analyzer.check.allTargets": false, + "rust-analyzer.linkedProjects": [ + "host/Cargo.toml", + "host-macros/Cargo.toml", + "examples/apps/Cargo.toml" + // uncomment the examples you want to explore below + // "examples/esp32/Cargo.toml", + // "examples/nrf-sdc/Cargo.toml", + // "examples/rp-pico-w/Cargo.toml", + // "examples/rp-pico-2-w/Cargo.toml", + // "examples/serial-hci/Cargo.toml", + // "examples/apache-nimble/Cargo.toml" + ] +} diff --git a/ci.sh b/ci.sh index b499151d..f1099168 100755 --- a/ci.sh +++ b/ci.sh @@ -2,36 +2,36 @@ set -eo pipefail -if ! command -v cargo-batch &> /dev/null; then - mkdir -p "$HOME"/.cargo/bin - curl -L https://github.com/embassy-rs/cargo-batch/releases/download/batch-0.6.0/cargo-batch > "$HOME"/.cargo/bin/cargo-batch - chmod +x "$HOME"/.cargo/bin/cargo-batch +if ! command -v cargo-batch &>/dev/null; then + mkdir -p "$HOME"/.cargo/bin + curl -L https://github.com/embassy-rs/cargo-batch/releases/download/batch-0.6.0/cargo-batch >"$HOME"/.cargo/bin/cargo-batch + chmod +x "$HOME"/.cargo/bin/cargo-batch fi export RUSTFLAGS=-Dwarnings export DEFMT_LOG=trace export CARGO_NET_GIT_FETCH_WITH_CLI=true if [[ -z "${CARGO_TARGET_DIR}" ]]; then - export CARGO_TARGET_DIR=target_ci + export CARGO_TARGET_DIR=target_ci fi cargo batch \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,scan \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral,defmt \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,central \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral,central,scan \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52840 \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52833 --artifact-dir tests/nrf-sdc \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52832 \ - --- build --release --manifest-path examples/esp32/Cargo.toml --features esp32c3 --target riscv32imc-unknown-none-elf --artifact-dir tests/esp32 \ - --- build --release --manifest-path examples/serial-hci/Cargo.toml \ - --- build --release --manifest-path examples/tests/Cargo.toml \ - --- build --release --manifest-path examples/rp-pico-w/Cargo.toml --target thumbv6m-none-eabi --features skip-cyw43-firmware \ - --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware + --- build --release --manifest-path host/Cargo.toml --no-default-features --features peripheral \ + --- build --release --manifest-path host/Cargo.toml --no-default-features --features central \ + --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,scan \ + --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral \ + --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral,defmt \ + --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral \ + --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,central \ + --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral,central,scan \ + --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52840 \ + --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52833 --artifact-dir tests/nrf-sdc \ + --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52832 \ + --- build --release --manifest-path examples/esp32/Cargo.toml --features esp32c3 --target riscv32imc-unknown-none-elf --artifact-dir tests/esp32 \ + --- build --release --manifest-path examples/serial-hci/Cargo.toml \ + --- build --release --manifest-path examples/tests/Cargo.toml \ + --- build --release --manifest-path examples/rp-pico-w/Cargo.toml --target thumbv6m-none-eabi --features skip-cyw43-firmware \ + --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware # --- build --release --manifest-path examples/apache-nimble/Cargo.toml --target thumbv7em-none-eabihf cargo fmt --check --manifest-path ./host/Cargo.toml diff --git a/examples/README.md b/examples/README.md index e04bc5e7..0aa9cadb 100644 --- a/examples/README.md +++ b/examples/README.md @@ -30,9 +30,9 @@ The hardware for which each example uses is listed below: - **[rp-pico-2-w](./rp-pico-2-w/Cargo.toml)**: [Raspberry Pi Pico 2 W](https://thepihut.com/products/raspberry-pi-pico-2-w?variant=53727839027585&country=GB¤cy=GBP&utm_medium=product_sync&utm_source=google&utm_content=sag_organic&utm_campaign=sag_organic&gad_source=1&gclid=CjwKCAiAkc28BhB0EiwAM001TXNknX7fTXNwbaySLfbvbUJRaOgFseqj6RcDeu4Dd8RE64GgZ0imnxoCVVYQAvD_BwE) - **[rp-pico-w](./rp-pico-w/Cargo.toml)**: [Raspberry Pico W](https://thepihut.com/products/raspberry-pi-pico-w) - **[serial-hci](./serial-hci/Cargo.toml)**: Can be used with any Serial HCI, the following has been used: - - [Example 1]() - - [Example 2]() - - [Example 3]() + - [Example 1]() + - [Example 2]() + - [Example 3]() ## Tests From 6120832344e6cf9f6246132270964950071dac02 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 15:45:22 +0000 Subject: [PATCH 25/61] attempt to fix megalinter ci --- .github/workflows/.mega-linter.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 20f11536..2e02bc6b 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -67,7 +67,7 @@ jobs: # You can override MegaLinter flavor used to have faster performances # More info at https://megalinter.io/latest/flavors/ - uses: oxsecurity/megalinter@v8 + uses: oxsecurity/megalinter@v8.3.0 id: ml From 77c8df699b4091aab749a807b1fb63dc28dc9e59 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 15:46:17 +0000 Subject: [PATCH 26/61] removed another example --- .github/workflows/.mega-linter.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 2e02bc6b..9aec3342 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -222,8 +222,8 @@ jobs: run: cargo clippy --manifest-path examples/apps/Cargo.toml # - name: Cargo Clippy esp32 # run: cargo clippy --manifest-path examples/esp32/Cargo.toml # Portable Atomic Error - - name: Cargo Clippy nrf-sdc - run: cargo clippy --manifest-path examples/nrf-sdc/Cargo.toml + # - name: Cargo Clippy nrf-sdc + # run: cargo clippy --manifest-path examples/nrf-sdc/Cargo.toml - name: Cargo Clippy rp-pico-2-w run: cargo clippy --manifest-path examples/rp-pico-2-w/Cargo.toml - name: Cargo Clippy rp-pico-w From f0dc31e1e5bfdfc63b66349add9882141c373efe Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 15:58:51 +0000 Subject: [PATCH 27/61] adjusted clippy checks to do it inside the projects --- .github/workflows/.mega-linter.yaml | 42 ++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 9aec3342..8292ab4e 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -208,7 +208,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Cargo Clippy check on host Macros - run: cargo clippy --manifest-path host-macros/Cargo.toml --all-features + run: | + cd host-macros + cargo clippy --all-features cargo_clippy_examples: name: Cargo Clippy Examples @@ -216,19 +218,35 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - # - name: Cargo Clippy check on apache-nimble - # run: cargo clippy --manifest-path examples/apache-nimble/Cargo.toml + - name: Cargo Clippy check on apache-nimble + run: | + cd examples/apache-nimble + cargo clippy - name: Cargo Clippy apps - run: cargo clippy --manifest-path examples/apps/Cargo.toml - # - name: Cargo Clippy esp32 - # run: cargo clippy --manifest-path examples/esp32/Cargo.toml # Portable Atomic Error - # - name: Cargo Clippy nrf-sdc - # run: cargo clippy --manifest-path examples/nrf-sdc/Cargo.toml + run: | + cd examples/apps + cargo clippy + - name: Cargo Clippy esp32 + run: | + cd examples/esp32 + cargo clippy + - name: Cargo Clippy nrf-sdc + run: | + cd examples/nrf-sdc + cargo clippy - name: Cargo Clippy rp-pico-2-w - run: cargo clippy --manifest-path examples/rp-pico-2-w/Cargo.toml + run: | + cd examples/rp-pico-2-w + cargo clippy - name: Cargo Clippy rp-pico-w - run: cargo clippy --manifest-path examples/rp-pico-w/Cargo.toml + run: | + cd examples/rp-pico-w + cargo clippy - name: Cargo Clippy serial-hci - run: cargo clippy --manifest-path examples/serial-hci/Cargo.toml + run: | + cd examples/serial-hci + cargo clippy - name: Cargo Clippy tests - run: cargo clippy --manifest-path examples/tests/Cargo.toml + run: | + cd examples/tests + cargo clippy From 1ce7ab9da5139683e4b4548579218f6bd5c3d6ab Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:03:55 +0000 Subject: [PATCH 28/61] fixed scan.rs --- host/src/scan.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/host/src/scan.rs b/host/src/scan.rs index 915f6283..d516c329 100644 --- a/host/src/scan.rs +++ b/host/src/scan.rs @@ -3,18 +3,15 @@ use crate::command::CommandState; use crate::connection::ScanConfig; use crate::BleHostError; use bt_hci::cmd::le::LeSetScanParams; -use bt_hci::param::{AddrKind, FilterDuplicates, LeAdvReport, LeExtAdvReport, ScanningPhy}; -use bt_hci::FromHciBytes; -use embassy_futures::yield_now; -use embassy_sync::blocking_mutex::raw::NoopRawMutex; -use embassy_sync::pipe::{DynamicReader, DynamicWriter, Pipe}; -use embassy_time::{with_deadline, Instant}; +use bt_hci::cmd::le::{ + LeAddDeviceToFilterAcceptList, LeClearFilterAcceptList, LeSetExtScanEnable, LeSetExtScanParams, LeSetScanEnable, +}; +use bt_hci::controller::{Controller, ControllerCmdSync}; +use bt_hci::param::{AddrKind, FilterDuplicates, ScanningPhy}; +pub use bt_hci::param::{LeAdvReportsIter, LeExtAdvReportsIter}; +use embassy_time::Instant; - -use crate::command::CommandState; -use crate::connection::ScanConfig; -use crate::host::ScanState; -use crate::{BleHostError, Central, Error}; +use crate::Central; /// A scanner that wraps a central to provide additional functionality /// around BLE scanning. From 8d91231991f7ae11b5a25a17c150e22e7f93d6e4 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:04:32 +0000 Subject: [PATCH 29/61] remove clippy and fmt from ci.sh --- ci.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci.sh b/ci.sh index f1099168..8c908db6 100755 --- a/ci.sh +++ b/ci.sh @@ -34,8 +34,7 @@ cargo batch \ --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware # --- build --release --manifest-path examples/apache-nimble/Cargo.toml --target thumbv7em-none-eabihf -cargo fmt --check --manifest-path ./host/Cargo.toml -cargo clippy --manifest-path ./host/Cargo.toml --features gatt,peripheral,central +# Run tests cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture cargo test --manifest-path ./host/Cargo.toml --no-run -- --nocapture cargo test --manifest-path ./examples/tests/Cargo.toml --no-run -- --nocapture From 47b91a7726f428456f0787d62e0e61f3797791ba Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:05:58 +0000 Subject: [PATCH 30/61] ran cargo fmt --- host/src/scan.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/host/src/scan.rs b/host/src/scan.rs index d516c329..a73ed242 100644 --- a/host/src/scan.rs +++ b/host/src/scan.rs @@ -1,17 +1,16 @@ //! Scan config. -use crate::command::CommandState; -use crate::connection::ScanConfig; -use crate::BleHostError; -use bt_hci::cmd::le::LeSetScanParams; use bt_hci::cmd::le::{ LeAddDeviceToFilterAcceptList, LeClearFilterAcceptList, LeSetExtScanEnable, LeSetExtScanParams, LeSetScanEnable, + LeSetScanParams, }; use bt_hci::controller::{Controller, ControllerCmdSync}; use bt_hci::param::{AddrKind, FilterDuplicates, ScanningPhy}; pub use bt_hci::param::{LeAdvReportsIter, LeExtAdvReportsIter}; use embassy_time::Instant; -use crate::Central; +use crate::command::CommandState; +use crate::connection::ScanConfig; +use crate::{BleHostError, Central}; /// A scanner that wraps a central to provide additional functionality /// around BLE scanning. From 6e58aa66c5a24b9e8b52e07a249a9b1bbf157132 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:11:51 +0000 Subject: [PATCH 31/61] do full scan on all stages for linting --- .github/workflows/.mega-linter.yaml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 8292ab4e..bcbbf2f4 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -170,12 +170,14 @@ jobs: rustup toolchain install nightly-x86_64-unknown-linux-gnu rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - name: Rustfmt check on host + continue-on-error: true run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check - name: Rustfmt check on host macros + continue-on-error: true run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check cargo_fmt_examples: - name: Cargo Formatter Examples + name: Cargo Formatter (Examples) runs-on: ubuntu-latest steps: - name: Checkout code @@ -185,20 +187,28 @@ jobs: rustup toolchain install nightly-x86_64-unknown-linux-gnu rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - name: Rustfmt check on apache-nimble + continue-on-error: true run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check - name: Rustfmt check on apps + continue-on-error: true run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check - name: Rustfmt check on esp32 + continue-on-error: true run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check - name: Rustfmt check on nrf-sdc + continue-on-error: true run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check - name: Rustfmt check on rp-pico-2-w + continue-on-error: true run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check - name: Rustfmt check on rp-pico-w + continue-on-error: true run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check - name: Rustfmt check on serial-hci + continue-on-error: true run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check - name: Rustfmt check on tests + continue-on-error: true run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check cargo_clippy_library: @@ -219,34 +229,42 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Cargo Clippy check on apache-nimble + continue-on-error: true run: | cd examples/apache-nimble cargo clippy - name: Cargo Clippy apps + continue-on-error: true run: | cd examples/apps cargo clippy - name: Cargo Clippy esp32 + continue-on-error: true run: | cd examples/esp32 cargo clippy - name: Cargo Clippy nrf-sdc + continue-on-error: true run: | cd examples/nrf-sdc cargo clippy - name: Cargo Clippy rp-pico-2-w + continue-on-error: true run: | cd examples/rp-pico-2-w cargo clippy - name: Cargo Clippy rp-pico-w + continue-on-error: true run: | cd examples/rp-pico-w cargo clippy - name: Cargo Clippy serial-hci + continue-on-error: true run: | cd examples/serial-hci cargo clippy - name: Cargo Clippy tests + continue-on-error: true run: | cd examples/tests cargo clippy From 542418737df96fb3b1956c1e3a4ff632297b396a Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:11:59 +0000 Subject: [PATCH 32/61] fixed ble scanner --- examples/apps/src/ble_scanner.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/apps/src/ble_scanner.rs b/examples/apps/src/ble_scanner.rs index 75f00c37..56e2494d 100644 --- a/examples/apps/src/ble_scanner.rs +++ b/examples/apps/src/ble_scanner.rs @@ -1,6 +1,7 @@ +use core::cell::RefCell; + use bt_hci::cmd::le::LeSetScanParams; use bt_hci::controller::ControllerCmdSync; -use core::cell::RefCell; use embassy_futures::join::join; use embassy_time::{Duration, Timer}; use heapless::Deque; From 517009c821a5e2cbaa4a28d189a77f3138793f62 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:14:16 +0000 Subject: [PATCH 33/61] removed continue-on-error --- .github/workflows/.mega-linter.yaml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index bcbbf2f4..8e322830 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -170,10 +170,9 @@ jobs: rustup toolchain install nightly-x86_64-unknown-linux-gnu rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - name: Rustfmt check on host - continue-on-error: true run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check - name: Rustfmt check on host macros - continue-on-error: true + run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check cargo_fmt_examples: @@ -187,28 +186,20 @@ jobs: rustup toolchain install nightly-x86_64-unknown-linux-gnu rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - name: Rustfmt check on apache-nimble - continue-on-error: true run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check - name: Rustfmt check on apps - continue-on-error: true run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check - name: Rustfmt check on esp32 - continue-on-error: true run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check - name: Rustfmt check on nrf-sdc - continue-on-error: true run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check - name: Rustfmt check on rp-pico-2-w - continue-on-error: true run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check - name: Rustfmt check on rp-pico-w - continue-on-error: true run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check - name: Rustfmt check on serial-hci - continue-on-error: true run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check - name: Rustfmt check on tests - continue-on-error: true run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check cargo_clippy_library: @@ -229,42 +220,34 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Cargo Clippy check on apache-nimble - continue-on-error: true run: | cd examples/apache-nimble cargo clippy - name: Cargo Clippy apps - continue-on-error: true run: | cd examples/apps cargo clippy - name: Cargo Clippy esp32 - continue-on-error: true run: | cd examples/esp32 cargo clippy - name: Cargo Clippy nrf-sdc - continue-on-error: true run: | cd examples/nrf-sdc cargo clippy - name: Cargo Clippy rp-pico-2-w - continue-on-error: true run: | cd examples/rp-pico-2-w cargo clippy - name: Cargo Clippy rp-pico-w - continue-on-error: true run: | cd examples/rp-pico-w cargo clippy - name: Cargo Clippy serial-hci - continue-on-error: true run: | cd examples/serial-hci cargo clippy - name: Cargo Clippy tests - continue-on-error: true run: | cd examples/tests cargo clippy From 66c920e1891a705e063706ddef70f905d4957a6c Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:18:16 +0000 Subject: [PATCH 34/61] fail on warnings --- .github/workflows/.mega-linter.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 8e322830..b45ee9d1 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -211,7 +211,7 @@ jobs: - name: Cargo Clippy check on host Macros run: | cd host-macros - cargo clippy --all-features + cargo clippy -- --D warnings --all-features cargo_clippy_examples: name: Cargo Clippy Examples @@ -222,32 +222,32 @@ jobs: - name: Cargo Clippy check on apache-nimble run: | cd examples/apache-nimble - cargo clippy + cargo clippy -- --D warnings - name: Cargo Clippy apps run: | cd examples/apps - cargo clippy + cargo clippy -- --D warnings - name: Cargo Clippy esp32 run: | cd examples/esp32 - cargo clippy + cargo clippy -- --D warnings - name: Cargo Clippy nrf-sdc run: | cd examples/nrf-sdc - cargo clippy + cargo clippy -- --D warnings - name: Cargo Clippy rp-pico-2-w run: | cd examples/rp-pico-2-w - cargo clippy + cargo clippy -- --D warnings - name: Cargo Clippy rp-pico-w run: | cd examples/rp-pico-w - cargo clippy + cargo clippy -- --D warnings - name: Cargo Clippy serial-hci run: | cd examples/serial-hci - cargo clippy + cargo clippy -- --D warnings - name: Cargo Clippy tests run: | cd examples/tests - cargo clippy + cargo clippy -- --D warnings From c07ef4988a053fb682d1b0473da15107fb06f1aa Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:20:53 +0000 Subject: [PATCH 35/61] removed old docs --- .gitignore | 4 +- docs/Diagram.drawio.svg | 296 ---------------------------------------- examples/README.md | 63 --------- 3 files changed, 3 insertions(+), 360 deletions(-) delete mode 100644 docs/Diagram.drawio.svg delete mode 100644 examples/README.md diff --git a/.gitignore b/.gitignore index d4b4c1e4..996ae9ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ **/target **/target_ci Cargo.lock -megalinter-reports/ \ No newline at end of file +megalinter-reports/ +# Mac Users +.DS_Store \ No newline at end of file diff --git a/docs/Diagram.drawio.svg b/docs/Diagram.drawio.svg deleted file mode 100644 index bd47b55c..00000000 --- a/docs/Diagram.drawio.svg +++ /dev/null @@ -1,296 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - Pull Request - -
-
-
-
- - Pull Request - -
-
- - - - - - - - -
-
-
- Trigger -
- Hardware Independent -
- host tests -
-
-
-
- - Trigger... - -
-
- - - - - - - - - - -
-
-
- Self Hosted Runner -
-
-
-
- - Self Hosted Runner - -
-
- - - - - - - - -
-
-
- RodBot -
-
-
-
- - RodBot - -
-
- - - - -
-
-
- Integration Tests -
-
-
-
- - Integration Tests - -
-
- - - - - - -
-
-
- Example Tests -
-
-
-
- - Example Tests - -
-
- - - - -
-
-
- ci.yaml -
-
-
-
- - ci.yaml - -
-
- - - - -
-
-
- tests.yaml -
-
-
-
- - tests.yaml - -
-
- - - - -
-
-
- - Cloud - -
- - Runner - -
-
-
-
-
- - Cloud... - -
-
- - - - - - - -
-
-
- Self Hosted Runner -
-
-
-
- - Self Hosted Runner - -
-
- - - - -
-
-
- HIL Bench -
-
-
-
- - HIL Be... - -
-
- - - - - - -
-
-
- - USB - -
-
-
-
- - USB - -
-
- - - - - - -
-
-
- - USB - -
-
-
-
- - USB - -
-
-
- - - - - Text is not SVG - cannot display - - - -
\ No newline at end of file diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 0aa9cadb..00000000 --- a/examples/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# Examples - -## Summary - -Within this directory we have numerous examples showing how to get started using Trouble in your projects. We also test these examples using Automated CI. More information on this can be found below: - -## Example Applications - -Within this examples directory we have the following structure: - -```bash -tree -L 1 -. -├── README.md -├── apache-nimble -├── apps -├── esp32 -├── nrf-sdc -├── rp-pico-2-w -├── rp-pico-w -├── serial-hci -``` - -The `apps` folder contains the functionality that is used in every example across the multiple platforms. This crate is then pulled into each example and can be run by simply flashing the code onto the devices using `cargo run` within each of the project directories. - -The hardware for which each example uses is listed below: - -- **[apache-nimble](./apache-nimble/Cargo.toml)**: -- **[esp32](./esp32/Cargo.toml)**: [ESP-Rust-Board](https://github.com/esp-rs/esp-rust-board) -- **[rp-pico-2-w](./rp-pico-2-w/Cargo.toml)**: [Raspberry Pi Pico 2 W](https://thepihut.com/products/raspberry-pi-pico-2-w?variant=53727839027585&country=GB¤cy=GBP&utm_medium=product_sync&utm_source=google&utm_content=sag_organic&utm_campaign=sag_organic&gad_source=1&gclid=CjwKCAiAkc28BhB0EiwAM001TXNknX7fTXNwbaySLfbvbUJRaOgFseqj6RcDeu4Dd8RE64GgZ0imnxoCVVYQAvD_BwE) -- **[rp-pico-w](./rp-pico-w/Cargo.toml)**: [Raspberry Pico W](https://thepihut.com/products/raspberry-pi-pico-w) -- **[serial-hci](./serial-hci/Cargo.toml)**: Can be used with any Serial HCI, the following has been used: - - [Example 1]() - - [Example 2]() - - [Example 3]() - -## Tests - -### Hardware Indepedent Tests - -The Tests inside the [tests crate](./tests/Cargo.toml) are being ran inside the GitHub Actions Runner on a cloud host. The commands for this can be found [here](../ci.sh) and [here](../.github/workflows/ci.yaml). - -### Hardware in the Loop Tests - -The Tests inside the [tests crate](./tests/Cargo.toml) are also run using a `self-hosted` runner utilising the [Hil Bench](https://github.com/lulf/hilbench/tree/main). This works by using the [tests.yaml](../.github/workflows/tests.yaml) flow in which `example-tests` is used alongside integrations tests. - -The self hosted HIL Bench setup can be further understood using the following diagram: - -![HIL Bench Setup](../docs/Diagram.drawio.svg) - -[RodBot](https://github.com/ctron/rodbot) is used to setup the `tests` by using dedicated approvers to call the integration and example tests. - -## Integration tests - -In terms of integration tests these are defined in the [tests.yaml](../.github/workflows/tests.yaml) under `integration_tests` job. Which are running the tests in the [host crate](../host/tests/). These require the following hardware: - -These tests do not use the [hilbench](https://github.com/lulf/hilbench/tree/main) helper crate. - -## Example Tests - -The tests that use hardware are the [example tests](../examples/tests/tests/). These tests require the hilbench. - -The integration tests first work by downloading the artifacts which downloads the bins for each test. Then using the [config.json](../.ci/config.json) it selects the MCU to flash and run the tests on. Each time the tests are done on the Linux side with the examples being connected too. From 90f495828cf57ddee1345f1af7e37cc9832f7d1a Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:24:41 +0000 Subject: [PATCH 36/61] fixed clippy warnings --- examples/apps/src/ble_scanner.rs | 14 ++++++++------ examples/apps/src/fmt.rs | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/apps/src/ble_scanner.rs b/examples/apps/src/ble_scanner.rs index 56e2494d..9acf26f1 100644 --- a/examples/apps/src/ble_scanner.rs +++ b/examples/apps/src/ble_scanner.rs @@ -32,11 +32,13 @@ where }; let mut scanner = Scanner::new(central); let _ = join(runner.run_with_handler(&printer), async { - let mut config = ScanConfig::default(); - config.active = true; - config.phys = PhySet::M1; - config.interval = Duration::from_secs(1); - config.window = Duration::from_secs(1); + let config = ScanConfig::<'_> { + active: true, + phys: PhySet::M1, + interval: Duration::from_secs(1), + window: Duration::from_secs(1), + ..Default::default() + }; let mut _session = scanner.scan(&config).await.unwrap(); // Scan forever loop { @@ -54,7 +56,7 @@ impl EventHandler for Printer { fn on_adv_reports(&self, mut it: LeAdvReportsIter<'_>) { let mut seen = self.seen.borrow_mut(); while let Some(Ok(report)) = it.next() { - if seen.iter().find(|b| b.raw() == report.addr.raw()).is_none() { + if !seen.iter().any(|b| b.raw() == report.addr.raw()) { info!("discovered: {:?}", report.addr); if seen.is_full() { seen.pop_front(); diff --git a/examples/apps/src/fmt.rs b/examples/apps/src/fmt.rs index c46fff33..6c8f7402 100644 --- a/examples/apps/src/fmt.rs +++ b/examples/apps/src/fmt.rs @@ -233,19 +233,19 @@ impl Try for Result { #[allow(unused)] pub(crate) struct Bytes<'a>(pub &'a [u8]); -impl<'a> Debug for Bytes<'a> { +impl Debug for Bytes<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{:#02x?}", self.0) } } -impl<'a> Display for Bytes<'a> { +impl Display for Bytes<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{:#02x?}", self.0) } } -impl<'a> LowerHex for Bytes<'a> { +impl LowerHex for Bytes<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{:#02x?}", self.0) } From f7b42531e769e7a28346d3644a839bf580c5fc73 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:26:41 +0000 Subject: [PATCH 37/61] removed tests that imediately fail --- .github/workflows/.mega-linter.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index b45ee9d1..0a0625cb 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -219,18 +219,18 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Cargo Clippy check on apache-nimble - run: | - cd examples/apache-nimble - cargo clippy -- --D warnings + # - name: Cargo Clippy check on apache-nimble + # run: | + # cd examples/apache-nimble + # cargo clippy -- --D warnings - name: Cargo Clippy apps run: | cd examples/apps cargo clippy -- --D warnings - - name: Cargo Clippy esp32 - run: | - cd examples/esp32 - cargo clippy -- --D warnings + # - name: Cargo Clippy esp32 + # run: | + # cd examples/esp32 + # cargo clippy -- --D warnings - name: Cargo Clippy nrf-sdc run: | cd examples/nrf-sdc From ee40712b39a5ff646becfbf56051bf56f6a8a265 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:28:49 +0000 Subject: [PATCH 38/61] dont need all-features flag in host-macros --- .github/workflows/.mega-linter.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 0a0625cb..757f7574 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -211,7 +211,7 @@ jobs: - name: Cargo Clippy check on host Macros run: | cd host-macros - cargo clippy -- --D warnings --all-features + cargo clippy -- --D warnings cargo_clippy_examples: name: Cargo Clippy Examples From d500c48064b23a0baf9bc4e6df74e5c32233902a Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:30:59 +0000 Subject: [PATCH 39/61] made it a bit clearer on the GitHub Runner side --- .github/workflows/.mega-linter.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 757f7574..6712eeb8 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -203,7 +203,7 @@ jobs: run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check cargo_clippy_library: - name: Cargo Clippy Host Macros + name: Cargo Clippy (Host Macros) runs-on: ubuntu-latest steps: - name: Checkout code @@ -211,10 +211,10 @@ jobs: - name: Cargo Clippy check on host Macros run: | cd host-macros - cargo clippy -- --D warnings + cargo clippy -- --D warnings cargo_clippy_examples: - name: Cargo Clippy Examples + name: Cargo Clippy (Examples) runs-on: ubuntu-latest steps: - name: Checkout code From b244463a4529a43a8357c42d3f377cec420f99f2 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:40:58 +0000 Subject: [PATCH 40/61] commented back in examples checking --- .github/workflows/.mega-linter.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 6712eeb8..90e9514a 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -219,18 +219,18 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - # - name: Cargo Clippy check on apache-nimble - # run: | - # cd examples/apache-nimble - # cargo clippy -- --D warnings + - name: Cargo Clippy check on apache-nimble + run: | + cd examples/apache-nimble + cargo clippy -- --D warnings - name: Cargo Clippy apps run: | cd examples/apps cargo clippy -- --D warnings - # - name: Cargo Clippy esp32 - # run: | - # cd examples/esp32 - # cargo clippy -- --D warnings + - name: Cargo Clippy esp32 + run: | + cd examples/esp32 + cargo clippy -- --D warnings - name: Cargo Clippy nrf-sdc run: | cd examples/nrf-sdc From c374ce15bf9b72a6cc5266e2fb968e1c29567f4e Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Mon, 27 Jan 2025 16:46:37 +0000 Subject: [PATCH 41/61] added Default --- examples/tests/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/tests/src/lib.rs b/examples/tests/src/lib.rs index dbccd3ee..5df228f7 100644 --- a/examples/tests/src/lib.rs +++ b/examples/tests/src/lib.rs @@ -31,3 +31,9 @@ impl TestContext { Ok(DeviceUnderTest::new(target)) } } + +impl Default for TestContext { + fn default() -> Self { + Self::new() + } +} From 720b5478810064dc523642fe231546b68cb91243 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 10:31:48 +0000 Subject: [PATCH 42/61] added extensions --- .vscode/extensions.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4b16fb23..08707587 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,8 +5,14 @@ "recommendations": [ "rust-lang.rust-analyzer", "tamasfe.even-better-toml", - "fill-labs.dependi" + "fill-labs.dependi", + "tamasfe.even-better-toml", + "esbenp.prettier-vscode", + "foxundermoon.shell-format", + "charliermarsh.ruff", + "timonwong.shellcheck", + "davidanson.vscode-markdownlint" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] -} +} \ No newline at end of file From 294213a31fa18c1d39f5801514f7101953e5853a Mon Sep 17 00:00:00 2001 From: ScottGibb <44235263+ScottGibb@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:35:17 +0000 Subject: [PATCH 43/61] [MegaLinter] Apply linters automatic fixes --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 08707587..85b8d01e 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -15,4 +15,4 @@ ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] -} \ No newline at end of file +} From f890a90a7ff4b0aa5ae74fb26c621deebaed0494 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 12:36:51 +0000 Subject: [PATCH 44/61] added esp32 clippy tests --- .github/workflows/.mega-linter.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 90e9514a..3794cd5b 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -230,7 +230,12 @@ jobs: - name: Cargo Clippy esp32 run: | cd examples/esp32 - cargo clippy -- --D warnings + cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32c3--target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings - name: Cargo Clippy nrf-sdc run: | cd examples/nrf-sdc From 1949a342d934f52915910e8745eb6910fe91b3e1 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 13:03:06 +0000 Subject: [PATCH 45/61] removed whitespaces --- .github/workflows/.mega-linter.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 3794cd5b..d3dfb631 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -230,12 +230,12 @@ jobs: - name: Cargo Clippy esp32 run: | cd examples/esp32 - cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings - cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings - cargo clippy --no-default-features --features=esp32c3--target=riscv32imc-unknown-none-elf -- -D warnings - cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings - cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings - cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32c3--target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings - name: Cargo Clippy nrf-sdc run: | cd examples/nrf-sdc From 920aabf84b55f1ccddab7310cde8192078c94611 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 13:04:52 +0000 Subject: [PATCH 46/61] removed apache-nimble from CI --- .github/workflows/.mega-linter.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index d3dfb631..aac25f2d 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -219,10 +219,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Cargo Clippy check on apache-nimble - run: | - cd examples/apache-nimble - cargo clippy -- --D warnings + # - name: Cargo Clippy check on apache-nimble # (Disabled due to version bumps needed) + # run: | + # cd examples/apache-nimble + # cargo clippy -- --D warnings - name: Cargo Clippy apps run: | cd examples/apps From 3ddf894b58444544b41edfba5616e655dba7e8d9 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 14:33:09 +0000 Subject: [PATCH 47/61] commented out broken toolchains --- .github/workflows/.mega-linter.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index aac25f2d..246bc86b 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -230,12 +230,12 @@ jobs: - name: Cargo Clippy esp32 run: | cd examples/esp32 - cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings + # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings cargo clippy --no-default-features --features=esp32c3--target=riscv32imc-unknown-none-elf -- -D warnings cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings - cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings + # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) - name: Cargo Clippy nrf-sdc run: | cd examples/nrf-sdc From c979cbac1f22e298839ad19505b8ed8766990342 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 14:43:11 +0000 Subject: [PATCH 48/61] fix --- .github/workflows/.mega-linter.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 246bc86b..b2bc4573 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -232,7 +232,7 @@ jobs: cd examples/esp32 # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings - cargo clippy --no-default-features --features=esp32c3--target=riscv32imc-unknown-none-elf -- -D warnings + cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) From 7fe81a07eb88b2da77fbdbf67ce46e403ccff54e Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 15:02:13 +0000 Subject: [PATCH 49/61] removed esp32c6 --- .github/workflows/.mega-linter.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index b2bc4573..1f65e3d4 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -230,11 +230,17 @@ jobs: - name: Cargo Clippy esp32 run: | cd examples/esp32 + # echo "Checking esp32" # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) + echo "Checking esp32c3" cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings + echo "Checking esp32c3" cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings - cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings + # echo "Checking esp32c6" + # cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings + echo "Checking esp32h2" cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings + # echo "Checking esp32s2" # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) - name: Cargo Clippy nrf-sdc run: | From d57350dd22a4666183f85b93e225d3831f45480f Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 15:04:05 +0000 Subject: [PATCH 50/61] and esp32h2 --- .github/workflows/.mega-linter.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 1f65e3d4..07f82d3a 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -238,8 +238,8 @@ jobs: cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings # echo "Checking esp32c6" # cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings - echo "Checking esp32h2" - cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings + # echo "Checking esp32h2" + # cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings # echo "Checking esp32s2" # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) - name: Cargo Clippy nrf-sdc From 8632e9c8347006e06f0acc2614a32305769276d9 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 15:10:59 +0000 Subject: [PATCH 51/61] update echo strings --- .github/workflows/.mega-linter.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 07f82d3a..65aee0c3 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -232,7 +232,7 @@ jobs: cd examples/esp32 # echo "Checking esp32" # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) - echo "Checking esp32c3" + echo "Checking esp32c2" cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings echo "Checking esp32c3" cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings @@ -240,7 +240,7 @@ jobs: # cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings # echo "Checking esp32h2" # cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings - # echo "Checking esp32s2" + # echo "Checking esp32s3" # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) - name: Cargo Clippy nrf-sdc run: | From 34c4d5513df2fd527cbf99ae66a7cd86af63b320 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 16:01:08 +0000 Subject: [PATCH 52/61] added nrf clippy --- .github/workflows/.mega-linter.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 65aee0c3..55be1b99 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -245,7 +245,12 @@ jobs: - name: Cargo Clippy nrf-sdc run: | cd examples/nrf-sdc - cargo clippy -- --D warnings + echo "Checking nrf52832" + cargo clippy --features=nrf52832 -- -D warnings + echo "Checking nrf52833" + cargo clippy --features=nrf52833 -- -D warnings + echo "Checking nrf52840" + cargo clippy --features=nrf52840 -- -D warnings - name: Cargo Clippy rp-pico-2-w run: | cd examples/rp-pico-2-w From f791c4bf384a7d2c5f535eadbfad7e2d7e3dc29f Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 16:51:30 +0000 Subject: [PATCH 53/61] adding back esp32c6 and esp32h2 --- .github/workflows/.mega-linter.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 55be1b99..b2e0e122 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -236,10 +236,10 @@ jobs: cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings echo "Checking esp32c3" cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings - # echo "Checking esp32c6" - # cargo clippy --no-default-features --features=esp32c6 --target=riscv32imc-unknown-none-elf -- -D warnings - # echo "Checking esp32h2" - # cargo clippy --no-default-features --features=esp32h2 --target=riscv32imc-unknown-none-elf -- -D warnings + echo "Checking esp32c6" + cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings + echo "Checking esp32h2" + cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings # echo "Checking esp32s3" # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) - name: Cargo Clippy nrf-sdc From a4a7197746df3e16423d3acb7e8fa1fd1e7157c7 Mon Sep 17 00:00:00 2001 From: Scott Gibb Date: Tue, 28 Jan 2025 17:05:35 +0000 Subject: [PATCH 54/61] added toolchain --- .github/workflows/.mega-linter.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index b2e0e122..a9d58fbe 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -219,6 +219,9 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Install toolchains + run: | + rustup target add riscv32imac-unknown-none-elf # - name: Cargo Clippy check on apache-nimble # (Disabled due to version bumps needed) # run: | # cd examples/apache-nimble From 9db0f7c8bc1aab5833d0560b3a805ca962df8616 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 4 Mar 2025 14:13:02 +0000 Subject: [PATCH 55/61] removed issue with duplicated imports --- host/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/host/src/lib.rs b/host/src/lib.rs index faf1e904..ec735309 100644 --- a/host/src/lib.rs +++ b/host/src/lib.rs @@ -14,11 +14,9 @@ use core::mem::MaybeUninit; use advertise::AdvertisementDataError; use bt_hci::FromHciBytesError; -use bt_hci::FromHciBytesError; use bt_hci::cmd::status::ReadRssi; use bt_hci::cmd::{AsyncCmd, SyncCmd}; use bt_hci::param::{AddrKind, BdAddr}; -use bt_hci::param::{AddrKind, BdAddr}; use crate::att::AttErrorCode; use crate::channel_manager::{ChannelStorage, PacketChannel}; From 8d872619715d82911c1244a441acce5ea2315721 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 4 Mar 2025 14:14:17 +0000 Subject: [PATCH 56/61] removed double import --- host/src/central.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/host/src/central.rs b/host/src/central.rs index f668a168..51f61cce 100644 --- a/host/src/central.rs +++ b/host/src/central.rs @@ -7,9 +7,6 @@ use embassy_futures::select::{Either, select}; use crate::connection::{ConnectConfig, Connection, PhySet}; use crate::{BleHostError, Error, Stack}; -use crate::connection::{ConnectConfig, Connection, PhySet}; -use crate::{BleHostError, Error, Stack}; - /// A type implementing the BLE central role. pub struct Central<'stack, C> { pub(crate) stack: &'stack Stack<'stack, C>, From e9ecf4428a53f16898e1a25a68d321cd2727ffa9 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 4 Mar 2025 14:37:39 +0000 Subject: [PATCH 57/61] all formatting and clippy now done in ci.sh --- .github/workflows/.mega-linter.yaml | 214 ++++++++++++++-------------- .mega-linter.yaml | 2 +- ci.sh | 47 ++++++ 3 files changed, 155 insertions(+), 108 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index a9d58fbe..9f6ee264 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -159,114 +159,114 @@ jobs: exit 1 fi # Required due to Mega Linter not currently supporting Rust Format - cargo_fmt_library: - name: Cargo Formatter (Library) - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Toolchains - run: | - rustup toolchain install nightly-x86_64-unknown-linux-gnu - rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - - name: Rustfmt check on host - run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check - - name: Rustfmt check on host macros + # cargo_fmt_library: + # name: Cargo Formatter (Library) + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + # - name: Install Toolchains + # run: | + # rustup toolchain install nightly-x86_64-unknown-linux-gnu + # rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt + # - name: Rustfmt check on host + # run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check + # - name: Rustfmt check on host macros - run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check + # run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check - cargo_fmt_examples: - name: Cargo Formatter (Examples) - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Toolchains - run: | - rustup toolchain install nightly-x86_64-unknown-linux-gnu - rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - - name: Rustfmt check on apache-nimble - run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check - - name: Rustfmt check on apps - run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check - - name: Rustfmt check on esp32 - run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check - - name: Rustfmt check on nrf-sdc - run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check - - name: Rustfmt check on rp-pico-2-w - run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check - - name: Rustfmt check on rp-pico-w - run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check - - name: Rustfmt check on serial-hci - run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check - - name: Rustfmt check on tests - run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check + # cargo_fmt_examples: + # name: Cargo Formatter (Examples) + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + # - name: Install Toolchains + # run: | + # rustup toolchain install nightly-x86_64-unknown-linux-gnu + # rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt + # - name: Rustfmt check on apache-nimble + # run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check + # - name: Rustfmt check on apps + # run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check + # - name: Rustfmt check on esp32 + # run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check + # - name: Rustfmt check on nrf-sdc + # run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check + # - name: Rustfmt check on rp-pico-2-w + # run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check + # - name: Rustfmt check on rp-pico-w + # run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check + # - name: Rustfmt check on serial-hci + # run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check + # - name: Rustfmt check on tests + # run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check - cargo_clippy_library: - name: Cargo Clippy (Host Macros) - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Cargo Clippy check on host Macros - run: | - cd host-macros - cargo clippy -- --D warnings + # cargo_clippy_library: + # name: Cargo Clippy (Host Macros) + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + # - name: Cargo Clippy check on host Macros + # run: | + # cd host-macros + # cargo clippy -- --D warnings - cargo_clippy_examples: - name: Cargo Clippy (Examples) - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install toolchains - run: | - rustup target add riscv32imac-unknown-none-elf - # - name: Cargo Clippy check on apache-nimble # (Disabled due to version bumps needed) - # run: | - # cd examples/apache-nimble - # cargo clippy -- --D warnings - - name: Cargo Clippy apps - run: | - cd examples/apps - cargo clippy -- --D warnings - - name: Cargo Clippy esp32 - run: | - cd examples/esp32 - # echo "Checking esp32" - # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) - echo "Checking esp32c2" - cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings - echo "Checking esp32c3" - cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings - echo "Checking esp32c6" - cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings - echo "Checking esp32h2" - cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings - # echo "Checking esp32s3" - # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) - - name: Cargo Clippy nrf-sdc - run: | - cd examples/nrf-sdc - echo "Checking nrf52832" - cargo clippy --features=nrf52832 -- -D warnings - echo "Checking nrf52833" - cargo clippy --features=nrf52833 -- -D warnings - echo "Checking nrf52840" - cargo clippy --features=nrf52840 -- -D warnings - - name: Cargo Clippy rp-pico-2-w - run: | - cd examples/rp-pico-2-w - cargo clippy -- --D warnings - - name: Cargo Clippy rp-pico-w - run: | - cd examples/rp-pico-w - cargo clippy -- --D warnings - - name: Cargo Clippy serial-hci - run: | - cd examples/serial-hci - cargo clippy -- --D warnings - - name: Cargo Clippy tests - run: | - cd examples/tests - cargo clippy -- --D warnings + # cargo_clippy_examples: + # name: Cargo Clippy (Examples) + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + # - name: Install toolchains + # run: | + # rustup target add riscv32imac-unknown-none-elf + # # - name: Cargo Clippy check on apache-nimble # (Disabled due to version bumps needed) + # # run: | + # # cd examples/apache-nimble + # # cargo clippy -- --D warnings + # - name: Cargo Clippy apps + # run: | + # cd examples/apps + # cargo clippy -- --D warnings + # - name: Cargo Clippy esp32 + # run: | + # cd examples/esp32 + # # echo "Checking esp32" + # # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) + # echo "Checking esp32c2" + # cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings + # echo "Checking esp32c3" + # cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings + # echo "Checking esp32c6" + # cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings + # echo "Checking esp32h2" + # cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings + # # echo "Checking esp32s3" + # # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) + # - name: Cargo Clippy nrf-sdc + # run: | + # cd examples/nrf-sdc + # echo "Checking nrf52832" + # cargo clippy --features=nrf52832 -- -D warnings + # echo "Checking nrf52833" + # cargo clippy --features=nrf52833 -- -D warnings + # echo "Checking nrf52840" + # cargo clippy --features=nrf52840 -- -D warnings + # - name: Cargo Clippy rp-pico-2-w + # run: | + # cd examples/rp-pico-2-w + # cargo clippy -- --D warnings + # - name: Cargo Clippy rp-pico-w + # run: | + # cd examples/rp-pico-w + # cargo clippy -- --D warnings + # - name: Cargo Clippy serial-hci + # run: | + # cd examples/serial-hci + # cargo clippy -- --D warnings + # - name: Cargo Clippy tests + # run: | + # cd examples/tests + # cargo clippy -- --D warnings diff --git a/.mega-linter.yaml b/.mega-linter.yaml index 39d5a0cd..300b0328 100644 --- a/.mega-linter.yaml +++ b/.mega-linter.yaml @@ -14,7 +14,7 @@ APPLY_FIXES: all # If you use ENABLE_LINTERS variable, all other linters will be disabled by default ENABLE_LINTERS: - ACTION_ACTIONLINT - - RUST_CLIPPY + # - RUST_CLIPPY # Removed as doing inside ci.sh - MARKDOWN_MARKDOWNLINT - MARKDOWN_MARKDOWN_LINK_CHECK - MARKDOWN_MARKDOWN_TABLE_FORMATTER diff --git a/ci.sh b/ci.sh index 0364ad1e..b309a189 100755 --- a/ci.sh +++ b/ci.sh @@ -52,6 +52,53 @@ cargo batch \ --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware # --- build --release --manifest-path examples/apache-nimble/Cargo.toml --target thumbv7em-none-eabihf +# Run Cargo fmt +cargo batch \ + # Core Library + --- fmt --manifest-path host/Cargo.toml -- --check + --- fmt --manifest-path host-macros/Cargo.toml -- --check + # Examples + --- fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check + --- fmt --manifest-path examples/apps/Cargo.toml -- --check + --- fmt --manifest-path examples/esp32/Cargo.toml -- --check + --- fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check + --- fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check + --- fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check + --- fmt --manifest-path examples/serial-hci/Cargo.toml -- --check + --- fmt --manifest-path examples/tests/Cargo.toml -- --check + +# Clippy Main Library +cd host && cargo clippy -- -D warnings && cd .. +cd host-macros && cargo clippy -- -D warnings && cd .. + +# Clippy Examples +cd examples +cd apache-nimble && cargo clippy -- -D warnings && cd .. +cd apps && cargo clippy -- -D warnings && cd .. +# ESP32 Examples +cd esp32 && cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings && cd .. +cd esp32c2 && cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings && cd .. +cd esp32c3 && cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings && cd.. +cd esp32c6 && cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings && cd.. +cd esp32h2 && cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings && cd.. +cd esp32s3 && cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings && cd.. +# nrf-sdc +cd nrf-sdc +cargo clippy --features=nrf52832 -- -D warnings +cargo clippy --features=nrf52833 -- -D warnings +cargo clippy --features=nrf52840 -- -D warnings +cd.. +# rp-pico-2-w +cd rp-pico-2-w && cargo clippy -- --D warnings && cd.. +# rp-pico-w +cd rp-pico-w && cargo clippy -- --D warnings && cd.. +# serial-hci +cd serial-hci && cargo clippy -- --D warnings && cd.. +# tests +cd tests && cargo clippy -- --D warnings && cd.. +# Leave examples folder +cd.. + # Run tests cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture cargo test --manifest-path ./host/Cargo.toml --no-run -- --nocapture From 5ee9d856237f73441c83541e251fb4f1d37d7255 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 4 Mar 2025 14:43:24 +0000 Subject: [PATCH 58/61] added missing \ --- ci.sh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/ci.sh b/ci.sh index b309a189..19471f16 100755 --- a/ci.sh +++ b/ci.sh @@ -8,6 +8,7 @@ if ! command -v cargo-batch &>/dev/null; then chmod +x "$HOME"/.cargo/bin/cargo-batch fi + export RUSTFLAGS=-Dwarnings export DEFMT_LOG=trace export CARGO_NET_GIT_FETCH_WITH_CLI=true @@ -31,7 +32,7 @@ cargo batch \ --- build --release --manifest-path examples/serial-hci/Cargo.toml \ --- build --release --manifest-path examples/tests/Cargo.toml \ --- build --release --manifest-path examples/rp-pico-w/Cargo.toml --target thumbv6m-none-eabi --features skip-cyw43-firmware \ - --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware + --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware \ --- build --release --manifest-path host/Cargo.toml --no-default-features --features peripheral \ --- build --release --manifest-path host/Cargo.toml --no-default-features --features central \ --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,scan \ @@ -54,18 +55,16 @@ cargo batch \ # Run Cargo fmt cargo batch \ - # Core Library - --- fmt --manifest-path host/Cargo.toml -- --check - --- fmt --manifest-path host-macros/Cargo.toml -- --check - # Examples - --- fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check - --- fmt --manifest-path examples/apps/Cargo.toml -- --check - --- fmt --manifest-path examples/esp32/Cargo.toml -- --check - --- fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check - --- fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check - --- fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check - --- fmt --manifest-path examples/serial-hci/Cargo.toml -- --check - --- fmt --manifest-path examples/tests/Cargo.toml -- --check + --- fmt --manifest-path host/Cargo.toml -- --check \ + --- fmt --manifest-path host-macros/Cargo.toml -- --check \ + --- fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check \ + --- fmt --manifest-path examples/apps/Cargo.toml -- --check \ + --- fmt --manifest-path examples/esp32/Cargo.toml -- --check \ + --- fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check \ + --- fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check \ + --- fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check \ + --- fmt --manifest-path examples/serial-hci/Cargo.toml -- --check \ + --- fmt --manifest-path examples/tests/Cargo.toml -- --check \ # Clippy Main Library cd host && cargo clippy -- -D warnings && cd .. @@ -99,6 +98,10 @@ cd tests && cargo clippy -- --D warnings && cd.. # Leave examples folder cd.. +# Run MegaLinter (if enabled) + + + # Run tests cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture cargo test --manifest-path ./host/Cargo.toml --no-run -- --nocapture From 48d5fbf90b22e64755c7a308637d96683a1853b7 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 4 Mar 2025 15:01:15 +0000 Subject: [PATCH 59/61] added print statements --- ci.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ci.sh b/ci.sh index 19471f16..ca8a7069 100755 --- a/ci.sh +++ b/ci.sh @@ -15,7 +15,7 @@ export CARGO_NET_GIT_FETCH_WITH_CLI=true if [[ -z "${CARGO_TARGET_DIR}" ]]; then export CARGO_TARGET_DIR=target_ci fi - +echo "Running Cargo Build" cargo batch \ --- build --release --manifest-path host/Cargo.toml --no-default-features --features peripheral \ --- build --release --manifest-path host/Cargo.toml --no-default-features --features central \ @@ -54,6 +54,7 @@ cargo batch \ # --- build --release --manifest-path examples/apache-nimble/Cargo.toml --target thumbv7em-none-eabihf # Run Cargo fmt +echo "Running Cargo fmt" cargo batch \ --- fmt --manifest-path host/Cargo.toml -- --check \ --- fmt --manifest-path host-macros/Cargo.toml -- --check \ @@ -66,7 +67,9 @@ cargo batch \ --- fmt --manifest-path examples/serial-hci/Cargo.toml -- --check \ --- fmt --manifest-path examples/tests/Cargo.toml -- --check \ + # Clippy Main Library +echo "Running Cargo Clippy" cd host && cargo clippy -- -D warnings && cd .. cd host-macros && cargo clippy -- -D warnings && cd .. @@ -98,11 +101,11 @@ cd tests && cargo clippy -- --D warnings && cd.. # Leave examples folder cd.. -# Run MegaLinter (if enabled) - +# Run and install MegaLinter (if enabled) # Run tests +echo "Running Cargo Clippy" cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture cargo test --manifest-path ./host/Cargo.toml --no-run -- --nocapture cargo test --manifest-path ./examples/tests/Cargo.toml --no-run -- --nocapture From 84bf2fb9f03aa0f93bd3f59a71c249ec63f02c12 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 4 Mar 2025 15:29:14 +0000 Subject: [PATCH 60/61] commented out mega-linter --- .github/workflows/.mega-linter.yaml | 498 ++++++++++++++-------------- .github/workflows/ci.yaml | 4 +- ci.sh | 48 ++- 3 files changed, 298 insertions(+), 252 deletions(-) diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml index 9f6ee264..d86f3aca 100644 --- a/.github/workflows/.mega-linter.yaml +++ b/.github/workflows/.mega-linter.yaml @@ -1,272 +1,272 @@ -# MegaLinter GitHub Action configuration file -# More info at https://megalinter.io ---- -name: MegaLinter +# # MegaLinter GitHub Action configuration file +# # More info at https://megalinter.io +# --- +# name: MegaLinter -# Trigger mega-linter at every push. Action will also be visible from -# Pull Requests to main -on: - # Comment this line to trigger action only on pull-requests---------------------------------------------------------------- - # (not recommended if you don't pay for GH Actions) - push: - branches: - - main - - master - pull_request: - branches: - - main - - master - workflow_call: +# # Trigger mega-linter at every push. Action will also be visible from +# # Pull Requests to main +# on: +# # Comment this line to trigger action only on pull-requests---------------------------------------------------------------- +# # (not recommended if you don't pay for GH Actions) +# push: +# branches: +# - main +# - master +# pull_request: +# branches: +# - main +# - master +# workflow_call: -# Comment env block if you do not want to apply fixes -env: - # Apply linter fixes configuration - # - # When active, APPLY_FIXES must also be defined as environment variable - # (in github/workflows/mega-linter.yml or other CI tool) - APPLY_FIXES: all +# # Comment env block if you do not want to apply fixes +# env: +# # Apply linter fixes configuration +# # +# # When active, APPLY_FIXES must also be defined as environment variable +# # (in github/workflows/mega-linter.yml or other CI tool) +# APPLY_FIXES: all - # Decide which event triggers application of fixes in a commit or a PR - # (pull_request, push, all) - APPLY_FIXES_EVENT: pull_request +# # Decide which event triggers application of fixes in a commit or a PR +# # (pull_request, push, all) +# APPLY_FIXES_EVENT: pull_request - # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) - # or posted in a PR (pull_request) - APPLY_FIXES_MODE: pull_request +# # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) +# # or posted in a PR (pull_request) +# APPLY_FIXES_MODE: pull_request -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true +# concurrency: +# group: ${{ github.ref }}-${{ github.workflow }} +# cancel-in-progress: true -jobs: - megalinter: - name: MegaLinter - runs-on: ubuntu-latest +# jobs: +# megalinter: +# name: MegaLinter +# runs-on: ubuntu-latest - # Give the default GITHUB_TOKEN write permission to commit and push, comment - # issues, and post new Pull Requests; remove the ones you do not need - permissions: - contents: write - issues: write - pull-requests: write - statuses: write +# # Give the default GITHUB_TOKEN write permission to commit and push, comment +# # issues, and post new Pull Requests; remove the ones you do not need +# permissions: +# contents: write +# issues: write +# pull-requests: write +# statuses: write - steps: - # Git Checkout - - name: Checkout Code - uses: actions/checkout@v4 - with: - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} +# steps: +# # Git Checkout +# - name: Checkout Code +# uses: actions/checkout@v4 +# with: +# token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} - # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to - # improve performance - fetch-depth: 0 +# # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to +# # improve performance +# fetch-depth: 0 - # MegaLinter - - name: MegaLinter +# # MegaLinter +# - name: MegaLinter - # You can override MegaLinter flavor used to have faster performances - # More info at https://megalinter.io/latest/flavors/ - uses: oxsecurity/megalinter@v8.3.0 +# # You can override MegaLinter flavor used to have faster performances +# # More info at https://megalinter.io/latest/flavors/ +# uses: oxsecurity/megalinter@v8.3.0 - id: ml +# id: ml - # All available variables are described in documentation - # https://megalinter.io/latest/config-file/ - env: - # Validates all source when push on main, else just the git diff with - # main. Override with true if you always want to lint all sources - # - # To validate the entire codebase, set to: - # VALIDATE_ALL_CODEBASE: true - # - # To validate only diff with main, set to: - # VALIDATE_ALL_CODEBASE: >- - # ${{ - # github.event_name == 'push' && - # github.ref == 'refs/heads/main' - # }} - VALIDATE_ALL_CODEBASE: true +# # All available variables are described in documentation +# # https://megalinter.io/latest/config-file/ +# env: +# # Validates all source when push on main, else just the git diff with +# # main. Override with true if you always want to lint all sources +# # +# # To validate the entire codebase, set to: +# # VALIDATE_ALL_CODEBASE: true +# # +# # To validate only diff with main, set to: +# # VALIDATE_ALL_CODEBASE: >- +# # ${{ +# # github.event_name == 'push' && +# # github.ref == 'refs/heads/main' +# # }} +# VALIDATE_ALL_CODEBASE: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF - # .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY +# # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF +# # .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY - # Upload MegaLinter artifacts - - name: Archive production artifacts - uses: actions/upload-artifact@v4 - if: success() || failure() - with: - name: MegaLinter reports - path: | - megalinter-reports - mega-linter.log +# # Upload MegaLinter artifacts +# - name: Archive production artifacts +# uses: actions/upload-artifact@v4 +# if: success() || failure() +# with: +# name: MegaLinter reports +# path: | +# megalinter-reports +# mega-linter.log - # Create pull request if applicable - # (for now works only on PR from same repository, not from forks) - - name: Create Pull Request with applied fixes - uses: peter-evans/create-pull-request@v7 - id: cpr - if: >- - steps.ml.outputs.has_updated_sources == 1 && - ( - env.APPLY_FIXES_EVENT == 'all' || - env.APPLY_FIXES_EVENT == github.event_name - ) && - env.APPLY_FIXES_MODE == 'pull_request' && - ( - github.event_name == 'push' || - github.event.pull_request.head.repo.full_name == github.repository - ) && - !contains(github.event.head_commit.message, 'skip fix') - with: - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} - commit-message: "[MegaLinter] Apply linters automatic fixes" - title: "[MegaLinter] Apply linters automatic fixes" - labels: bot - branch: megalinter-fixes-${{ github.head_ref }} - body: | - MegaLinter has automatically applied linters fixes on this PR. - Please review the changes and merge if they are correct. - base: ${{ github.head_ref }} +# # Create pull request if applicable +# # (for now works only on PR from same repository, not from forks) +# - name: Create Pull Request with applied fixes +# uses: peter-evans/create-pull-request@v7 +# id: cpr +# if: >- +# steps.ml.outputs.has_updated_sources == 1 && +# ( +# env.APPLY_FIXES_EVENT == 'all' || +# env.APPLY_FIXES_EVENT == github.event_name +# ) && +# env.APPLY_FIXES_MODE == 'pull_request' && +# ( +# github.event_name == 'push' || +# github.event.pull_request.head.repo.full_name == github.repository +# ) && +# !contains(github.event.head_commit.message, 'skip fix') +# with: +# token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} +# commit-message: "[MegaLinter] Apply linters automatic fixes" +# title: "[MegaLinter] Apply linters automatic fixes" +# labels: bot +# branch: megalinter-fixes-${{ github.head_ref }} +# body: | +# MegaLinter has automatically applied linters fixes on this PR. +# Please review the changes and merge if they are correct. +# base: ${{ github.head_ref }} - - name: Post PR Comment - if: >- - steps.ml.outputs.has_updated_sources == 1 && - ( - env.APPLY_FIXES_EVENT == 'all' || - env.APPLY_FIXES_EVENT == github.event_name - ) && - env.APPLY_FIXES_MODE == 'pull_request' && - ( - github.event_name == 'push' || - github.event.pull_request.head.repo.full_name == github.repository - ) && - !contains(github.event.head_commit.message, 'skip fix') - uses: marocchino/sticky-pull-request-comment@v2 - with: - message: | - MegaLinter has automatically applied linters fixes on this PR. - Please review the changes and merge if they are correct. - PR: ${{ steps.cpr.outputs.pull-request-url }} - hide_and_recreate: true +# - name: Post PR Comment +# if: >- +# steps.ml.outputs.has_updated_sources == 1 && +# ( +# env.APPLY_FIXES_EVENT == 'all' || +# env.APPLY_FIXES_EVENT == github.event_name +# ) && +# env.APPLY_FIXES_MODE == 'pull_request' && +# ( +# github.event_name == 'push' || +# github.event.pull_request.head.repo.full_name == github.repository +# ) && +# !contains(github.event.head_commit.message, 'skip fix') +# uses: marocchino/sticky-pull-request-comment@v2 +# with: +# message: | +# MegaLinter has automatically applied linters fixes on this PR. +# Please review the changes and merge if they are correct. +# PR: ${{ steps.cpr.outputs.pull-request-url }} +# hide_and_recreate: true - - name: Fail if PR Created - run: | - if [ "${{ steps.cpr.outputs.pull-request-url }}" != "" ]; then - echo "A PR with formatting fixes has been created. Please merge it before proceeding." - exit 1 - fi - # Required due to Mega Linter not currently supporting Rust Format - # cargo_fmt_library: - # name: Cargo Formatter (Library) - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # - name: Install Toolchains - # run: | - # rustup toolchain install nightly-x86_64-unknown-linux-gnu - # rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - # - name: Rustfmt check on host - # run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check - # - name: Rustfmt check on host macros +# - name: Fail if PR Created +# run: | +# if [ "${{ steps.cpr.outputs.pull-request-url }}" != "" ]; then +# echo "A PR with formatting fixes has been created. Please merge it before proceeding." +# exit 1 +# fi +# # Required due to Mega Linter not currently supporting Rust Format +# # cargo_fmt_library: +# # name: Cargo Formatter (Library) +# # runs-on: ubuntu-latest +# # steps: +# # - name: Checkout code +# # uses: actions/checkout@v4 +# # - name: Install Toolchains +# # run: | +# # rustup toolchain install nightly-x86_64-unknown-linux-gnu +# # rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt +# # - name: Rustfmt check on host +# # run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check +# # - name: Rustfmt check on host macros - # run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check +# # run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check - # cargo_fmt_examples: - # name: Cargo Formatter (Examples) - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # - name: Install Toolchains - # run: | - # rustup toolchain install nightly-x86_64-unknown-linux-gnu - # rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt - # - name: Rustfmt check on apache-nimble - # run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check - # - name: Rustfmt check on apps - # run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check - # - name: Rustfmt check on esp32 - # run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check - # - name: Rustfmt check on nrf-sdc - # run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check - # - name: Rustfmt check on rp-pico-2-w - # run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check - # - name: Rustfmt check on rp-pico-w - # run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check - # - name: Rustfmt check on serial-hci - # run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check - # - name: Rustfmt check on tests - # run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check +# # cargo_fmt_examples: +# # name: Cargo Formatter (Examples) +# # runs-on: ubuntu-latest +# # steps: +# # - name: Checkout code +# # uses: actions/checkout@v4 +# # - name: Install Toolchains +# # run: | +# # rustup toolchain install nightly-x86_64-unknown-linux-gnu +# # rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt +# # - name: Rustfmt check on apache-nimble +# # run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check +# # - name: Rustfmt check on apps +# # run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check +# # - name: Rustfmt check on esp32 +# # run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check +# # - name: Rustfmt check on nrf-sdc +# # run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check +# # - name: Rustfmt check on rp-pico-2-w +# # run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check +# # - name: Rustfmt check on rp-pico-w +# # run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check +# # - name: Rustfmt check on serial-hci +# # run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check +# # - name: Rustfmt check on tests +# # run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check - # cargo_clippy_library: - # name: Cargo Clippy (Host Macros) - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # - name: Cargo Clippy check on host Macros - # run: | - # cd host-macros - # cargo clippy -- --D warnings +# # cargo_clippy_library: +# # name: Cargo Clippy (Host Macros) +# # runs-on: ubuntu-latest +# # steps: +# # - name: Checkout code +# # uses: actions/checkout@v4 +# # - name: Cargo Clippy check on host Macros +# # run: | +# # cd host-macros +# # cargo clippy -- --D warnings - # cargo_clippy_examples: - # name: Cargo Clippy (Examples) - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # - name: Install toolchains - # run: | - # rustup target add riscv32imac-unknown-none-elf - # # - name: Cargo Clippy check on apache-nimble # (Disabled due to version bumps needed) - # # run: | - # # cd examples/apache-nimble - # # cargo clippy -- --D warnings - # - name: Cargo Clippy apps - # run: | - # cd examples/apps - # cargo clippy -- --D warnings - # - name: Cargo Clippy esp32 - # run: | - # cd examples/esp32 - # # echo "Checking esp32" - # # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) - # echo "Checking esp32c2" - # cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings - # echo "Checking esp32c3" - # cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings - # echo "Checking esp32c6" - # cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings - # echo "Checking esp32h2" - # cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings - # # echo "Checking esp32s3" - # # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) - # - name: Cargo Clippy nrf-sdc - # run: | - # cd examples/nrf-sdc - # echo "Checking nrf52832" - # cargo clippy --features=nrf52832 -- -D warnings - # echo "Checking nrf52833" - # cargo clippy --features=nrf52833 -- -D warnings - # echo "Checking nrf52840" - # cargo clippy --features=nrf52840 -- -D warnings - # - name: Cargo Clippy rp-pico-2-w - # run: | - # cd examples/rp-pico-2-w - # cargo clippy -- --D warnings - # - name: Cargo Clippy rp-pico-w - # run: | - # cd examples/rp-pico-w - # cargo clippy -- --D warnings - # - name: Cargo Clippy serial-hci - # run: | - # cd examples/serial-hci - # cargo clippy -- --D warnings - # - name: Cargo Clippy tests - # run: | - # cd examples/tests - # cargo clippy -- --D warnings +# # cargo_clippy_examples: +# # name: Cargo Clippy (Examples) +# # runs-on: ubuntu-latest +# # steps: +# # - name: Checkout code +# # uses: actions/checkout@v4 +# # - name: Install toolchains +# # run: | +# # rustup target add riscv32imac-unknown-none-elf +# # # - name: Cargo Clippy check on apache-nimble # (Disabled due to version bumps needed) +# # # run: | +# # # cd examples/apache-nimble +# # # cargo clippy -- --D warnings +# # - name: Cargo Clippy apps +# # run: | +# # cd examples/apps +# # cargo clippy -- --D warnings +# # - name: Cargo Clippy esp32 +# # run: | +# # cd examples/esp32 +# # # echo "Checking esp32" +# # # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) +# # echo "Checking esp32c2" +# # cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings +# # echo "Checking esp32c3" +# # cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings +# # echo "Checking esp32c6" +# # cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings +# # echo "Checking esp32h2" +# # cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings +# # # echo "Checking esp32s3" +# # # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) +# # - name: Cargo Clippy nrf-sdc +# # run: | +# # cd examples/nrf-sdc +# # echo "Checking nrf52832" +# # cargo clippy --features=nrf52832 -- -D warnings +# # echo "Checking nrf52833" +# # cargo clippy --features=nrf52833 -- -D warnings +# # echo "Checking nrf52840" +# # cargo clippy --features=nrf52840 -- -D warnings +# # - name: Cargo Clippy rp-pico-2-w +# # run: | +# # cd examples/rp-pico-2-w +# # cargo clippy -- --D warnings +# # - name: Cargo Clippy rp-pico-w +# # run: | +# # cd examples/rp-pico-w +# # cargo clippy -- --D warnings +# # - name: Cargo Clippy serial-hci +# # run: | +# # cd examples/serial-hci +# # cargo clippy -- --D warnings +# # - name: Cargo Clippy tests +# # run: | +# # cd examples/tests +# # cargo clippy -- --D warnings diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 99d2d2c8..891a9d2b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,10 +8,12 @@ on: tags: - "v*" pull_request: - + jobs: build: runs-on: ubuntu-latest + env: + ENABLE_MEGALINTER: true steps: - uses: actions/checkout@v4 - name: Add dependencies diff --git a/ci.sh b/ci.sh index ca8a7069..69f8fc7f 100755 --- a/ci.sh +++ b/ci.sh @@ -75,10 +75,10 @@ cd host-macros && cargo clippy -- -D warnings && cd .. # Clippy Examples cd examples -cd apache-nimble && cargo clippy -- -D warnings && cd .. +# cd apache-nimble && cargo clippy -- -D warnings && cd .. cd apps && cargo clippy -- -D warnings && cd .. # ESP32 Examples -cd esp32 && cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings && cd .. +# cd esp32 && cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings && cd .. cd esp32c2 && cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings && cd .. cd esp32c3 && cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings && cd.. cd esp32c6 && cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings && cd.. @@ -101,11 +101,55 @@ cd tests && cargo clippy -- --D warnings && cd.. # Leave examples folder cd.. +# Enable MegaLinter (you can set this flag in your CI/CD or local environment) +ENABLE_MEGALINTER=${ENABLE_MEGALINTER:-false} # Use variable or default to true # Run and install MegaLinter (if enabled) +# Check if MegaLinter should be enabled +if [ "$ENABLE_MEGALINTER" = true ]; then + echo "MegaLinter is enabled. Installing and running..." + # Check if Node.js is installed; install if necessary + if ! command -v node >/dev/null 2>&1; then + install_node + fi + # Install MegaLinter globally (if not already installed) + if ! command -v mega-linter-runner >/dev/null 2>&1; then + echo "Installing MegaLinter..." + npm install -g @megalinter/mega-linter-runner + else + echo "MegaLinter is already installed." + fi + + # Run MegaLinter + echo "Running MegaLinter..." + mega-linter-runner +else + echo "MegaLinter is not enabled. Skipping..." +fi # Run tests echo "Running Cargo Clippy" cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture cargo test --manifest-path ./host/Cargo.toml --no-run -- --nocapture cargo test --manifest-path ./examples/tests/Cargo.toml --no-run -- --nocapture + + +# Function to install Node.js if not installed +install_node() { + echo "Node.js is not installed. Installing..." + # Detect OS and install Node.js + if [ "$(uname)" = "Darwin" ]; then + brew install node + elif [ "$(uname -s)" = "Linux" ]; then + apt-get install nodejs + else + echo "Unsupported operating system. Please install Node.js manually." + exit 1 + fi + + # Confirm npm is now available after Node.js installation + if ! command -v npm >/dev/null 2>&1; then + echo "npm is not available even after Node.js installation. Please check your installation." + exit 1 + fi +} \ No newline at end of file From ae7cda415f32555bef6ca45753b754b3212c738f Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 4 Mar 2025 16:08:54 +0000 Subject: [PATCH 61/61] added working linter setup script --- .github/workflows/.mega-linter.yaml | 272 ---------------------------- .github/workflows/ci.yaml | 4 +- .mega-linter.yaml | 7 - README.md | 9 + ci.sh | 213 +++++++++++----------- 5 files changed, 123 insertions(+), 382 deletions(-) delete mode 100644 .github/workflows/.mega-linter.yaml diff --git a/.github/workflows/.mega-linter.yaml b/.github/workflows/.mega-linter.yaml deleted file mode 100644 index d86f3aca..00000000 --- a/.github/workflows/.mega-linter.yaml +++ /dev/null @@ -1,272 +0,0 @@ -# # MegaLinter GitHub Action configuration file -# # More info at https://megalinter.io -# --- -# name: MegaLinter - -# # Trigger mega-linter at every push. Action will also be visible from -# # Pull Requests to main -# on: -# # Comment this line to trigger action only on pull-requests---------------------------------------------------------------- -# # (not recommended if you don't pay for GH Actions) -# push: -# branches: -# - main -# - master -# pull_request: -# branches: -# - main -# - master -# workflow_call: - -# # Comment env block if you do not want to apply fixes -# env: -# # Apply linter fixes configuration -# # -# # When active, APPLY_FIXES must also be defined as environment variable -# # (in github/workflows/mega-linter.yml or other CI tool) -# APPLY_FIXES: all - -# # Decide which event triggers application of fixes in a commit or a PR -# # (pull_request, push, all) -# APPLY_FIXES_EVENT: pull_request - -# # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) -# # or posted in a PR (pull_request) -# APPLY_FIXES_MODE: pull_request - -# concurrency: -# group: ${{ github.ref }}-${{ github.workflow }} -# cancel-in-progress: true - -# jobs: -# megalinter: -# name: MegaLinter -# runs-on: ubuntu-latest - -# # Give the default GITHUB_TOKEN write permission to commit and push, comment -# # issues, and post new Pull Requests; remove the ones you do not need -# permissions: -# contents: write -# issues: write -# pull-requests: write -# statuses: write - -# steps: -# # Git Checkout -# - name: Checkout Code -# uses: actions/checkout@v4 -# with: -# token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} - -# # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to -# # improve performance -# fetch-depth: 0 - -# # MegaLinter -# - name: MegaLinter - -# # You can override MegaLinter flavor used to have faster performances -# # More info at https://megalinter.io/latest/flavors/ -# uses: oxsecurity/megalinter@v8.3.0 - -# id: ml - -# # All available variables are described in documentation -# # https://megalinter.io/latest/config-file/ -# env: -# # Validates all source when push on main, else just the git diff with -# # main. Override with true if you always want to lint all sources -# # -# # To validate the entire codebase, set to: -# # VALIDATE_ALL_CODEBASE: true -# # -# # To validate only diff with main, set to: -# # VALIDATE_ALL_CODEBASE: >- -# # ${{ -# # github.event_name == 'push' && -# # github.ref == 'refs/heads/main' -# # }} -# VALIDATE_ALL_CODEBASE: true - -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -# # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF -# # .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY - -# # Upload MegaLinter artifacts -# - name: Archive production artifacts -# uses: actions/upload-artifact@v4 -# if: success() || failure() -# with: -# name: MegaLinter reports -# path: | -# megalinter-reports -# mega-linter.log - -# # Create pull request if applicable -# # (for now works only on PR from same repository, not from forks) -# - name: Create Pull Request with applied fixes -# uses: peter-evans/create-pull-request@v7 -# id: cpr -# if: >- -# steps.ml.outputs.has_updated_sources == 1 && -# ( -# env.APPLY_FIXES_EVENT == 'all' || -# env.APPLY_FIXES_EVENT == github.event_name -# ) && -# env.APPLY_FIXES_MODE == 'pull_request' && -# ( -# github.event_name == 'push' || -# github.event.pull_request.head.repo.full_name == github.repository -# ) && -# !contains(github.event.head_commit.message, 'skip fix') -# with: -# token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} -# commit-message: "[MegaLinter] Apply linters automatic fixes" -# title: "[MegaLinter] Apply linters automatic fixes" -# labels: bot -# branch: megalinter-fixes-${{ github.head_ref }} -# body: | -# MegaLinter has automatically applied linters fixes on this PR. -# Please review the changes and merge if they are correct. -# base: ${{ github.head_ref }} - -# - name: Post PR Comment -# if: >- -# steps.ml.outputs.has_updated_sources == 1 && -# ( -# env.APPLY_FIXES_EVENT == 'all' || -# env.APPLY_FIXES_EVENT == github.event_name -# ) && -# env.APPLY_FIXES_MODE == 'pull_request' && -# ( -# github.event_name == 'push' || -# github.event.pull_request.head.repo.full_name == github.repository -# ) && -# !contains(github.event.head_commit.message, 'skip fix') -# uses: marocchino/sticky-pull-request-comment@v2 -# with: -# message: | -# MegaLinter has automatically applied linters fixes on this PR. -# Please review the changes and merge if they are correct. -# PR: ${{ steps.cpr.outputs.pull-request-url }} -# hide_and_recreate: true - -# - name: Fail if PR Created -# run: | -# if [ "${{ steps.cpr.outputs.pull-request-url }}" != "" ]; then -# echo "A PR with formatting fixes has been created. Please merge it before proceeding." -# exit 1 -# fi -# # Required due to Mega Linter not currently supporting Rust Format -# # cargo_fmt_library: -# # name: Cargo Formatter (Library) -# # runs-on: ubuntu-latest -# # steps: -# # - name: Checkout code -# # uses: actions/checkout@v4 -# # - name: Install Toolchains -# # run: | -# # rustup toolchain install nightly-x86_64-unknown-linux-gnu -# # rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt -# # - name: Rustfmt check on host -# # run: cargo +nightly fmt --manifest-path host/Cargo.toml -- --check -# # - name: Rustfmt check on host macros - -# # run: cargo +nightly fmt --manifest-path host-macros/Cargo.toml -- --check - -# # cargo_fmt_examples: -# # name: Cargo Formatter (Examples) -# # runs-on: ubuntu-latest -# # steps: -# # - name: Checkout code -# # uses: actions/checkout@v4 -# # - name: Install Toolchains -# # run: | -# # rustup toolchain install nightly-x86_64-unknown-linux-gnu -# # rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt -# # - name: Rustfmt check on apache-nimble -# # run: cargo +nightly fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check -# # - name: Rustfmt check on apps -# # run: cargo +nightly fmt --manifest-path examples/apps/Cargo.toml -- --check -# # - name: Rustfmt check on esp32 -# # run: cargo +nightly fmt --manifest-path examples/esp32/Cargo.toml -- --check -# # - name: Rustfmt check on nrf-sdc -# # run: cargo +nightly fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check -# # - name: Rustfmt check on rp-pico-2-w -# # run: cargo +nightly fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check -# # - name: Rustfmt check on rp-pico-w -# # run: cargo +nightly fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check -# # - name: Rustfmt check on serial-hci -# # run: cargo +nightly fmt --manifest-path examples/serial-hci/Cargo.toml -- --check -# # - name: Rustfmt check on tests -# # run: cargo +nightly fmt --manifest-path examples/tests/Cargo.toml -- --check - -# # cargo_clippy_library: -# # name: Cargo Clippy (Host Macros) -# # runs-on: ubuntu-latest -# # steps: -# # - name: Checkout code -# # uses: actions/checkout@v4 -# # - name: Cargo Clippy check on host Macros -# # run: | -# # cd host-macros -# # cargo clippy -- --D warnings - -# # cargo_clippy_examples: -# # name: Cargo Clippy (Examples) -# # runs-on: ubuntu-latest -# # steps: -# # - name: Checkout code -# # uses: actions/checkout@v4 -# # - name: Install toolchains -# # run: | -# # rustup target add riscv32imac-unknown-none-elf -# # # - name: Cargo Clippy check on apache-nimble # (Disabled due to version bumps needed) -# # # run: | -# # # cd examples/apache-nimble -# # # cargo clippy -- --D warnings -# # - name: Cargo Clippy apps -# # run: | -# # cd examples/apps -# # cargo clippy -- --D warnings -# # - name: Cargo Clippy esp32 -# # run: | -# # cd examples/esp32 -# # # echo "Checking esp32" -# # # cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings # (Disabled due to missing toolchain) -# # echo "Checking esp32c2" -# # cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings -# # echo "Checking esp32c3" -# # cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings -# # echo "Checking esp32c6" -# # cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings -# # echo "Checking esp32h2" -# # cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings -# # # echo "Checking esp32s3" -# # # cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings # (Disabled due to missing toolchain) -# # - name: Cargo Clippy nrf-sdc -# # run: | -# # cd examples/nrf-sdc -# # echo "Checking nrf52832" -# # cargo clippy --features=nrf52832 -- -D warnings -# # echo "Checking nrf52833" -# # cargo clippy --features=nrf52833 -- -D warnings -# # echo "Checking nrf52840" -# # cargo clippy --features=nrf52840 -- -D warnings -# # - name: Cargo Clippy rp-pico-2-w -# # run: | -# # cd examples/rp-pico-2-w -# # cargo clippy -- --D warnings -# # - name: Cargo Clippy rp-pico-w -# # run: | -# # cd examples/rp-pico-w -# # cargo clippy -- --D warnings -# # - name: Cargo Clippy serial-hci -# # run: | -# # cd examples/serial-hci -# # cargo clippy -- --D warnings -# # - name: Cargo Clippy tests -# # run: | -# # cd examples/tests -# # cargo clippy -- --D warnings diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 891a9d2b..81e5a87d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,11 +8,11 @@ on: tags: - "v*" pull_request: - + jobs: build: runs-on: ubuntu-latest - env: + env: ENABLE_MEGALINTER: true steps: - uses: actions/checkout@v4 diff --git a/.mega-linter.yaml b/.mega-linter.yaml index 300b0328..32eb0b35 100644 --- a/.mega-linter.yaml +++ b/.mega-linter.yaml @@ -43,12 +43,5 @@ OUTPUT_DETAIL: detailed # Linter Configuration MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdownlint.json -RUST_CLIPPY_ARGUMENTS: - - -- - - --manifest-path - - host/Cargo.toml - - --features - - gatt,peripheral,central - JSON_JSONLINT_ARGUMENTS: - --comments diff --git a/README.md b/README.md index 7dde64c8..308d1e45 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,15 @@ See `examples` for example applications for different BLE controllers. Since a lot of the examples demo the same BLE functionality, they only contain basic wiring specific to the BLE controller, and share the 'business logic' within the `examples/apps` folder. +## Linting Process + +The project uses a variety of linters through the use of cargo and [MegaLinter](https://github.com/oxsecurity/megalinter). In order to use these locally, you simply run the [ci.sh](./ci.sh) file which will install the necessary tools. +If you want to use MegaLinter as well, you must set the following environment variable: + +```yaml +ENABLE_MEGALINTER: true +``` + ## License Trouble is licensed under either of diff --git a/ci.sh b/ci.sh index 69f8fc7f..718e223a 100755 --- a/ci.sh +++ b/ci.sh @@ -8,7 +8,6 @@ if ! command -v cargo-batch &>/dev/null; then chmod +x "$HOME"/.cargo/bin/cargo-batch fi - export RUSTFLAGS=-Dwarnings export DEFMT_LOG=trace export CARGO_NET_GIT_FETCH_WITH_CLI=true @@ -16,140 +15,152 @@ if [[ -z "${CARGO_TARGET_DIR}" ]]; then export CARGO_TARGET_DIR=target_ci fi echo "Running Cargo Build" -cargo batch \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,scan \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral,defmt \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,central \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral,central,scan \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52840 \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52833 --artifact-dir tests/nrf-sdc \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52832 \ - --- build --release --manifest-path examples/esp32/Cargo.toml --features esp32c3 --target riscv32imc-unknown-none-elf --artifact-dir tests/esp32 \ - --- build --release --manifest-path examples/serial-hci/Cargo.toml \ - --- build --release --manifest-path examples/tests/Cargo.toml \ - --- build --release --manifest-path examples/rp-pico-w/Cargo.toml --target thumbv6m-none-eabi --features skip-cyw43-firmware \ - --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,scan \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral,defmt \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,central \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral,central,scan \ - --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral,central,scan,controller-host-flow-control \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52840 \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52833 --artifact-dir tests/nrf-sdc \ - --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52832 \ - --- build --release --manifest-path examples/esp32/Cargo.toml --features esp32c3 --target riscv32imc-unknown-none-elf --artifact-dir tests/esp32 \ - --- build --release --manifest-path examples/serial-hci/Cargo.toml \ - --- build --release --manifest-path examples/tests/Cargo.toml \ - --- build --release --manifest-path benchmarks/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52840 \ - --- build --release --manifest-path examples/rp-pico-w/Cargo.toml --target thumbv6m-none-eabi --features skip-cyw43-firmware \ - --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware -# --- build --release --manifest-path examples/apache-nimble/Cargo.toml --target thumbv7em-none-eabihf +# cargo batch \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features peripheral \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features central \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,scan \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral,defmt \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,central \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral,central,scan \ +# --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52840 \ +# --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52833 --artifact-dir tests/nrf-sdc \ +# --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52832 \ +# --- build --release --manifest-path examples/esp32/Cargo.toml --features esp32c3 --target riscv32imc-unknown-none-elf --artifact-dir tests/esp32 \ +# --- build --release --manifest-path examples/serial-hci/Cargo.toml \ +# --- build --release --manifest-path examples/tests/Cargo.toml \ +# --- build --release --manifest-path examples/rp-pico-w/Cargo.toml --target thumbv6m-none-eabi --features skip-cyw43-firmware \ +# --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features peripheral \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features central \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,scan \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features central,peripheral,defmt \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,central \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral,central,scan \ +# --- build --release --manifest-path host/Cargo.toml --no-default-features --features gatt,peripheral,central,scan,controller-host-flow-control \ +# --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52840 \ +# --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52833 --artifact-dir tests/nrf-sdc \ +# --- build --release --manifest-path examples/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52832 \ +# --- build --release --manifest-path examples/esp32/Cargo.toml --features esp32c3 --target riscv32imc-unknown-none-elf --artifact-dir tests/esp32 \ +# --- build --release --manifest-path examples/serial-hci/Cargo.toml \ +# --- build --release --manifest-path examples/tests/Cargo.toml \ +# --- build --release --manifest-path benchmarks/nrf-sdc/Cargo.toml --target thumbv7em-none-eabihf --features nrf52840 \ +# --- build --release --manifest-path examples/rp-pico-w/Cargo.toml --target thumbv6m-none-eabi --features skip-cyw43-firmware \ +# --- build --release --manifest-path examples/rp-pico-2-w/Cargo.toml --target thumbv8m.main-none-eabihf --features skip-cyw43-firmware +# # --- build --release --manifest-path examples/apache-nimble/Cargo.toml --target thumbv7em-none-eabihf # Run Cargo fmt echo "Running Cargo fmt" -cargo batch \ - --- fmt --manifest-path host/Cargo.toml -- --check \ - --- fmt --manifest-path host-macros/Cargo.toml -- --check \ - --- fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check \ - --- fmt --manifest-path examples/apps/Cargo.toml -- --check \ - --- fmt --manifest-path examples/esp32/Cargo.toml -- --check \ - --- fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check \ - --- fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check \ - --- fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check \ - --- fmt --manifest-path examples/serial-hci/Cargo.toml -- --check \ - --- fmt --manifest-path examples/tests/Cargo.toml -- --check \ - +# cargo batch \ +# --- fmt --manifest-path host/Cargo.toml -- --check \ +# --- fmt --manifest-path host-macros/Cargo.toml -- --check \ +# --- fmt --manifest-path examples/apache-nimble/Cargo.toml -- --check \ +# --- fmt --manifest-path examples/apps/Cargo.toml -- --check \ +# --- fmt --manifest-path examples/esp32/Cargo.toml -- --check \ +# --- fmt --manifest-path examples/nrf-sdc/Cargo.toml -- --check \ +# --- fmt --manifest-path examples/rp-pico-2-w/Cargo.toml -- --check \ +# --- fmt --manifest-path examples/rp-pico-w/Cargo.toml -- --check \ +# --- fmt --manifest-path examples/serial-hci/Cargo.toml -- --check \ +# --- fmt --manifest-path examples/tests/Cargo.toml -- --check \ # Clippy Main Library echo "Running Cargo Clippy" cd host && cargo clippy -- -D warnings && cd .. -cd host-macros && cargo clippy -- -D warnings && cd .. +cd host-macros && cargo clippy -- -D warnings && cd .. # Clippy Examples cd examples +echo "Running Cargo Clippy on the examples directory" # cd apache-nimble && cargo clippy -- -D warnings && cd .. -cd apps && cargo clippy -- -D warnings && cd .. +cd apps && cargo clippy -- -D warnings && cd .. + # ESP32 Examples +echo "Running Cargo Clippy on ESP32 examples" +cd esp32 # cd esp32 && cargo clippy --no-default-features --features=esp32 --target=xtensa-esp32-none-elf -- -D warnings && cd .. -cd esp32c2 && cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings && cd .. -cd esp32c3 && cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings && cd.. -cd esp32c6 && cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings && cd.. -cd esp32h2 && cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings && cd.. -cd esp32s3 && cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings && cd.. +cargo clippy --no-default-features --features=esp32c2 --target=riscv32imc-unknown-none-elf -- -D warnings +cargo clippy --no-default-features --features=esp32c3 --target=riscv32imc-unknown-none-elf -- -D warnings +cargo clippy --no-default-features --features=esp32c6 --target=riscv32imac-unknown-none-elf -- -D warnings +cargo clippy --no-default-features --features=esp32h2 --target=riscv32imac-unknown-none-elf -- -D warnings +# cargo clippy --no-default-features --features=esp32s3 --target=xtensa-esp32s3-none-elf -- -D warnings +cd .. # nrf-sdc +echo "Running Cargo Clippy on nrf-sdc example" cd nrf-sdc -cargo clippy --features=nrf52832 -- -D warnings -cargo clippy --features=nrf52833 -- -D warnings -cargo clippy --features=nrf52840 -- -D warnings -cd.. +# cargo clippy --features=nrf52832 -- -D warnings +# cargo clippy --features=nrf52833 -- -D warnings +# cargo clippy --features=nrf52840 -- -D warnings +cd .. + # rp-pico-2-w -cd rp-pico-2-w && cargo clippy -- --D warnings && cd.. +echo "Running Cargo Clippy on rp-pico-2-w example" +cd rp-pico-2-w && cargo clippy -- --D warnings && cd .. + # rp-pico-w -cd rp-pico-w && cargo clippy -- --D warnings && cd.. +echo "Running Cargo Clippy on rp-pico-w example" +cd rp-pico-w && cargo clippy -- --D warnings && cd .. + # serial-hci -cd serial-hci && cargo clippy -- --D warnings && cd.. +echo "Running Cargo Clippy on serial-hci example" +cd serial-hci && cargo clippy -- --D warnings && cd .. + # tests -cd tests && cargo clippy -- --D warnings && cd.. +echo "Running Cargo Clippy on tests example" +cd tests && cargo clippy -- --D warnings && cd .. # Leave examples folder -cd.. +cd .. # Enable MegaLinter (you can set this flag in your CI/CD or local environment) -ENABLE_MEGALINTER=${ENABLE_MEGALINTER:-false} # Use variable or default to true +ENABLE_MEGALINTER=${ENABLE_MEGALINTER:-true} # Use variable or default to true # Run and install MegaLinter (if enabled) # Check if MegaLinter should be enabled if [ "$ENABLE_MEGALINTER" = true ]; then - echo "MegaLinter is enabled. Installing and running..." - - # Check if Node.js is installed; install if necessary - if ! command -v node >/dev/null 2>&1; then - install_node - fi - # Install MegaLinter globally (if not already installed) - if ! command -v mega-linter-runner >/dev/null 2>&1; then - echo "Installing MegaLinter..." - npm install -g @megalinter/mega-linter-runner - else - echo "MegaLinter is already installed." - fi - - # Run MegaLinter - echo "Running MegaLinter..." - mega-linter-runner + echo "MegaLinter is enabled. Installing and running..." + + # Check if Node.js is installed; install if necessary + if ! command -v node >/dev/null 2>&1; then + install_node + fi + # Install MegaLinter globally (if not already installed) + if ! command -v mega-linter-runner >/dev/null 2>&1; then + echo "Installing MegaLinter..." + npm install -g mega-linter-runner + else + echo "MegaLinter is already installed." + fi + + # Run MegaLinter + echo "Running MegaLinter..." + mega-linter-runner else - echo "MegaLinter is not enabled. Skipping..." + echo "MegaLinter is not enabled. Skipping..." fi # Run tests -echo "Running Cargo Clippy" +echo "Running Cargo test" cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture cargo test --manifest-path ./host/Cargo.toml --no-run -- --nocapture cargo test --manifest-path ./examples/tests/Cargo.toml --no-run -- --nocapture - # Function to install Node.js if not installed install_node() { - echo "Node.js is not installed. Installing..." - # Detect OS and install Node.js - if [ "$(uname)" = "Darwin" ]; then - brew install node + echo "Node.js is not installed. Installing..." + # Detect OS and install Node.js + if [ "$(uname)" = "Darwin" ]; then + brew install node elif [ "$(uname -s)" = "Linux" ]; then - apt-get install nodejs + apt-get install nodejs else - echo "Unsupported operating system. Please install Node.js manually." - exit 1 - fi - - # Confirm npm is now available after Node.js installation - if ! command -v npm >/dev/null 2>&1; then - echo "npm is not available even after Node.js installation. Please check your installation." - exit 1 - fi -} \ No newline at end of file + echo "Unsupported operating system. Please install Node.js manually." + exit 1 + fi + + # Confirm npm is now available after Node.js installation + if ! command -v npm >/dev/null 2>&1; then + echo "npm is not available even after Node.js installation. Please check your installation." + exit 1 + fi +}