diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1fa6c8c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,69 @@ +name: Rust CI + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + + workflow_dispatch: + + +jobs: + fmt: + name: Check code formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + component: rustfmt + - name: Run cargo fmt + run: cargo fmt --all -- --check + + clippy: + name: Clippy linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + component: clippy + - name: Run cargo clippy + run: cargo clippy --all-targets --all-features -- -D warnings + + test: + name: Run tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Run cargo test + env: + RUST_BACKTRACE: full + RUST_LOG: debug + run: cargo test + + build: + name: Build project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Build release binary + run: cargo build --release + - name: Upload binary artifact + uses: actions/upload-artifact@v4 + with: + name: rust-binary + path: target/release/