From e0155496d37715c9687eddbf3e0d5df081c70104 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Wed, 29 Oct 2025 17:09:35 +0100 Subject: [PATCH 1/6] fix: update create and deploy scripts for consistency with versioning --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index dfb3f5f..4074e0e 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "test:unit": "graph test unit", "test:e2e": "mocha tests/e2e/**/*.ts", "coverage": "graph test -- -c", - "create": "dotenv -e .env -- sh -c 'graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}'", - "deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-bellecour/poco-v5}'", + "create": "dotenv -e .env -- sh -c 'graph create ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020}'", + "deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-dev}'", "deploy-studio": "dotenv -e .env -- sh -c 'graph deploy ${SUBGRAPH_SLUG} --deploy-key ${SUBGRAPH_DEPLOY_KEY} --network ${SUBGRAPH_NETWORK_NAME} --version-label ${VERSION_LABEL}'", "all": "npm run build && npm run create && npm run deploy", "stop-test-stack": "cd test-stack && docker compose down --remove-orphans --volumes", @@ -58,4 +58,4 @@ "dependencies": { "@iexec/poco": "^5.5.0" } -} \ No newline at end of file +} From 6ecae8baf7f32aca58dbdb936ebd488a406e1d27 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Wed, 29 Oct 2025 18:09:42 +0100 Subject: [PATCH 2/6] fix: update API URL in integration tests to point to poco-v5 --- tests/e2e/integration.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/integration.test.ts b/tests/e2e/integration.test.ts index b37b491..83608eb 100644 --- a/tests/e2e/integration.test.ts +++ b/tests/e2e/integration.test.ts @@ -6,7 +6,7 @@ import { env } from '../../config/env'; import { AppRegistry__factory, IexecInterfaceToken__factory } from '../../generated/typechain'; import config from '../../networks.json' with { type: 'json' }; -const APIURL = `http://localhost:8000/subgraphs/name/${env.NETWORK_NAME}/poco`; +const APIURL = `http://localhost:8000/subgraphs/name/${env.NETWORK_NAME}/poco-v5`; const client = new ApolloClient({ uri: APIURL, cache: new InMemoryCache(), From aa1e86a0535497f3fd95ada719b1fba9a7a77dcd Mon Sep 17 00:00:00 2001 From: Robin Le Caignec <72495599+Le-Caignec@users.noreply.github.com> Date: Thu, 30 Oct 2025 13:46:18 +0100 Subject: [PATCH 3/6] Update package.json Co-authored-by: Zied Guesmi <26070035+zguesmi@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4074e0e..f1fe82c 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test:unit": "graph test unit", "test:e2e": "mocha tests/e2e/**/*.ts", "coverage": "graph test -- -c", - "create": "dotenv -e .env -- sh -c 'graph create ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020}'", + "create": "dotenv -e .env -- sh -c 'graph create ${NETWORK_NAME:-bellecour}/${DEPLOY_ENV:+$DEPLOY_ENV-}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020}'", "deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-dev}'", "deploy-studio": "dotenv -e .env -- sh -c 'graph deploy ${SUBGRAPH_SLUG} --deploy-key ${SUBGRAPH_DEPLOY_KEY} --network ${SUBGRAPH_NETWORK_NAME} --version-label ${VERSION_LABEL}'", "all": "npm run build && npm run create && npm run deploy", From 2cc0d605c9e7aae1dc64ed16deb3bcae9b106607 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 30 Oct 2025 13:59:44 +0100 Subject: [PATCH 4/6] feat: add DEPLOY_ENV variable for environment-specific deployment configurations --- .env.template | 7 +++++++ README.md | 37 +++++++++++++++++++++++++++++++++++++ config/env.ts | 9 ++++++++- package.json | 2 +- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/.env.template b/.env.template index 3fce21e..f286dd3 100644 --- a/.env.template +++ b/.env.template @@ -18,3 +18,10 @@ SUBGRAPH_DEPLOY_KEY=... # The network name for The Graph Network deployment (e.g., arbitrum-sepolia, arbitrum) SUBGRAPH_NETWORK_NAME=... + +# DEPLOY_ENV specifies the deployment environment. +# Possible values: +# - empty: For production deployment. +# - tmp: For temporary indexing and avoiding downtime during production deployment. +# - staging: For staging environment deployment. +DEPLOY_ENV=... diff --git a/README.md b/README.md index 9431708..e73f98e 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,43 @@ docker run --rm \ poco-subgraph-deployer ``` +#### Manual Deployment with Custom Values + +To deploy the subgraph manually using the deploy script, follow these steps: + +1. Set up environment variables in the `.env` file: + + ```bash + NETWORK_NAME= + DEPLOY_ENV= + IPFS_URL= + GRAPHNODE_URL= + VERSION_LABEL= + ``` + + Example: + + ```bash + NETWORK_NAME=bellecour + DEPLOY_ENV=staging + IPFS_URL=http://localhost:5001 + GRAPHNODE_URL=http://localhost:8020 + VERSION_LABEL=1.0.0 + ``` + + **DEPLOY_ENV Possible Values:** + - `empty`: For production deployment. + - `tmp`: For temporary indexing and avoiding downtime during production deployment. + - `staging`: For staging environment deployment. + +2. Run the deploy script: + + ```bash + npm run deploy + ``` + + This will deploy the subgraph using the specified values, including the `DEPLOY_ENV` variable for environment-specific configurations. + #### Github Actions pipeline deployment The subgraph can be deployed using Github Actions (recommended). The dedicated job can be triggered with the desired configuration (environment, version, ...). diff --git a/config/env.ts b/config/env.ts index 32f641c..0c8a5cb 100644 --- a/config/env.ts +++ b/config/env.ts @@ -2,6 +2,13 @@ import 'dotenv/config'; import { z } from 'zod'; const envSchema = z.object({ + DEPLOY_ENV: z + .string() + .default('staging') + .refine((value) => ['tmp', 'staging', ''].includes(value), { + message: 'DEPLOY_ENV must be one of: tmp, staging, or empty', + }), + NETWORK_NAME: z.string().min(1, 'NETWORK_NAME is required').default('bellecour'), GRAPHNODE_URL: z @@ -11,7 +18,7 @@ const envSchema = z.object({ IPFS_URL: z.string().url('IPFS_URL must be a valid URL').default('http://localhost:5001'), - VERSION_LABEL: z.string().min(1, 'VERSION_LABEL is required').default('bellecour/poco-v5'), + VERSION_LABEL: z.string().min(1, 'VERSION_LABEL is required').default('dev'), SUBGRAPH_SLUG: z.string().min(1, 'SUBGRAPH_SLUG must not be empty').optional(), diff --git a/package.json b/package.json index f1fe82c..84290fb 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test:e2e": "mocha tests/e2e/**/*.ts", "coverage": "graph test -- -c", "create": "dotenv -e .env -- sh -c 'graph create ${NETWORK_NAME:-bellecour}/${DEPLOY_ENV:+$DEPLOY_ENV-}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020}'", - "deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}${DEPLOY_ENV:-/}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-dev}'", + "deploy": "dotenv -e .env -- sh -c 'graph deploy ${NETWORK_NAME:-bellecour}/${DEPLOY_ENV:+$DEPLOY_ENV-}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --network ${NETWORK_NAME:-bellecour} --version-label ${VERSION_LABEL:-dev}'", "deploy-studio": "dotenv -e .env -- sh -c 'graph deploy ${SUBGRAPH_SLUG} --deploy-key ${SUBGRAPH_DEPLOY_KEY} --network ${SUBGRAPH_NETWORK_NAME} --version-label ${VERSION_LABEL}'", "all": "npm run build && npm run create && npm run deploy", "stop-test-stack": "cd test-stack && docker compose down --remove-orphans --volumes", From 29be97979b81282c5b66292a1948dbba10105ef3 Mon Sep 17 00:00:00 2001 From: Robin Le Caignec <72495599+Le-Caignec@users.noreply.github.com> Date: Thu, 30 Oct 2025 15:12:25 +0100 Subject: [PATCH 5/6] Update .env.template Co-authored-by: Zied Guesmi <26070035+zguesmi@users.noreply.github.com> --- .env.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.template b/.env.template index f286dd3..7d49f4b 100644 --- a/.env.template +++ b/.env.template @@ -24,4 +24,4 @@ SUBGRAPH_NETWORK_NAME=... # - empty: For production deployment. # - tmp: For temporary indexing and avoiding downtime during production deployment. # - staging: For staging environment deployment. -DEPLOY_ENV=... +DEPLOY_ENV= From 00ace62acf5ba85966a93a07876268b0a6e8074e Mon Sep 17 00:00:00 2001 From: Robin Le Caignec <72495599+Le-Caignec@users.noreply.github.com> Date: Thu, 30 Oct 2025 15:12:36 +0100 Subject: [PATCH 6/6] Update README.md Co-authored-by: Zied Guesmi <26070035+zguesmi@users.noreply.github.com> --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e73f98e..12946a1 100644 --- a/README.md +++ b/README.md @@ -139,9 +139,9 @@ To deploy the subgraph manually using the deploy script, follow these steps: ``` **DEPLOY_ENV Possible Values:** - - `empty`: For production deployment. - - `tmp`: For temporary indexing and avoiding downtime during production deployment. - - `staging`: For staging environment deployment. + - `''`: For production deployment. + - `'tmp'`: For temporary indexing and avoiding downtime during production deployment. + - `'staging'`: For staging environment deployment. 2. Run the deploy script: