diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 994b8b88c702..d024e494afb7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,18 +24,21 @@ env: jobs: test: name: Test ${{ matrix.crate }} - runs-on: ${{ fromJSON( - github.repository == 'libp2p/rust-libp2p' && ( - (contains(fromJSON('["libp2p-webrtc", "libp2p"]'), matrix.crate) && '["self-hosted", "linux", "x64", "2xlarge"]') || - (contains(fromJSON('["libp2p-quic", "libp2p-perf"]'), matrix.crate) && '["self-hosted", "linux", "x64", "xlarge"]') || - '["self-hosted", "linux", "x64", "large"]' - ) || '"ubuntu-latest"') }} + runs-on: "ubuntu-latest" + # runs-on: ${{ fromJSON( +# github.repository == 'libp2p/rust-libp2p' && ( +# (contains(fromJSON('["libp2p-webrtc", "libp2p"]'), matrix.crate) && '["self-hosted", "linux", "x64", "2xlarge"]') || +# (contains(fromJSON('["libp2p-quic", "libp2p-perf"]'), matrix.crate) && '["self-hosted", "linux", "x64", "xlarge"]') || +# '["self-hosted", "linux", "x64", "large"]' +# ) || '"ubuntu-latest"') }} timeout-minutes: 10 - needs: gather_published_crates +# needs: gather_published_crates strategy: fail-fast: false matrix: - crate: ${{ fromJSON(needs.gather_published_crates.outputs.members) }} +# crate: ${{ fromJSON(needs.gather_published_crates.outputs.members) }} + crate: + - "libp2p-webrtc" env: CRATE: ${{ matrix.crate }} steps: @@ -116,315 +119,314 @@ jobs: HEAD_SHA: ${{ github.event.pull_request.head.sha }} PR_BASE: ${{ github.event.pull_request.base.ref }} - wasm_tests: - name: Run all WASM tests - if: inputs.testsOnly == false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - with: - target: wasm32-unknown-unknown - - - uses: taiki-e/cache-cargo-install-action@v2 - with: - tool: wasm-pack@0.12.0 - - - name: Install chromedriver - uses: nanasess/setup-chromedriver@v2 - - - name: Run all tests - run: ./wasm-tests/run-all.sh - - cross: - name: Compile on ${{ matrix.target }} - if: inputs.testsOnly == false - strategy: - matrix: - include: - - target: "wasm32-unknown-unknown" - os: ubuntu-latest - - target: "wasm32-unknown-emscripten" - os: ubuntu-latest - - target: "wasm32-wasip1" - os: ubuntu-latest - - target: "x86_64-apple-darwin" - os: macos-latest - - target: "x86_64-pc-windows-msvc" - os: windows-latest - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - with: - target: ${{ matrix.target }} - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - with: - key: ${{ matrix.target }} - save-if: ${{ github.ref == 'refs/heads/master' }} - - - run: cargo check --package libp2p --all-features --target=${{ matrix.target }} - - msrv: - name: Compile with MSRV - runs-on: ubuntu-latest - if: inputs.testsOnly == false - steps: - - uses: actions/checkout@v4 - - - name: Extract MSRV from workspace manifest - shell: bash - run: | - MSRV=$(grep -oP 'rust-version\s*=\s*"\K[^"]+' Cargo.toml) - echo "MSRV=$MSRV" >> $GITHUB_ENV - - - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ env.MSRV }} - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - with: - save-if: ${{ github.ref == 'refs/heads/master' }} - - - run: cargo +$MSRV check --workspace --all-features - - feature_matrix: # Test various feature combinations work correctly - name: Compile with select features (${{ matrix.features }}) - if: inputs.testsOnly == false - runs-on: ubuntu-latest - strategy: - matrix: - include: - - features: "mdns tcp dns tokio" - - features: "mdns tcp dns async-std" - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - with: - key: ${{ matrix.features }} - save-if: ${{ github.ref == 'refs/heads/master' }} - - - run: cargo check --package libp2p --features="${{ matrix.features }}" - - check-rustdoc-links: - name: Check rustdoc intra-doc links - if: inputs.testsOnly == false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - with: - save-if: ${{ github.ref == 'refs/heads/master' }} - - - 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 - - clippy: - runs-on: ubuntu-latest - if: inputs.testsOnly == false - strategy: - fail-fast: false - matrix: - rust-version: [ - 1.83.0, # current stable - beta, - ] - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust-version }} - components: clippy - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - with: - save-if: ${{ github.ref == 'refs/heads/master' }} - - - run: cargo clippy --all-targets --all-features - - ipfs-integration-test: - name: IPFS Integration tests - if: inputs.testsOnly == false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - with: - save-if: ${{ github.ref == 'refs/heads/master' }} - - - name: Run ipfs-kad example - get peers - run: cd ./examples/ipfs-kad/ && RUST_LOG=libp2p_swarm=debug,libp2p_kad=trace,libp2p_tcp=debug cargo run -- get-peers - - - name: Run ipfs-kad example - put PK record - run: cd ./examples/ipfs-kad/ && RUST_LOG=libp2p_swarm=debug,libp2p_kad=trace,libp2p_tcp=debug cargo run -- put-pk-record - - examples: - runs-on: ubuntu-latest - if: inputs.testsOnly == false - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - with: - shared-key: stable-cache - save-if: false - - - name: Compile all examples - run: | - set -e; - - for toml in examples/**/Cargo.toml; do - cargo check --manifest-path "$toml"; - done - - - uses: taiki-e/cache-cargo-install-action@v2 - with: - tool: wasm-pack@0.12.0 - - - name: Build webrtc-browser example - run: | - cd examples/browser-webrtc - wasm-pack build --target web --out-dir static - - semver: - runs-on: ubuntu-latest - if: inputs.testsOnly == false - env: - # Unset the global `RUSTFLAGS` env to allow warnings. - # cargo-semver-checks intentionally re-locks dependency versions - # before checking, and we shouldn't fail here if a dep has a warning. - # - # More context: - # https://github.com/libp2p/rust-libp2p/pull/4932#issuecomment-1829014527 - # https://github.com/obi1kenobi/cargo-semver-checks/issues/589 - RUSTFLAGS: '' - steps: - - uses: actions/checkout@v4 - - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.36.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin - shell: bash - - uses: obi1kenobi/cargo-semver-checks-action@7272cc2caa468d3e009a2b0a9cc366839348237b # v2.6 - - rustfmt: - runs-on: ubuntu-latest - if: inputs.testsOnly == false - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - name: Check formatting - run: cargo fmt -- --check - - manifest_lint: - runs-on: ubuntu-latest - if: inputs.testsOnly == false - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - - - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - - 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(" ")') - - echo "$ALL_FEATURES"; - echo "$FULL_FEATURE"; - - test "$ALL_FEATURES" = "$FULL_FEATURE" - +# wasm_tests: +# name: Run all WASM tests +#+ if: inputs.testsOnly == false +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@stable +# with: +# target: wasm32-unknown-unknown +# +# - uses: taiki-e/cache-cargo-install-action@v2 +# with: +# tool: wasm-pack@0.12.0 +# +# - name: Install chromedriver +# uses: nanasess/setup-chromedriver@v2 +# +# - name: Run all tests +# run: ./wasm-tests/run-all.sh +# +# cross: +# name: Compile on ${{ matrix.target }} +#+ if: inputs.testsOnly == false +# strategy: +# matrix: +# include: +# - target: "wasm32-unknown-unknown" +# os: ubuntu-latest +# - target: "wasm32-unknown-emscripten" +# os: ubuntu-latest +# - target: "wasm32-wasip1" +# os: ubuntu-latest +# - target: "x86_64-apple-darwin" +# os: macos-latest +# - target: "x86_64-pc-windows-msvc" +# os: windows-latest +# runs-on: ${{ matrix.os }} +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@stable +# with: +# target: ${{ matrix.target }} +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# with: +# key: ${{ matrix.target }} +# save-if: ${{ github.ref == 'refs/heads/master' }} +# +# - run: cargo check --package libp2p --all-features --target=${{ matrix.target }} +# +# msrv: +# name: Compile with MSRV +# runs-on: ubuntu-latest +#+ if: inputs.testsOnly == false +# steps: +# - uses: actions/checkout@v4 +# +# - name: Extract MSRV from workspace manifest +# shell: bash +# run: | +# MSRV=$(grep -oP 'rust-version\s*=\s*"\K[^"]+' Cargo.toml) +# echo "MSRV=$MSRV" >> $GITHUB_ENV +# +# - uses: dtolnay/rust-toolchain@master +# with: +# toolchain: ${{ env.MSRV }} +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# with: +# save-if: ${{ github.ref == 'refs/heads/master' }} +# +# - run: cargo +$MSRV check --workspace --all-features +# +# feature_matrix: # Test various feature combinations work correctly +# name: Compile with select features (${{ matrix.features }}) +#+ if: inputs.testsOnly == false +# runs-on: ubuntu-latest +# strategy: +# matrix: +# include: +# - features: "mdns tcp dns tokio" +# - features: "mdns tcp dns async-std" +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@stable +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# with: +# key: ${{ matrix.features }} +# save-if: ${{ github.ref == 'refs/heads/master' }} +# +# - run: cargo check --package libp2p --features="${{ matrix.features }}" +# +# check-rustdoc-links: +# name: Check rustdoc intra-doc links +#+ if: inputs.testsOnly == false +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@stable +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# with: +# save-if: ${{ github.ref == 'refs/heads/master' }} +# +# - 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 +# +# clippy: +# runs-on: ubuntu-latest +#+ if: inputs.testsOnly == false +# strategy: +# fail-fast: false +# matrix: +# rust-version: [ +# 1.83.0, # current stable +# beta, +# ] +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@master +# with: +# toolchain: ${{ matrix.rust-version }} +# components: clippy +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# with: +# save-if: ${{ github.ref == 'refs/heads/master' }} +# +# - run: cargo clippy --all-targets --all-features +# +# ipfs-integration-test: +# name: IPFS Integration tests +#+ if: inputs.testsOnly == false +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@stable +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# with: +# save-if: ${{ github.ref == 'refs/heads/master' }} +# +# - name: Run ipfs-kad example - get peers +# run: cd ./examples/ipfs-kad/ && RUST_LOG=libp2p_swarm=debug,libp2p_kad=trace,libp2p_tcp=debug cargo run -- get-peers +# +# - name: Run ipfs-kad example - put PK record +# run: cd ./examples/ipfs-kad/ && RUST_LOG=libp2p_swarm=debug,libp2p_kad=trace,libp2p_tcp=debug cargo run -- put-pk-record +# +# examples: +# runs-on: ubuntu-latest +#+ if: inputs.testsOnly == false +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@stable +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# with: +# shared-key: stable-cache +# save-if: false +# +# - name: Compile all examples +# run: | +# set -e; +# +# for toml in examples/**/Cargo.toml; do +# cargo check --manifest-path "$toml"; +# done +# +# - uses: taiki-e/cache-cargo-install-action@v2 +# with: +# tool: wasm-pack@0.12.0 +# +# - name: Build webrtc-browser example +# run: | +# cd examples/browser-webrtc +# wasm-pack build --target web --out-dir static +# +# semver: +# runs-on: ubuntu-latest +#+ if: inputs.testsOnly == false +# env: +# # Unset the global `RUSTFLAGS` env to allow warnings. +# # cargo-semver-checks intentionally re-locks dependency versions +# # before checking, and we shouldn't fail here if a dep has a warning. +# # +# # More context: +# # https://github.com/libp2p/rust-libp2p/pull/4932#issuecomment-1829014527 +# # https://github.com/obi1kenobi/cargo-semver-checks/issues/589 +# RUSTFLAGS: '' +# steps: +# - uses: actions/checkout@v4 +# - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.36.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin +# shell: bash +# - uses: obi1kenobi/cargo-semver-checks-action@7272cc2caa468d3e009a2b0a9cc366839348237b # v2.6 +# +# rustfmt: +# runs-on: ubuntu-latest +#+ if: inputs.testsOnly == false +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@nightly +# with: +# components: rustfmt +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - name: Check formatting +# run: cargo fmt -- --check +# +# manifest_lint: +# runs-on: ubuntu-latest +#+ if: inputs.testsOnly == false +# steps: +# - uses: actions/checkout@v4 +# +# - uses: dtolnay/rust-toolchain@stable +# +# - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 +# +# - 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(" ")') +# +# echo "$ALL_FEATURES"; +# echo "$FULL_FEATURE"; +# +# test "$ALL_FEATURES" = "$FULL_FEATURE" +# gather_published_crates: runs-on: ubuntu-latest - if: inputs.testsOnly == false outputs: - members: ${{ steps.cargo-metadata.outputs.members }} - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - - - id: cargo-metadata - run: | - WORKSPACE_MEMBERS=$(cargo metadata --format-version=1 --no-deps | jq -c '.packages | map(select(.publish == null) | .name)') - echo "members=${WORKSPACE_MEMBERS}" >> $GITHUB_OUTPUT - - check-proto-files: - name: Check for changes in proto files - if: inputs.testsOnly == false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - - - run: cargo install --version 0.10.0 pb-rs --locked - - - name: Glob match - uses: tj-actions/glob@v22 - id: glob - with: - files: | - **/generated/*.proto - - - name: Generate proto files - run: pb-rs --dont_use_cow ${{ steps.glob.outputs.paths }} - - - name: Ensure generated files are unmodified # https://stackoverflow.com/a/5737794 - run: | - git_status=$(git status --porcelain) - - echo $git_status - test -z "$git_status" - - ensure-lockfile-uptodate: - name: Ensure that `Cargo.lock` is up-to-date - if: inputs.testsOnly == false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 - - run: cargo metadata --locked --format-version=1 > /dev/null - - cargo-deny: - runs-on: ubuntu-latest - if: inputs.testsOnly == false + members: ${{ steps.cargo-metadata.outputs.members }} steps: - - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v2 - with: - command: check advisories bans licenses sources + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + + - id: cargo-metadata + run: | + WORKSPACE_MEMBERS=$(cargo metadata --format-version=1 --no-deps | jq -c '.packages | map(select(.publish == null) | .name)') + echo "members=${WORKSPACE_MEMBERS}" >> $GITHUB_OUTPUT +# +# check-proto-files: +# name: Check for changes in proto files +#+ if: inputs.testsOnly == false +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# +# - run: cargo install --version 0.10.0 pb-rs --locked +# +# - name: Glob match +# uses: tj-actions/glob@v22 +# id: glob +# with: +# files: | +# **/generated/*.proto +# +# - name: Generate proto files +# run: pb-rs --dont_use_cow ${{ steps.glob.outputs.paths }} +# +# - name: Ensure generated files are unmodified # https://stackoverflow.com/a/5737794 +# run: | +# git_status=$(git status --porcelain) +# +# echo $git_status +# test -z "$git_status" +# +# ensure-lockfile-uptodate: +# name: Ensure that `Cargo.lock` is up-to-date +#+ if: inputs.testsOnly == false +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7 +# - run: cargo metadata --locked --format-version=1 > /dev/null +# +# cargo-deny: +# runs-on: ubuntu-latest +#+ if: inputs.testsOnly == false +# steps: +# - uses: actions/checkout@v4 +# - uses: EmbarkStudios/cargo-deny-action@v2 +# with: +# command: check advisories bans licenses sources