Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e fork testing #76

Merged
merged 12 commits into from
Nov 17, 2023
249 changes: 249 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
version: 2.1

parameters:
node-version:
type: string
default: "18.18.0"

commands:
yarn-install:
steps:
- run: yarn install --immutable

install-anvil:
steps:
- restore_cache:
keys:
- foundry-{{ .Environment.FOUNDRY_CACHE_VERSION }}

- run:
name: "Install Foundry"
working_directory: ~/
environment:
SHELL: /bin/bash
command: |-
export PATH="$PATH:$HOME/.foundry/bin"
echo 'export PATH=$PATH:$HOME/.foundry/bin' >> $BASH_ENV

if command -v anvil; then
echo "Anvil already installed"
anvil --version
else
curl -L https://foundry.paradigm.xyz | bash
foundryup
fi

- save_cache:
key: foundry-{{ .Environment.FOUNDRY_CACHE_VERSION }}
paths:
- "~/.foundry"

run-anvil:
parameters:
provider-url:
type: string
port:
type: integer
default: 8545
steps:
- run:
name: Run anvil on 127.0.0.1:<< parameters.port >>
command: |
anvil \
--port << parameters.port >> \
--fork-url << parameters.provider-url >>
background: true

wait-for-anvil:
parameters:
port:
type: integer
default: 8545
steps:
- run:
name: Wait for anvil ready on 127.0.0.1:<< parameters.port >>
command: wget -q -O - --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 --post-data='{"method":"eth_chainId","params":[],"id":1,"jsonrpc":"2.0"}' --header='Content-Type:application/json' http://127.0.0.1:<< parameters.port >>

install-ipfs:
steps:
- restore_cache:
keys:
- ipfs-{{ .Environment.IPFS_CACHE_VERSION }}

- run:
name: "Install IPFS"
working_directory: ~/
command: |
export PATH="$PATH:$HOME/go-ipfs"
echo 'export PATH=$PATH:$HOME/go-ipfs' >> $BASH_ENV

if command -v ipfs; then
echo "IPFS already installed"
ipfs version
ipfs id
else
LATEST_VERSION=$(curl -sSL https://dist.ipfs.tech/go-ipfs/versions | tail -n 1)
LATEST_VERSION_NUMBER=${LATEST_VERSION#*v}
DOWNLOAD_URL="https://dist.ipfs.tech/go-ipfs/${LATEST_VERSION}/go-ipfs_${LATEST_VERSION}_linux-amd64.tar.gz"
echo "DOWNLOAD_URL=$DOWNLOAD_URL"
curl -sSL -o ipfs.tar.gz $DOWNLOAD_URL
tar -xzf ipfs.tar.gz
rm -rf ~/.ipfs
ipfs init
fi

- save_cache:
key: ipfs-{{ .Environment.IPFS_CACHE_VERSION }}
paths:
- "~/go-ipfs"
- "~/.ipfs"

run-ipfs:
steps:
- run:
command: ipfs daemon
background: true

wait-for-ipfs:
steps:
- run:
name: "Wait for IPFS daemon to start"
command: wget --output-document - --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 --post-data '' "http://localhost:5001/api/v0/version"

jobs:
lint:
docker:
- image: cimg/node:<< pipeline.parameters.node-version >>
steps:
- checkout
- yarn-install
- run: yarn dedupe --check
- run: yarn pretty:check

fork-test:
parameters:
toml:
type: string
preset:
type: string
default: "main"
chain-id:
type: integer
provider-url:
type: string
upgrade-from:
type: string
default: "synthetix-omnibus:latest"
docker:
- image: cimg/node:<< pipeline.parameters.node-version >>
steps:
- checkout
- install-anvil
- run-anvil:
provider-url: << parameters.provider-url >>
#- install-ipfs
#- run-ipfs
- yarn-install
- wait-for-anvil
#- wait-for-ipfs

- run:
name: "Generate upgrade transactions"
command: |
yarn cannon build << parameters.toml >> \
--dry-run \
--preset << parameters.preset >> \
--upgrade-from << parameters.upgrade-from >> \
--chain-id << parameters.chain-id >> \
--provider-url << parameters.provider-url >> \
--write-script ./e2e/deployments/upgrade.ndjson \
--write-script-format json | tee ./cannon-build.log

- run: grep '💥' ./cannon-build.log
- run:
name: "Halt if no changes detected"
command: |
[ -s ./e2e/deployments/upgrade.ndjson ] || circleci-agent step halt

- store_artifacts:
path: "./e2e/deployments/upgrade.ndjson"

- run:
name: "Check for Proxies redeployment"
environment:
- PROXIES: "contract.InitialCoreProxy contract.InitialProxy contract.InitialSpotMarketProxy"
command: |
for PROXY in $PROXIES; do
echo "grep -c "Executing [$PROXY]" ./cannon-build.log"
if [ $(grep -c "Executing [$PROXY]" ./cannon-build.log) -gt 0 ]; then
echo "Proxy $PROXY was modified"
exit 1
fi
done

- run:
name: "Generate deployments"
command: node e2e/fetch-local-deployment.js ./cannon-build.log

- store_artifacts:
path: "./e2e/deployments"

- run:
name: "Upgrade on local fork"
command: node e2e/deploy.js ./e2e/deployments/upgrade.ndjson

- run:
name: "Run tests"
environment:
- DEBUG: "tasks:*"
command: yarn mocha e2e/tests/<< parameters.toml >>/*.e2e.js

workflows:
version: 2.1

tests:
jobs:
- lint

- fork-test:
name: base-goerli-andromeda
toml: omnibus-base-goerli-andromeda.toml
preset: andromeda
chain-id: 84531
provider-url: https://base-goerli.infura.io/v3/$INFURA_API_KEY

- fork-test:
name: base-goerli
toml: omnibus-base-goerli.toml
chain-id: 84531
provider-url: https://base-goerli.infura.io/v3/$INFURA_API_KEY

- fork-test:
name: goerli
toml: omnibus-goerli.toml
chain-id: 5
provider-url: https://goerli.infura.io/v3/$INFURA_API_KEY

- fork-test:
name: mainnet
toml: omnibus-mainnet.toml
chain-id: 1
provider-url: https://mainnet.infura.io/v3/$INFURA_API_KEY

- fork-test:
name: optimism-mainnet
toml: omnibus-optimism-mainnet.toml
chain-id: 10
provider-url: https://optimism-mainnet.infura.io/v3/$INFURA_API_KEY

- fork-test:
name: sepolia
toml: omnibus-sepolia.toml
chain-id: 11155111
provider-url: https://sepolia.infura.io/v3/$INFURA_API_KEY

- fork-test:
name: polygon-mumbai
toml: omnibus-polygon-mumbai.toml
chain-id: 80001
provider-url: https://polygon-mumbai.infura.io/v3/$INFURA_API_KEY
68 changes: 0 additions & 68 deletions .github/workflows/e2e.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/lint.yml

This file was deleted.

Loading