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/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-check.yaml b/.github/workflows/rust-check.yaml new file mode 100644 index 0000000000..7305ad69e8 --- /dev/null +++ b/.github/workflows/rust-check.yaml @@ -0,0 +1,154 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + msrv: + 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 Projects + run: ./scripts/workflows/build.sh + + semver: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: actions/cache@v2 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry- + - uses: actions/cache@v2 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-index- + - 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: ./scripts/workflows/semver.sh + + 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: ./scripts/workflows/format.sh + + 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: ./scripts/workflows/clippy.sh + + 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: Checkout repository + uses: actions/checkout@v4 + + - name: Set OS environment variable + run: echo "CI_OS=${{ matrix.os }}" >> $GITHUB_ENV + + - name: Run CI script + run: ./scripts/workflows/test.sh + working-directory: . + + ci-example: + 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: Checkout repository + uses: actions/checkout@v4 + + - name: Set OS environment variable + run: echo "CI_OS=${{ matrix.os }}" >> $GITHUB_ENV + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Run examples script + run: ./scripts/workflows/example.sh + working-directory: . 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 diff --git a/scripts/workflows/build.sh b/scripts/workflows/build.sh new file mode 100755 index 0000000000..1cbf755f23 --- /dev/null +++ b/scripts/workflows/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash +for manifest in \ + benches/Cargo.toml \ + protocols/Cargo.toml \ + roles/Cargo.toml \ + utils/Cargo.toml; do + cargo build --manifest-path="$manifest" +done diff --git a/scripts/workflows/clippy.sh b/scripts/workflows/clippy.sh new file mode 100755 index 0000000000..0238578a75 --- /dev/null +++ b/scripts/workflows/clippy.sh @@ -0,0 +1,10 @@ +#!/bin/bash +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 diff --git a/scripts/workflows/example.sh b/scripts/workflows/example.sh new file mode 100755 index 0000000000..a3db62bba7 --- /dev/null +++ b/scripts/workflows/example.sh @@ -0,0 +1,7 @@ +#!/bin/bash +for example in \ + "examples/ping-pong-with-noise/Cargo.toml --bin ping_pong_with_noise -- 10" \ + "examples/ping-pong-without-noise/Cargo.toml --bin ping_pong_without_noise -- 10"; do + # shellcheck disable=SC2046 + cargo run --manifest-path=$(echo "$example" | awk '{print $1}') $(echo "$example" | cut -d' ' -f2-) +done \ No newline at end of file diff --git a/scripts/workflows/format.sh b/scripts/workflows/format.sh new file mode 100755 index 0000000000..bc3ce569b6 --- /dev/null +++ b/scripts/workflows/format.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Check if the active toolchain is nightly +if ! rustup show active-toolchain | grep -q "nightly"; then + echo "The Rust nightly toolchain is not active. Activate it with:" + echo " rustup default nightly" + exit 1 +fi + +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 diff --git a/scripts/workflows/semver.sh b/scripts/workflows/semver.sh new file mode 100755 index 0000000000..d517e1958e --- /dev/null +++ b/scripts/workflows/semver.sh @@ -0,0 +1,25 @@ +#!/bin/bash +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 diff --git a/scripts/workflows/test.sh b/scripts/workflows/test.sh new file mode 100755 index 0000000000..6a278516af --- /dev/null +++ b/scripts/workflows/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +for manifest in \ + benches/Cargo.toml \ + common/Cargo.toml \ + protocols/Cargo.toml \ + roles/Cargo.toml \ + utils/Cargo.toml; do + cargo test --manifest-path="$manifest" +done + +cargo test --manifest-path=protocols/Cargo.toml --features prop_test