ethers-rs/.github/workflows/ci.yml

203 lines
7.1 KiB
YAML

name: CI
on:
push:
branches: [master]
pull_request:
# Yeah I know it's bad practice to have API keys, this is a read-only API key
# so that we do not get rate limited by Etherscan (and it's free to generate as
# many as you want)
env:
ETHERSCAN_API_KEY_ETHEREUM: I5BXNZYP5GEDWFINGVEZKYIVU2695NPQZB
ETHERSCAN_API_KEY_CELO: B13XSMUT6Q3Q4WZ5DNQR8RXDBA2KNTMT4M
GOERLI_PRIVATE_KEY: "fa4a1a79e869a96fcb42727f75e3232d6865a82ea675bb95de967a7fe6a773b2"
GETH_BUILD: "1.11.2-73b01f40"
SOLC_VERSION: "0.8.19"
RUSTFLAGS: "-D warnings"
jobs:
tests:
name: tests ${{ matrix.toolchain }}-${{ matrix.job.target }}
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
toolchain: ["stable", "nightly"]
exclude:
# ntapi crate does not compile on nightly due to E0793:
# https://github.com/gakonst/ethers-rs/actions/runs/4266119447/jobs/7426254381
- job:
os: windows-latest
toolchain: nightly
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.job.target }}
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install test binaries
shell: bash
run: ./.github/scripts/install_test_binaries.sh
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: test
shell: bash
run: |
export ETHERSCAN_API_KEY="$ETHERSCAN_API_KEY_ETHEREUM"
cargo +${{ matrix.toolchain }} test --workspace --target ${{ matrix.job.target }}
feature-tests:
name: feature tests ${{ matrix.toolchain }}-${{ matrix.job.target }}
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
# Note: we cannot compile --all-features on windows due to sha2-asm
toolchain: ["stable", "nightly"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.job.target }}
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install test binaries
shell: bash
run: ./.github/scripts/install_test_binaries.sh
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: test
shell: bash
run: |
export ETHERSCAN_API_KEY="$ETHERSCAN_API_KEY_CELO"
cargo +${{ matrix.toolchain }} test --workspace --target ${{ matrix.job.target }} --all-features
feature-checks:
name: feature checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
- name: cargo hack
run:
cargo hack check --all --feature-powerset --depth 2 -Z avoid-dev-deps --keep-going
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: clippy
run: cargo clippy --workspace --tests --all-features
docs:
name: docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
# TODO: Remove nightly override: rust-lang/rust#{108334,108378}
toolchain: nightly-2023-02-07
components: rust-docs
- uses: Swatinem/rust-cache@v2
- name: doc
run: cargo doc --lib --workspace --all-features
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: fmt --check
run: cargo fmt --all --check
wasm:
name: WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- uses: Swatinem/rust-cache@v2
- name: Check
run: cargo test --workspace --target wasm32-unknown-unknown
- name: Check all features
run: cargo test --workspace --target wasm32-unknown-unknown --all-features
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
- name: Run wasm example
run: |
cd examples/ethers-wasm
yarn
yarn anvil &
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
kill %1
examples:
name: Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install test binaries
run: ./.github/scripts/install_test_binaries.sh
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build and run all examples
run: ./scripts/examples.sh