This repository was archived by the owner on Jan 18, 2023. It is now read-only.
forked from Desert-Defi/set-protocol-v2-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
202 lines (190 loc) · 7.75 KB
/
Copy pathTaskfile.yml
File metadata and controls
202 lines (190 loc) · 7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
version: "3"
dotenv: [
"./docker/custom.env",
"./docker/.env",
]
tasks:
default:
cmds:
- task --list
clean:
desc: "Clean up deployments. Options: 'subgraph' (default), 'graphnode', 'hardhat', or 'all'."
dir: docker/
cmds:
- docker-compose -f {{.TARGET}} down --volumes {{.ARGS}}
- rm -rf ../generated ../build
vars:
TARGET:
sh: if [ "{{.CLI_ARGS}}" = "hardhat" ]; then
echo "docker-compose.hardhat.yml";
elif [ "{{.CLI_ARGS}}" = "graphnode" ]; then
echo "docker-compose.graphnode.yml";
else
echo "docker-compose.local.yml";
fi
ARGS:
sh: if [ "{{.CLI_ARGS}}" = "all" ]; then
echo "--remove-orphans";
else
echo "";
fi
deploy-hardhat:
desc: "Deploy a local Hardhat node and (optionally) a state deployment test script."
dir: docker/
cmds:
- docker-compose -f docker-compose.hardhat.yml run --name {{.HARDHAT_IP}} --rm hardhat-build bash /app/scripts/deploy-hardhat.sh
vars:
REPO_URL:
sh: if [ $(echo "{{.CLI_ARGS}}" | cut -d" " -f1) ]; then
echo "{{.CLI_ARGS}}" | cut -d" " -f1;
else
echo "{{.HARDHAT_STATE_TARGET_REPO}}";
fi
TEST_SCRIPT:
sh: if [ $(echo "{{.CLI_ARGS}}" | cut -d" " -s -f2) ]; then
echo "{{.CLI_ARGS}}" | cut -d" " -s -f2;
else
echo "{{.HARDHAT_STATE_TEST_SCRIPT}}";
fi
env:
REPO_URL: "{{.REPO_URL}}"
REPO_BRANCH_OR_TAG: "{{.HARDHAT_REPO_BRANCH_OR_TAG}}"
TEST_SCRIPT: "{{.TEST_SCRIPT}}"
deploy-hosted:
desc: "Build and deploy subgraph on Hosted Service."
dir: docker/
cmds:
- docker-compose -f docker-compose.hosted.yml up
vars:
NETWORK_NAME:
sh: if [ $(echo "{{.CLI_ARGS}}" | cut -d" " -f1) ]; then
echo "{{.CLI_ARGS}}" | cut -d" " -f1;
else
echo "{{.NETWORK_EXTERNAL}}";
fi
SUBGRAPH_ACCESS_TOKEN:
sh: if [ $(echo "{{.CLI_ARGS}}" | cut -d" " -s -f2) ]; then
echo "{{.CLI_ARGS}}" | cut -d" " -s -f2;
else
echo "{{.SUBGRAPH_ACCESS_TOKEN}}";
fi
env:
ACCESS_TOKEN: "{{.SUBGRAPH_ACCESS_TOKEN}}"
DEPLOYMENT: "hosted"
NETWORK_NAME: "{{.NETWORK_NAME}}"
preconditions:
- sh: if [ -z "$(ls -A ../abis)" ]; then exit 1; fi
msg: "ERROR: No ABIs found. Run 'task gen-abi' first."
deploy-local:
desc: "Build graph-node and ipfs services then deploy subgraph on local network."
dir: docker/
cmds:
- docker-compose -f docker-compose.graphnode.yml -f docker-compose.local.yml up {{.DETACH}}
vars:
DETACH:
sh: if [ "{{.CLI_ARGS}}" = "detach" ]; then echo "-d"; else echo ""; fi
env:
DEPLOYMENT: "local"
ACCESS_TOKEN: "{{.LOCAL_ACCESS_TOKEN}}"
IPFS_IP: "{{.IPFS_CONTAINER}}:{{.IPFS_PORT}}"
GRAPH_NODE_IP: "{{.GRAPH_NODE_CONTAINER}}:{{.GRAPH_NODE_PORT}}"
NETWORK_NAME: "{{.NETWORK_LOCAL}}"
preconditions:
- sh: if [ -z "$(ls -A ../abis)" ]; then exit 1; fi
msg: "ERROR: No ABIs found. Run 'task gen-abi' first."
deploy-local-graphnode:
desc: "Build and deploy graph-node and ipfs services on local network."
dir: docker/
cmds:
- docker-compose -f docker-compose.graphnode.yml up {{.DETACH}}
vars:
DETACH:
sh: if [ "{{.CLI_ARGS}}" = "detach" ]; then echo "-d"; else echo ""; fi
env:
DEPLOYMENT: "local"
ACCESS_TOKEN: "{{.LOCAL_ACCESS_TOKEN}}"
IPFS_IP: "{{.IPFS_CONTAINER}}:{{.IPFS_PORT}}"
GRAPH_NODE_IP: "{{.GRAPH_NODE_CONTAINER}}:{{.GRAPH_NODE_PORT}}"
NETWORK_NAME: "{{.NETWORK_LOCAL}}"
preconditions:
- sh: if [ -z "$(ls -A ../abis)" ]; then exit 1; fi
msg: "ERROR: No ABIs found. Run 'task gen-abi' first."
deploy-local-subgraph:
desc: "Deploy subgraph on running local graph-node and ipfs network."
dir: docker/
cmds:
- if [ "{{.REFRESH}}" = "true" ]; then echo "Deleting IPFS database and re-building..."; else echo "Skipping IPFS refresh..."; fi
- if [ "{{.REFRESH}}" = "true" ]; then docker-compose -f docker-compose.graphnode.yml exec ipfs rm -rf /data/ipfs/*; fi
- if [ "{{.REFRESH}}" = "true" ]; then docker-compose -f docker-compose.graphnode.yml restart ipfs; fi
- if [ "{{.REFRESH}}" = "true" ]; then docker-compose -f docker-compose.graphnode.yml restart graph-node; fi
- docker-compose -f docker-compose.local.yml run setprotocol-subgraph
- docker-compose -f docker-compose.local.yml rm -f setprotocol-subgraph
vars:
REFRESH:
sh: if [ "{{.CLI_ARGS}}" = "refresh" ]; then echo "true"; else echo "false"; fi
env:
DEPLOYMENT: "local"
ACCESS_TOKEN: "{{.LOCAL_ACCESS_TOKEN}}"
IPFS_IP: "{{.IPFS_CONTAINER}}:{{.IPFS_PORT}}"
GRAPH_NODE_IP: "{{.GRAPH_NODE_CONTAINER}}:{{.GRAPH_NODE_PORT}}"
NETWORK_NAME: "{{.NETWORK_LOCAL}}"
preconditions:
- sh: if [ $( docker container inspect -f '{{.State.Status}}' {{.GRAPH_NODE_CONTAINER}} ) != "running" ]; then exit 1; fi
msg: "ERROR: Docker container '{{.GRAPH_NODE_CONTAINER}}' is not running."
- sh: if [ $( docker container inspect -f '{{.State.Status}}' {{.IPFS_CONTAINER}} ) != "running" ]; then exit 1; fi
msg: "ERROR: Docker container '{{.IPFS_CONTAINER}}' is not running."
- sh: if [ -z "$(ls -A ../abis)" ]; then exit 1; fi
msg: "ERROR: No ABIs found. Run 'task gen-abi' first."
deploy-studio:
desc: "Build and deploy subgraph on Studio Subgraph."
dir: docker/
cmds:
- docker-compose -f docker-compose.studio.yml up
vars:
NETWORK_NAME:
sh: if [ $(echo "{{.CLI_ARGS}}" | cut -d" " -f1) ]; then
echo "{{.CLI_ARGS}}" | cut -d" " -f1;
else
echo "{{.NETWORK_EXTERNAL}}";
fi
SUBGRAPH_DEPLOY_KEY:
sh: if [ $(echo "{{.CLI_ARGS}}" | cut -d" " -s -f2) ]; then
echo "{{.CLI_ARGS}}" | cut -d" " -s -f2;
else
echo "{{.SUBGRAPH_DEPLOY_KEY}}";
fi
env:
DEPLOY_KEY: "{{.SUBGRAPH_DEPLOY_KEY}}"
DEPLOYMENT: "studio"
NETWORK_NAME: "{{.NETWORK_NAME}}"
preconditions:
- sh: if [ -z "$(ls -A ../abis)" ]; then exit 1; fi
msg: "ERROR: No ABIs found. Run 'task gen-abi' first."
docker-build:
desc: "Build Docker image based on defined node version base (default: 16-slim)."
cmds:
- docker build -t {{.SET_IMAGE_NAME}}:node-{{.NODE_VER}} -f docker/Dockerfile.base --build-arg NODE_VER={{.NODE_VER}} .
gen-abi:
desc: "Pull latest Set Protocol ABIs into the build environment."
cmds:
# Note the following command requires node ver 16 or below (only 12 and 16 tested working)
- docker-compose -f docker/docker-compose.abi.yml run --rm gen-abi bash scripts/update-abis.sh
env:
PROTOCOL_REPO_URL: "{{.PROTOCOL_REPO_URL}}"
PROTOCOL_REPO_BRANCH_OR_TAG: "{{.PROTOCOL_REPO_BRANCH_OR_TAG}}"
STRATEGIES_REPO_URL: "{{.STRATEGIES_REPO_URL}}"
STRATEGIES_REPO_BRANCH_OR_TAG: "{{.STRATEGIES_REPO_BRANCH_OR_TAG}}"
gen-schema:
desc: "Generate schema intermediate artifacts for development without a full deploy."
cmds:
- rm -rf generated/ build/
- docker-compose -f docker/docker-compose.schema.yml run gen-schema
- docker-compose -f docker/docker-compose.schema.yml rm -f gen-schema
vars:
NETWORK_NAME:
sh: if [ "{{.CLI_ARGS}}" = "hosted" ]; then echo "{{.NETWORK_EXTERNAL}}"; else echo "{{.NETWORK_LOCAL}}"; fi
env:
NETWORK_NAME: "{{.NETWORK_NAME}}"
preconditions:
- sh: if [ -z "$(ls -A ./abis)" ]; then exit 1; fi
msg: "ERROR: No ABIs found. Run 'task gen-abi' first."