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

314 lines
11 KiB
YAML
Raw Normal View History

on:
2022-09-28 18:58:26 +00:00
push:
branches:
- master
pull_request:
name: Tests
# 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:
2022-09-28 18:58:26 +00:00
ETHERSCAN_API_KEY_ETHEREUM: I5BXNZYP5GEDWFINGVEZKYIVU2695NPQZB
ETHERSCAN_API_KEY_CELO: B13XSMUT6Q3Q4WZ5DNQR8RXDBA2KNTMT4M
GOERLI_PRIVATE_KEY: "fa4a1a79e869a96fcb42727f75e3232d6865a82ea675bb95de967a7fe6a773b2"
feat(providers): add a subset of admin namespace (#1880) * tell Geth to expose the admin namespace * wip: add admin namespace support * add networking and peer related structs * add rest of chain config fields * add datadir to geth * fix data dir ref * add dev flag to geth * set dev only if block_time is not set * put mutually exclusive options in an enum * make block_time use the devmode enum * add p2p port to geth * add basic impls for admin endpoints * move from_int_or_hex to ethers-core utils * fix nodeinfo protocol field * the type is better represented by a struct which can have either eth or snap * add chain id and discovery toggle for Geth * remove PeerEvent * should re-add when peer event endpoints are implemented * simplify serde options for admin responses * change signature for peer modification apis * these admin apis accept an enode, which _may_ be an enr, but could also be a legacy enode "v4" url. * add note on where `ChainConfig` fields come from * add note on PeerInfo about the source of fields * add admin namespace support to CHANGELOG * update pr number in changelog * cargo fmt * move chainconfig to genesis in utils * accept genesis file in geth * add genesis writing to geth spawn * finally get geth nodes to connect * import io::Read in provider tests * fix PeerInfo and use enode id for provider test * make clippy happy * improve documentation for genesis module * remove not(wasm) attributes on genesis module * remove debugging printlns * remove io::Read from provider tests * add failing post merge test case * add full mainnet nodeinfo for testing * support deserializing json bignums to U256 * the serde_json arbitrary_precision feature is necessary so the serde_json::Number variant of `IntOrHexOrBigNum` can be converted into a string and fed into U256::from_dec_string * fix from_int_or_hex_opt doc string * remove third variant from IntOrHex * unnecessary since serde_json::Number handles smaller ints as well * add comments for ids * fix enode id type in admin_peers provider test * fix admin typo in Cargo.toml Co-authored-by: Georgios Konstantopoulos <me@gakonst.com> * add method to wait on a gethinstance adding a peer * fix dial loop and wait_to_add_peer doc comments * update geth * the build can be updated by changing the GETH_BUILD env var * wait for geth to exit on drop * remove unnecessary wait * fix mid-handshake PeerInfo deserialization * remove println * make tests less flaky * handle discovery with the rest of the non dev opts * dump geth stderr to debug failing ci test * add method which dumps the unread stderr of the geth instance into a string * remove call_raw debug println * bug is due to authrpc endpoint being in use * use unused port when authrpc port is not specified * remove dump_stderr from GethInstance * did not work properly anyways Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2022-11-30 21:22:44 +00:00
GETH_BUILD: 1.10.26-e5eb32ac
jobs:
2022-09-28 18:58:26 +00:00
tests:
name: ethereum tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
2022-09-28 18:58:26 +00:00
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install Solc
run: |
mkdir -p "$HOME/bin"
wget -q https://github.com/ethereum/solidity/releases/download/v0.8.10/solc-static-linux -O $HOME/bin/solc
chmod u+x "$HOME/bin/solc"
export PATH=$HOME/bin:$PATH
solc --version
2022-09-28 18:58:26 +00:00
- name: Install geth
run: |
mkdir -p "$HOME/bin"
feat(providers): add a subset of admin namespace (#1880) * tell Geth to expose the admin namespace * wip: add admin namespace support * add networking and peer related structs * add rest of chain config fields * add datadir to geth * fix data dir ref * add dev flag to geth * set dev only if block_time is not set * put mutually exclusive options in an enum * make block_time use the devmode enum * add p2p port to geth * add basic impls for admin endpoints * move from_int_or_hex to ethers-core utils * fix nodeinfo protocol field * the type is better represented by a struct which can have either eth or snap * add chain id and discovery toggle for Geth * remove PeerEvent * should re-add when peer event endpoints are implemented * simplify serde options for admin responses * change signature for peer modification apis * these admin apis accept an enode, which _may_ be an enr, but could also be a legacy enode "v4" url. * add note on where `ChainConfig` fields come from * add note on PeerInfo about the source of fields * add admin namespace support to CHANGELOG * update pr number in changelog * cargo fmt * move chainconfig to genesis in utils * accept genesis file in geth * add genesis writing to geth spawn * finally get geth nodes to connect * import io::Read in provider tests * fix PeerInfo and use enode id for provider test * make clippy happy * improve documentation for genesis module * remove not(wasm) attributes on genesis module * remove debugging printlns * remove io::Read from provider tests * add failing post merge test case * add full mainnet nodeinfo for testing * support deserializing json bignums to U256 * the serde_json arbitrary_precision feature is necessary so the serde_json::Number variant of `IntOrHexOrBigNum` can be converted into a string and fed into U256::from_dec_string * fix from_int_or_hex_opt doc string * remove third variant from IntOrHex * unnecessary since serde_json::Number handles smaller ints as well * add comments for ids * fix enode id type in admin_peers provider test * fix admin typo in Cargo.toml Co-authored-by: Georgios Konstantopoulos <me@gakonst.com> * add method to wait on a gethinstance adding a peer * fix dial loop and wait_to_add_peer doc comments * update geth * the build can be updated by changing the GETH_BUILD env var * wait for geth to exit on drop * remove unnecessary wait * fix mid-handshake PeerInfo deserialization * remove println * make tests less flaky * handle discovery with the rest of the non dev opts * dump geth stderr to debug failing ci test * add method which dumps the unread stderr of the geth instance into a string * remove call_raw debug println * bug is due to authrpc endpoint being in use * use unused port when authrpc port is not specified * remove dump_stderr from GethInstance * did not work properly anyways Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2022-11-30 21:22:44 +00:00
wget -q https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-$GETH_BUILD.tar.gz
tar -xvf geth-linux-amd64-$GETH_BUILD.tar.gz
mv geth-linux-amd64-$GETH_BUILD/geth $HOME/bin/geth
2022-09-28 18:58:26 +00:00
chmod u+x "$HOME/bin/geth"
export PATH=$HOME/bin:$PATH
geth version
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: cargo test
run: |
export PATH=$HOME/bin:$PATH
export ETHERSCAN_API_KEY=$ETHERSCAN_API_KEY_ETHEREUM
cargo test
2022-09-28 18:58:26 +00:00
feature-tests:
name: celo tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
2022-09-28 18:58:26 +00:00
# TODO: can we combine these shared steps in github actions?
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install Solc
run: |
mkdir -p "$HOME/bin"
wget -q https://github.com/ethereum/solidity/releases/download/v0.8.10/solc-static-linux -O $HOME/bin/solc
chmod u+x "$HOME/bin/solc"
export PATH=$HOME/bin:$PATH
solc --version
- name: Install geth
run: |
mkdir -p "$HOME/bin"
feat(providers): add a subset of admin namespace (#1880) * tell Geth to expose the admin namespace * wip: add admin namespace support * add networking and peer related structs * add rest of chain config fields * add datadir to geth * fix data dir ref * add dev flag to geth * set dev only if block_time is not set * put mutually exclusive options in an enum * make block_time use the devmode enum * add p2p port to geth * add basic impls for admin endpoints * move from_int_or_hex to ethers-core utils * fix nodeinfo protocol field * the type is better represented by a struct which can have either eth or snap * add chain id and discovery toggle for Geth * remove PeerEvent * should re-add when peer event endpoints are implemented * simplify serde options for admin responses * change signature for peer modification apis * these admin apis accept an enode, which _may_ be an enr, but could also be a legacy enode "v4" url. * add note on where `ChainConfig` fields come from * add note on PeerInfo about the source of fields * add admin namespace support to CHANGELOG * update pr number in changelog * cargo fmt * move chainconfig to genesis in utils * accept genesis file in geth * add genesis writing to geth spawn * finally get geth nodes to connect * import io::Read in provider tests * fix PeerInfo and use enode id for provider test * make clippy happy * improve documentation for genesis module * remove not(wasm) attributes on genesis module * remove debugging printlns * remove io::Read from provider tests * add failing post merge test case * add full mainnet nodeinfo for testing * support deserializing json bignums to U256 * the serde_json arbitrary_precision feature is necessary so the serde_json::Number variant of `IntOrHexOrBigNum` can be converted into a string and fed into U256::from_dec_string * fix from_int_or_hex_opt doc string * remove third variant from IntOrHex * unnecessary since serde_json::Number handles smaller ints as well * add comments for ids * fix enode id type in admin_peers provider test * fix admin typo in Cargo.toml Co-authored-by: Georgios Konstantopoulos <me@gakonst.com> * add method to wait on a gethinstance adding a peer * fix dial loop and wait_to_add_peer doc comments * update geth * the build can be updated by changing the GETH_BUILD env var * wait for geth to exit on drop * remove unnecessary wait * fix mid-handshake PeerInfo deserialization * remove println * make tests less flaky * handle discovery with the rest of the non dev opts * dump geth stderr to debug failing ci test * add method which dumps the unread stderr of the geth instance into a string * remove call_raw debug println * bug is due to authrpc endpoint being in use * use unused port when authrpc port is not specified * remove dump_stderr from GethInstance * did not work properly anyways Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2022-11-30 21:22:44 +00:00
wget -q https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-$GETH_BUILD.tar.gz
tar -xvf geth-linux-amd64-$GETH_BUILD.tar.gz
mv geth-linux-amd64-$GETH_BUILD/geth $HOME/bin/geth
2022-09-28 18:58:26 +00:00
chmod u+x "$HOME/bin/geth"
export PATH=$HOME/bin:$PATH
geth version
2022-09-28 18:58:26 +00:00
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: cargo test (Celo)
run: |
export PATH=$HOME/bin:$PATH
export ETHERSCAN_API_KEY=$ETHERSCAN_API_KEY_CELO
cargo test --all-features
2022-09-28 18:58:26 +00:00
lint:
name: lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
2022-09-28 18:58:26 +00:00
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
components: rustfmt, clippy
override: true
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: cargo fmt
run: cargo +nightly fmt --all -- --check
- name: cargo clippy
run: cargo +nightly clippy --all-features -- -D warnings
docs:
name: docs
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: cargo doc
run: cargo +nightly doc --lib --all-features
env:
RUSTFLAGS: --cfg docsrs
RUSTDOCFLAGS: --cfg docsrs -Dwarnings
2022-09-28 18:58:26 +00:00
wasm:
name: WASM
runs-on: ubuntu-latest
2022-09-28 18:58:26 +00:00
steps:
- name: Checkout sources
uses: actions/checkout@v3
2022-09-28 18:58:26 +00:00
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
profile: minimal
override: true
2022-09-28 18:58:26 +00:00
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
2022-09-28 18:58:26 +00:00
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
2021-09-13 20:48:03 +00:00
2022-09-28 18:58:26 +00:00
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --target wasm32-unknown-unknown
2022-09-28 18:58:26 +00:00
- name: Launch Anvil
run:
anvil --block-time 2 -m "stuff inherit faith park genre spread huge knee ecology
private marble supreme" &
2022-09-28 18:58:26 +00:00
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
2022-09-28 18:58:26 +00:00
- name: Wasm-pack test firefox
run: |
cd examples/ethers-wasm
wasm-pack test --headless --firefox
2022-09-28 18:58:26 +00:00
- name: Wasm-pack test chrome
run: |
cd examples/ethers-wasm
wasm-pack test --headless --chrome
2022-09-28 18:58:26 +00:00
examples:
name: Examples
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
2022-09-28 18:58:26 +00:00
- name: Install geth (for state overrides example)
run: |
mkdir -p "$HOME/bin"
feat(providers): add a subset of admin namespace (#1880) * tell Geth to expose the admin namespace * wip: add admin namespace support * add networking and peer related structs * add rest of chain config fields * add datadir to geth * fix data dir ref * add dev flag to geth * set dev only if block_time is not set * put mutually exclusive options in an enum * make block_time use the devmode enum * add p2p port to geth * add basic impls for admin endpoints * move from_int_or_hex to ethers-core utils * fix nodeinfo protocol field * the type is better represented by a struct which can have either eth or snap * add chain id and discovery toggle for Geth * remove PeerEvent * should re-add when peer event endpoints are implemented * simplify serde options for admin responses * change signature for peer modification apis * these admin apis accept an enode, which _may_ be an enr, but could also be a legacy enode "v4" url. * add note on where `ChainConfig` fields come from * add note on PeerInfo about the source of fields * add admin namespace support to CHANGELOG * update pr number in changelog * cargo fmt * move chainconfig to genesis in utils * accept genesis file in geth * add genesis writing to geth spawn * finally get geth nodes to connect * import io::Read in provider tests * fix PeerInfo and use enode id for provider test * make clippy happy * improve documentation for genesis module * remove not(wasm) attributes on genesis module * remove debugging printlns * remove io::Read from provider tests * add failing post merge test case * add full mainnet nodeinfo for testing * support deserializing json bignums to U256 * the serde_json arbitrary_precision feature is necessary so the serde_json::Number variant of `IntOrHexOrBigNum` can be converted into a string and fed into U256::from_dec_string * fix from_int_or_hex_opt doc string * remove third variant from IntOrHex * unnecessary since serde_json::Number handles smaller ints as well * add comments for ids * fix enode id type in admin_peers provider test * fix admin typo in Cargo.toml Co-authored-by: Georgios Konstantopoulos <me@gakonst.com> * add method to wait on a gethinstance adding a peer * fix dial loop and wait_to_add_peer doc comments * update geth * the build can be updated by changing the GETH_BUILD env var * wait for geth to exit on drop * remove unnecessary wait * fix mid-handshake PeerInfo deserialization * remove println * make tests less flaky * handle discovery with the rest of the non dev opts * dump geth stderr to debug failing ci test * add method which dumps the unread stderr of the geth instance into a string * remove call_raw debug println * bug is due to authrpc endpoint being in use * use unused port when authrpc port is not specified * remove dump_stderr from GethInstance * did not work properly anyways Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2022-11-30 21:22:44 +00:00
wget -q https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-$GETH_BUILD.tar.gz
tar -xvf geth-linux-amd64-$GETH_BUILD.tar.gz
mv geth-linux-amd64-$GETH_BUILD/geth $HOME/bin/geth
2022-09-28 18:58:26 +00:00
chmod u+x "$HOME/bin/geth"
export PATH=$HOME/bin:$PATH
geth version
2022-09-28 18:58:26 +00:00
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
2022-09-28 18:58:26 +00:00
- name: Install Solc
run: |
mkdir -p "$HOME/bin"
wget -q https://github.com/ethereum/solidity/releases/download/v0.8.10/solc-static-linux -O $HOME/bin/solc
chmod u+x "$HOME/bin/solc"
export PATH=$HOME/bin:$PATH
solc --version
2022-09-28 18:58:26 +00:00
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: Build all examples
run: |
export PATH=$HOME/bin:$PATH
examples=$(cargo metadata --format-version 1 | \
jq -c '.packages[]
| select(.name == "ethers")
| .targets[]
| select(.kind[] | contains("example"))
| with_entries(select([.key]
| inside(["name", "required-features"])))'
)
for example in $examples; do
name="$(echo "$example" | jq -r '.name')"
args=(
-p ethers
--example "$name"
)
features="$(echo "$example" | jq -r 'try(."required-features" | join(","))')"
if [[ ! -z "$features" ]]; then
args+=(--features "$features")
fi
2022-09-28 18:58:26 +00:00
echo "building $name"
cargo build "${args[@]}"
done
- name: Run all examples
run: |
export PATH=$HOME/bin:$PATH
chmod +x ./scripts/examples.sh
./scripts/examples.sh
2022-09-28 18:58:26 +00:00
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]
2022-09-28 18:58:26 +00:00
steps:
- name: checkout
uses: actions/checkout@v3
2022-09-28 18:58:26 +00:00
# Run build
- name: Update Rustup
2022-09-28 18:58:26 +00:00
run: |
# disable download progress bar
$ProgressPreference = "SilentlyContinue"
rustup update
2022-09-28 18:58:26 +00:00
rustup target add ${{ matrix.target }}
shell: powershell
2022-09-28 18:58:26 +00:00
- 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
2022-09-28 18:58:26 +00:00
- 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
2022-09-28 18:58:26 +00:00
- 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