Rust Lint + Build + Tests #344
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust Workflow | |
| run-name: Rust Lint + Build + Tests | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| - v2 | |
| workflow_dispatch: | |
| env: | |
| RUSTVERS: "1.90.0" # only applies to non solana platform tools rustc | |
| SOLANAVERS: "3.1.1" # make sure this matches the one in README | |
| # all the stuff that usually gets cached to ~ | |
| # now gets cached to repo dir so that cache action can pick it up | |
| HOME: ${{ github.workspace }} | |
| CARGO_HOME: ${{ github.workspace }}/.cargo | |
| jobs: | |
| # hax from https://github.com/orgs/community/discussions/26324#discussioncomment-3251460 | |
| # so that we can interpolate env vars in docker image name | |
| output-rust-build-image-name: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image: ${{ steps.set_image.outputs.image }} | |
| steps: | |
| - id: set_image | |
| run: echo "image=rust:${{ env.RUSTVERS }}-bookworm" >> $GITHUB_OUTPUT | |
| fmt: | |
| runs-on: ubuntu-latest | |
| needs: output-rust-build-image-name | |
| container: | |
| image: ${{ needs.output-rust-build-image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install rustfmt | |
| run: rustup component add rustfmt | |
| - name: Format | |
| run: cargo fmt --all -- --check | |
| fetch: | |
| runs-on: ubuntu-latest | |
| needs: output-rust-build-image-name | |
| container: | |
| image: ${{ needs.output-rust-build-image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: cargo fetch Cache | |
| uses: ./.github/actions/cache-cargo-fetch | |
| - name: Fetch | |
| run: cargo fetch | |
| lint: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - output-rust-build-image-name | |
| - fetch | |
| container: | |
| image: ${{ needs.output-rust-build-image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install clippy | |
| run: rustup component add clippy | |
| - name: cargo fetch Cache Restore | |
| uses: ./.github/actions/restore-cache-cargo-fetch | |
| - name: clippy cache | |
| uses: ./.github/actions/cache-clippy | |
| - name: clippy | |
| run: cargo clippy --all-features --tests -- -D clippy::all | |
| # hax from https://github.com/orgs/community/discussions/26324#discussioncomment-3251460 | |
| # so that we can interpolate env vars in docker image name | |
| output-solana-build-image-name: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image: ${{ steps.set_image.outputs.image }} | |
| steps: | |
| - id: set_image | |
| # TODO: change this from santumso/ back to solanafoundation/ once theyve released 3.1.1 | |
| run: echo "image=sanctumso/solana-verifiable-build:${{ env.SOLANAVERS }}" >> $GITHUB_OUTPUT | |
| build-sbf: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - output-solana-build-image-name | |
| - fetch | |
| container: | |
| image: ${{ needs.output-solana-build-image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: cargo fetch Cache Restore | |
| uses: ./.github/actions/restore-cache-cargo-fetch | |
| - name: cargo-build-sbf Cache | |
| uses: ./.github/actions/cache-cargo-build-sbf | |
| - name: Build | |
| run: cargo-build-sbf | |
| - name: Upload | |
| uses: ./.github/actions/upload-sbf-progs | |
| test-sbf: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - output-solana-build-image-name | |
| - fetch | |
| - build-sbf | |
| container: | |
| image: ${{ needs.output-solana-build-image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: cargo fetch Cache Restore | |
| uses: ./.github/actions/restore-cache-cargo-fetch | |
| - name: cargo-build-sbf Cache Restore | |
| uses: ./.github/actions/restore-cache-cargo-build-sbf | |
| - name: cargo-test-sbf Cache | |
| # use cache instead of artifact because | |
| # cargo-test-sbf runs cargo-build-sbf again | |
| uses: ./.github/actions/cache-cargo-test-sbf | |
| - name: Test SBF | |
| run: cargo-test-sbf | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - output-rust-build-image-name | |
| - fetch | |
| - build-sbf | |
| container: | |
| image: ${{ needs.output-rust-build-image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download SBF Programs | |
| uses: ./.github/actions/download-sbf-progs | |
| - name: cargo fetch Cache Restore | |
| uses: ./.github/actions/restore-cache-cargo-fetch | |
| - name: cargo test Cache | |
| uses: ./.github/actions/cache-cargo-test | |
| - name: Test | |
| run: cargo test | |
| # hax from https://github.com/orgs/community/discussions/26324#discussioncomment-3251460 | |
| # so that we can interpolate env vars in docker image name | |
| output-wasm-build-image-name: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image: ${{ steps.set_image.outputs.image }} | |
| steps: | |
| - id: set_image | |
| run: echo "image=dylanowen/wasm-pack:${{ env.RUSTVERS }}" >> $GITHUB_OUTPUT | |
| build-wasm: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - output-wasm-build-image-name | |
| - fetch | |
| container: | |
| image: ${{ needs.output-wasm-build-image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: cargo fetch Cache Restore | |
| uses: ./.github/actions/restore-cache-cargo-fetch | |
| - name: wasm Cache | |
| uses: ./.github/actions/cache-wasm-build | |
| - name: Delete Outdated System wasm-opt | |
| # causes wasm-opt to fail. Delete to force to | |
| # use the one bundled in wasm-pack instead | |
| run: rm -rf /usr/local/cargo/bin/wasm-opt | |
| - name: Build wasm | |
| working-directory: ts/sdk | |
| # wasm build image does not have nodejs required to run full `make`, | |
| # so we only run until prod target | |
| run: make prod | |
| - name: Upload | |
| uses: ./.github/actions/upload-wasm-pkg | |
| # TODO: uncomment to reactivate ts CI tests | |
| # once swapv2 instructions are done | |
| # | |
| # test-ts: | |
| # runs-on: ubuntu-latest | |
| # needs: | |
| # - build-sbf | |
| # - build-wasm | |
| # steps: | |
| # - name: Checkout | |
| # uses: actions/checkout@v4 | |
| # - name: Download wasm pkg | |
| # uses: ./.github/actions/download-wasm-pkg | |
| # - name: Download SBF Programs | |
| # uses: ./.github/actions/download-sbf-progs | |
| # - name: wasm Postbuild | |
| # # Run postbuild step that was omitted in build-wasm | |
| # working-directory: ts/sdk/postbuild | |
| # run: node postbuild.mjs | |
| # - name: pnpm Setup | |
| # uses: pnpm/action-setup@v4 | |
| # with: | |
| # version: 10 | |
| # # false because we need to run it in working-directory | |
| # run_install: false | |
| # - name: Install pnpm Deps | |
| # # TODO: cache pnpm install when required. | |
| # # Currently takes ~3s to download all deps, so prolly not worth it | |
| # working-directory: ts/tests | |
| # run: pnpm install | |
| # - name: Test TS | |
| # working-directory: ts/tests | |
| # run: pnpm test |