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 clippy: description: Install Clippy if `true`. Defaults to `false`. required: false purge: description: Purge unused directories if `true`. Defaults to `false`. required: false rustfmt: description: Install Rustfmt if `true`. Defaults to `false`. required: false solana: description: Install Solana if `true`. Defaults to `false`. required: false runs: using: 'composite' steps: - name: Setup pnpm uses: pnpm/action-setup@v3 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: 'pnpm' - name: Purge unused ubuntu runner directories if: ${{ inputs.purge == 'true' }} shell: bash run: | # If there are still disk space issues, try to add more packages from # https://github.com/jlumbroso/free-disk-space sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/share/swift sudo rm -rf /usr/share/mysql sudo rm -rf /usr/share/az_* sudo rm -rf /usr/share/postgresql-common sudo rm -rf /opt/ghc sudo rm -rf /usr/local/.ghcup sudo rm -rf /opt/az sudo rm -rf /opt/pipx sudo rm -rf /opt/microsoft sudo rm -rf /opt/google sudo rm -rf /opt/hostedtoolcache sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/local/lib/heroku sudo rm -rf /imagegeneration sudo rm -rf "$AGENT_TOOLSDIRECTORY" sudo docker image prune --all --force sudo docker system prune -af # Clear additional caches that might be large sudo rm -rf /tmp/* sudo rm -rf /var/tmp/* # This packages aren't that big, ~500MB total #sudo apt-get remove -y '^php.*' --fix-missing #sudo apt-get remove -y '^dotnet-.*' --fix-missing #sudo apt-get remove -y '^mongodb-.*' --fix-missing #sudo apt-get remove -y '^mysql-.*' --fix-missing sudo apt-get remove -y '^aspnetcore-.*' azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri google-cloud-cli --fix-missing sudo apt-get autoremove -y sudo apt-get clean #sudo swapoff -a #sudo rm -f /mnt/swapfile - name: Install Dependencies run: pnpm install --frozen-lockfile shell: bash - name: Set Environment Variables shell: bash run: pnpm zx ./scripts/ci/set-env.mjs - name: Install Rustfmt if: ${{ inputs.rustfmt == 'true' }} uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.TOOLCHAIN_FORMAT }} components: rustfmt - name: Install Clippy if: ${{ inputs.clippy == 'true' }} uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.TOOLCHAIN_LINT }} components: clippy - name: Install Solana if: ${{ inputs.solana == 'true' }} uses: solana-program/actions/install-solana@v1 with: version: ${{ env.SOLANA_VERSION }} cache: true - 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 }}