Skip to content

Commit 08ce6a7

Browse files
authored
Merge pull request #36 from iExecBlockchainComputing/feature/clean-and-correct
Clean and correct with Jenkins Lib part 1
2 parents 932aabe + b0762c7 commit 08ce6a7

File tree

7 files changed

+328
-92
lines changed

7 files changed

+328
-92
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ build
33
generated
44
yarn.lock
55
test/.bin
6-
subgraph.yaml
76
subgraph.test.yaml

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## vNEXT
4+
- Rewrite Jenkins CI for future migration (#36)
5+
36
## v1.1.0 - Support deal sponsor
47
- Add `sponsor` to `deal`. (#31)
58
- Update deployment hosts:

Jenkinsfile

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,67 @@
1-
@Library('global-jenkins-library@2.7.7') _
1+
//Readme @ http://gitlab.iex.ec:30000/iexec/jenkins-library
22

3+
@Library('global-jenkins-library@feature/subgraph-networks') _
34
def userInput
45

56
node {
6-
docker.image('node:20-alpine').inside('--user root') {
7-
stage('Setup') {
8-
checkout scm
7+
stage('Choose deployment parameters') {
8+
timeout(time: 5, unit: 'MINUTES') {
9+
userInput = input(
10+
id: 'deployment-params',
11+
message: 'Select deployment parameters',
12+
parameters: [
13+
choice(
14+
name: 'networkName',
15+
choices: ['bellecour'],
16+
description: 'Select the target network'
17+
),
18+
choice(
19+
name: 'environment',
20+
choices: ['staging','tmp','prod'],
21+
description: 'Select deployment environment'
22+
),
23+
string(
24+
name: 'versionLabel',
25+
defaultValue: 'v1.0.0',
26+
description: 'Version label for the deployment'
27+
),
28+
string(
29+
name: 'subgraphName',
30+
defaultValue: 'poco-v5',
31+
description: 'Name of the subgraph'
32+
)
33+
]
34+
)
935
}
1036

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-
}
37+
// Define host mappings
38+
def hosts = [
39+
'staging': [
40+
'graphNode': 'azubgrpbx-thegraph-staging.public.az2.internal',
41+
'ipfs': 'ipfs-upload.stagingv8.iex.ec',
42+
'env' : 'staging-'
43+
],
44+
'tmp': [
45+
'graphNode': 'azubgrpbp-thegraph.public.az2.internal',
46+
'ipfs': 'ipfs-upload.v8-bellecour.iex.ec',
47+
'env' : 'tmp-'
48+
],
49+
'prod': [
50+
'graphNode': 'azubgrpbp-thegraph.public.az2.internal',
51+
'ipfs': 'ipfs-upload.v8-bellecour.iex.ec',
52+
'env' : ''
53+
]
54+
]
55+
56+
// Call deploySubGraph with user inputs
57+
deploySubGraph(
58+
targetRemoteHostGraphNode: hosts[userInput.environment].graphNode,
59+
targetRemoteHostIPFS: hosts[userInput.environment].ipfs,
60+
subgraphFolder: './',
61+
networkName: userInput.networkName,
62+
deployEnv: hosts[userInput.environment].env,
63+
subgraphName: userInput.subgraphName,
64+
subgraphVersionLabel: userInput.versionLabel
65+
)
6266
}
6367
}

Jenkinsfile_Subgraph_bellecour_stagingv8

Lines changed: 0 additions & 11 deletions
This file was deleted.

README.md

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,45 +62,70 @@ _NB_: other blockchains setups are availables in [docker/README.md](./docker/REA
6262

6363
---
6464

65-
## Generating Subgraph and Jenkins Configuration Files
65+
Here's the revised "Generating Subgraph and Jenkins Configuration Files" section for your README:
6666

67-
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`.
6867

68+
## Deployment Configuration
6969

70-
**Run the script with the network name**:
71-
```bash
72-
bash generate_subgraph_file.sh <network-name>
73-
```
70+
### Jenkins Pipeline Deployment
71+
72+
The project uses a Jenkins pipeline for automated deployment of the subgraph. The deployment can be triggered through Jenkins with interactive parameter selection.
73+
74+
#### Available Parameters
75+
76+
- **Network**: Choose the target blockchain network
77+
- **Environment**: Select deployment environment
78+
- `staging`: Deploy to staging environment
79+
- `tmp`: Deploy to temporary environment
80+
- `prod`: Deploy to production environment
81+
- **Version Label**: Specify the version of the deployment (e.g., `v1.0.0`)
82+
- **Subgraph Name**: Name of the subgraph (default: `poco-v5`)
83+
84+
#### Environment-specific Configurations
7485

75-
### Configuration
86+
Each environment has specific host configurations:
7687

77-
Ensure `config.json` is populated with the required values. Example:
88+
### Adding New Networks
89+
90+
To add support for a new network, update the `networks.json` file with the network configuration:
7891

7992
```json
8093
{
81-
"bellecour": {
82-
"START_BLOCK": 4543300,
83-
"ERC1538_ADDRESS": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
84-
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
85-
"APP_REGISTRY_ADDRESS": "0xB1C52075b276f87b1834919167312221d50c9D16",
86-
"DATATSET_REGISTRY_ADDRESS": "0x799DAa22654128d0C64d5b79eac9283008158730",
87-
"WORKERPOOL_REGISTRY_ADDRESS": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
94+
"network-name": {
95+
"ERC1538": {
96+
"address": "0x...",
97+
"startBlock": 1234567
98+
},
99+
"Core": {
100+
"address": "0x...",
101+
"startBlock": 1234567
102+
},
103+
"AppRegistry": {
104+
"address": "0x...",
105+
"startBlock": 1234567
106+
},
107+
"DatasetRegistry": {
108+
"address": "0x...",
109+
"startBlock": 1234567
110+
},
111+
"WorkerpoolRegistry": {
112+
"address": "0x...",
113+
"startBlock": 1234567
114+
}
88115
}
89116
}
90117
```
91118

92-
### Files Generated
93-
94-
- **subgraph.<network>.yaml**: Subgraph configuration with placeholders replaced.
95-
96-
#### Example Command
97-
98-
```bash
99-
bash generate_subgraph_file.sh bellecour
119+
Also, update the Jenkins pipeline choices to include the new network:
120+
```groovy
121+
choice(
122+
name: 'networkName',
123+
choices: ['bellecour', 'new-network'],
124+
description: 'Select the target network'
125+
)
100126
```
101127

102-
This command generates `subgraph.bellecour.yaml`.
103-
128+
The deployment process will automatically generate the appropriate subgraph configuration using the network-specific addresses and start blocks from `networks.json`.
104129

105130
## Resources
106131

networks.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,27 @@
4242
"address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4",
4343
"startBlock": 4543300
4444
}
45+
},
46+
"mainnet": {
47+
"ERC1538": {
48+
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
49+
"startBlock": 9917600
50+
},
51+
"Core": {
52+
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
53+
"startBlock": 9917600
54+
},
55+
"AppRegistry": {
56+
"address": "0xB1C52075b276f87b1834919167312221d50c9D16",
57+
"startBlock": 9917600
58+
},
59+
"DatasetRegistry": {
60+
"address": "0x799DAa22654128d0C64d5b79eac9283008158730",
61+
"startBlock": 9917600
62+
},
63+
"WorkerpoolRegistry": {
64+
"address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4",
65+
"startBlock": 9917600
66+
}
4567
}
4668
}

0 commit comments

Comments
 (0)