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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

251 lines
8.7 KiB
YAML
Raw Normal View History

2023-02-24 19:45:48 +00:00
name: CI
on:
push:
2023-02-24 19:45:48 +00:00
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"
2023-02-24 19:45:48 +00:00
GETH_BUILD: "1.11.2-73b01f40"
SOLC_VERSION: "0.8.19"
RUSTFLAGS: "-D warnings"
jobs:
tests:
2023-02-24 19:45:48 +00:00
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
- os: ubuntu-latest
2023-02-24 20:16:58 +00:00
target: wasm32-unknown-unknown
2023-02-24 19:45:48 +00:00
toolchain: ["stable", "nightly"]
steps:
2023-02-24 19:45:48 +00:00
- 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
2023-02-24 19:45:48 +00:00
- name: Install test binaries
shell: bash
run: ./.github/scripts/install_test_binaries.sh
- uses: Swatinem/rust-cache@v2
2021-09-13 20:48:03 +00:00
with:
cache-on-failure: true
2023-02-24 19:45:48 +00:00
- name: test
shell: bash
run: |
2023-02-24 19:45:48 +00:00
export ETHERSCAN_API_KEY="$ETHERSCAN_API_KEY_ETHEREUM"
rustup run ${{ matrix.toolchain }}-${{ matrix.job.target }} cargo test --workspace
feature-tests:
2023-02-24 19:45:48 +00:00
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
- os: windows-latest
target: x86_64-pc-windows-msvc
toolchain: ["stable", "nightly"]
steps:
2023-02-24 19:45:48 +00:00
- 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
2023-02-24 19:45:48 +00:00
- name: Install test binaries
shell: bash
run: ./.github/scripts/install_test_binaries.sh
- uses: Swatinem/rust-cache@v2
2021-09-13 20:48:03 +00:00
with:
cache-on-failure: true
2023-02-24 19:45:48 +00:00
- name: test
shell: bash
run: |
2023-02-24 19:45:48 +00:00
export ETHERSCAN_API_KEY="$ETHERSCAN_API_KEY_CELO"
rustup run ${{ matrix.toolchain }}-${{ matrix.job.target }} cargo test --workspace
2023-02-24 19:45:48 +00:00
features:
name: features
runs-on: ubuntu-latest
steps:
2023-02-24 19:45:48 +00:00
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
- 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
2021-09-13 20:48:03 +00:00
with:
2023-02-24 19:45:48 +00:00
components: clippy
- uses: Swatinem/rust-cache@v2
- name: clippy
run: cargo clippy --workspace --tests --all-features
docs:
name: docs
runs-on: ubuntu-latest
steps:
2023-02-24 19:45:48 +00:00
- 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:
2023-02-24 19:45:48 +00:00
components: rustfmt
- name: fmt --check
run: cargo fmt --all --check
wasm:
name: WASM
runs-on: ubuntu-latest
steps:
2023-02-24 19:45:48 +00:00
- 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
2023-02-24 19:45:48 +00:00
- uses: Swatinem/rust-cache@v2
2021-09-13 20:48:03 +00:00
with:
cache-on-failure: true
- name: Check
2023-02-24 20:03:20 +00:00
run: rustup run stable-wasm32-unknown-unknown cargo check --workspace
2023-02-24 19:45:48 +00:00
- name: Check all features
2023-02-24 20:03:20 +00:00
run: rustup run stable-wasm32-unknown-unknown cargo check --workspace --all-features
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
2023-02-24 19:45:48 +00:00
- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
- name: Run wasm example
run: |
cd examples/ethers-wasm
2023-02-24 19:45:48 +00:00
yarn
yarn anvil &
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
2023-02-24 19:45:48 +00:00
kill %1
examples:
name: Examples
runs-on: ubuntu-latest
steps:
2023-02-24 19:45:48 +00:00
- uses: actions/checkout@v3
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
2023-02-24 19:45:48 +00:00
- 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
2023-02-24 19:45:48 +00:00
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
refactor: examples (#1940) * ToC * Big numbers section * Middleware examples: builder * Middleware examples: gas_escalator * Middleware examples: gas_oracle * Middleware examples: signer * Middleware examples: missing stubs * review: applied DaniPopes suggestions to big numbers * typo * Middleware examples: nonce_manager * cargo +nightly fmt * update roadmap * Middleware examples: policy * Middleware examples: added docs * Contracts examples: created folder; included abigen example * Contracts examples: refactor abigen docs. Fixed cargo example reference * Contracts examples: contract_events; minor docs changes * Moved each example under its own crate. Cargo builds locally TODO: Fix broken examples CI * Big numbers examples: used regular operators for math * Single examples run correctly (missing overall CI execution) Example crates dependencies Removed duplicates * review: Applied gakonst note to remove commented items in workspace manifest * review: Applied gakonst note to restore visibility on contract constructor * ci: - Run/Build examples in a single step to avoid duplicated scripts - Removed ci.yaml step "Build all examples" * cargo +nightly fmt * ci: fix WASM step error * Removed deprecated EthGasStation example * WASM example uses local copy of `contract_abi.json`. In this way we keep the WASM example auto-consistent, at the cost of a small duplication * Cargo.lock aligned to master branch * Removed useless comments in examples * review: Applied gakonst note to add panic!() on the policy middleware example * review: Applied gakonst suggestion to add a custom middleware example * typos in docs * Update examples/big-numbers/examples/bn_math_operations.rs review: Accepted commit suggested by DaniPopes Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * review: Applied DaniPopes suggestion on assert_eq! * Update examples/big-numbers/README.md review: Accepted DaniPopes suggestion on big-numbers docs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * review: All imports now reference the "ethers" crate * ci: added features ["ws", "rustls"] where needed cargo +nigthly fmt * Examples with special features (e.g. ipc, trezor etc.) are built alongside them. This is expressed as a "default" requirement in their respective Cargo.toml * cargo +nightly fmt * Examples: Gas oracle API keys from env Added missing features in middleware Cargo.toml * typo: use expect() instead of unwrap() * Updated ToC Moved 2 examples under more relevant folders * Gas oracle examples raise panic on middleware errors * review: removed useless [[example]] in Cargo.toml * review: removed #[allow(unused_must_use)] from gas_escalator example * review: Removed prefixes from file names * review: removed useless [[example]] in Cargo.toml * docs: Updated description to run examples in the workspace README.md Co-authored-by: Andrea Simeoni <> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
2022-12-29 12:53:11 +00:00
- name: Build and run all examples
2023-02-24 19:45:48 +00:00
run: ./scripts/examples.sh
# windows-build:
# runs-on: windows-latest
# name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
# env:
# CFG_RELEASE_CHANNEL: ${{ matrix.cfg_release_channel }}
# strategy:
# fail-fast: false
# matrix:
# target:
# [
# i686-pc-windows-gnu,
# i686-pc-windows-msvc,
# x86_64-pc-windows-gnu,
# x86_64-pc-windows-msvc,
# ]
# cfg_release_channel: [nightly]
# steps:
# - name: checkout
# uses: actions/checkout@v3
# # Run build
# - name: Update Rustup
# run: |
# # disable download progress bar
# $ProgressPreference = "SilentlyContinue"
# rustup update
# rustup target add ${{ matrix.target }}
# shell: powershell
# - name: Add mingw32 to path for i686-gnu
# run: |
# echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
# if: matrix.target == 'i686-pc-windows-gnu' && matrix.channel == 'nightly'
# shell: bash
# - name: Add mingw64 to path for x86_64-gnu
# run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
# if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
# shell: bash
# - name: build
# run: |
# rustc -Vv
# cargo -V
# # we test without --all-features on Windows so that sha2-asm is not activated.
# cargo check
# shell: cmd