|
1 | | -name: Rust |
| 1 | +name: CI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [ master, dev ] |
| 5 | + branches: [master, dev] |
6 | 6 | pull_request: |
7 | | - branches: [ master, dev ] |
| 7 | + branches: [master, dev] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + RUST_BACKTRACE: 1 |
8 | 12 |
|
9 | 13 | jobs: |
10 | | - build: |
11 | | - runs-on: ${{ matrix.os }} |
| 14 | + rust-check: |
| 15 | + name: Rust Check |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Install Rust toolchain |
| 22 | + uses: dtolnay/rust-toolchain@nightly |
| 23 | + with: |
| 24 | + components: rustfmt, clippy |
| 25 | + |
| 26 | + - name: Cache cargo registry |
| 27 | + uses: actions/cache@v4 |
| 28 | + with: |
| 29 | + path: | |
| 30 | + ~/.cargo/registry |
| 31 | + ~/.cargo/git |
| 32 | + target |
| 33 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 34 | + restore-keys: | |
| 35 | + ${{ runner.os }}-cargo- |
| 36 | +
|
| 37 | + - name: Check formatting |
| 38 | + run: cargo fmt --all -- --check |
| 39 | + |
| 40 | + - name: Run clippy |
| 41 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 42 | + |
| 43 | + - name: Check compilation |
| 44 | + run: cargo check --all-targets --all-features |
| 45 | + |
| 46 | + rust-test: |
| 47 | + name: Rust Test |
12 | 48 | strategy: |
| 49 | + fail-fast: false |
13 | 50 | matrix: |
14 | | - os: [ubuntu-latest, macos-latest, windows-latest] |
| 51 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 52 | + feature: [no-default, default, all] |
| 53 | + runs-on: ${{ matrix.os }} |
| 54 | + steps: |
| 55 | + - name: Checkout repository |
| 56 | + uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - name: Install Rust toolchain |
| 59 | + uses: dtolnay/rust-toolchain@nightly |
| 60 | + |
| 61 | + - name: Cache cargo registry |
| 62 | + uses: actions/cache@v4 |
| 63 | + with: |
| 64 | + path: | |
| 65 | + ~/.cargo/registry |
| 66 | + ~/.cargo/git |
| 67 | + target |
| 68 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 69 | + restore-keys: | |
| 70 | + ${{ runner.os }}-cargo- |
| 71 | +
|
| 72 | + - name: Run tests (no-default features) |
| 73 | + if: matrix.feature == 'no-default' |
| 74 | + run: cargo test --workspace --no-default-features |
| 75 | + |
| 76 | + - name: Run tests (default features) |
| 77 | + if: matrix.feature == 'default' |
| 78 | + run: cargo test --workspace |
| 79 | + |
| 80 | + - name: Run tests (all features) |
| 81 | + if: matrix.feature == 'all' |
| 82 | + run: cargo test --workspace --all-features |
| 83 | + |
| 84 | + js-check: |
| 85 | + name: JavaScript/TypeScript Check |
| 86 | + runs-on: ubuntu-latest |
15 | 87 | steps: |
16 | | - - run: git config --global core.autocrlf false |
17 | | - - uses: actions/checkout@v2 |
18 | | - - name: Rust Nightly |
19 | | - uses: actions-rs/toolchain@v1 |
| 88 | + - name: Checkout repository |
| 89 | + uses: actions/checkout@v4 |
| 90 | + |
| 91 | + - name: Setup Node.js |
| 92 | + uses: actions/setup-node@v4 |
| 93 | + with: |
| 94 | + node-version: "20" |
| 95 | + |
| 96 | + - name: Install pnpm |
| 97 | + uses: pnpm/action-setup@v4 |
20 | 98 | with: |
21 | | - toolchain: nightly |
22 | | - override: true |
23 | | - components: rustfmt, clippy |
24 | | - - name: Build |
25 | | - run: cargo build --release |
26 | | - - name: Tests |
27 | | - run: cargo test --release |
| 99 | + version: 10 |
| 100 | + |
| 101 | + - name: Get pnpm store directory |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT |
| 105 | + id: pnpm-cache |
| 106 | + |
| 107 | + - name: Setup pnpm cache |
| 108 | + uses: actions/cache@v4 |
| 109 | + with: |
| 110 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 111 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 112 | + restore-keys: | |
| 113 | + ${{ runner.os }}-pnpm-store- |
| 114 | +
|
| 115 | + - name: Install dependencies |
| 116 | + run: pnpm install --frozen-lockfile |
| 117 | + |
| 118 | + - name: Run linter |
| 119 | + run: pnpm run lint |
| 120 | + |
| 121 | + - name: Run tests |
| 122 | + run: pnpm run test |
| 123 | + |
| 124 | + - name: Build project |
| 125 | + run: pnpm run build |
0 commit comments