Skip to content
Merged
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ script:
- docker-compose exec graph-node graph-node --version
# - docker-compose logs graph-node
- echo -en 'travis_fold:end:script.2\\r'
- sleep 120

- npm run lint
- npm run jest
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: '3'
services:
graph-node:
image: >-
graphprotocol/graph-node@sha256:688f00bd12d619c3cc8c8c0b11aee47d61b5f5e36d62ad002e5ce1e7f3c116f2
image: 'graphprotocol/graph-node:v0.15.1'
ports:
- '8000:8000'
- '8001:8001'
Expand Down
60 changes: 51 additions & 9 deletions ops/graph-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ const { runGraphCli, subgraphLocation: defaultSubgraphLocation} = require('./gra
const { graphNode, ipfsNode, subgraphName: defaultSubgraphName } = require('./settings')
const cwd = path.resolve(`${__dirname}/..`)

function extractSubgraphId(output) {
return output
.trim()
.split('\n')
.reverse()
.find(line => line.match(/(Build completed|Subgraph): Qm/))
.split(':')
.slice(-1)[0]
.trim()
}

async function deploy (opts = {}) {
if (!opts.subgraphLocation) {
Expand Down Expand Up @@ -33,21 +43,53 @@ async function deploy (opts = {}) {
}
}

result = await runGraphCli([
'deploy',
'--access-token "${access_token-""}"',
'--ipfs ' + ipfsNode,
'--node ' + graphNode,
opts.subgraphName,
opts.subgraphLocation
], cwd)
/* upload subgraph files to the other IPFS node */
let builtSubgraphId
if (graphNode.match(/thegraph\.com/)) {
let otherIpfsNode = ipfsNode.match(/staging/)
? 'https://api.thegraph.com/ipfs/'
: 'https://api.staging.thegraph.com/ipfs/'
result = await runGraphCli(['build', '--ipfs', otherIpfsNode, opts.subgraphLocation])
msg = result[1] + result[2]
if (result[0] === 1 || result[0] === 127) {
throw Error(`Failed to upload subgraph files to ${otherIpfsNode}: ${msg}`)
}

builtSubgraphId = extractSubgraphId(result[1])
console.log(`Uploaded subgraph: ${builtSubgraphId}`)
}

result = await runGraphCli(
[
'deploy',
'--access-token "${access_token-""}"',
'--ipfs ' + ipfsNode,
'--node ' + graphNode,
opts.subgraphName,
opts.subgraphLocation,
],
cwd
)
msg = result[1] + result[2]
if ((result[0] === 1)|| (result[0] === 127)){
if (result[0] === 1 || result[0] === 127) {
throw Error(`Deployment failed! ${msg}`)
}
if (msg.toLowerCase().indexOf('error') > 0) {
throw Error(`Deployment failed! ${msg}`)
}

if (graphNode.match(/thegraph\.com/)) {
let deployedSubgraphId = extractSubgraphId(result[1])
console.log(`Deployed subgraph: ${deployedSubgraphId}`)

if (builtSubgraphId !== deployedSubgraphId) {
console.error(
`Subgraph ID mismatch between 'build' and 'deploy':`,
`${builtSubgraphId} !== ${deployedSubgraphId}`
)
}
}

return result
}

Expand Down
115 changes: 90 additions & 25 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"watch": "^1.0.2"
},
"dependencies": {
"@graphprotocol/graph-cli": "^0.14.0",
"@graphprotocol/graph-ts": "^0.14.0",
"@graphprotocol/graph-cli": "^0.15.0",
"@graphprotocol/graph-ts": "^0.15.0",
"@types/node": "^10.14.4",
"apollo-client": "^2.4.5",
"apollo-link-ws": "^1.0.9",
Expand Down