|
1 | 1 | name: Setup environment |
2 | 2 |
|
3 | 3 | inputs: |
4 | | - cache: |
5 | | - description: Enable caching |
6 | | - default: "true" |
7 | | - node: |
8 | | - description: The Node.js version to install |
9 | | - required: true |
| 4 | + cargo-cache-key: |
| 5 | + description: The key to cache cargo dependencies. Skips cargo caching if not provided. |
| 6 | + required: false |
| 7 | + cargo-cache-fallback-key: |
| 8 | + description: The fallback key to use when caching cargo dependencies. Default to not using a fallback key. |
| 9 | + required: false |
| 10 | + cargo-cache-local-key: |
| 11 | + description: The key to cache local cargo dependencies. Skips local cargo caching if not provided. |
| 12 | + required: false |
| 13 | + clippy: |
| 14 | + description: Install Clippy if `true`. Defaults to `false`. |
| 15 | + required: false |
| 16 | + rustfmt: |
| 17 | + description: Install Rustfmt if `true`. Defaults to `false`. |
| 18 | + required: false |
10 | 19 | solana: |
11 | | - description: The Solana version to install |
| 20 | + description: Install Solana if `true`. Defaults to `false`. |
| 21 | + required: false |
12 | 22 |
|
13 | 23 | runs: |
14 | | - using: "composite" |
| 24 | + using: 'composite' |
15 | 25 | steps: |
16 | 26 | - name: Setup pnpm |
17 | 27 | uses: pnpm/action-setup@v3 |
| 28 | + |
18 | 29 | - name: Setup Node.js |
19 | 30 | uses: actions/setup-node@v4 |
20 | 31 | with: |
21 | | - node-version: ${{ inputs.node }} |
22 | | - cache: "pnpm" |
23 | | - - name: Install dependencies |
| 32 | + node-version: 20 |
| 33 | + cache: 'pnpm' |
| 34 | + |
| 35 | + - name: Install Dependencies |
24 | 36 | run: pnpm install --frozen-lockfile |
25 | 37 | shell: bash |
| 38 | + |
| 39 | + - name: Set Environment Variables |
| 40 | + shell: bash |
| 41 | + run: pnpm zx ./scripts/ci/set-env.mjs |
| 42 | + |
| 43 | + - name: Install Rustfmt |
| 44 | + if: ${{ inputs.rustfmt == 'true' }} |
| 45 | + uses: dtolnay/rust-toolchain@master |
| 46 | + with: |
| 47 | + toolchain: ${{ env.TOOLCHAIN_FORMAT }} |
| 48 | + components: rustfmt |
| 49 | + |
| 50 | + - name: Install Clippy |
| 51 | + if: ${{ inputs.clippy == 'true' }} |
| 52 | + uses: dtolnay/rust-toolchain@master |
| 53 | + with: |
| 54 | + toolchain: ${{ env.TOOLCHAIN_LINT }} |
| 55 | + components: clippy |
| 56 | + |
26 | 57 | - name: Install Solana |
27 | | - if: ${{ inputs.solana != '' }} |
| 58 | + if: ${{ inputs.solana == 'true' }} |
28 | 59 | uses: metaplex-foundation/actions/install-solana@v1 |
29 | 60 | with: |
30 | | - version: ${{ inputs.solana }} |
31 | | - cache: ${{ inputs.cache }} |
| 61 | + version: ${{ env.SOLANA_VERSION }} |
| 62 | + cache: true |
| 63 | + |
| 64 | + - name: Cache Cargo Dependencies |
| 65 | + if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }} |
| 66 | + uses: actions/cache@v4 |
| 67 | + with: |
| 68 | + path: | |
| 69 | + ~/.cargo/bin/ |
| 70 | + ~/.cargo/registry/index/ |
| 71 | + ~/.cargo/registry/cache/ |
| 72 | + ~/.cargo/git/db/ |
| 73 | + target/ |
| 74 | + key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }} |
| 75 | + restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }} |
| 76 | + |
| 77 | + - name: Cache Cargo Dependencies With Fallback |
| 78 | + if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }} |
| 79 | + uses: actions/cache@v4 |
| 80 | + with: |
| 81 | + path: | |
| 82 | + ~/.cargo/bin/ |
| 83 | + ~/.cargo/registry/index/ |
| 84 | + ~/.cargo/registry/cache/ |
| 85 | + ~/.cargo/git/db/ |
| 86 | + target/ |
| 87 | + key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }} |
| 88 | + restore-keys: | |
| 89 | + ${{ runner.os }}-${{ inputs.cargo-cache-key }} |
| 90 | + ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }} |
| 91 | + ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }} |
| 92 | +
|
| 93 | + - name: Cache Local Cargo Dependencies |
| 94 | + if: ${{ inputs.cargo-cache-local-key }} |
| 95 | + uses: actions/cache@v4 |
| 96 | + with: |
| 97 | + path: | |
| 98 | + .cargo/bin/ |
| 99 | + .cargo/registry/index/ |
| 100 | + .cargo/registry/cache/ |
| 101 | + .cargo/git/db/ |
| 102 | + key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }} |
| 103 | + restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }} |
0 commit comments