Skip to content

feat(ci): parallelize jobs #394

feat(ci): parallelize jobs

feat(ci): parallelize jobs #394

Workflow file for this run

name: CI
on:
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
MSRV: "1.85"
RS_EXAMPLES_LIST: "browser-chat browser-echo custom-router dumbpipe-web framed-messages frosty iroh-automerge iroh-automerge-repo iroh-gateway extism/host extism/plugin extism/iroh-extism-host-functions"
WASM_EXAMPLES_LIST: "browser-chat browser-echo"
IROH_FORCE_STAGING_RELAYS: "1"
jobs:
# Prepare dependencies and cache them for all other jobs
prepare:
name: Prepare dependencies
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy,rustfmt
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "iroh-examples-shared"
cache-all-crates: true
- name: Fetch dependencies
run: |
for example in $RS_EXAMPLES_LIST; do
if [ -f "$example/Cargo.toml" ]; then
echo "Fetching dependencies for $example"
cargo fetch --manifest-path "$example/Cargo.toml" --locked 2>/dev/null || cargo fetch --manifest-path "$example/Cargo.toml"
fi
done
# Check formatting for all examples in a single job (fast)
fmt:
name: Format check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: |
for example in $RS_EXAMPLES_LIST; do
if [ -f "$example/Cargo.toml" ]; then
echo "Checking format: $example"
cargo fmt --manifest-path "$example/Cargo.toml" --all -- --check
fi
done
# Build WASM examples
wasm:
name: WASM build
runs-on: ubuntu-latest
timeout-minutes: 20
needs: prepare
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "iroh-examples-shared"
- name: Build WASM examples
run: |
for example in $WASM_EXAMPLES_LIST; do
echo "Building WASM: $example"
cd "$example"
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build --target wasm32-unknown-unknown
cd ..
done
env:
RUST_LOG: ${{ runner.debug && 'DEBUG' || 'INFO'}}
# Parallel testing matrix for all examples
test:
name: Test ${{ matrix.example }}
runs-on: ubuntu-latest
timeout-minutes: 20
needs: prepare
strategy:
fail-fast: false
matrix:
example:
- browser-chat
- browser-echo
- custom-router
- dumbpipe-web
- framed-messages
- frosty
- iroh-automerge
- iroh-automerge-repo
- iroh-gateway
- extism/host
- extism/plugin
- extism/iroh-extism-host-functions
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "iroh-examples-shared"
workspaces: ${{ matrix.example }}
- name: Check
run: |
echo "Checking ${{ matrix.example }}"
cargo check --manifest-path "${{ matrix.example }}/Cargo.toml" --all-features
env:
RUST_LOG: ${{ runner.debug && 'DEBUG' || 'INFO'}}
- name: Clippy
run: |
echo "Running clippy on ${{ matrix.example }}"
cargo clippy --manifest-path "${{ matrix.example }}/Cargo.toml" --all-features
env:
RUST_LOG: ${{ runner.debug && 'DEBUG' || 'INFO'}}
- name: Test
run: |
echo "Testing ${{ matrix.example }}"
cargo test --manifest-path "${{ matrix.example }}/Cargo.toml" --all-features
env:
RUST_LOG: ${{ runner.debug && 'DEBUG' || 'INFO'}}