SDK improvements #4202
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
| # Rust Tests: CI for Rust components (Blockchain & Storage Providers) | |
| # | |
| # Overview: | |
| # 1. Prepare: This job handles the setup phase where the cargo nextest archive is created | |
| # and uploaded to the workflow for use in the subsequent jobs | |
| # 2. All Rust Tests: Executes the full suite of Rust tests across two partitions to | |
| # to reduce total execution time. | |
| name: Rust Tests | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} | |
| cancel-in-progress: true | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| setup: | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| outputs: | |
| node_changed: ${{ steps.node_check.outputs.changed }} | |
| env: | |
| SKIP_BUILD_LABEL_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'skip-node-build') }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if Parachain Node needs rebuild | |
| id: node_check | |
| run: | | |
| BASE_SHA="${{ github.event.pull_request.base.sha || github.event.before }}" | |
| HEAD_SHA="${{ github.sha }}" | |
| if [[ "${{ env.SKIP_BUILD_LABEL_PRESENT }}" != "true" ]] && git diff --name-only $BASE_SHA $HEAD_SHA | grep -E '^(client|node|pallets|runtime|backend)/|^Cargo\.toml$'; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Comparing changes from $BASE_SHA to $HEAD_SHA" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| prepare: | |
| needs: [setup] | |
| if: needs.setup.outputs.node_changed == 'true' | |
| name: Prepare artifacts | |
| runs-on: blacksmith-16vcpu-ubuntu-2404 | |
| env: | |
| SCCACHE_GHA_ENABLED: 'true' | |
| RUSTC_WRAPPER: 'sccache' | |
| CARGO_INCREMENTAL: '0' | |
| CARGO_TERM_COLOR: always | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # By default actions/checkout checks out a merge commit. Check out the PR head instead. | |
| # https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - uses: actions-rust-lang/[email protected] | |
| with: | |
| cache: true | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/[email protected] | |
| - name: Cache cargo registry and git index | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - uses: rui314/setup-mold@v1 | |
| - name: Set build flags (use mold linker) | |
| run: echo "RUSTFLAGS=${{ env.RUSTFLAGS }} -C linker=clang -C link-arg=-fuse-ld=mold" >> $GITHUB_ENV | |
| - name: Install nextest | |
| uses: taiki-e/install-action@nextest | |
| # Install libpq-dev | |
| - name: Install libpq-dev | |
| run: sudo apt-get update && sudo apt-get install -y libpq-dev libclang-dev | |
| - name: Install Protoc | |
| uses: arduino/setup-protoc@v3 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and archive tests | |
| run: cargo nextest archive --archive-file nextest-archive.tar.zst --workspace --features sh-msp-backend-lib/mocks | |
| - name: Build Stats | |
| run: sccache --show-stats || true | |
| - name: Upload archive to workflow | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nextest-archive | |
| path: nextest-archive.tar.zst | |
| all-rust-tests: | |
| needs: [setup, prepare] | |
| if: needs.setup.outputs.node_changed == 'true' | |
| name: Run all tests (/w partitioning) | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| partition: [1, 2] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Install nextest | |
| uses: taiki-e/install-action@nextest | |
| - name: Download archive | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nextest-archive | |
| - name: Run Tests for All Projects! | |
| run: | | |
| ~/.cargo/bin/cargo-nextest nextest run \ | |
| --archive-file nextest-archive.tar.zst \ | |
| --partition count:${{ matrix.partition }}/2 |