From 3600e94d9b19689a4e7fca729ad7150414759020 Mon Sep 17 00:00:00 2001 From: devworlds Date: Fri, 20 Dec 2024 01:03:09 -0300 Subject: [PATCH 1/3] chore: remove test.yaml, rust-msrv.yaml, semver-check.yaml, lockfiles.yaml, fmt.yaml, clippy-lint.yaml, and add general-check.yaml to combine all in one file. --- .github/workflows/clippy-lint.yaml | 40 ---- .github/workflows/fmt.yaml | 40 ---- .github/workflows/general-check.yaml | 315 +++++++++++++++++++++++++++ .github/workflows/lockfiles.yaml | 28 --- .github/workflows/rust-msrv.yaml | 35 --- .github/workflows/semver-check.yaml | 129 ----------- .github/workflows/test.yaml | 95 -------- 7 files changed, 315 insertions(+), 367 deletions(-) delete mode 100644 .github/workflows/clippy-lint.yaml delete mode 100644 .github/workflows/fmt.yaml create mode 100644 .github/workflows/general-check.yaml delete mode 100644 .github/workflows/lockfiles.yaml delete mode 100644 .github/workflows/rust-msrv.yaml delete mode 100644 .github/workflows/semver-check.yaml delete mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/clippy-lint.yaml b/.github/workflows/clippy-lint.yaml deleted file mode 100644 index b8d4cba361..0000000000 --- a/.github/workflows/clippy-lint.yaml +++ /dev/null @@ -1,40 +0,0 @@ -on: - push: - branches: - - main - pull_request: - branches: - - main - -name: Clippy Lint - -jobs: - clippy-check: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - include: - - os: macos-latest - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.75.0 - override: true - components: clippy - - name: Run Clippy on different workspaces and crates - run: | - cargo clippy --manifest-path=benches/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=common/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=protocols/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=roles/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=utils/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=utils/message-generator/Cargo.toml -- -D warnings -A dead-code diff --git a/.github/workflows/fmt.yaml b/.github/workflows/fmt.yaml deleted file mode 100644 index 181fc6088f..0000000000 --- a/.github/workflows/fmt.yaml +++ /dev/null @@ -1,40 +0,0 @@ -on: - push: - branches: - - main - pull_request: - branches: - - main - -name: Rustfmt - -jobs: - fmt: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - include: - - os: macos-latest - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt - - name: Run fmt in different workspaces and crates - run: | - cargo fmt --all --manifest-path=benches/Cargo.toml -- --check - cargo fmt --all --manifest-path=common/Cargo.toml -- --check - cargo fmt --all --manifest-path=protocols/Cargo.toml -- --check - cargo fmt --all --manifest-path=roles/Cargo.toml -- --check - cargo fmt --all --manifest-path=utils/Cargo.toml -- --check - cargo fmt --all --manifest-path=utils/message-generator/Cargo.toml -- --check diff --git a/.github/workflows/general-check.yaml b/.github/workflows/general-check.yaml new file mode 100644 index 0000000000..8069a5f010 --- /dev/null +++ b/.github/workflows/general-check.yaml @@ -0,0 +1,315 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + + MSRV-1.75-Check: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + rust: + - 1.75.0 # MSRV + + steps: + - uses: actions/checkout@v2 + - uses: Swatinem/rust-cache@v1.2.0 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - name: Build Benches + run: cargo build --manifest-path=benches/Cargo.toml + - name: Build Protocols + run: cargo build --manifest-path=protocols/Cargo.toml + - name: Build Roles + run: cargo build --manifest-path=roles/Cargo.toml + - name: Build Utils + run: cargo build --manifest-path=utils/Cargo.toml + + semver-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Rust stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Cache Cargo registry + uses: actions/cache@v2 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry- + + - name: Cache Cargo index + uses: actions/cache@v2 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-index- + + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y cmake + + - name: Install cargo-semver-checks + run: cargo install cargo-semver-checks --version 0.37.0 --locked + + - name: Run semver checks for common + working-directory: common + run: cargo semver-checks + + - name: Run semver checks for utils/buffer + working-directory: utils/buffer + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/binary-sv2/no-serde-sv2/codec + working-directory: protocols/v2/binary-sv2/no-serde-sv2/codec + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/binary-sv2/serde-sv2 + working-directory: protocols/v2/binary-sv2/serde-sv2 + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/binary-sv2/binary-sv2 + working-directory: protocols/v2/binary-sv2/binary-sv2 + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/const-sv2 + working-directory: protocols/v2/const-sv2 + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/framing-sv2 + working-directory: protocols/v2/framing-sv2 + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/noise-sv2 + working-directory: protocols/v2/noise-sv2 + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/codec-sv2 + working-directory: protocols/v2/codec-sv2 + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/subprotocols/common-messages + working-directory: protocols/v2/subprotocols/common-messages + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/subprotocols/job-declaration + working-directory: protocols/v2/subprotocols/job-declaration + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/subprotocols/mining + working-directory: protocols/v2/subprotocols/mining + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/subprotocols/template-distribution + working-directory: protocols/v2/subprotocols/template-distribution + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/sv2-ffi + working-directory: protocols/v2/sv2-ffi + run: cargo semver-checks + + - name: Run semver checks for protocols/v2/roles-logic-sv2 + working-directory: protocols/v2/roles-logic-sv2 + run: cargo semver-checks --default-features + + - name: Run semver checks for protocols/v1 + working-directory: protocols/v1 + run: cargo semver-checks + + - name: Run semver checks for utils/bip32-key-derivation + working-directory: utils/bip32-key-derivation + run: cargo semver-checks + + - name: Run semver checks for utils/error-handling + working-directory: utils/error-handling + run: cargo semver-checks + + - name: Run semver checks for utils/key-utils + working-directory: utils/key-utils + run: cargo semver-checks + + - name: Run semver checks for roles/roles-utils/network-helpers + working-directory: roles/roles-utils/network-helpers + run: cargo semver-checks + + - name: Run semver checks for roles/roles-utils/rpc + working-directory: roles/roles-utils/rpc + run: cargo semver-checks + + Lockfiles: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Build with locked dependencies + run: | + cargo build --manifest-path=roles/Cargo.toml --locked + cargo build --manifest-path=utils/Cargo.toml --locked + + Rust-fmt: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - macos-latest + - ubuntu-latest + include: + - os: macos-latest + target: x86_64-apple-darwin + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt + - name: Run fmt in different workspaces and crates + run: | + cargo fmt --all --manifest-path=benches/Cargo.toml -- --check + cargo fmt --all --manifest-path=common/Cargo.toml -- --check + cargo fmt --all --manifest-path=protocols/Cargo.toml -- --check + cargo fmt --all --manifest-path=roles/Cargo.toml -- --check + cargo fmt --all --manifest-path=utils/Cargo.toml -- --check + cargo fmt --all --manifest-path=utils/message-generator/Cargo.toml -- --check + + clippy-check-lint: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - macos-latest + - ubuntu-latest + include: + - os: macos-latest + target: x86_64-apple-darwin + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: 1.75.0 + override: true + components: clippy + - name: Run Clippy on different workspaces and crates + run: | + cargo clippy --manifest-path=benches/Cargo.toml -- -D warnings -A dead-code + cargo clippy --manifest-path=common/Cargo.toml -- -D warnings -A dead-code + cargo clippy --manifest-path=protocols/Cargo.toml -- -D warnings -A dead-code + cargo clippy --manifest-path=roles/Cargo.toml -- -D warnings -A dead-code + cargo clippy --manifest-path=utils/Cargo.toml -- -D warnings -A dead-code + cargo clippy --manifest-path=utils/message-generator/Cargo.toml -- -D warnings -A dead-code + + Tests-ci: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - macos-13 + - ubuntu-latest + include: + - os: macos-13 + target: x86_64-apple-darwin + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + + steps: + - name: Install stable toolchain & components + uses: actions/checkout@v4 + with: + profile: minimal + toolchain: nightly + override: true + + - name: Build + run: | + cargo build --manifest-path=benches/Cargo.toml + cargo build --manifest-path=common/Cargo.toml + cargo build --manifest-path=protocols/Cargo.toml + cargo build --manifest-path=roles/Cargo.toml + cargo build --manifest-path=utils/Cargo.toml + + - name: Roles Integration Tests + run: | + cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture + + - name: Run sv1-client-and-server example + run: | + cargo run --manifest-path=examples/sv1-client-and-server/Cargo.toml --bin client_and_server -- 60 + + - name: interop-test + run: | + if [ ${{ matrix.os }} == "ubuntu-latest" ]; then + ./run.sh 30 + else + echo "Skipping interop-test on ${{ matrix.os }} - not supported" + fi + working-directory: examples/interop-cpp/ + + # TODO this is only usefull if we want to build c bindings with guix + #- name: interop-no-cargo-test + # run: | + # if [ ${{ matrix.os }} == "ubuntu-latest" ]; then + # ./run.sh 30 + # else + # echo "Skipping interop-test on ${{ matrix.os }} - not supported" + # fi + # working-directory: examples/interop-cpp-no-cargo/ + + - name: fuzz tests + run: | + if [ ${{ matrix.os }} == "ubuntu-latest" ]; then + ./run.sh 30 + else + echo "Skipping fuzz test on ${{ matrix.os }} - not supported" + fi + working-directory: utils/buffer/fuzz + + - name: Test + run: | + cargo test --manifest-path=benches/Cargo.toml + cargo test --manifest-path=common/Cargo.toml + cargo test --manifest-path=protocols/Cargo.toml + cargo test --manifest-path=roles/Cargo.toml + cargo test --manifest-path=utils/Cargo.toml + + - name: Property based testing + run: | + cargo test --manifest-path=protocols/Cargo.toml --features prop_test + + - name: Run ping-pong-with-noise example + run: | + cargo run --manifest-path=examples/ping-pong-with-noise/Cargo.toml --bin ping_pong_with_noise -- 10 + + - name: Run ping-pong-without-noise example + run: | + cargo run --manifest-path=examples/ping-pong-without-noise/Cargo.toml --bin ping_pong_without_noise -- 10 + \ No newline at end of file diff --git a/.github/workflows/lockfiles.yaml b/.github/workflows/lockfiles.yaml deleted file mode 100644 index 91131bfb98..0000000000 --- a/.github/workflows/lockfiles.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Lockfiles - -# Trigger the workflow on push or pull request events for the main branch -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Build with locked dependencies - run: | - cargo build --manifest-path=roles/Cargo.toml --locked - cargo build --manifest-path=utils/Cargo.toml --locked \ No newline at end of file diff --git a/.github/workflows/rust-msrv.yaml b/.github/workflows/rust-msrv.yaml deleted file mode 100644 index 62ba418b15..0000000000 --- a/.github/workflows/rust-msrv.yaml +++ /dev/null @@ -1,35 +0,0 @@ -on: - push: - branches: - - main - pull_request: - branches: - - main - -name: MSRV 1.75 Check - -jobs: - - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - rust: - - 1.75.0 # MSRV - - steps: - - uses: actions/checkout@v2 - - uses: Swatinem/rust-cache@v1.2.0 - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - override: true - - name: Build Benches - run: cargo build --manifest-path=benches/Cargo.toml - - name: Build Protocols - run: cargo build --manifest-path=protocols/Cargo.toml - - name: Build Roles - run: cargo build --manifest-path=roles/Cargo.toml - - name: Build Utils - run: cargo build --manifest-path=utils/Cargo.toml diff --git a/.github/workflows/semver-check.yaml b/.github/workflows/semver-check.yaml deleted file mode 100644 index cd7eb72552..0000000000 --- a/.github/workflows/semver-check.yaml +++ /dev/null @@ -1,129 +0,0 @@ -name: Semver Check - -on: - push: - branches: - - "main" - pull_request: - branches: - - "main" - -jobs: - semver-check: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Rust stable - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Cache Cargo registry - uses: actions/cache@v2 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-registry- - - - name: Cache Cargo index - uses: actions/cache@v2 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-index- - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y cmake - - - name: Install cargo-semver-checks - run: cargo install cargo-semver-checks --version 0.37.0 --locked - - - name: Run semver checks for common - working-directory: common - run: cargo semver-checks - - - name: Run semver checks for utils/buffer - working-directory: utils/buffer - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/binary-sv2/no-serde-sv2/codec - working-directory: protocols/v2/binary-sv2/no-serde-sv2/codec - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/binary-sv2/serde-sv2 - working-directory: protocols/v2/binary-sv2/serde-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/binary-sv2/binary-sv2 - working-directory: protocols/v2/binary-sv2/binary-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/const-sv2 - working-directory: protocols/v2/const-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/framing-sv2 - working-directory: protocols/v2/framing-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/noise-sv2 - working-directory: protocols/v2/noise-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/codec-sv2 - working-directory: protocols/v2/codec-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/common-messages - working-directory: protocols/v2/subprotocols/common-messages - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/job-declaration - working-directory: protocols/v2/subprotocols/job-declaration - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/mining - working-directory: protocols/v2/subprotocols/mining - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/template-distribution - working-directory: protocols/v2/subprotocols/template-distribution - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/sv2-ffi - working-directory: protocols/v2/sv2-ffi - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/roles-logic-sv2 - working-directory: protocols/v2/roles-logic-sv2 - run: cargo semver-checks --default-features - - - name: Run semver checks for protocols/v1 - working-directory: protocols/v1 - run: cargo semver-checks - - - name: Run semver checks for utils/bip32-key-derivation - working-directory: utils/bip32-key-derivation - run: cargo semver-checks - - - name: Run semver checks for utils/error-handling - working-directory: utils/error-handling - run: cargo semver-checks - - - name: Run semver checks for utils/key-utils - working-directory: utils/key-utils - run: cargo semver-checks - - - name: Run semver checks for roles/roles-utils/network-helpers - working-directory: roles/roles-utils/network-helpers - run: cargo semver-checks - - - name: Run semver checks for roles/roles-utils/rpc - working-directory: roles/roles-utils/rpc - run: cargo semver-checks \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 3c817fa440..0000000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,95 +0,0 @@ -on: - push: - branches: - - main - pull_request: - branches: - - main - -name: Test, Prop Tests, Example Tests - -jobs: - ci: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-13 - - ubuntu-latest - include: - - os: macos-13 - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - steps: - - name: Install stable toolchain & components - uses: actions/checkout@v4 - with: - profile: minimal - toolchain: nightly - override: true - - - name: Build - run: | - cargo build --manifest-path=benches/Cargo.toml - cargo build --manifest-path=common/Cargo.toml - cargo build --manifest-path=protocols/Cargo.toml - cargo build --manifest-path=roles/Cargo.toml - cargo build --manifest-path=utils/Cargo.toml - - - name: Roles Integration Tests - run: | - cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture - - - name: Run sv1-client-and-server example - run: | - cargo run --manifest-path=examples/sv1-client-and-server/Cargo.toml --bin client_and_server -- 60 - - - name: interop-test - run: | - if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - ./run.sh 30 - else - echo "Skipping interop-test on ${{ matrix.os }} - not supported" - fi - working-directory: examples/interop-cpp/ - - # TODO this is only usefull if we want to build c bindings with guix - #- name: interop-no-cargo-test - # run: | - # if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - # ./run.sh 30 - # else - # echo "Skipping interop-test on ${{ matrix.os }} - not supported" - # fi - # working-directory: examples/interop-cpp-no-cargo/ - - - name: fuzz tests - run: | - if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - ./run.sh 30 - else - echo "Skipping fuzz test on ${{ matrix.os }} - not supported" - fi - working-directory: utils/buffer/fuzz - - - name: Test - run: | - cargo test --manifest-path=benches/Cargo.toml - cargo test --manifest-path=common/Cargo.toml - cargo test --manifest-path=protocols/Cargo.toml - cargo test --manifest-path=roles/Cargo.toml - cargo test --manifest-path=utils/Cargo.toml - - - name: Property based testing - run: | - cargo test --manifest-path=protocols/Cargo.toml --features prop_test - - - name: Run ping-pong-with-noise example - run: | - cargo run --manifest-path=examples/ping-pong-with-noise/Cargo.toml --bin ping_pong_with_noise -- 10 - - - name: Run ping-pong-without-noise example - run: | - cargo run --manifest-path=examples/ping-pong-without-noise/Cargo.toml --bin ping_pong_without_noise -- 10 From beb520f70e8346031d0d84a5ce8434e79ddacf2a Mon Sep 17 00:00:00 2001 From: devworlds Date: Fri, 20 Dec 2024 10:20:15 -0300 Subject: [PATCH 2/3] chore: fix MSRV incorrect job syntax --- .github/workflows/general-check.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/general-check.yaml b/.github/workflows/general-check.yaml index 8069a5f010..05a94c52e1 100644 --- a/.github/workflows/general-check.yaml +++ b/.github/workflows/general-check.yaml @@ -8,7 +8,7 @@ on: jobs: - MSRV-1.75-Check: + Msrv-Check: runs-on: ubuntu-latest strategy: fail-fast: false @@ -32,7 +32,7 @@ jobs: - name: Build Utils run: cargo build --manifest-path=utils/Cargo.toml - semver-check: + Semver-check: runs-on: ubuntu-latest steps: From a2d2bcd1e8651087cf4ca7a0596dd8d47f2117bf Mon Sep 17 00:00:00 2001 From: devworlds Date: Mon, 23 Dec 2024 17:49:29 -0300 Subject: [PATCH 3/3] chore: update general-check to be more clean --- .github/workflows/general-check.yaml | 317 ++++++--------------------- 1 file changed, 70 insertions(+), 247 deletions(-) diff --git a/.github/workflows/general-check.yaml b/.github/workflows/general-check.yaml index 05a94c52e1..80c461cbad 100644 --- a/.github/workflows/general-check.yaml +++ b/.github/workflows/general-check.yaml @@ -7,7 +7,6 @@ on: - main jobs: - Msrv-Check: runs-on: ubuntu-latest strategy: @@ -23,164 +22,78 @@ jobs: with: toolchain: ${{ matrix.rust }} override: true - - name: Build Benches - run: cargo build --manifest-path=benches/Cargo.toml - - name: Build Protocols - run: cargo build --manifest-path=protocols/Cargo.toml - - name: Build Roles - run: cargo build --manifest-path=roles/Cargo.toml - - name: Build Utils - run: cargo build --manifest-path=utils/Cargo.toml + - name: Build Projects + run: | + cargo build --manifest-path=benches/Cargo.toml + cargo build --manifest-path=protocols/Cargo.toml + cargo build --manifest-path=roles/Cargo.toml + cargo build --manifest-path=utils/Cargo.toml + + shared-strategy: &shared-strategy + strategy: + matrix: + os: + - macos-latest + - ubuntu-latest + include: + - os: macos-latest + target: x86_64-apple-darwin + - os: ubuntu-latest + target: x86_64-unknown-linux-musl Semver-check: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Rust stable - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 with: toolchain: stable override: true - - - name: Cache Cargo registry - uses: actions/cache@v2 + - uses: actions/cache@v2 with: path: ~/.cargo/registry key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo-registry- - - - name: Cache Cargo index - uses: actions/cache@v2 + - uses: actions/cache@v2 with: path: ~/.cargo/git key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo-index- - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y cmake - - - name: Install cargo-semver-checks - run: cargo install cargo-semver-checks --version 0.37.0 --locked - - - name: Run semver checks for common - working-directory: common - run: cargo semver-checks - - - name: Run semver checks for utils/buffer - working-directory: utils/buffer - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/binary-sv2/no-serde-sv2/codec - working-directory: protocols/v2/binary-sv2/no-serde-sv2/codec - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/binary-sv2/serde-sv2 - working-directory: protocols/v2/binary-sv2/serde-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/binary-sv2/binary-sv2 - working-directory: protocols/v2/binary-sv2/binary-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/const-sv2 - working-directory: protocols/v2/const-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/framing-sv2 - working-directory: protocols/v2/framing-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/noise-sv2 - working-directory: protocols/v2/noise-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/codec-sv2 - working-directory: protocols/v2/codec-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/common-messages - working-directory: protocols/v2/subprotocols/common-messages - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/job-declaration - working-directory: protocols/v2/subprotocols/job-declaration - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/mining - working-directory: protocols/v2/subprotocols/mining - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/template-distribution - working-directory: protocols/v2/subprotocols/template-distribution - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/sv2-ffi - working-directory: protocols/v2/sv2-ffi - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/roles-logic-sv2 - working-directory: protocols/v2/roles-logic-sv2 - run: cargo semver-checks --default-features - - - name: Run semver checks for protocols/v1 - working-directory: protocols/v1 - run: cargo semver-checks - - - name: Run semver checks for utils/bip32-key-derivation - working-directory: utils/bip32-key-derivation - run: cargo semver-checks - - - name: Run semver checks for utils/error-handling - working-directory: utils/error-handling - run: cargo semver-checks - - - name: Run semver checks for utils/key-utils - working-directory: utils/key-utils - run: cargo semver-checks - - - name: Run semver checks for roles/roles-utils/network-helpers - working-directory: roles/roles-utils/network-helpers - run: cargo semver-checks - - - name: Run semver checks for roles/roles-utils/rpc - working-directory: roles/roles-utils/rpc - run: cargo semver-checks - - Lockfiles: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Build with locked dependencies + - run: sudo apt-get update && sudo apt-get install -y cmake + - run: cargo install cargo-semver-checks --version 0.37.0 --locked + - name: Run Semver Checks run: | - cargo build --manifest-path=roles/Cargo.toml --locked - cargo build --manifest-path=utils/Cargo.toml --locked + for dir in \ + common \ + utils/buffer \ + protocols/v2/binary-sv2/no-serde-sv2/codec \ + protocols/v2/binary-sv2/serde-sv2 \ + protocols/v2/binary-sv2/binary-sv2 \ + protocols/v2/const-sv2 \ + protocols/v2/framing-sv2 \ + protocols/v2/noise-sv2 \ + protocols/v2/codec-sv2 \ + protocols/v2/subprotocols/common-messages \ + protocols/v2/subprotocols/job-declaration \ + protocols/v2/subprotocols/mining \ + protocols/v2/subprotocols/template-distribution \ + protocols/v2/sv2-ffi \ + protocols/v2/roles-logic-sv2 \ + protocols/v1 \ + utils/bip32-key-derivation \ + utils/error-handling \ + utils/key-utils \ + roles/roles-utils/network-helpers \ + roles/roles-utils/rpc; do + cargo semver-checks --manifest-path="$dir/Cargo.toml" + done Rust-fmt: + <<: *shared-strategy runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - include: - - os: macos-latest - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - steps: - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 @@ -191,26 +104,19 @@ jobs: components: rustfmt - name: Run fmt in different workspaces and crates run: | - cargo fmt --all --manifest-path=benches/Cargo.toml -- --check - cargo fmt --all --manifest-path=common/Cargo.toml -- --check - cargo fmt --all --manifest-path=protocols/Cargo.toml -- --check - cargo fmt --all --manifest-path=roles/Cargo.toml -- --check - cargo fmt --all --manifest-path=utils/Cargo.toml -- --check - cargo fmt --all --manifest-path=utils/message-generator/Cargo.toml -- --check - + for manifest in \ + benches/Cargo.toml \ + common/Cargo.toml \ + protocols/Cargo.toml \ + roles/Cargo.toml \ + utils/Cargo.toml \ + utils/message-generator/Cargo.toml; do + cargo fmt --all --manifest-path=$manifest -- --check + done + clippy-check-lint: + <<: *shared-strategy runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - include: - - os: macos-latest - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - steps: - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 @@ -221,95 +127,12 @@ jobs: components: clippy - name: Run Clippy on different workspaces and crates run: | - cargo clippy --manifest-path=benches/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=common/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=protocols/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=roles/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=utils/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=utils/message-generator/Cargo.toml -- -D warnings -A dead-code - - Tests-ci: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-13 - - ubuntu-latest - include: - - os: macos-13 - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - steps: - - name: Install stable toolchain & components - uses: actions/checkout@v4 - with: - profile: minimal - toolchain: nightly - override: true - - - name: Build - run: | - cargo build --manifest-path=benches/Cargo.toml - cargo build --manifest-path=common/Cargo.toml - cargo build --manifest-path=protocols/Cargo.toml - cargo build --manifest-path=roles/Cargo.toml - cargo build --manifest-path=utils/Cargo.toml - - - name: Roles Integration Tests - run: | - cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture - - - name: Run sv1-client-and-server example - run: | - cargo run --manifest-path=examples/sv1-client-and-server/Cargo.toml --bin client_and_server -- 60 - - - name: interop-test - run: | - if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - ./run.sh 30 - else - echo "Skipping interop-test on ${{ matrix.os }} - not supported" - fi - working-directory: examples/interop-cpp/ - - # TODO this is only usefull if we want to build c bindings with guix - #- name: interop-no-cargo-test - # run: | - # if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - # ./run.sh 30 - # else - # echo "Skipping interop-test on ${{ matrix.os }} - not supported" - # fi - # working-directory: examples/interop-cpp-no-cargo/ - - - name: fuzz tests - run: | - if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - ./run.sh 30 - else - echo "Skipping fuzz test on ${{ matrix.os }} - not supported" - fi - working-directory: utils/buffer/fuzz - - - name: Test - run: | - cargo test --manifest-path=benches/Cargo.toml - cargo test --manifest-path=common/Cargo.toml - cargo test --manifest-path=protocols/Cargo.toml - cargo test --manifest-path=roles/Cargo.toml - cargo test --manifest-path=utils/Cargo.toml - - - name: Property based testing - run: | - cargo test --manifest-path=protocols/Cargo.toml --features prop_test - - - name: Run ping-pong-with-noise example - run: | - cargo run --manifest-path=examples/ping-pong-with-noise/Cargo.toml --bin ping_pong_with_noise -- 10 - - - name: Run ping-pong-without-noise example - run: | - cargo run --manifest-path=examples/ping-pong-without-noise/Cargo.toml --bin ping_pong_without_noise -- 10 - \ No newline at end of file + for manifest in \ + benches/Cargo.toml \ + common/Cargo.toml \ + protocols/Cargo.toml \ + roles/Cargo.toml \ + utils/Cargo.toml \ + utils/message-generator/Cargo.toml; do + cargo clippy --manifest-path=$manifest -- -D warnings -A dead-code + done