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: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ build
generated
yarn.lock
test/.bin
subgraph.yaml
subgraph.test.yaml
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## vNEXT
- Rewrite Jenkins CI for future migration (#36)

## v1.1.0 - Support deal sponsor
- Add `sponsor` to `deal`. (#31)
- Update deployment hosts:
Expand Down
114 changes: 59 additions & 55 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
@Library('global-jenkins-library@2.7.7') _
//Readme @ http://gitlab.iex.ec:30000/iexec/jenkins-library

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

node {
docker.image('node:20-alpine').inside('--user root') {
stage('Setup') {
checkout scm
stage('Choose deployment parameters') {
timeout(time: 5, unit: 'MINUTES') {
userInput = input(
id: 'deployment-params',
message: 'Select deployment parameters',
parameters: [
choice(
name: 'networkName',
choices: ['bellecour'],
description: 'Select the target network'
),
choice(
name: 'environment',
choices: ['staging','tmp','prod'],
description: 'Select deployment environment'
),
string(
name: 'versionLabel',
defaultValue: 'v1.0.0',
description: 'Version label for the deployment'
),
string(
name: 'subgraphName',
defaultValue: 'poco-v5',
description: 'Name of the subgraph'
)
]
)
}

stage('Choose network and host') {
timeout(time: 5, unit: 'MINUTES') {
userInput = input(
id: 'select-deployment',
message: 'Select environment & service',
parameters: [
string(name: 'network', description: 'Target network name of the subgraph'),
string(name: 'targetRemoteHost', description: 'Hostname where to deploy the subgraph')
]
)
}
echo "Selected network: '${userInput.network}'"
echo "Selected hostname: '${userInput.targetRemoteHost}'"
}

stage('Setup Docker Image') {
sh 'apk add jq bash'
}

stage('Generate subgraph file') {
sh """
bash generate_subgraph_file.sh '${userInput.network}'
"""

// Validate subgraph file generation
sh """
FILE=./subgraph.${userInput.network}.yaml
if test -f "\$FILE"; then
echo "Subgraph file generated successfully"
else
echo "Failed to generate subgraph file"
exit 1
fi
"""
}

stage('Build') {
sh """
yarn global add @graphprotocol/graph-cli &&
cd ./ &&
yarn install &&
graph codegen subgraph.${userInput.network}.yaml &&
graph build subgraph.${userInput.network}.yaml &&
graph create ${userInput.network}/poco-v5 --node http://${userInput.targetRemoteHost}:8020 &&
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
"""
}

stage('The End') {
echo 'The end.'
}
// Define host mappings
def hosts = [
'staging': [
'graphNode': 'azubgrpbx-thegraph-staging.public.az2.internal',
'ipfs': 'ipfs-upload.stagingv8.iex.ec',
'env' : 'staging-'
],
'tmp': [
'graphNode': 'azubgrpbp-thegraph.public.az2.internal',
'ipfs': 'ipfs-upload.v8-bellecour.iex.ec',
'env' : 'tmp-'
],
'prod': [
'graphNode': 'azubgrpbp-thegraph.public.az2.internal',
'ipfs': 'ipfs-upload.v8-bellecour.iex.ec',
'env' : ''
]
]

// Call deploySubGraph with user inputs
deploySubGraph(
targetRemoteHostGraphNode: hosts[userInput.environment].graphNode,
targetRemoteHostIPFS: hosts[userInput.environment].ipfs,
subgraphFolder: './',
networkName: userInput.networkName,
deployEnv: hosts[userInput.environment].env,
subgraphName: userInput.subgraphName,
subgraphVersionLabel: userInput.versionLabel
)
}
}
11 changes: 0 additions & 11 deletions Jenkinsfile_Subgraph_bellecour_stagingv8

This file was deleted.

75 changes: 50 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,45 +62,70 @@ _NB_: other blockchains setups are availables in [docker/README.md](./docker/REA

---

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

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

## Deployment Configuration

**Run the script with the network name**:
```bash
bash generate_subgraph_file.sh <network-name>
```
### Jenkins Pipeline Deployment

The project uses a Jenkins pipeline for automated deployment of the subgraph. The deployment can be triggered through Jenkins with interactive parameter selection.

#### Available Parameters

- **Network**: Choose the target blockchain network
- **Environment**: Select deployment environment
- `staging`: Deploy to staging environment
- `tmp`: Deploy to temporary environment
- `prod`: Deploy to production environment
- **Version Label**: Specify the version of the deployment (e.g., `v1.0.0`)
- **Subgraph Name**: Name of the subgraph (default: `poco-v5`)

#### Environment-specific Configurations

### Configuration
Each environment has specific host configurations:

Ensure `config.json` is populated with the required values. Example:
### Adding New Networks

To add support for a new network, update the `networks.json` file with the network configuration:

```json
{
"bellecour": {
"START_BLOCK": 4543300,
"ERC1538_ADDRESS": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
"IEXECE_INTERFACE_TOKEN_CORE_ADDRESS": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
"APP_REGISTRY_ADDRESS": "0xB1C52075b276f87b1834919167312221d50c9D16",
"DATATSET_REGISTRY_ADDRESS": "0x799DAa22654128d0C64d5b79eac9283008158730",
"WORKERPOOL_REGISTRY_ADDRESS": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4"
"network-name": {
"ERC1538": {
"address": "0x...",
"startBlock": 1234567
},
"Core": {
"address": "0x...",
"startBlock": 1234567
},
"AppRegistry": {
"address": "0x...",
"startBlock": 1234567
},
"DatasetRegistry": {
"address": "0x...",
"startBlock": 1234567
},
"WorkerpoolRegistry": {
"address": "0x...",
"startBlock": 1234567
}
}
}
```

### Files Generated

- **subgraph.<network>.yaml**: Subgraph configuration with placeholders replaced.

#### Example Command

```bash
bash generate_subgraph_file.sh bellecour
Also, update the Jenkins pipeline choices to include the new network:
```groovy
choice(
name: 'networkName',
choices: ['bellecour', 'new-network'],
description: 'Select the target network'
)
```

This command generates `subgraph.bellecour.yaml`.

The deployment process will automatically generate the appropriate subgraph configuration using the network-specific addresses and start blocks from `networks.json`.

## Resources

Expand Down
22 changes: 22 additions & 0 deletions networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,27 @@
"address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4",
"startBlock": 4543300
}
},
"mainnet": {
"ERC1538": {
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
"startBlock": 9917600
},
"Core": {
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
"startBlock": 9917600
},
"AppRegistry": {
"address": "0xB1C52075b276f87b1834919167312221d50c9D16",
"startBlock": 9917600
},
"DatasetRegistry": {
"address": "0x799DAa22654128d0C64d5b79eac9283008158730",
"startBlock": 9917600
},
"WorkerpoolRegistry": {
"address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4",
"startBlock": 9917600
}
}
}
Loading