Skip to content

ci: Add cargo

ci: Add cargo #26

Workflow file for this run

name: CI
on: [push, pull_request]
jobs:
toml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install taplo
run: cargo install taplo-cli --locked
- name: List versions
run: |
cargo --version
taplo --version
- name: Run taplo
run: taplo format --check --diff
- name: Taplo failure info
if: failure()
run: |
echo 'TOML is not formatted correctly'
echo 'Please run `taplo format`'
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: rustfmt
- name: List version
run: |
cargo --version
cargo fmt --version
- name: Cargo format
run: cargo fmt --all -- --check
- name: Cargo fmt failure info
if: failure()
run: |
echo '.rs files are not formatted correctly'
echo 'Please run `cargo fmt --all`'
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown
components: clippy
- name: List version
run: |
cargo --version
cargo clippy --version
- name: Cargo clippy
run: cargo clippy -- -D warnings
- name: Cargo clippy failure info
if: failure()
run: |
echo '`cargo clippy` failed'
echo 'Please fix the issue generated by clippy'
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install protobuf compiler
run: |
sudo apt-get update
sudo apt-get install protobuf-compiler
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown
- name: List version
run: cargo --version
- name: Build with try-runtime feature
run: RUSTFLAGS="-D warnings" cargo build --features try-runtime
- name: try-runtime build failure
if: failure()
run: |
echo 'Building with `try-runtime` feature failed'
- name: Build node runtime
run: RUSTFLAGS="-D warnings" cargo build -p polka-storage-runtime
- name: Node runtime build failure
if: failure()
run: |
echo 'Building the node runtime failed'
- name: Build node with runtime-benchmark feature
run: RUSTFLAGS="-D warnings" cargo build -p polka-storage-node --features runtime-benchmarks
- name: runtime-benchmark build failure
if: failure()
run: |
echo 'Failed to build node with runtime-benchmark feature'
- name: Build in release mode
run: RUSTFLAGS="-D warnings" cargo build --release
- name: Release build failed
if: failure()
run: |
echo '`cargo build --release` failed'
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install protobuf compiler
run: |
sudo apt-get update
sudo apt-get install protobuf-compiler
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown
- name: List version
run: cargo --version
- name: Run tests
run: RUSTFLAGS="-D warnings" cargo test --workspace
- name: Cargo test fail
if: failure()
run: |
echo '`cargo test --workspace` failed'