name: Continuous integration
on:
pull_request:
push:
branches:
- master
jobs:
test-desktop:
name: Build and test
runs-on: ubuntu-latest
strategy:
matrix:
args: [
"--no-default-features",
"--all-features",
"--benches --all-features",
]
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@bb6001c4ea612bf59c3abfc4756fbceee4f870c7 with:
access_token: ${{ github.token }}
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@6720f05bc48b77f96918929a9019fb2203ff71f8 with:
key: ${{ matrix.args }}
- run: cargo test --workspace ${{ matrix.args }}
test-wasm:
name: Build on WASM
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: [
wasm32-unknown-emscripten,
wasm32-wasi
]
include:
- toolchain: wasm32-unknown-unknown
args: "--features wasm-bindgen"
env:
CC: clang-11
defaults:
run:
shell: bash
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@bb6001c4ea612bf59c3abfc4756fbceee4f870c7 with:
access_token: ${{ github.token }}
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/checkout@v3
- name: Install Rust ${{ matrix.toolchain }}
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af with:
toolchain: stable
target: ${{ matrix.toolchain }}
override: true
- name: Install a recent version of clang
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
- name: Install CMake
run: sudo apt-get install -y cmake
- uses: Swatinem/rust-cache@6720f05bc48b77f96918929a9019fb2203ff71f8 with:
key: ${{ matrix.toolchain }}
- name: Build on ${{ matrix.toolchain }}
run: cargo build --target=${{ matrix.toolchain }} ${{ matrix.args }}
check-rustdoc-links:
name: Check rustdoc intra-doc links
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@bb6001c4ea612bf59c3abfc4756fbceee4f870c7 with:
access_token: ${{ github.token }}
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@6720f05bc48b77f96918929a9019fb2203ff71f8
- name: Check rustdoc links
run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links --deny warnings" cargo doc --verbose --workspace --no-deps --all-features --document-private-items
check-clippy:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@bb6001c4ea612bf59c3abfc4756fbceee4f870c7 with:
access_token: ${{ github.token }}
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af with:
profile: minimal
toolchain: stable
override: true
components: clippy
- uses: Swatinem/rust-cache@6720f05bc48b77f96918929a9019fb2203ff71f8
- name: Run cargo clippy
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 with:
command: custom-clippy
integration-test:
name: Integration tests
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@bb6001c4ea612bf59c3abfc4756fbceee4f870c7 with:
access_token: ${{ github.token }}
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@6720f05bc48b77f96918929a9019fb2203ff71f8
- name: Run ipfs-kad example
run: RUST_LOG=libp2p_swarm=debug,libp2p_kad=trace,libp2p_tcp=debug cargo run --example ipfs-kad --features full
rustfmt:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@bb6001c4ea612bf59c3abfc4756fbceee4f870c7 with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- name: Check formatting
run: cargo fmt -- --check
manifest_lint:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@bb6001c4ea612bf59c3abfc4756fbceee4f870c7 with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af with:
profile: minimal
toolchain: stable
override: true
- name: Ensure `full` feature contains all features
run: |
ALL_FEATURES=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "libp2p") | .features | keys | map(select(. != "full")) | sort | join(" ")')
FULL_FEATURE=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "libp2p") | .features["full"] | sort | join(" ")')
test "$ALL_FEATURES = $FULL_FEATURE"
echo "$ALL_FEATURES";
echo "$FULL_FEATURE";
test "$ALL_FEATURES" = "$FULL_FEATURE"
gather_crates_for_semver_checks:
runs-on: ubuntu-latest
outputs:
members: ${{ steps.cargo-metadata.outputs.members }}
steps:
- uses: actions/checkout@v3
- id: cargo-metadata
run: |
WORKSPACE_MEMBERS=$(cargo metadata --format-version=1 --no-deps | jq -c '.packages | .[] | select(.publish == null) | .name' | jq -s '.' | jq -c '.')
echo "::set-output name=members::${WORKSPACE_MEMBERS}"
semver-check:
runs-on: ubuntu-latest
needs: gather_crates_for_semver_checks
strategy:
fail-fast: false
matrix:
crate: ${{ fromJSON(needs.gather_crates_for_semver_checks.outputs.members) }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@bb6001c4ea612bf59c3abfc4756fbceee4f870c7 with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af with:
profile: minimal
toolchain: stable
override: true
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: Swatinem/rust-cache@6720f05bc48b77f96918929a9019fb2203ff71f8
- run: cargo install cargo-semver-checks
- name: Semver Check
run: cargo semver-checks check-release -p ${{ matrix.crate }}