From 89710e444bfa947878de7dc9b20a9218a014b2da Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:01:51 -0700 Subject: [PATCH] add rust ci and lint makefile --- .github/workflows/rust.yml | 55 ++++++++++++++++++++++++++++++++++++++ Makefile | 16 +++++++++++ 2 files changed, 71 insertions(+) create mode 100644 .github/workflows/rust.yml create mode 100644 Makefile diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..9527a5f --- /dev/null +++ b/.github/workflows/rust.yml @@ -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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d8d0c38 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.DEFAULT_GOAL := help + +##@ Help +.PHONY: help +help: # Display this help. + @awk 'BEGIN {FS = ":.*#"; printf "Usage:\n make \033[34m\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 \ No newline at end of file