Add github actions workflows
- Check, format and lint code when committing - Check pull requests for formatting
This commit is contained in:
parent
653291dc02
commit
94c7af7709
2 changed files with 75 additions and 0 deletions
54
.github/workflows/check-and-lint.yaml
vendored
Normal file
54
.github/workflows/check-and-lint.yaml
vendored
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
name: Check and Lint
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libudev-dev
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- name: "cargo check"
|
||||||
|
run: cargo check
|
||||||
|
|
||||||
|
format:
|
||||||
|
name: Format
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: rustfmt
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- name: "cargo fmt"
|
||||||
|
uses: mbrobbel/rustfmt-check@master
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: Clippy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: clippy
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libudev-dev
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- name: "cargo clippy"
|
||||||
|
run: cargo clippy --all-features --workspace --tests --no-deps
|
21
.github/workflows/check-pr.yaml
vendored
Normal file
21
.github/workflows/check-pr.yaml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
name: Check Pull Request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
format:
|
||||||
|
name: Format
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Rust
|
||||||
|
uses: dtolnay/rust-toolchain@nightly
|
||||||
|
with:
|
||||||
|
components: rustfmt
|
||||||
|
- name: "cargo fmt"
|
||||||
|
uses: mbrobbel/rustfmt-check@master
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
mode: review
|
Loading…
Add table
Reference in a new issue