Skip to content

Switch CI from GitLab to GitHub Actions #6

Switch CI from GitLab to GitHub Actions

Switch CI from GitLab to GitHub Actions #6

Workflow file for this run

name: Rust CI/CD
on:
push:
branches:
- master
pull_request:
jobs:
# Checks
clippy:
runs-on: ubuntu-latest
container: paritytech/ci-unified:bullseye-1.73.0-2023-05-23-v20231009
steps:
- name: Checkout code/.
uses: actions/checkout@v4
# - name: Set up Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# components: clippy
# profile: minimal
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Run Clippy
run: |
cargo +stable clippy --locked -- -Dwarnings
cargo +stable clippy --locked -p parity-scale-codec-derive -- -Dwarnings
cargo +stable clippy --locked --test clippy -- -Dwarnings
checks:
runs-on: ubuntu-latest
container: paritytech/ci-unified:bullseye-1.73.0-2023-05-23-v20231009
steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Set up Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# profile: minimal
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Check Rust Stable (no_derive_no_std)
run: time cargo +stable check --verbose --no-default-features --features bit-vec,bytes,generic-array
- name: Check Rust Stable (no_std-chain-error)
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable check --verbose --no-default-features --features chain-error
- name: check-rust-stable-no_derive
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable check --verbose --features bit-vec,bytes,generic-array
- name: check-rust-stable-only_mel
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable check --verbose --features max-encoded-len
# Tests
tests:
runs-on: ubuntu-latest
container: paritytech/ci-unified:bullseye-1.73.0
steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Set up Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# profile: minimal
# - name: Cache Rust dependencies
# uses: swatinem/rust-cache@v2
# with:
# key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
# - name: Test Rust Stable
# run: |
# export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
# time cargo +stable test --verbose --all --features bit-vec,bytes,generic-array,derive,max-encoded-len
- name: Test Rust Stable (no_derive)
run: |
cargo -vV
rustc -vV
rustup show
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable test --verbose --no-default-features --features bit-vec,bytes,generic-array
- name: Test Rust Stable (only_mel)
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable test --verbose --features max-encoded-len
- name: Test Rust Stable (only_mel-no_default_std)
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable test --verbose --no-default-features --features max-encoded-len
# Benches
bench-rust-nightly:
runs-on: ubuntu-latest-16-cores
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Bench Rust Nightly
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +nightly bench --features bit-vec,bytes,generic-array,derive,max-encoded-len
miri:
runs-on: ubuntu-latest-16-cores
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: miri
profile: minimal
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Run Miri
run: |
export RUST_BACKTRACE=1
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
export MIRIFLAGS='-Zmiri-disable-isolation'
time cargo +nightly miri test --features bit-vec,bytes,generic-array,arbitrary --release
# Build
build-linux-ubuntu-amd64:
runs-on: ubuntu-latest
needs: [clippy, checks, tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Build for Linux (Ubuntu, AMD64)
run: cargo build --verbose --release --features bit-vec,bytes,generic-array,derive
publish-dry-run:
runs-on: ubuntu-latest
needs: [build-linux-ubuntu-amd64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Dry Run Publish
if: github.event_name == 'pull_request'
run: cargo publish -p parity-scale-codec --dry-run
# publish-crate:
# runs-on: ubuntu-latest
# needs: [publish-dry-run]
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Set up Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# - name: Cache Rust dependencies
# uses: swatinem/rust-cache@v2
# with:
# key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
# - name: Publish Crate
# if: startsWith(github.ref, 'refs/tags/v')
# run: cargo publish -p parity-scale-codec