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

Add basic CI to build the subgraph in GA #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Dependencies
node_modules

# Production
build
types
subgraph.yaml
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Tests"
on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-16.04
env:
CI: true
name: Tests
steps:
- uses: actions/checkout@v2

- name: Test subgraph build
run: docker-compose -f ./scripts/docker-compose.yml up --abort-on-container-exit --build --force-recreate --renew-anon-volumes --timeout 0
# --abort-on-container-exit: Only the test service should exit.
# Then, the overall exit code will the the test service exit code
# --build: Make sure to apply test container possible changes
# --force-recreate: Make sure to clear ephemeral container
# --renew-anon-volumes: Make sure postgress and ganache data deleted
# --timeout 0: Speed up teardown
4 changes: 2 additions & 2 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ fi

# Select IPFS and The Graph nodes
if [[ "$NETWORK" = "rpc" ]]; then
IPFS_NODE="http://localhost:5001"
GRAPH_NODE="http://127.0.0.1:8020"
IPFS_NODE="${IPFS_NODE:-'http://localhost:5001'}"
GRAPH_NODE="${GRAPH_NODE:-'http://127.0.0.1:8020'}"
else
IPFS_NODE="https://api.thegraph.com/ipfs/"
GRAPH_NODE="https://api.thegraph.com/deploy/"
Expand Down
61 changes: 61 additions & 0 deletions scripts/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: "3"
services:
graph:
container_name: graph
image: graphprotocol/graph-node
ports:
- "8000:8000"
- "8001:8001"
- "8020:8020"
- "8030:8030"
- "8040:8040"
depends_on:
- ipfs
- ethereum
- postgres
environment:
postgres_host: postgres:5432
postgres_user: graph
postgres_pass: let-me-in
postgres_db: graph
ipfs: "ipfs:5001"
ethereum: "mainnet:http://ethereum:8545"
RUST_LOG: info

ipfs:
container_name: ipfs
image: ipfs/go-ipfs:v0.4.23
ports:
- "5001:5001"

postgres:
container_name: postgres
image: postgres
ports:
- "5432:5432"
command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]
environment:
POSTGRES_USER: graph
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: graph

ethereum:
container_name: ganache
image: trufflesuite/ganache-cli
ports:
- "8545:8545"
- "8546:8546"
command: --networkId 15 --gasLimit 8000000 --gasPrice 1 --deterministic --noVMErrorsOnRPCResponse

test:
container_name: test
build:
context: ../
dockerfile: scripts/test/Dockerfile
depends_on:
- graph
- ipfs
environment:
IPFS_NODE: http://ipfs:5001
GRAPH_NODE: http://graph:8020
GRAPHQL_SERVER: http://graph:8000
16 changes: 16 additions & 0 deletions scripts/test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node

RUN apt-get update -qq
RUN apt-get install wait-for-it -y -qq

WORKDIR /usr/src/app

# Context must be the root directory of this repo
COPY package*.json ./
RUN npm install
RUN npm install @graphprotocol/graph-cli

COPY . ./
COPY scripts/test/entrypoint.sh .

CMD ["./entrypoint.sh"]
11 changes: 11 additions & 0 deletions scripts/test/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Note: URL must not contain a protocol (http://)
wait-for-it --timeout=30 ${GRAPH_NODE#http://}

# TODO: Run truffle to create blockchain state
# Note: Mock address
export COURT=0x2E645469f354BB4F5c8a05B3b30A929361cf77eC

# Deploy subgraph
npm run deploy:rpc

# TODO: Query $GRAPHQL_SERVER with a GraphQL client