|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + name: Test on ${{ matrix.os }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Install Rust |
| 26 | + uses: dtolnay/rust-toolchain@stable |
| 27 | + |
| 28 | + - name: Cache cargo registry |
| 29 | + uses: actions/cache@v4 |
| 30 | + with: |
| 31 | + path: ~/.cargo/registry |
| 32 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 33 | + restore-keys: | |
| 34 | + ${{ runner.os }}-cargo-registry- |
| 35 | +
|
| 36 | + - name: Cache cargo index |
| 37 | + uses: actions/cache@v4 |
| 38 | + with: |
| 39 | + path: ~/.cargo/git |
| 40 | + key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} |
| 41 | + restore-keys: | |
| 42 | + ${{ runner.os }}-cargo-git- |
| 43 | +
|
| 44 | + - name: Cache target directory |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: target |
| 48 | + key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-target- |
| 51 | +
|
| 52 | + - name: Run tests |
| 53 | + run: cargo test --verbose |
| 54 | + |
| 55 | + - name: Run tests (release mode) |
| 56 | + run: cargo test --release --verbose |
| 57 | + |
| 58 | + - name: Build release binary |
| 59 | + run: cargo build --release --verbose |
| 60 | + |
| 61 | + lint: |
| 62 | + name: Lint and Format |
| 63 | + runs-on: ubuntu-latest |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Checkout code |
| 67 | + uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - name: Install Rust |
| 70 | + uses: dtolnay/rust-toolchain@stable |
| 71 | + with: |
| 72 | + components: rustfmt, clippy |
| 73 | + |
| 74 | + - name: Check formatting |
| 75 | + run: cargo fmt -- --check |
| 76 | + |
| 77 | + - name: Run clippy |
| 78 | + run: cargo clippy --all-targets --all-features -- -D warnings |
0 commit comments