| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- name: Setup environment
- inputs:
- cargo-cache-key:
- description: The key to cache cargo dependencies. Skips cargo caching if not provided.
- required: false
- cargo-cache-fallback-key:
- description: The fallback key to use when caching cargo dependencies. Default to not using a fallback key.
- required: false
- cargo-cache-local-key:
- description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
- required: false
- pnpm:
- description: Install pnpm if `true`. Defaults to `false`.
- required: false
- solana:
- description: Install Solana if `true`. Defaults to `false`.
- required: false
- toolchain:
- description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`, `test`].
- required: false
- runs:
- using: 'composite'
- steps:
- - name: Set Environment Variables
- shell: bash
- run: |
- source ./vars.env
- echo "RUST_TOOLCHAIN_NIGHTLY=$RUST_TOOLCHAIN_NIGHTLY" >> "$GITHUB_ENV"
- echo "SOLANA_CLI_VERSION=$SOLANA_CLI_VERSION" >> "$GITHUB_ENV"
- - name: Setup pnpm
- if: ${{ inputs.pnpm == 'true' }}
- uses: pnpm/action-setup@v3
- - name: Setup Node.js
- if: ${{ inputs.pnpm == 'true' }}
- uses: actions/setup-node@v4
- with:
- node-version: 20
- cache: 'pnpm'
- - name: Install Dependencies
- if: ${{ inputs.pnpm == 'true' }}
- run: pnpm install --frozen-lockfile
- shell: bash
- - name: Install Rust 'build' Toolchain
- if: ${{ contains(inputs.toolchain, 'build') }}
- uses: dtolnay/rust-toolchain@master
- with:
- toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
- - name: Install Rust 'format' Toolchain
- if: ${{ contains(inputs.toolchain, 'format') }}
- uses: dtolnay/rust-toolchain@master
- with:
- toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
- components: rustfmt
- - name: Install Rust 'lint' Toolchain
- if: ${{ contains(inputs.toolchain, 'lint') }}
- uses: dtolnay/rust-toolchain@master
- with:
- toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
- components: clippy
- - name: Install Rust 'test' Toolchain
- if: ${{ contains(inputs.toolchain, 'test') }}
- uses: dtolnay/rust-toolchain@master
- with:
- toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
- - name: Install Solana
- if: ${{ inputs.solana == 'true' }}
- uses: solana-program/actions/install-solana@v1
- with:
- version: ${{ env.SOLANA_CLI_VERSION }}
- cache: true
- - name: Install 'cargo-hack'
- if: ${{ contains(inputs.toolchain, 'lint') }}
- shell: bash
- run: cargo install cargo-hack
- - name: Cache Cargo Dependencies
- if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
- uses: actions/cache@v4
- with:
- path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- target/
- key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
- restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}
- - name: Cache Cargo Dependencies With Fallback
- if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
- uses: actions/cache@v4
- with:
- path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- target/
- key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
- restore-keys: |
- ${{ runner.os }}-${{ inputs.cargo-cache-key }}
- ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}
- ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}
- - name: Cache Local Cargo Dependencies
- if: ${{ inputs.cargo-cache-local-key }}
- uses: actions/cache@v4
- with:
- path: |
- .cargo/bin/
- .cargo/registry/index/
- .cargo/registry/cache/
- .cargo/git/db/
- key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
- restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}
|