Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add MegaLinter and Cargo Clippy CI Cycle #278

Draft
wants to merge 57 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
face142
Documents
ScottGibb Jan 24, 2025
3b90c94
attempt at megalinter
ScottGibb Jan 24, 2025
efd1683
fixed formatting
ScottGibb Jan 24, 2025
2a038e7
added crates checks
ScottGibb Jan 24, 2025
3e50372
updated uses tag
ScottGibb Jan 24, 2025
1ba9adf
need to investiaget lint checks
ScottGibb Jan 24, 2025
aab9ec8
rearranged commands
ScottGibb Jan 27, 2025
a804847
added toolchains
ScottGibb Jan 27, 2025
c97ad79
fixed python and markdown
ScottGibb Jan 27, 2025
ab25ffd
fixed shell script
ScottGibb Jan 27, 2025
1d6995a
bumped ci dependency
ScottGibb Jan 27, 2025
908bfa0
Fixed YAML and added allow comments
ScottGibb Jan 27, 2025
a60ae92
yaml fixes
ScottGibb Jan 27, 2025
33aab51
jsonlint removed trailing comma
ScottGibb Jan 27, 2025
ab6c3e3
removed trailing spaces
ScottGibb Jan 27, 2025
82d774c
fixed globbing
ScottGibb Jan 27, 2025
e3dc4a9
removed commas and extra spaces
ScottGibb Jan 27, 2025
b148e97
fixed markdown error
ScottGibb Jan 27, 2025
4b3095a
ran cargo fmt on the codebase
ScottGibb Jan 27, 2025
1fcaf4f
commented out apache-nimble
ScottGibb Jan 27, 2025
c8a0dc9
removed trailing comma
ScottGibb Jan 27, 2025
b257627
removed esp32 from clippy
ScottGibb Jan 27, 2025
ed71371
made mega-linter match ci.sh
ScottGibb Jan 27, 2025
0507242
added megalinter fixes
ScottGibb Jan 27, 2025
6120832
attempt to fix megalinter ci
ScottGibb Jan 27, 2025
77c8df6
removed another example
ScottGibb Jan 27, 2025
f0dc31e
adjusted clippy checks to do it inside the projects
ScottGibb Jan 27, 2025
acfb5af
Merge branch 'main' into add-linter
ScottGibb Jan 27, 2025
1ce7ab9
fixed scan.rs
ScottGibb Jan 27, 2025
8d91231
remove clippy and fmt from ci.sh
ScottGibb Jan 27, 2025
47b91a7
ran cargo fmt
ScottGibb Jan 27, 2025
6e58aa6
do full scan on all stages for linting
ScottGibb Jan 27, 2025
5424187
fixed ble scanner
ScottGibb Jan 27, 2025
517009c
removed continue-on-error
ScottGibb Jan 27, 2025
66c920e
fail on warnings
ScottGibb Jan 27, 2025
c07ef49
removed old docs
ScottGibb Jan 27, 2025
90f4958
fixed clippy warnings
ScottGibb Jan 27, 2025
f7b4253
removed tests that imediately fail
ScottGibb Jan 27, 2025
ee40712
dont need all-features flag in host-macros
ScottGibb Jan 27, 2025
d500c48
made it a bit clearer on the GitHub Runner side
ScottGibb Jan 27, 2025
b244463
commented back in examples checking
ScottGibb Jan 27, 2025
c374ce1
added Default
ScottGibb Jan 27, 2025
720b547
added extensions
ScottGibb Jan 28, 2025
294213a
[MegaLinter] Apply linters automatic fixes
ScottGibb Jan 28, 2025
a7ca57d
Merge pull request #2 from dysonltd/megalinter-fixes-add-linter
ScottGibb Jan 28, 2025
f890a90
added esp32 clippy tests
ScottGibb Jan 28, 2025
1949a34
removed whitespaces
ScottGibb Jan 28, 2025
920aabf
removed apache-nimble from CI
ScottGibb Jan 28, 2025
3ddf894
commented out broken toolchains
ScottGibb Jan 28, 2025
c979cba
fix
ScottGibb Jan 28, 2025
7fe81a0
removed esp32c6
ScottGibb Jan 28, 2025
d57350d
and esp32h2
ScottGibb Jan 28, 2025
8632e9c
update echo strings
ScottGibb Jan 28, 2025
34c4d55
added nrf clippy
ScottGibb Jan 28, 2025
f791c4b
adding back esp32c6 and esp32h2
ScottGibb Jan 28, 2025
a4a7197
added toolchain
ScottGibb Jan 28, 2025
f4d4922
Merge branch 'main' into add-linter
ScottGibb Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"probe": "303a:1001:60:55:F9:BF:A9:44",
"labels": {
"target": "esp32",
"board": "esp-rust-board"
"board": "esp-rust-board"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions .github/rodbot.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
on:
issue_comment:
- if:
Expand Down
272 changes: 272 additions & 0 deletions .github/workflows/.mega-linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
# 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/[email protected]

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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: CI

on:
Expand All @@ -17,7 +18,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: |
Expand Down
Loading