Skip to content

Commit cacdd58

Browse files
authored
Merge pull request #19 from iExecBlockchainComputing/feat/subgraph_c13
Creating a generic Jenkins file to deploy Poco Subgraph
2 parents 25e659e + 93b03d6 commit cacdd58

File tree

6 files changed

+419
-13
lines changed

6 files changed

+419
-13
lines changed

Jenkinsfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
@Library('[email protected]') _
2+
3+
def userInput
4+
5+
node {
6+
docker.image('node:20-alpine').inside('--user root') {
7+
stage('Setup') {
8+
checkout scm
9+
}
10+
11+
stage('Choose network and host') {
12+
timeout(time: 5, unit: 'MINUTES') {
13+
userInput = input(
14+
id: 'select-deployment',
15+
message: 'Select environment & service',
16+
parameters: [
17+
string(name: 'network', description: 'Target network name of the subgraph'),
18+
string(name: 'targetRemoteHost', description: 'Hostname where to deploy the subgraph')
19+
]
20+
)
21+
}
22+
echo "Selected network: '${userInput.network}'"
23+
echo "Selected hostname: '${userInput.targetRemoteHost}'"
24+
}
25+
26+
stage('Setup Docker Image') {
27+
sh 'apk add jq bash'
28+
}
29+
30+
stage('Generate subgraph file') {
31+
sh """
32+
bash generate_subgraph_file.sh '${userInput.network}'
33+
"""
34+
35+
// Validate subgraph file generation
36+
sh """
37+
FILE=./subgraph.${userInput.network}.yaml
38+
if test -f "\$FILE"; then
39+
echo "Subgraph file generated successfully"
40+
else
41+
echo "Failed to generate subgraph file"
42+
exit 1
43+
fi
44+
"""
45+
}
46+
47+
stage('Build') {
48+
sh """
49+
yarn global add @graphprotocol/graph-cli &&
50+
cd ./ &&
51+
yarn install &&
52+
graph codegen subgraph.${userInput.network}.yaml &&
53+
graph build subgraph.${userInput.network}.yaml &&
54+
graph create ${userInput.network}/poco-v5 --node http://${userInput.targetRemoteHost}:8020 &&
55+
graph deploy ${userInput.network}/poco-v5 subgraph.${userInput.network}.yaml --node http://${userInput.targetRemoteHost}:8020 --ipfs http://${userInput.targetRemoteHost}:5001 --version-label v1.0.0-rc.1
56+
"""
57+
}
58+
59+
stage('The End') {
60+
echo 'The end.'
61+
}
62+
}
63+
}

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,49 @@ debugging:
4949

5050
_NB_: other blockchains setups are availables in [docker/README.md](./docker/README.md).
5151

52+
53+
---
54+
55+
## Generating Subgraph and Jenkins Configuration Files
56+
57+
This project includes a bash script, `generate_subgraph.sh`, to automate the creation of subgraph YAML configuration files and Jenkinsfiles based on the network settings in `config.json`.
58+
59+
60+
**Run the script with the network name**:
61+
```bash
62+
bash generate_subgraph_file.sh <network-name>
63+
```
64+
65+
### Configuration
66+
67+
Ensure `config.json` is populated with the required values. Example:
68+
69+
```json
70+
{
71+
"bellecour": {
72+
"START_BLOCK": 4543300,
73+
"ERC1538_ADDRESS": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
74+
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
75+
"APP_REGISTRY_ADDRESS": "0xB1C52075b276f87b1834919167312221d50c9D16",
76+
"DATATSET_REGISTRY_ADDRESS": "0x799DAa22654128d0C64d5b79eac9283008158730",
77+
"WORKERPOOL_REGISTRY_ADDRESS": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
78+
}
79+
}
80+
```
81+
82+
### Files Generated
83+
84+
- **subgraph.<network>.yaml**: Subgraph configuration with placeholders replaced.
85+
86+
#### Example Command
87+
88+
```bash
89+
bash generate_subgraph_file.sh bellecour
90+
```
91+
92+
This command generates `subgraph.bellecour.yaml`.
93+
94+
5295
## Resources
5396

5497
- [thegraph docs](https://thegraph.com/docs/en/)

config.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"bellecour": {
3+
"START_BLOCK": 4543300,
4+
"ERC1538_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
5+
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
6+
"APP_REGISTRY_ADDRESS" : "0xB1C52075b276f87b1834919167312221d50c9D16",
7+
"DATATSET_REGISTRY_ADDRESS" : "0x799DAa22654128d0C64d5b79eac9283008158730",
8+
"WORKERPOOL_REGISTRY_ADDRESS" : "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
9+
},
10+
"c13": {
11+
"START_BLOCK": 4543300,
12+
"ERC1538_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
13+
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
14+
"APP_REGISTRY_ADDRESS" : "0xB1C52075b276f87b1834919167312221d50c9D16",
15+
"DATATSET_REGISTRY_ADDRESS" : "0x799DAa22654128d0C64d5b79eac9283008158730",
16+
"WORKERPOOL_REGISTRY_ADDRESS" : "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
17+
},
18+
"goerli": {
19+
"START_BLOCK": 2564000,
20+
"ERC1538_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
21+
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
22+
"APP_REGISTRY_ADDRESS" : "0xB1C52075b276f87b1834919167312221d50c9D16",
23+
"DATATSET_REGISTRY_ADDRESS" : "0x799DAa22654128d0C64d5b79eac9283008158730",
24+
"WORKERPOOL_REGISTRY_ADDRESS" : "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
25+
},
26+
"mainnet": {
27+
"START_BLOCK": 9917600,
28+
"ERC1538_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
29+
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
30+
"APP_REGISTRY_ADDRESS" : "0xB1C52075b276f87b1834919167312221d50c9D16",
31+
"DATATSET_REGISTRY_ADDRESS" : "0x799DAa22654128d0C64d5b79eac9283008158730",
32+
"WORKERPOOL_REGISTRY_ADDRESS" : "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
33+
},
34+
"rinkeby": {
35+
"START_BLOCK": 6355862,
36+
"ERC1538_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
37+
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
38+
"APP_REGISTRY_ADDRESS" : "0xB1C52075b276f87b1834919167312221d50c9D16",
39+
"DATATSET_REGISTRY_ADDRESS" : "0x799DAa22654128d0C64d5b79eac9283008158730",
40+
"WORKERPOOL_REGISTRY_ADDRESS" : "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
41+
},
42+
"viviani": {
43+
"START_BLOCK": 5556000,
44+
"ERC1538_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
45+
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS" : "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
46+
"APP_REGISTRY_ADDRESS" : "0xB1C52075b276f87b1834919167312221d50c9D16",
47+
"DATATSET_REGISTRY_ADDRESS" : "0x799DAa22654128d0C64d5b79eac9283008158730",
48+
"WORKERPOOL_REGISTRY_ADDRESS" : "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
49+
},
50+
"test": {
51+
"START_BLOCK": 0,
52+
"ERC1538_ADDRESS" : "0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca",
53+
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS" : "0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca",
54+
"APP_REGISTRY_ADDRESS" : "0xbB66c75dc79D21E8A5b9EF5DE346021082469892",
55+
"DATATSET_REGISTRY_ADDRESS" : "0xe325907A7E0E320A4dcBfAC0cBCda120e7788A0D",
56+
"WORKERPOOL_REGISTRY_ADDRESS" : "0xDaecE9E92C2414D1F4AFcf6B79d76A2491dfd6A6"
57+
}
58+
}

generate_subgraph_file.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# Check if jq is installed
4+
if ! command -v jq &> /dev/null; then
5+
echo "jq is required but not installed. Please install jq to proceed."
6+
exit 1
7+
fi
8+
9+
if [ -z "$1" ]; then
10+
echo "Usage: $0 <network-name>"
11+
exit 1
12+
fi
13+
14+
generate_yaml() {
15+
local network=$1
16+
local config_file="config.json"
17+
local template_file="subgraph.template.yaml"
18+
local output_file="subgraph.${network}.yaml"
19+
20+
# Read values from config.json
21+
local start_block=$(jq -r ".${network}.START_BLOCK" ${config_file})
22+
local erc1538_address=$(jq -r ".${network}.ERC1538_ADDRESS" ${config_file})
23+
local core_address=$(jq -r ".${network}.IEXECE_INTERFACE_TOKEN_CORE_ADDRESS" ${config_file})
24+
local app_registry_address=$(jq -r ".${network}.APP_REGISTRY_ADDRESS" ${config_file})
25+
local dataset_registry_address=$(jq -r ".${network}.DATATSET_REGISTRY_ADDRESS" ${config_file})
26+
local workerpool_registry_address=$(jq -r ".${network}.WORKERPOOL_REGISTRY_ADDRESS" ${config_file})
27+
28+
# Replace placeholders in the template and create the output file
29+
sed -e "s/#NETWORK_NAME#/network: ${network}/g" \
30+
-e "s/#START_BLOCK#/startBlock: ${start_block}/g" \
31+
-e "s|#ERC1538_ADDRESS#|address: \"${erc1538_address}\"|g" \
32+
-e "s|#IEXECE_INTERFACE_TOKEN_CORE_ADDRESS#|address: \"${core_address}\"|g" \
33+
-e "s|#APP_REGISTRY_ADDRESS#|address: \"${app_registry_address}\"|g" \
34+
-e "s|#DATATSET_REGISTRY_ADDRESS#|address: \"${dataset_registry_address}\"|g" \
35+
-e "s|#WORKERPOOL_REGISTRY_ADDRESS#|address: \"${workerpool_registry_address}\"|g" \
36+
${template_file} > ${output_file}
37+
38+
echo "Generated ${output_file}"
39+
}
40+
41+
network_name=$1
42+
43+
generate_yaml ${network_name}

subgraph.bellecour.yaml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
# Copyright 2020 IEXEC BLOCKCHAIN TECH
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
1+
# SPDX-FileCopyrightText: 2020-2024 IEXEC BLOCKCHAIN TECH <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
143

154
specVersion: 0.0.4
165
description: iExecPoCoV5

0 commit comments

Comments
 (0)