Skip to content

Commit

Permalink
Merge pull request #34 from sygmaprotocol/mj52951/add-e2e-testing
Browse files Browse the repository at this point in the history
feat: Add e2e testing
  • Loading branch information
tcar121293 authored Dec 18, 2024
2 parents 09ab98c + 08a8ec9 commit b60a50f
Show file tree
Hide file tree
Showing 19 changed files with 751 additions and 149 deletions.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DB_NAME=squid
DB_PASS=squid
DB_PORT=5432
DB_USERNAME=postgres
DB_HOST=localhost

SHARED_CONFIG_URL="https://ipfs.io/ipfs/bafkreiasnla2ya55of6nwm3swjstip4q2ixfa3t6tvixyibclfovxnerte"
31 changes: 31 additions & 0 deletions .github/workflows/e2e_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: E2E Tests

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
- name: Run Docker
run: docker compose up --build -d
- name: Wait
run: sleep 80s
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn run test:e2e
- name: Clean up Docker containers
if: always()
run: docker compose down
165 changes: 70 additions & 95 deletions commands.json
Original file line number Diff line number Diff line change
@@ -1,98 +1,73 @@
{
"$schema": "https://cdn.subsquid.io/schemas/commands.json",
"commands": {
"clean": {
"description": "delete all build artifacts",
"cmd": ["npx", "--yes", "rimraf", "lib"]
},
"build": {
"description": "Build the squid project",
"deps": ["clean"],
"cmd": ["tsc"]
},
"up": {
"description": "Start indexer",
"cmd": [
"docker",
"compose",
"up",
"-d"
]
},
"down": {
"description": "Drop indexer",
"cmd": [
"docker",
"compose",
"down"
]
},
"migration:apply": {
"description": "Apply the DB migrations",
"cmd": ["squid-typeorm-migration", "apply"]
},
"migration:generate": {
"description": "Generate a DB migration matching the TypeORM entities",
"deps": ["migration:clean"],
"cmd": ["squid-typeorm-migration", "generate"]
},
"migration:clean": {
"description": "Clean the migrations folder",
"cmd": ["npx", "--yes", "rimraf", "./db/migrations/*.js"]
},
"migration": {
"cmd": ["squid-typeorm-migration", "generate"],
"hidden": true
},
"codegen": {
"description": "Generate TypeORM entities from the schema file",
"cmd": ["squid-typeorm-codegen"]
},
"evm-typegen": {
"description": "Generate data access classes for an ABI file(s) in the ./abi folder",
"cmd": ["squid-evm-typegen", "./src/abi", {"glob": "./src/abi/*.json"}, "--multicall"]
},
"substrate-typegen": {
"description": "Generate data access classes for an substrate metadata",
"cmd": ["squid-substrate-typegen", "./typegen.json"]
},
"start-sepolia":{
"description": "Start Sepolia indexer",
"deps": ["build", "migration:apply"],
"cmd": ["node", "--require=dotenv/config", "lib/main.js", "dotenv_config_path=envs/.env.sepolia"]
},
"start-holesky":{
"description": "Start Holesky indexer",
"deps": ["build", "migration:apply"],
"cmd": ["node", "--require=dotenv/config", "lib/main.js", "dotenv_config_path=envs/.env.holesky"]
},
"process": {
"description": "Load .env and start the squid processor",
"deps": ["build", "migration:apply"],
"cmd": ["node", "--require=dotenv/config", "lib/main.js"]
},
"start-init": {
"description": "Initialize the database and load config data",
"deps": ["build", "migration:apply"],
"cmd": ["node", "--require=dotenv/config", "lib/main_init.js"]
},
"process:prod": {
"description": "Start the squid processor",
"cmd": ["node", "lib/main.js"],
"hidden": true
},
"check-updates": {
"cmd": ["npx", "--yes", "npm-check-updates", "--filter=/subsquid/", "--upgrade"],
"hidden": true
},
"bump": {
"description": "Bump @subsquid packages to the latest versions",
"deps": ["check-updates"],
"cmd": ["npm", "i", "-f"]
},
"open": {
"description": "Open a local browser window",
"cmd": ["npx", "--yes", "opener"]
}
"$schema": "https://cdn.subsquid.io/schemas/commands.json",
"commands": {
"clean": {
"description": "delete all build artifacts",
"cmd": ["npx", "--yes", "rimraf", "lib"]
},
"build": {
"description": "Build the squid project",
"deps": ["clean"],
"cmd": ["tsc"]
},
"up": {
"description": "Start indexer",
"cmd": [
"docker",
"compose",
"up",
"-d"
]
},
"down": {
"description": "Drop indexer",
"cmd": [
"docker",
"compose",
"down"
]
},
"migration:apply": {
"description": "Apply the DB migrations",
"cmd": ["squid-typeorm-migration", "apply"]
},
"migration:generate": {
"description": "Generate a DB migration matching the TypeORM entities",
"deps": ["migration:clean"],
"cmd": ["squid-typeorm-migration", "generate"]
},
"migration:clean": {
"description": "Clean the migrations folder",
"cmd": ["npx", "--yes", "rimraf", "./db/migrations/*.js"]
},
"migration": {
"cmd": ["squid-typeorm-migration", "generate"],
"hidden": true
},
"codegen": {
"description": "Generate TypeORM entities from the schema file",
"cmd": ["squid-typeorm-codegen"]
},
"evm-typegen": {
"description": "Generate data access classes for an ABI file(s) in the ./abi folder",
"cmd": ["squid-evm-typegen", "./src/abi", {"glob": "./src/abi/*.json"}, "--multicall"]
},
"substrate-typegen": {
"description": "Generate data access classes for an substrate metadata",
"cmd": ["squid-substrate-typegen", "./typegen.json"]
},
"check-updates": {
"cmd": ["npx", "--yes", "npm-check-updates", "--filter=/subsquid/", "--upgrade"],
"hidden": true
},
"bump": {
"description": "Bump @subsquid packages to the latest versions",
"deps": ["check-updates"],
"cmd": ["npm", "i", "-f"]
},
"open": {
"description": "Open a local browser window",
"cmd": ["npx", "--yes", "opener"]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 42 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
version: "3"

services:

evm1:
image: ghcr.io/sygmaprotocol/indexer-evm1:latest
container_name: evm1
command: ganache-cli --chainId 1337 -d --db data/ --blockTime 2 > /dev/null
logging:
driver: none
ports:
- "8545:8545"

evm2:
image: ghcr.io/sygmaprotocol/indexer-evm2:latest
command: ganache-cli --chainId 1338 -d --db data/ --blockTime 2 > /dev/null
container_name: evm2
logging:
driver: none
ports:
- "8547:8545"

substrate-pallet:
container_name: substrate-pallet
command: ["--pruning=25000"]
image: ghcr.io/sygmaprotocol/indexer-substrate:latest
ports:
- "9944:9944"
- "9933:9933"
logging:
driver: none

db:
image: postgres:15
environment:
Expand All @@ -17,22 +46,30 @@ services:
depends_on:
- db
env_file: ./envs/.env.init
indexer-sepolia:
indexer_evm1:
build:
context: .
dockerfile: ./Dockerfile
restart: on-failure
depends_on:
- indexer-init
env_file: ./envs/.env.sepolia
indexer-holesky:
env_file: ./envs/.env.evm-1
indexer_evm2:
build:
context: .
dockerfile: ./Dockerfile
restart: on-failure
depends_on:
- indexer-init
env_file: ./envs/.env.holesky
env_file: ./envs/.env.evm-2
indexer_substrate:
build:
context: .
dockerfile: ./Dockerfile
restart: on-failure
depends_on:
- indexer-init
env_file: ./envs/.env.substrate
api:
build:
context: .
Expand All @@ -41,5 +78,4 @@ services:
- indexer-init
env_file: ./envs/.env.api
ports:
- "8000:8000"

- "8000:8000"
5 changes: 5 additions & 0 deletions envs/.env.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_NAME=squid
DB_PASS=squid
DB_PORT=5432
DB_USERNAME=postgres
DB_HOST=db
9 changes: 0 additions & 9 deletions envs/.env.api.example

This file was deleted.

13 changes: 13 additions & 0 deletions envs/.env.evm-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DB_NAME=squid
DB_PASS=squid
DB_PORT=5432
DB_USERNAME=postgres
DB_HOST=db
START_SCRIPT_ENV=index

PROCESSOR_PROMETHEUS_PORT=3000

SHARED_CONFIG_URL="https://ipfs.io/ipfs/bafkreiasnla2ya55of6nwm3swjstip4q2ixfa3t6tvixyibclfovxnerte"

DOMAIN_ID=1
1_METADATA='{"rpcUrl": "http://evm1:8545"}'
13 changes: 13 additions & 0 deletions envs/.env.evm-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DB_NAME=squid
DB_PASS=squid
DB_PORT=5432
DB_USERNAME=postgres
DB_HOST=db
START_SCRIPT_ENV=index

PROCESSOR_PROMETHEUS_PORT=3002

SHARED_CONFIG_URL="https://ipfs.io/ipfs/bafkreiasnla2ya55of6nwm3swjstip4q2ixfa3t6tvixyibclfovxnerte"

DOMAIN_ID=2
2_METADATA='{"rpcUrl": "http://evm2:8545"}'
5 changes: 4 additions & 1 deletion envs/.env.init.example → envs/.env.init
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ DB_USERNAME=postgres
DB_HOST=db
START_SCRIPT_ENV=init

SHARED_CONFIG_URL=
SHARED_CONFIG_URL="https://ipfs.io/ipfs/bafkreiasnla2ya55of6nwm3swjstip4q2ixfa3t6tvixyibclfovxnerte"

0_METADATA='{"rpcUrl": ""}'
DOMAIN_ID=0
Loading

0 comments on commit b60a50f

Please sign in to comment.