Skip to content

Commit

Permalink
feat(ci): add & enable ci/cd (#1)
Browse files Browse the repository at this point in the history
* feat: add ci/cd

* chore: adding execute permissions

* chore: missing deps

* permissions

* add msrv

* fix: push missing node_modules folder

* chore: do not run anvil

* chore: ignore it tests
  • Loading branch information
Evalir authored Oct 4, 2023
1 parent a40ec54 commit 54f38aa
Show file tree
Hide file tree
Showing 20 changed files with 7,920 additions and 8 deletions.
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
msrv = "1.65"
89 changes: 89 additions & 0 deletions .github/scripts/install_test_binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# Installs Solc and Geth binaries
# Note: intended for use only with CI (x86_64 Ubuntu, MacOS or Windows)
set -e

GETH_BUILD=${GETH_BUILD:-"1.11.2-73b01f40"}

BIN_DIR=${BIN_DIR:-"$HOME/bin"}

PLATFORM="$(uname -s | awk '{print tolower($0)}')"
if [ "$PLATFORM" != "linux" ] && [ "$PLATFORM" != "darwin" ]; then
EXT=".exe"
fi

main() {
mkdir -p "$BIN_DIR"
cd "$BIN_DIR"
export PATH="$BIN_DIR:$PATH"
if [ "$GITHUB_PATH" ]; then
echo "$BIN_DIR" >> "$GITHUB_PATH"
fi

install_geth &
g=$!
install_solc &
wait $g $!

echo ""
echo "Installed Geth:"
geth version
echo ""
echo "Installed Solc:"
solc --version
}

# Installs geth from https://geth.ethereum.org/downloads
install_geth() {
case "$PLATFORM" in
linux|darwin)
name="geth-$PLATFORM-amd64-$GETH_BUILD"
curl -s "https://gethstore.blob.core.windows.net/builds/$name.tar.gz" | tar -xzf -
mv -f "$name/geth" ./
rm -rf "$name"
chmod +x geth
;;
*)
name="geth-windows-amd64-$GETH_BUILD"
zip="$name.zip"
curl -so "$zip" "https://gethstore.blob.core.windows.net/builds/$zip"
unzip "$zip"
mv -f "$name/geth.exe" ./
rm -rf "$name" "$zip"
;;
esac
}

# Installs solc from https://binaries.soliditylang.org (https://github.com/ethereum/solc-bin)
install_solc() {
bins_url="https://binaries.soliditylang.org"
case "$PLATFORM" in
linux) bins_url+="/linux-amd64";;
darwin) bins_url+="/macosx-amd64";;
*) bins_url+="/windows-amd64";;
esac

list=$(curl -s "$bins_url/list.json")
# use latest version
if [ -z "$SOLC_VERSION" ]; then
SOLC_VERSION="$(echo "$list" | jq -r ".latestRelease")"
fi
bin=$(echo "$list" | jq -r ".releases[\"$SOLC_VERSION\"]")

if [ "$bin" = "null" ]; then
echo "Invalid Solc version: $SOLC_VERSION" 1>&2
exit 1
fi

# windows versions <= 0.7.1 use .zip
if [[ "$bin" = *.zip ]]; then
echo "Cannot install solc <= 0.7.1" 1>&2
exit 1
fi

curl -so "$bin" "$bins_url/$bin"
mv -f "$bin" "solc$EXT"
chmod +x "solc$EXT"
}

main
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
name: test ${{ matrix.flags.name }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
flags:
- name: no default features
flags: --no-default-features
- name: default features
flags: ""
- name: all features
flags: --all-features
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Install test binaries
shell: bash
run: ./.github/scripts/install_test_binaries.sh
- name: Install nextest
uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: test ${{ matrix.flags.flags }}
shell: bash
run: |
cargo nextest run \
${{ matrix.flags.flags }} \
-E "!(kind(test))" \
--retries 2
feature-checks:
name: feature checks
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
- name: cargo hack
run: cargo hack check --feature-powerset --depth 1 --all-targets

clippy:
name: clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@clippy
- uses: Swatinem/rust-cache@v2
- name: clippy
run: cargo clippy --workspace --all-features --all-targets
env:
RUSTFLAGS: "-D warnings"

docs:
name: docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-docs
- uses: Swatinem/rust-cache@v2
- name: doc
run: cargo doc --workspace --all-features --no-deps --document-private-items
env:
RUSTDOCFLAGS: "--cfg docsrs -D warnings"

fmt:
name: fmt
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: fmt --check
run: cargo fmt --all --check
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/Cargo.lock

cache/
artifacts/

.vscode
/.envrc
Expand Down
16 changes: 15 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ serde_json = "1.0"

# tracing
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", default-features = false }
tracing-futures = "0.2.5"

tiny-keccak = { version = "2.0.2", default-features = false }
sha2 = { version = "0.10.7", default-features = false, optional = true }
md-5 = "0.10.5"

semver = { version = "1", features = ["serde"] }
semver = { version = "1.0", features = ["serde"] }
walkdir = "2.3"
once_cell = "1.18"
regex = "1.9"
Expand Down Expand Up @@ -59,6 +61,18 @@ svm = { package = "svm-rs", version = "0.3", default-features = false, features
], optional = true }
svm-builds = { package = "svm-rs-builds", version = "0.2", optional = true }
tokio = { version = "1.32", features = ["rt-multi-thread"] }
tokio-tungstenite = { version = "0.20", default-features = false }
futures = { version = "0.3.28", default-features = false, features = ["std"] }
futures-core = "0.3.28"
futures-util = "0.3.28"
futures-executor = "0.3.28"
futures-channel = "0.3.28"
futures-locks = { version = "0.7.1", default-features = false }
futures-timer = { version = "3.0.2", default-features = false, features = ["wasm-bindgen"] }
pin-project = "1.1"
reqwest = { version = "0.11.19", default-features = false }
url = { version = "2.4", default-features = false }


[dev-dependencies]
criterion = { version = "0.5", features = ["async_tokio"] }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Utilities for working with native `solc` and compiling projects.

To also compile contracts during `cargo build` (so that ethers `abigen!` can pull in updated abi automatically) you can configure a `foundry_compilers::Project` in your `build.rs` file

First add `ethers-solc` to your cargo build-dependencies.
First add `foundry-compilers` to your cargo build-dependencies.

Once you compiled the project, you can configure cargo change detection with `rerun_if_sources_changed`, so that cargo will execute the `build.rs` file if a contract in the sources directory has changed

Expand Down
Loading

0 comments on commit 54f38aa

Please sign in to comment.