ci: split tests workflow into two and refactor them #618
Workflow file for this run
This file contains 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: Tests | |
on: | |
push: | |
branches: | |
- main | |
- 0.[0-9]+ | |
pull_request: | |
jobs: | |
package_crypto: | |
name: package_crypto | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./packages/crypto | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.60.0 | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo | |
key: cargocache-v2-package_crypto-rust:1.60.0-${{ hashFiles('Cargo.lock') }} | |
- name: Version information | |
run: rustc --version; cargo --version; rustup --version; rustup target list --installed | |
- name: Build | |
working-directory: ${{env.working-directory}} | |
run: cargo build --locked | |
- name: Run tests | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked | |
package_derive: | |
name: package_derive | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./packages/derive | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.60.0 | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo | |
key: cargocache-v2-package_derive-rust:1.60.0-${{ hashFiles('Cargo.lock') }} | |
- name: Version information | |
run: rustc --version; cargo --version; rustup --version; rustup target list --installed | |
- name: Build | |
working-directory: ${{env.working-directory}} | |
run: cargo build --locked | |
- name: Run tests | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked | |
package_schema: | |
name: package_schema | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./packages/schema | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.60.0 | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo | |
key: cargocache-v2-package_schema-rust:1.60.0-${{ hashFiles('Cargo.lock') }} | |
- name: Version information | |
run: rustc --version; cargo --version; rustup --version; rustup target list --installed | |
- name: Build | |
working-directory: ${{env.working-directory}} | |
run: cargo build --locked | |
- name: Run tests | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked | |
package_std: | |
name: package_std | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./packages/std | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.60.0 | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo | |
key: cargocache-v2-package_std-rust:1.60.0-${{ hashFiles('Cargo.lock') }} | |
- name: Version information | |
run: rustc --version; cargo --version; rustup --version; rustup target list --installed | |
- name: Add wasm32 target | |
run: rustup target add wasm32-unknown-unknown && rustup target list --installed | |
- name: Build library for native target (no features) | |
working-directory: ${{env.working-directory}} | |
run: cargo build --locked --no-default-features | |
- name: Build library for wasm target (no features) | |
working-directory: ${{env.working-directory}} | |
run: cargo wasm --locked --no-default-features | |
- name: Run unit tests (no features) | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked --no-default-features | |
- name: Build library for native target (all features) | |
working-directory: ${{env.working-directory}} | |
run: cargo build --locked --features iterator,staking,stargate | |
- name: Build library for wasm target (all features) | |
working-directory: ${{env.working-directory}} | |
run: cargo wasm --locked --features iterator,staking,stargate | |
- name: Run unit tests (all features) | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked --features iterator,staking,stargate | |
- name: Build and run schema generator | |
working-directory: ${{env.working-directory}} | |
run: cargo schema --locked | |
- name: Ensure schemas are up-to-date | |
run: | | |
CHANGES_IN_REPO=$(git status --porcelain) | |
if [[ -n "$CHANGES_IN_REPO" ]]; then | |
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" | |
git status && git --no-pager diff | |
exit 1 | |
fi | |
package_storage: | |
name: package_storage | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./packages/storage | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.60.0 | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo | |
key: cargocache-v2-package_storage-rust:1.60.0-${{ hashFiles('Cargo.lock') }} | |
- name: Version information | |
run: rustc --version; cargo --version; rustup --version; rustup target list --installed | |
- name: Build library for native target | |
working-directory: ${{env.working-directory}} | |
run: cargo build --locked | |
- name: Run unit tests | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked | |
- name: Run unit tests (with iterator support) | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked --features iterator | |
package_vm: | |
name: package_vm | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./packages/vm | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.60.0 | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo | |
key: cargocache-v2-package_vm-rust:1.60.0-${{ hashFiles('Cargo.lock') }} | |
- name: Version information | |
run: rustc --version; cargo --version; rustup --version; rustup target list --installed | |
- name: Build | |
working-directory: ${{env.working-directory}} | |
run: cargo build --locked | |
- name: Build with all features | |
working-directory: ${{env.working-directory}} | |
run: cargo build --locked --features iterator,staking,stargate | |
- name: Test | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked | |
- name: Test with all features | |
working-directory: ${{env.working-directory}} | |
run: cargo test --locked --features iterator,staking,stargate | |
clippy-and-fmt: | |
name: clippy-and-fmt | |
runs-on: ubuntu-latest | |
env: | |
packages: ./packages | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.60.0 | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
components: rustfmt, clippy | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo | |
key: cargocache-v2-fmt-rust:1.60.0-${{ hashFiles('Cargo.lock') }} | |
- name: Version information | |
run: rustc --version; cargo --version; rustup --version; rustup target list --installed | |
- name: Check formatting of workspace | |
run: cargo fmt -- --check | |
# | |
# Check clippy linting on Workspace packages | |
# | |
- name: Clippy linting on schema | |
working-directory: ${{env.packages}}/schema | |
run: cargo clippy -- -D warnings | |
- name: Clippy linting on std (no feature flags) | |
working-directory: ${{env.packages}}/std | |
run: cargo clippy -- -D warnings | |
- name: Clippy linting on std (all feature flags) | |
working-directory: ${{env.packages}}/std | |
run: cargo clippy --features iterator,staking -- -D warnings | |
- name: Clippy linting on storage (no feature flags) | |
working-directory: ${{env.packages}}/storage | |
run: cargo clippy -- -D warnings | |
- name: Clippy linting on storage (all feature flags) | |
working-directory: ${{env.packages}}/storage | |
run: cargo clippy --features iterator -- -D warnings | |
- name: Clippy linting on vm (no feature flags) | |
working-directory: ${{env.packages}}/vm | |
run: cargo clippy --no-default-features -- -D warnings | |
- name: Clippy linting on vm (all feature flags) | |
working-directory: ${{env.packages}}/vm | |
run: cargo clippy --features iterator,staking,stargate -- -D warnings |