From e06420566b669ed0e3af2d3f97cc6aa7e4dc596d Mon Sep 17 00:00:00 2001 From: Nicola Busanello Date: Tue, 21 May 2024 15:37:14 +0200 Subject: [PATCH] WIP: add cross-platform actions --- .github/workflows/build.yml | 57 ++++++++++++++++++++ .github/workflows/format.yml | 22 ++++++++ .github/workflows/lint.yml | 28 ++++++++++ .github/workflows/{checks.yml => test.yml} | 62 +++++++++------------- 4 files changed, 133 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/format.yml create mode 100644 .github/workflows/lint.yml rename .github/workflows/{checks.yml => test.yml} (65%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e93a561 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + timeout-minutes: 30 + runs-on: ${{ matrix.os }} + strategy: + matrix: + name: [linux, windows, macos] + include: + - name: linux + os: ubuntu-latest + - name: windows + os: windows-latest + - name: macos + os: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Build with default features + run: cargo build + + build_features: + timeout-minutes: 30 + runs-on: ${{ matrix.os }} + strategy: + matrix: + name: [linux, windows, macos] + include: + - name: linux + os: ubuntu-latest + - name: windows + os: windows-latest + - name: macos + os: macos-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Build with electrum feature + run: cargo test --no-default-features --features electrum + - name: Build with esplora feature + run: cargo test --no-default-features --features esplora + - name: Build with no default features + run: cargo test --no-default-features diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..fd1d030 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,22 @@ +name: Format code + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + format: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - name: Format + run: cargo fmt --all -- --check diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..a237b46 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: Lint code + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + - name: Lint with all features + run: cargo clippy --lib --all-features -- -D warnings + - name: Lint with no features + run: cargo clippy --lib --no-default-features -- -D warnings + - name: Lint with electrum feature + run: cargo clippy --lib --no-default-features --features electrum -- -D warnings + - name: Lint with esplora feature + run: cargo clippy --lib --no-default-features --features esplora -- -D warnings diff --git a/.github/workflows/checks.yml b/.github/workflows/test.yml similarity index 65% rename from .github/workflows/checks.yml rename to .github/workflows/test.yml index 84ccd3f..022ba8b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Code checks +name: Run tests on: push: @@ -10,57 +10,36 @@ env: CARGO_TERM_COLOR: always jobs: - lint: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: clippy - - name: Lint with all features - run: cargo clippy --lib --all-features -- -D warnings - - name: Lint with no features - run: cargo clippy --lib --no-default-features -- -D warnings - - name: Lint with electrum feature - run: cargo clippy --lib --no-default-features --features electrum -- -D warnings - - name: Lint with esplora feature - run: cargo clippy --lib --no-default-features --features esplora -- -D warnings - - format: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: rustfmt - - name: Format - run: cargo fmt --all -- --check - test_and_coverage: - runs-on: ubuntu-latest + timeout-minutes: 30 + runs-on: ${{ matrix.os }} + strategy: + matrix: + name: [linux, windows, macos] + include: + - name: linux + os: ubuntu-latest + - name: windows + os: windows-latest + - name: macos + os: macos-latest steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: components: llvm-tools-preview toolchain: stable - - name: Install llvm-cov env: LLVM_COV_RELEASES: https://github.com/taiki-e/cargo-llvm-cov/releases run: | host=$(rustc -Vv | grep host | sed 's/host: //') curl -fsSL $LLVM_COV_RELEASES/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C "$HOME/.cargo/bin" - - name: Test with all features and generate coverage report run: cargo llvm-cov --lcov --output-path coverage.lcov --workspace --all-features - - name: Upload coverage report uses: codecov/codecov-action@v4 with: @@ -70,8 +49,19 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} test_features: - runs-on: ubuntu-latest timeout-minutes: 30 + runs-on: ${{ matrix.os }} + strategy: + matrix: + name: [linux, windows, macos] + include: + - name: linux + os: ubuntu-latest + - name: windows + os: windows-latest + - name: macos + os: macos-latest + steps: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 @@ -87,6 +77,6 @@ jobs: cargo test --no-default-features --features esplora go_online::fail cargo test --no-default-features --features esplora send::min_confirmations_esplora cargo test --no-default-features --features esplora send::min_relay_fee_esplora - - name: Test with no features + - name: Test with no default features run: | cargo test --no-default-features