Skip to content

Commit

Permalink
add rust ci and lint makefile (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML authored Jan 22, 2025
1 parent 83b3a3e commit d1adf6b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Rust

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
CARGO_TERM_COLOR: always

jobs:
cargo-fmt:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust nightly
run: rustup install nightly

- name: Install rustfmt for nightly
run: rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt

- name: Run rustfmt
run: cargo +nightly fmt -- --check

cargo-clippy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Run Clippy
run: cargo clippy --all --all-targets --all-features --no-deps -- --deny warnings

build:
runs-on: ubuntu-latest
needs: [cargo-fmt, cargo-clippy]

steps:
- uses: actions/checkout@v4

- name: Build
run: cargo build --verbose

test:
runs-on: ubuntu-latest
needs: [cargo-fmt, cargo-clippy]

steps:
- uses: actions/checkout@v4

- name: Test
run: cargo test --workspace -- --nocapture
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.DEFAULT_GOAL := help

##@ Help
.PHONY: help
help: # Display this help.
@awk 'BEGIN {FS = ":.*#"; printf "Usage:\n make \033[34m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?#/ { printf " \033[34m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' $(MAKEFILE_LIST)

##@ Others
.PHONY: clean
clean: # Run `cargo clean`.
cargo clean

.PHONY: lint
lint: # Run `clippy` and `rustfmt`.
cargo +nightly fmt --all
cargo clippy --all --all-targets --all-features --no-deps -- --deny warnings
7 changes: 7 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
reorder_imports = true
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
wrap_comments = true
comment_width = 100
normalize_comments = true
format_code_in_doc_comments = true

0 comments on commit d1adf6b

Please sign in to comment.