Skip to content

Commit

Permalink
Revert "chore: remove integration tests (foundry-rs#196)"
Browse files Browse the repository at this point in the history
This reverts commit bab7e2d.
  • Loading branch information
shekhirin committed Dec 17, 2021
1 parent 5d38938 commit 8b15388
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
on:
push:
branches:
- master
pull_request:

name: e2e tests

env:
ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf
FORK_BLOCK: 13633752

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
# TODO: Can we automatically generate this matrix via `ls` and `fromJSON`?
# https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson
repo: ["lootloose", "solmate", "vaults", "geb", "solidity-stringutils", "multicall", "guni-lev", "drai"]

steps:
# clone
- uses: actions/checkout@v2
with:
submodules: recursive
# some deps require node
- uses: actions/setup-node@v2
# install rust
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
# ..with caching
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: Get git sha
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

# try to load `forge` from cache
- name: Cache forge
id: cache-forge
uses: actions/cache@v2
env:
cache-name: cache-forge
with:
path: ./target/debug/forge
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.vars.outputs.sha_short }}

# if couldn't get, install forge
- name: Install forge
if: steps.cache-forge.outputs.cache-hit != 'true'
run: cargo build --bin forge

- name: Test ${{ matrix.repo }}
run: ./test.sh ${{ matrix.repo }}
working-directory:
./integration-tests
25 changes: 25 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Benchmarks & Integration Tests

## Motivation

This sub-project is used for integration testing
[forge](https://github.com/gakonst/foundry/) with common dapptools repositories,
to ensure that it's compatible with the test cases in them, e.g. usage of HEVM
cheatcodes, proper forking mode integration, fuzzing etc.

It is also used for getting quick performance benchmarks for Forge.

## How to run?

1. Make sure forge & dapptools are installed
1. Run `./test.sh $REPO_NAME`, e.g. `./test.sh LootLoose`.

## Repositories Included

See the submodules linked within the [`testdata/`](./testdata) folder.

## Adding a new repository

We use git submodules (I know, I know submodules are not great, feel free to
recommend a working alternative), you can add a new one via:
`./add_test.sh $URL`
10 changes: 10 additions & 0 deletions integration-tests/add_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# Installs a new dapptools test repository to use

TESTDATA=testdata
REPO=$1

cd $TESTDATA
git submodule add $REPO

git commit -m "integration-tests: add $REPO"
31 changes: 31 additions & 0 deletions integration-tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set +x
set -e


# TODO: Add logic for running with all
REPO=$1
TESTDATA=testdata

ALLOWED_FAILURE_REPOS=("geb" "drai" "guni-lev")
if [[ " ${ALLOWED_FAILURE_REPOS[*]} " =~ " ${REPO} " ]]; then
export FORGE_ALLOW_FAILURE=1
fi

DIR=`pwd`

function runTests() {
cd $TESTDATA/$1

# run any installation step if needed
make install || true

# update the deps
$DIR/../target/debug/forge update
# always have the ffi flag turned on
$DIR/../target/debug/forge test --ffi

cd -
}

runTests $REPO
1 change: 1 addition & 0 deletions integration-tests/testdata/drai
Submodule drai added at f31ce4
1 change: 1 addition & 0 deletions integration-tests/testdata/geb
Submodule geb added at 50aa78
1 change: 1 addition & 0 deletions integration-tests/testdata/guni-lev
Submodule guni-lev added at e333f4
1 change: 1 addition & 0 deletions integration-tests/testdata/lootloose
Submodule lootloose added at 7b639e
1 change: 1 addition & 0 deletions integration-tests/testdata/multicall
Submodule multicall added at 1e1b44
1 change: 1 addition & 0 deletions integration-tests/testdata/solidity-stringutils
Submodule solidity-stringutils added at 01e955
1 change: 1 addition & 0 deletions integration-tests/testdata/solmate
Submodule solmate added at 938b2d
1 change: 1 addition & 0 deletions integration-tests/testdata/vaults
Submodule vaults added at 3d92db

0 comments on commit 8b15388

Please sign in to comment.