Skip to content

Commit e28dafd

Browse files
Le-CaignecTartanLeGrandzguesmi
authored
fix: Fix Subgraph deployment (#47)
* refactor: update CI workflow to include health checks and integration tests, remove obsolete Jenkinsfile * fix: update fork URL and block number retrieval in CI workflow * fix: update command options and environment variable retrieval in CI workflow * fix: correct health check options and update fork URL retrieval in CI workflow * fix: update IPFS image and health check commands in CI workflow * fix: update CI workflow to include genesis block retrieval and health checks for Graph Node * fix: update IPFS image to use kubo version in docker-compose * fix: retrieve fork URL and block number * fix: remove blockchain-fork service configuration from CI workflow * fix: update fetch block number to use static values and add IPFS readiness check * fix: remove code generation step from README * fix: remove unused services and streamline CI workflow * fix: update FORK_URL to use the correct endpoint for integration tests * fix: uncomment steps for installing dependencies, checking format, building, and running unit tests in CI workflow * fix: uncomment steps for preparing local stack environment and update FORK_BLOCK in test environment setup * fix: update fetch block step to source environment variables and use dynamic values for FORK_URL and FORK_BLOCK * fix: add NETWORK_NAME environment variable to prepare local stack environment step * fix: update fetch block step to source the correct environment file * fix: remove .idea directory from .gitignore * fix: reorder build step to occur before running unit tests * fix: reorder steps to run unit tests after build in CI workflow * fix: move NETWORK_NAME environment variable to the job level in CI workflow * Update test-stack/prepare-test-env.ts Co-authored-by: Zied Guesmi <[email protected]> * fix: update changelog for integration tests migration to GitHub Actions * fix: streamline test stack preparation in CI workflow (#46) * fix: remove NETWORK_NAME environment variable from job level in CI workflow * fix: update .env generation message in prepare-test-env script * fix: update integration test structure and add .env.template file * fix: add missing network configurations for avalancheFuji and arbitrumSepolia * fix: add Arbitrum & Avalanche network to changelog * fix: add dotenv and zod to package.json and package-lock.json; create env.ts for environment variable validation * fix: update test:unit script to include 'unit' argument for clarity * fix: update startBlock values and rename avalancheFuji to fuji in networks.json * feat: add Protocol entity to Core data source in subgraph.yaml * fix: update test:e2e script to specify test file pattern * fix: downgrade @graphprotocol/graph-ts to version 0.35.1 in package.json and package-lock.json * feat: add dotenv-cli dependency and update build scripts to use dotenv --------- Co-authored-by: Ugo Mignon <[email protected]> Co-authored-by: Zied Guesmi <[email protected]>
1 parent 8c8a1f1 commit e28dafd

File tree

10 files changed

+166
-34
lines changed

10 files changed

+166
-34
lines changed

.env.template

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The name of the network (e.g., mainnet, arbitrum, etc.)
2+
NETWORK_NAME=...
3+
4+
# The URL of the Graph Node endpoint for self-hosted Graph Node
5+
GRAPHNODE_URL=...
6+
7+
# The URL of the IPFS endpoint for self-hosted IPFS
8+
IPFS_URL=...
9+
10+
# The version label for the deployment (e.g., v1.0.0)
11+
VERSION_LABEL=...

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ subgraph.test.yaml
66
test-stack/.env
77
tests/.bin
88
tests/.latest.json
9+
.env

.mocharc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"extension": ["ts"],
3-
"spec": "itest/**/*.ts",
43
"require": ["ts-node/register"],
54
"timeout": 1000000,
65
"node-option": [

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## vNEXT
44

5+
- Add Arbitrum & Avalanche networks. (#47)
56
- Migrate integration tests from Jenkins to GitHub Actions. (#44)
67
- Remove unused files to streamline the repository. (#42)
78
- Rewrite Jenkins CI for future migration (#36, #37)

config/env.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'dotenv/config';
2+
import { z } from 'zod';
3+
4+
const envSchema = z.object({
5+
NETWORK_NAME: z.string().min(1, 'NETWORK_NAME is required').default('bellecour'),
6+
7+
GRAPHNODE_URL: z
8+
.string()
9+
.url('GRAPHNODE_URL must be a valid URL')
10+
.default('http://localhost:8020'),
11+
12+
IPFS_URL: z.string().url('IPFS_URL must be a valid URL').default('http://localhost:5001'),
13+
14+
VERSION_LABEL: z.string().min(1, 'VERSION_LABEL is required').default('bellecour/poco-v5'),
15+
});
16+
17+
export const env = envSchema.parse(process.env);

networks.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
11
{
2+
"fuji": {
3+
"ERC1538": {
4+
"address": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
5+
"startBlock": 39496461
6+
},
7+
"Core": {
8+
"address": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
9+
"startBlock": 39496461
10+
},
11+
"AppRegistry": {
12+
"address": "0x4a6531ce5150ee716b2d93865D0fbB9ce5492D17",
13+
"startBlock": 39496461
14+
},
15+
"DatasetRegistry": {
16+
"address": "0x3441A0C9FE488c51fcABa2bAAA048720f4D4F72D",
17+
"startBlock": 39496461
18+
},
19+
"WorkerpoolRegistry": {
20+
"address": "0xf81970E3CB0f8711bEaA79135e686873FfbBAC4A",
21+
"startBlock": 39496461
22+
}
23+
},
24+
"arbitrum-sepolia": {
25+
"ERC1538": {
26+
"address": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
27+
"startBlock": 145249746
28+
},
29+
"Core": {
30+
"address": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
31+
"startBlock": 145249746
32+
},
33+
"AppRegistry": {
34+
"address": "0x4a6531ce5150ee716b2d93865D0fbB9ce5492D17",
35+
"startBlock": 145249746
36+
},
37+
"DatasetRegistry": {
38+
"address": "0x3441A0C9FE488c51fcABa2bAAA048720f4D4F72D",
39+
"startBlock": 145249746
40+
},
41+
"WorkerpoolRegistry": {
42+
"address": "0xf81970E3CB0f8711bEaA79135e686873FfbBAC4A",
43+
"startBlock": 145249746
44+
}
45+
},
246
"bellecour": {
347
"ERC1538": {
448
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",

package-lock.json

Lines changed: 76 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"scripts": {
88
"prepare": "husky",
99
"generate:typechain": "typechain --target ethers-v6 --out-dir generated/typechain './node_modules/@iexec/poco/build/contracts/*.json' --ts-nocheck",
10-
"build": "rm -rf generated && rm -rf build && npm run generate:typechain && graph codegen && graph build --network ${NETWORK_NAME:-bellecour}",
10+
"build": "dotenv -e .env -- rm -rf generated && rm -rf build && npm run generate:typechain && graph codegen && graph build --network ${NETWORK_NAME:-bellecour}",
1111
"test": "npm run test:unit && npm run test:e2e",
12-
"test:unit": "graph test",
13-
"test:e2e": "NETWORK_NAME=${NETWORK_NAME:-bellecour} mocha",
12+
"test:unit": "graph test unit",
13+
"test:e2e": "mocha tests/e2e/**/*.ts",
1414
"coverage": "graph test -- -c",
15-
"create": "graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}",
16-
"deploy": "graph deploy ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --version-label ${VERSION_LABEL:-bellecour/poco-v5}",
15+
"create": "dotenv -e .env -- graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}",
16+
"deploy": "dotenv -e .env -- graph deploy ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --version-label ${VERSION_LABEL:-bellecour/poco-v5}",
1717
"all": "npm run build && npm run create && npm run deploy",
1818
"stop-test-stack": "cd test-stack && docker compose down --remove-orphans --volumes",
1919
"start-test-stack": "npm run stop-test-stack && cd test-stack && export NETWORK_NAME=${NETWORK_NAME:-bellecour} && tsx prepare-test-env.ts && docker compose build && docker compose up -d",
@@ -36,9 +36,11 @@
3636
"devDependencies": {
3737
"@apollo/client": "^3.11.8",
3838
"@graphprotocol/graph-cli": "^0.96.0",
39-
"@graphprotocol/graph-ts": "^0.38.0",
39+
"@graphprotocol/graph-ts": "0.35.1",
4040
"@typechain/ethers-v6": "^0.5.1",
4141
"@types/mocha": "^10.0.9",
42+
"dotenv": "^16.5.0",
43+
"dotenv-cli": "^8.0.0",
4244
"ethers": "^6.13.5",
4345
"husky": "^9.1.6",
4446
"lint-staged": "^15.2.10",
@@ -48,7 +50,8 @@
4850
"prettier-plugin-organize-imports": "^4.1.0",
4951
"testcontainers": "^10.13.2",
5052
"ts-node": "^10.9.2",
51-
"tsx": "^4.19.3"
53+
"tsx": "^4.19.3",
54+
"zod": "^3.24.3"
5255
},
5356
"dependencies": {
5457
"@iexec/poco": "^5.5.0",

subgraph.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dataSources:
4040
language: wasm/assemblyscript
4141
entities:
4242
- Category
43+
- Protocol
4344
- Account
4445
- AppOrder
4546
- DatasetOrder
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import { InMemoryCache } from '@apollo/client/cache';
22
import { ApolloClient, gql } from '@apollo/client/core';
33
import { equal } from 'assert';
44
import { JsonRpcProvider, Wallet, ZeroHash } from 'ethers';
5-
import { AppRegistry__factory, IexecInterfaceToken__factory } from '../generated/typechain';
6-
import config from '../networks.json' with { type: 'json' };
5+
import { env } from '../../config/env';
6+
import { AppRegistry__factory, IexecInterfaceToken__factory } from '../../generated/typechain';
7+
import config from '../../networks.json' with { type: 'json' };
78

8-
const APIURL = `http://localhost:8000/subgraphs/name/${process.env.NETWORK_NAME}/poco`;
9+
const APIURL = `http://localhost:8000/subgraphs/name/${env.NETWORK_NAME}/poco`;
910
const client = new ApolloClient({
1011
uri: APIURL,
1112
cache: new InMemoryCache(),
1213
});
13-
const networkName = process.env.NETWORK_NAME!;
14+
const networkName = env.NETWORK_NAME!;
1415
const iexecProxyAddress = (config as any)[networkName].ERC1538.address;
1516

1617
describe('Integration tests', () => {

0 commit comments

Comments
 (0)