chore: Enable rust tests in CI (#50)

* git: Run job from the `main` branch instead of `master`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* git: Expose terminal colors for CI

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* git: Fix CI and add extra checks

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Fix clippy

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* git: Add missing `cargo hack` command

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* git: Use actions-rs/target for wasm

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-02-21 14:01:46 +02:00
committed by GitHub
parent 1ea3299208
commit f84ba3ff49
2 changed files with 151 additions and 94 deletions
+148 -91
View File
@@ -1,116 +1,173 @@
name: Compilation and Testing Suite name: Compilation and Testing Suite
on: on:
pull_request: pull_request:
push: push:
branches: branches:
- master - main
tags: tags:
- v* - v*
paths-ignore: paths-ignore:
- 'README.md' - 'README.md'
env:
CARGO_TERM_COLOR: always
jobs: jobs:
fmt:
check-test-build: name: Cargo fmt
name: Check, test and build runs-on: ubuntu-latest
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: full
steps: steps:
- name: Cancel Previous Runs - name: Checkout sources
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # 0.11.0 uses: actions/checkout@v3
with:
access_token: ${{ github.token }}
- name: Checkout sources & submodules
uses: actions/checkout@v3
with:
fetch-depth: 5
submodules: recursive
## Check Stage
- name: Checking rust-stable
uses: actions-rs/cargo@v1
with:
command: check
toolchain: stable
args: --all --verbose
## Test Stage - name: Install Rust nightly toolchain
- name: Testing rust-stable uses: actions-rs/toolchain@v1
uses: actions-rs/cargo@v1
with: with:
command: test profile: minimal
toolchain: stable toolchain: nightly
args: --all --verbose override: true
components: rustfmt
## Build Stage - name: Rust Cache
- name: Building rust-stable uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
uses: actions-rs/cargo@v1
if: github.ref == 'refs/heads/master' - name: Cargo fmt
uses: actions-rs/cargo@v1.0.3
with: with:
command: build command: fmt
toolchain: stable args: --all -- --check
args: --all --verbose
docs:
name: Check documentation
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
- name: Check internal documentation links
run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc -vv --workspace --no-deps --document-private-items
- name: Run cargo test on documentation
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --doc
tests:
name: Cargo test
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --all-targets --workspace
clippy:
name: Cargo clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
check-wasm: check-wasm:
name: Check WASM name: Check WASM
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
RUST_BACKTRACE: full
steps: steps:
- name: Cancel Previous Runs - name: Checkout sources
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # 0.11.0 uses: actions/checkout@v3
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with: with:
access_token: ${{ github.token }} profile: minimal
- name: Checkout sources & submodules toolchain: stable
uses: actions/checkout@v3 components: clippy
target: wasm32-unknown-unknown
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
- name: Install cargo-hack
uses: baptiste0928/cargo-install@v1
with: with:
fetch-depth: 5 crate: cargo-hack
submodules: recursive version: 0.5
- name: Add WASM Utilities
run: rustup target add wasm32-unknown-unknown --toolchain stable - name: Checking wasm32 (v14)
## Check Stage run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features v14 --skip legacy,v8,v9,v10,v11,v12,v13 --depth 4 --target wasm32-unknown-unknown
- name: Checking wasm32 (v14)
uses: actions-rs/cargo@v1 - name: Checking wasm32 (all features)
uses: taiki-e/install-action@cargo-hack run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --skip decode,serde_full --depth 4 --target wasm32-unknown-unknown
with:
command: hack
toolchain: stable
args: check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features v14 --skip legacy,v8,v9,v10,v11,v12,v13 --depth 4 --target wasm32-unknown-unknown
- name: Checking wasm32 (all features)
uses: actions-rs/cargo@v1
uses: taiki-e/install-action@cargo-hack
with:
command: hack
toolchain: stable
args: check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --skip decode,serde_full --depth 4 --target wasm32-unknown-unknown
check-features: check-features:
name: Check Features name: Check Features
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
RUST_BACKTRACE: full
steps: steps:
- name: Cancel Previous Runs - name: Checkout sources
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # 0.11.0 uses: actions/checkout@v3
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with: with:
access_token: ${{ github.token }} profile: minimal
- name: Checkout sources & submodules toolchain: stable
uses: actions/checkout@v3 components: clippy
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
- name: Install cargo-hack
uses: baptiste0928/cargo-install@v1
with: with:
fetch-depth: 5 crate: cargo-hack
submodules: recursive version: 0.5
## Check Stage
- name: Checking v14 feature combinations (native) - name: Checking v14 feature combinations (native)
uses: actions-rs/cargo@v1 run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features v14 --skip legacy,v8,v9,v10,v11,v12,v13 --depth 4
uses: taiki-e/install-action@cargo-hack
with: - name: Checking feature combinations excluding decode/serde_full (native)
command: hack run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --skip decode,serde_full --depth 4
toolchain: stable
args: check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features v14 --skip legacy,v8,v9,v10,v11,v12,v13 --depth 4
- name: Checking feature combinations excluding decode/serde_full (native)
uses: actions-rs/cargo@v1
uses: taiki-e/install-action@cargo-hack
with:
command: hack
toolchain: stable
args: check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --skip decode,serde_full --depth 4
+3 -3
View File
@@ -101,9 +101,9 @@ pub use self::v14::*;
#[cfg_attr(feature = "serde_full", derive(Serialize))] #[cfg_attr(feature = "serde_full", derive(Serialize))]
pub struct RuntimeMetadataPrefixed(pub u32, pub RuntimeMetadata); pub struct RuntimeMetadataPrefixed(pub u32, pub RuntimeMetadata);
impl Into<Vec<u8>> for RuntimeMetadataPrefixed { impl From<RuntimeMetadataPrefixed> for Vec<u8> {
fn into(self) -> Vec<u8> { fn from(value: RuntimeMetadataPrefixed) -> Self {
self.encode() value.encode()
} }
} }