Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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=...
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<network-name>
DEPLOY_ENV=<deploy-environment>
IPFS_URL=<ipfs-url>
GRAPHNODE_URL=<graphnode-url>
VERSION_LABEL=<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, ...).
Expand Down
9 changes: 8 additions & 1 deletion config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(),

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:+$DEPLOY_ENV-}poco-v5 --node ${GRAPHNODE_URL:-http://localhost:8020}'",
"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",
Expand Down Expand Up @@ -58,4 +58,4 @@
"dependencies": {
"@iexec/poco": "^5.5.0"
}
}
}
2 changes: 1 addition & 1 deletion tests/e2e/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading