Skip to content

Commit

Permalink
Restructure integration tests + docker env
Browse files Browse the repository at this point in the history
  • Loading branch information
krebernisak committed Sep 4, 2022
1 parent d821378 commit 8ea8fbe
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 50 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/integration_contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Integration Contracts (Vendor, Examples)

on:
push:
branches:
- develop
- main
pull_request:

jobs:
integration_contracts_run_tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Install Nix
uses: cachix/install-nix-action@d64e0553100205688c0fb2fa16edb0fc8663c590 # v17
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Test
run: nix develop -c make test-integration-contracts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Contracts Integration (Vendor, Examples, Gauntlet)
name: Integration Gauntlet

on:
push:
Expand All @@ -8,7 +8,7 @@ on:
pull_request:

jobs:
contracts_integration_run_tests:
integration_gauntlet_run_tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
Expand All @@ -19,12 +19,8 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Build
run: nix develop -c make build-ts

- name: Test
run: nix develop -c make test-integration-contracts
run: nix develop -c make test-integration-gauntlet

- name: Test - Run Gauntlet CLI via Yarn
run: nix develop -c yarn gauntlet

38 changes: 34 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,44 @@ test-unit-go:
cd ./relayer && go test -v ./... -race -count=10

.PHONY: test-integration
test-integration: test-integration-smoke test-integration-contracts
test-integration: test-integration-smoke test-integration-contracts test-integration-gauntlet

.PHONY: test-integration-smoke
test-integration-smoke:
ginkgo -v -r --junit-report=tests-smoke-report.xml --keep-going --trace integration-tests/smoke

.PHONY: test-integration-contracts
test-integration-contracts: test-ts
# TODO: better network lifecycle setup - requires external network (L1 + L2)
test-integration-contracts: build-ts env-devnet-hardhat
cd examples/contracts/aggregator-consumer/ && \
yarn test
cd packages-ts/integration-eqlabs-multisig/ && \
yarn test
cd packages-ts/integration-starkgate/ && \
yarn test

.PHONY: test-integration-gauntlet
# TODO: better network lifecycle setup - tests setup/run their own network (L1 + conflict w/ above if not cleaned up)
test-integration-gauntlet: build-ts env-devnet-hardhat-down
cd packages-ts/starknet-gauntlet/ && \
yarn test
cd packages-ts/starknet-gauntlet-argent/ && \
yarn test
cd packages-ts/starknet-gauntlet-cli/ && \
yarn test
cd packages-ts/starknet-gauntlet-example/ && \
yarn test
cd packages-ts/starknet-gauntlet-multisig/ && \
yarn test
cd packages-ts/starknet-gauntlet-ocr2/ && \
yarn test
cd packages-ts/starknet-gauntlet-oz/ && \
yarn test
cd packages-ts/starknet-gauntlet-starkgate/ && \
yarn test

.PHONY: test-ts
test-ts: env-devnet-hardhat
yarn test
test-ts: test-ts-contracts test-integration-contracts test-integration-gauntlet

.PHONY: test-ts-contracts
test-ts-contracts: build-ts-contracts env-devnet-hardhat
Expand All @@ -181,3 +207,7 @@ test-ts-contracts: build-ts-contracts env-devnet-hardhat
.PHONY: env-devnet-hardhat
env-devnet-hardhat:
./ops/scripts/devnet-hardhat.sh

.PHONY: env-devnet-hardhat-down
env-devnet-hardhat-down:
./ops/scripts/devnet-hardhat-down.sh
1 change: 1 addition & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-waffle": "^2.0.3",
"@shardlabs/starknet-hardhat-plugin": "^0.6.2",
"@types/chai": "^4.3.3",
"@types/elliptic": "^6.4.14",
"@types/mocha": "^9.1.1",
"cairo-ls": "^0.0.4",
Expand Down
1 change: 1 addition & 0 deletions examples/contracts/aggregator-consumer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.1.0",
"@shardlabs/starknet-hardhat-plugin": "^0.6.2",
"@types/chai": "^4.3.3",
"@types/mocha": "^9.1.1",
"chai": "^4.3.6",
"hardhat": "^*"
Expand Down
28 changes: 28 additions & 0 deletions ops/scripts/devnet-hardhat-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# TODO: this script needs to be replaced with a predefined K8s enviroment

echo "Cleaning up StarkNet Devnet container..."

dpid=`docker ps | grep chainlink-starknet.starknet-devnet | awk '{print $1}'`;
echo "Checking for existing 'chainlink-starknet.starknet-devnet' docker container..."
if [ -z "$dpid" ]
then
echo "No docker StarkNet Devnet container running.";
else
docker kill $dpid;
docker rm $dpid;
fi

echo "Cleaning up Hardhat container..."

dpid=`docker ps | grep chainlink-starknet.hardhat | awk '{print $1}'`;
echo "Checking for existing 'chainlink-starknet.hardhat' docker container..."
if [ -z "$dpid" ]
then
echo "No docker Hardhat container running.";
else
docker kill $dpid;
docker rm $dpid;
fi

echo "Cleanup finished."
41 changes: 5 additions & 36 deletions ops/scripts/devnet-hardhat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,19 @@ cpu_struct=`arch`;
echo $cpu_struct;

node --version;
dpid=`docker ps | grep devnet | awk '{print $1}'`;
echo "Checking for existing docker containers for devnet..."
if [ -z "$dpid" ]
then
echo "No docker devnet container running...";
else
docker kill $dpid;
fi

devnet_image=`docker ps -a | grep devnet_local | awk '{print $1}'`
if [ -z "$devnet_image" ]
then
echo "No docker devnet imagse found...";
else
docker rm $devnet_image;
fi
# Clean up first
bash "$(dirname -- "$0";)/devnet-hardhat-down.sh"

echo "Checking CPU structure..."
if [[ $cpu_struct == *"arm"* ]]
then
echo "Starting arm devnet container..."
docker run -p 5050:5050 -p 8545:8545 -d --name devnet_local shardlabs/starknet-devnet:0.2.11-arm;
docker run -p 5050:5050 -p 8545:8545 -d --name chainlink-starknet.starknet-devnet shardlabs/starknet-devnet:0.2.11-arm;
else
echo "Starting i386 devnet container..."
docker run -p 5050:5050 -p 8545:8545 -d --name devnet_local shardlabs/starknet-devnet:0.2.11;
fi

echo "Checking for running hardhat process..."

hardhat_image=`docker image ls | grep hardhat | awk '{print $3}'`
if [ -z "$hardhat_image" ]
then
echo "No docker hardhat image found...";
else
docker rm $hardhat_image;
docker run -p 5050:5050 -p 8545:8545 -d --name chainlink-starknet.starknet-devnet shardlabs/starknet-devnet:0.2.11;
fi

dpid=`docker ps | grep hardhat | awk '{print $1}'`;
echo "Checking for existing docker containers for hardhat..."
if [ -z "$dpid" ]
then
echo "No docker hardhat container running...";
else
docker kill $dpid;
fi
echo "Starting hardhat..."
docker run --net container:devnet_local -d ethereumoptimism/hardhat
docker run --net container:chainlink-starknet.starknet-devnet -d --name chainlink-starknet.hardhat ethereumoptimism/hardhat
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
"devDependencies": {
"@changesets/cli": "^2.22.0",
"@types/bn.js": "^5.1.1",
"@types/mocha": "^9.1.1",
"@types/chai": "^4.3.1",
"@types/jest": "^28.1.0",
"@types/node": "^18.7.11",
"bn.js": "^5.2.1",
Expand Down
1 change: 1 addition & 0 deletions packages-ts/integration-eqlabs-multisig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@changesets/cli": "^2.22.0",
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@shardlabs/starknet-hardhat-plugin": "^0.6.2",
"@types/chai": "^4.3.3",
"@types/elliptic": "^6.4.14",
"@types/mocha": "^9.1.1",
"chai": "^4.3.6",
Expand Down
1 change: 1 addition & 0 deletions packages-ts/integration-starkgate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"license": "MIT",
"devDependencies": {
"@shardlabs/starknet-hardhat-plugin": "^0.6.2",
"@types/chai": "^4.3.3",
"@types/mocha": "^9.1.1",
"chai": "^4.3.6",
"hardhat": "^2.10.2"
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@
dependencies:
"@types/node" "*"

"@types/chai@*", "@types/chai@^4.3.1":
"@types/chai@*", "@types/chai@^4.3.3":
version "4.3.3"
resolved "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz#3c90752792660c4b562ad73b3fbd68bf3bc7ae07"
integrity sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==
Expand Down

0 comments on commit 8ea8fbe

Please sign in to comment.