From 9e4ac65a30f63b0a335e0a75734de03f71002675 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 10:42:47 +0200 Subject: [PATCH 01/27] refactor: update CI workflow to include health checks and integration tests, remove obsolete Jenkinsfile --- .github/workflows/main.yml | 110 ++++++++++++++++++++++++++++++++++++- Jenkinsfile-itest | 31 ----------- 2 files changed, 108 insertions(+), 33 deletions(-) delete mode 100644 Jenkinsfile-itest diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be5c11b..88054ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,9 +15,81 @@ concurrency: cancel-in-progress: true jobs: - build-subgraph: + build-and-test: runs-on: ubuntu-latest + services: + graphnode-postgres: + image: postgres:16.8 + ports: + - 5432:5432 + env: + POSTGRES_USER: graphnode + POSTGRES_PASSWORD: password + POSTGRES_DB: graphnode-db + POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C" + options: >- + --health-cmd "pg_isready -U graphnode -d graphnode-db" + --health-interval 10s + --health-timeout 5s + --health-retries 3 + + ipfs: + image: ipfs/go-ipfs:v0.34.1 + ports: + - 8080:8080 + - 5001:5001 + options: >- + --health-cmd "bash -c 'nc -z localhost 5001 && nc -z localhost 8080'" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + blockchain-fork: + image: ghcr.io/foundry-rs/foundry:v1.0.0 + ports: + - 8545:8545 + env: + FORK_URL: ${{ steps.prepare.outputs.bellecour_url }} + FORK_BLOCK: ${{ steps.prepare.outputs.bellecour_block }} + options: >- + --entrypoint anvil + --health-cmd "(echo >/dev/tcp/localhost/8545) &>/dev/null" + --health-interval 10s + --health-timeout 5s + --health-retries 3 + --health-start-period 30s + command: > + --host 0.0.0.0 + --port 8545 + --hardfork berlin + --fork-url ${{ secrets.FORK_URL || 'https://bellecour.iex.ec' }} + --fork-block-number ${{ secrets.FORK_BLOCK || '16758360' }} + --chain-id 134 + --gas-limit 6700000 + --gas-price 0 + + graphnode: + image: graphprotocol/graph-node:v0.37.0 + ports: + - 8000:8000 + - 8020:8020 + env: + postgres_host: graphnode-postgres + postgres_port: 5432 + postgres_user: graphnode + postgres_pass: password + postgres_db: graphnode-db + ipfs: ipfs:5001 + ethereum: bellecour:http://blockchain-fork:8545 + GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: ${{ secrets.FORK_BLOCK || '16758360' }} + options: >- + --health-cmd "netcat -w 1 localhost 8020" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + --health-start-period 30s + steps: - name: Checkout uses: actions/checkout@v4 @@ -28,7 +100,7 @@ jobs: node-version: 20 cache: 'npm' - - name: Init + - name: Install dependencies run: npm ci - name: Check Format @@ -40,3 +112,37 @@ jobs: - name: Run unit tests run: npm run test:unit + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Prepare local stack env + id: prepare + run: | + node test/scripts/prepare-test-env.js + + - name: Wait for services + run: | + # Wait for blockchain-fork to be ready + echo "Waiting for blockchain-fork to be ready..." + timeout 60 bash -c 'until (echo >/dev/tcp/localhost/8545) &>/dev/null; do sleep 2; done' + + # Wait for graph-node to be ready + echo "Waiting for graph-node to be ready..." + timeout 60 bash -c 'until curl -s http://localhost:8020/graphql > /dev/null; do sleep 2; done' + + - name: Build and run subgraph deployer + run: | + cd test-stack + + # Build the deployer image + docker build -t poco-subgraph-deployer -f ./Dockerfile .. + + # Run the deployer container + docker run --network host \ + -e GRAPHNODE_URL=http://localhost:8020 \ + -e IPFS_URL=http://localhost:5001 \ + -e NETWORK_NAME=bellecour \ + poco-subgraph-deployer + + - name: Run integration tests + run: npm run test:e2e diff --git a/Jenkinsfile-itest b/Jenkinsfile-itest deleted file mode 100644 index b2a5b2c..0000000 --- a/Jenkinsfile-itest +++ /dev/null @@ -1,31 +0,0 @@ -node('docker') { - stage('Clone') { - cleanWs() - checkoutInfo = checkout(scm) - echo "git checkout: ${checkoutInfo}" - } - stage('Pull images') { - withCredentials([ - usernamePassword(credentialsId: 'docker-regis', - usernameVariable: 'username', passwordVariable: 'password') - ]) { - def registry = 'docker-regis.iex.ec' - try { - sh "echo -n '${password}' | docker login --username '${username}' --password-stdin ${registry}" - sh 'cd docker/test/ && docker compose pull chain' - } finally { - sh "docker logout ${registry}" - } - } - } - docker.image('node:22-alpine') - .inside('-v /var/run/docker.sock:/var/run/docker.sock --network=host --user=root') { - stage('Init') { - sh 'apk add docker docker-compose' // TODO: Use already built image for a faster job execution - sh 'npm ci' - } - stage('Integration tests') { - sh 'npm run itest' - } - } -} From 85a202f944a02c4520e3651f35bf6061b1199092 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 10:50:44 +0200 Subject: [PATCH 02/27] fix: update fork URL and block number retrieval in CI workflow --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 88054ed..3cb1f43 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,8 +63,8 @@ jobs: --host 0.0.0.0 --port 8545 --hardfork berlin - --fork-url ${{ secrets.FORK_URL || 'https://bellecour.iex.ec' }} - --fork-block-number ${{ secrets.FORK_BLOCK || '16758360' }} + --fork-url $(cat /local-stack-env/BELLECOUR_FORK_URL) + --fork-block-number $(cat /local-stack-env/BELLECOUR_FORK_BLOCK) --chain-id 134 --gas-limit 6700000 --gas-price 0 From 3076c4f2fe9d284ef67ed8dc21c5b69c857a10fb Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 11:48:20 +0200 Subject: [PATCH 03/27] fix: update command options and environment variable retrieval in CI workflow --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3cb1f43..0849f04 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,8 +59,7 @@ jobs: --health-timeout 5s --health-retries 3 --health-start-period 30s - command: > - --host 0.0.0.0 + -- --host 0.0.0.0 --port 8545 --hardfork berlin --fork-url $(cat /local-stack-env/BELLECOUR_FORK_URL) @@ -82,7 +81,7 @@ jobs: postgres_db: graphnode-db ipfs: ipfs:5001 ethereum: bellecour:http://blockchain-fork:8545 - GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: ${{ secrets.FORK_BLOCK || '16758360' }} + GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: $(cat /local-stack-env/BELLECOUR_FORK_BLOCK) options: >- --health-cmd "netcat -w 1 localhost 8020" --health-interval 10s From 315e6004453b6205e3991d1b71802e01e598e09b Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 13:58:04 +0200 Subject: [PATCH 04/27] fix: correct health check options and update fork URL retrieval in CI workflow --- .github/workflows/main.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0849f04..180a65b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,10 +29,12 @@ jobs: POSTGRES_DB: graphnode-db POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C" options: >- - --health-cmd "pg_isready -U graphnode -d graphnode-db" - --health-interval 10s - --health-timeout 5s - --health-retries 3 + --health-cmd "pg_isready -U graphnode -d graphnode-db" + --health-interval 10s + --health-timeout 5s + --health-retries 3 + -- postgres + -cshared_preload_libraries=pg_stat_statements ipfs: image: ipfs/go-ipfs:v0.34.1 @@ -62,8 +64,8 @@ jobs: -- --host 0.0.0.0 --port 8545 --hardfork berlin - --fork-url $(cat /local-stack-env/BELLECOUR_FORK_URL) - --fork-block-number $(cat /local-stack-env/BELLECOUR_FORK_BLOCK) + --fork-url $(cat /local-stack-env/FORK_BLOCK) + --fork-block-number $(cat /local-stack-env/FORK_BLOCK) --chain-id 134 --gas-limit 6700000 --gas-price 0 @@ -81,7 +83,7 @@ jobs: postgres_db: graphnode-db ipfs: ipfs:5001 ethereum: bellecour:http://blockchain-fork:8545 - GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: $(cat /local-stack-env/BELLECOUR_FORK_BLOCK) + GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: $(cat /local-stack-env/FORK_BLOCK) options: >- --health-cmd "netcat -w 1 localhost 8020" --health-interval 10s From c11ac457c7ecfad54b8b224aa3d09582da8e5f27 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 14:38:09 +0200 Subject: [PATCH 05/27] fix: update IPFS image and health check commands in CI workflow --- .github/workflows/main.yml | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 180a65b..e041b05 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,15 +37,10 @@ jobs: -cshared_preload_libraries=pg_stat_statements ipfs: - image: ipfs/go-ipfs:v0.34.1 + image: ipfs/kubo:v0.34.1 ports: - 8080:8080 - 5001:5001 - options: >- - --health-cmd "bash -c 'nc -z localhost 5001 && nc -z localhost 8080'" - --health-interval 10s - --health-timeout 5s - --health-retries 5 blockchain-fork: image: ghcr.io/foundry-rs/foundry:v1.0.0 @@ -83,7 +78,7 @@ jobs: postgres_db: graphnode-db ipfs: ipfs:5001 ethereum: bellecour:http://blockchain-fork:8545 - GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: $(cat /local-stack-env/FORK_BLOCK) + GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: 33334802 options: >- --health-cmd "netcat -w 1 localhost 8020" --health-interval 10s @@ -113,23 +108,9 @@ jobs: - name: Run unit tests run: npm run test:unit - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Prepare local stack env id: prepare - run: | - node test/scripts/prepare-test-env.js - - - name: Wait for services - run: | - # Wait for blockchain-fork to be ready - echo "Waiting for blockchain-fork to be ready..." - timeout 60 bash -c 'until (echo >/dev/tcp/localhost/8545) &>/dev/null; do sleep 2; done' - - # Wait for graph-node to be ready - echo "Waiting for graph-node to be ready..." - timeout 60 bash -c 'until curl -s http://localhost:8020/graphql > /dev/null; do sleep 2; done' + run: npx tsx test/scripts/prepare-test-env.ts - name: Build and run subgraph deployer run: | From 8fed9dae06fd010a4d1139131f6f3814ca45281a Mon Sep 17 00:00:00 2001 From: Ugo Mignon Date: Thu, 24 Apr 2025 14:42:55 +0200 Subject: [PATCH 06/27] fix: update CI workflow to include genesis block retrieval and health checks for Graph Node --- .github/workflows/main.yml | 63 ++++++++++++++++++++++++-------------- .gitignore | 1 + 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e041b05..2d646c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,7 @@ jobs: ports: - 8080:8080 - 5001:5001 - + blockchain-fork: image: ghcr.io/foundry-rs/foundry:v1.0.0 ports: @@ -64,28 +64,7 @@ jobs: --chain-id 134 --gas-limit 6700000 --gas-price 0 - - graphnode: - image: graphprotocol/graph-node:v0.37.0 - ports: - - 8000:8000 - - 8020:8020 - env: - postgres_host: graphnode-postgres - postgres_port: 5432 - postgres_user: graphnode - postgres_pass: password - postgres_db: graphnode-db - ipfs: ipfs:5001 - ethereum: bellecour:http://blockchain-fork:8545 - GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: 33334802 - options: >- - --health-cmd "netcat -w 1 localhost 8020" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - --health-start-period 30s - + steps: - name: Checkout uses: actions/checkout@v4 @@ -112,6 +91,44 @@ jobs: id: prepare run: npx tsx test/scripts/prepare-test-env.ts + - name: Fetch genesis block number + id: fetch_block + run: | + BLOCK_NUMBER=$(cat /local-stack-env/FORK_BLOCK) + echo "BLOCK=$BLOCK_NUMBER" >> $GITHUB_OUTPUT + + - name: Start Graph Node + run: | + docker run -d \ + --name graphnode \ + --network graphnet \ + -p 8000:8000 \ + -p 8020:8020 \ + -e POSTGRES_HOST=graphnode-postgres \ + -e POSTGRES_PORT=5432 \ + -e POSTGRES_USER=graphnode \ + -e POSTGRES_PASSWORD=password \ + -e POSTGRES_DB=graphnode-db \ + -e IPFS=ipfs:5001 \ + -e ETHEREUM=bellecour:http://blockchain-fork:8545 \ + -e GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER="${{ steps.fetch_block.outputs.BLOCK }}" \ + --health-cmd "nc -w 1 localhost 8020" \ + --health-interval 10s \ + --health-timeout 5s \ + --health-retries 5 \ + --health-start-period 30s \ + graphprotocol/graph-node:v0.37.0 + + - name: Wait for services + run: | + # Wait for blockchain-fork to be ready + echo "Waiting for blockchain-fork to be ready..." + timeout 60 bash -c 'until (echo >/dev/tcp/localhost/8545) &>/dev/null; do sleep 2; done' + + # Wait for graph-node to be ready + echo "Waiting for graph-node to be ready..." + timeout 60 bash -c 'until curl -s http://localhost:8020/graphql > /dev/null; do sleep 2; done' + - name: Build and run subgraph deployer run: | cd test-stack diff --git a/.gitignore b/.gitignore index 6dbc95f..9e89143 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ subgraph.test.yaml test-stack/.env tests/.bin tests/.latest.json +.idea From c4451d0e0ac4f37bafbcc5fa8f9bff54590c4323 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 14:43:21 +0200 Subject: [PATCH 07/27] fix: update IPFS image to use kubo version in docker-compose --- test-stack/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-stack/docker-compose.yml b/test-stack/docker-compose.yml index c6eac8c..4055509 100644 --- a/test-stack/docker-compose.yml +++ b/test-stack/docker-compose.yml @@ -37,7 +37,7 @@ services: ipfs: restart: unless-stopped - image: ipfs/go-ipfs:v0.34.1 + image: ipfs/kubo:v0.34.1 expose: - 8080 - 5001 From 86568311b1e2ed9ee075370a357176c9b0316965 Mon Sep 17 00:00:00 2001 From: Ugo Mignon Date: Thu, 24 Apr 2025 14:53:01 +0200 Subject: [PATCH 08/27] fix: retrieve fork URL and block number --- .github/workflows/main.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d646c6..dd006c4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -94,8 +94,16 @@ jobs: - name: Fetch genesis block number id: fetch_block run: | - BLOCK_NUMBER=$(cat /local-stack-env/FORK_BLOCK) + BLOCK_NUMBER=$(cat /test-stack/FORK_BLOCK) + FORK_URL=$(cat /test-stack/FORK_URL) echo "BLOCK=$BLOCK_NUMBER" >> $GITHUB_OUTPUT + echo "URL=$FORK_URL" >> $GITHUB_OUTPUT + + - name: Start Anvil + uses: iExecBlockchainComputing/anvil-github-action@main + with: + fork-url: ${{ steps.fetch_block.outputs.URL }} + fork-block-number: ${{ steps.fetch_block.outputs.BLOCK }} - name: Start Graph Node run: | From 2041a68f92be0b582a37df7d9e95dd77018ede1b Mon Sep 17 00:00:00 2001 From: Ugo Mignon Date: Thu, 24 Apr 2025 14:53:57 +0200 Subject: [PATCH 09/27] fix: remove blockchain-fork service configuration from CI workflow --- .github/workflows/main.yml | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dd006c4..1799bd4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,29 +42,6 @@ jobs: - 8080:8080 - 5001:5001 - blockchain-fork: - image: ghcr.io/foundry-rs/foundry:v1.0.0 - ports: - - 8545:8545 - env: - FORK_URL: ${{ steps.prepare.outputs.bellecour_url }} - FORK_BLOCK: ${{ steps.prepare.outputs.bellecour_block }} - options: >- - --entrypoint anvil - --health-cmd "(echo >/dev/tcp/localhost/8545) &>/dev/null" - --health-interval 10s - --health-timeout 5s - --health-retries 3 - --health-start-period 30s - -- --host 0.0.0.0 - --port 8545 - --hardfork berlin - --fork-url $(cat /local-stack-env/FORK_BLOCK) - --fork-block-number $(cat /local-stack-env/FORK_BLOCK) - --chain-id 134 - --gas-limit 6700000 - --gas-price 0 - steps: - name: Checkout uses: actions/checkout@v4 From bc85f68f661dfd7aabcddbb59ba66ec1dc963cae Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 15:16:04 +0200 Subject: [PATCH 10/27] fix: update fetch block number to use static values and add IPFS readiness check --- .github/workflows/main.yml | 41 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dd006c4..ddd358c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,27 +75,35 @@ jobs: node-version: 20 cache: 'npm' - - name: Install dependencies - run: npm ci + # - name: Install dependencies + # run: npm ci - - name: Check Format - run: npm run check-format + # - name: Check Format + # run: npm run check-format - - name: Build - run: npm run build + # - name: Build + # run: npm run build - - name: Run unit tests - run: npm run test:unit + # - name: Run unit tests + # run: npm run test:unit - name: Prepare local stack env id: prepare - run: npx tsx test/scripts/prepare-test-env.ts + run: npx tsx ./test-stack/prepare-test-env.ts + + # - name: Fetch genesis block number + # id: fetch_block + # run: | + # BLOCK_NUMBER=$(cat /test-stack/FORK_BLOCK) + # FORK_URL=$(cat /test-stack/FORK_URL) + # echo "BLOCK=$BLOCK_NUMBER" >> $GITHUB_OUTPUT + # echo "URL=$FORK_URL" >> $GITHUB_OUTPUT - name: Fetch genesis block number id: fetch_block run: | - BLOCK_NUMBER=$(cat /test-stack/FORK_BLOCK) - FORK_URL=$(cat /test-stack/FORK_URL) + BLOCK_NUMBER=33335100 + FORK_URL="http://localhost:8545" echo "BLOCK=$BLOCK_NUMBER" >> $GITHUB_OUTPUT echo "URL=$FORK_URL" >> $GITHUB_OUTPUT @@ -105,11 +113,16 @@ jobs: fork-url: ${{ steps.fetch_block.outputs.URL }} fork-block-number: ${{ steps.fetch_block.outputs.BLOCK }} + - name: Wait for IPFS + run: | + # Wait for IPFS to be ready + echo "Waiting for IPFS to be ready..." + timeout 60 bash -c 'until curl -s http://localhost:5001 > /dev/null; do sleep 2; done' + - name: Start Graph Node run: | docker run -d \ --name graphnode \ - --network graphnet \ -p 8000:8000 \ -p 8020:8020 \ -e POSTGRES_HOST=graphnode-postgres \ @@ -117,8 +130,8 @@ jobs: -e POSTGRES_USER=graphnode \ -e POSTGRES_PASSWORD=password \ -e POSTGRES_DB=graphnode-db \ - -e IPFS=ipfs:5001 \ - -e ETHEREUM=bellecour:http://blockchain-fork:8545 \ + -e IPFS=http://localhost:5001 \ + -e ETHEREUM=bellecour:"${{ steps.fetch_block.outputs.URL }}" \ -e GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER="${{ steps.fetch_block.outputs.BLOCK }}" \ --health-cmd "nc -w 1 localhost 8020" \ --health-interval 10s \ From 52ca2aef9704e7af7dde02fe6be63401518a9104 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 16:25:03 +0200 Subject: [PATCH 11/27] fix: remove code generation step from README --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index a968697..748e7b9 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,6 @@ install project deps npm ci ``` -generate code - -```sh -npm run codegen -``` - build the project and generate the necessary files: ```sh From c41a006df52a4c28fa6dd4d317b734202fe8e735 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 16:56:34 +0200 Subject: [PATCH 12/27] fix: remove unused services and streamline CI workflow --- .github/workflows/main.yml | 100 ++++--------------------------------- 1 file changed, 10 insertions(+), 90 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9651235..b866e51 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,30 +17,6 @@ concurrency: jobs: build-and-test: runs-on: ubuntu-latest - - services: - graphnode-postgres: - image: postgres:16.8 - ports: - - 5432:5432 - env: - POSTGRES_USER: graphnode - POSTGRES_PASSWORD: password - POSTGRES_DB: graphnode-db - POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C" - options: >- - --health-cmd "pg_isready -U graphnode -d graphnode-db" - --health-interval 10s - --health-timeout 5s - --health-retries 3 - -- postgres - -cshared_preload_libraries=pg_stat_statements - - ipfs: - image: ipfs/kubo:v0.34.1 - ports: - - 8080:8080 - - 5001:5001 steps: - name: Checkout @@ -64,9 +40,9 @@ jobs: # - name: Run unit tests # run: npm run test:unit - - name: Prepare local stack env - id: prepare - run: npx tsx ./test-stack/prepare-test-env.ts + # - name: Prepare local stack env + # id: prepare + # run: npx tsx ./test-stack/prepare-test-env.ts # - name: Fetch genesis block number # id: fetch_block @@ -76,70 +52,14 @@ jobs: # echo "BLOCK=$BLOCK_NUMBER" >> $GITHUB_OUTPUT # echo "URL=$FORK_URL" >> $GITHUB_OUTPUT - - name: Fetch genesis block number - id: fetch_block - run: | - BLOCK_NUMBER=33335100 - FORK_URL="http://localhost:8545" - echo "BLOCK=$BLOCK_NUMBER" >> $GITHUB_OUTPUT - echo "URL=$FORK_URL" >> $GITHUB_OUTPUT - - - name: Start Anvil - uses: iExecBlockchainComputing/anvil-github-action@main + - name: Docker Compose Action + uses: hoverkraft-tech/compose-action@v2.2.0 with: - fork-url: ${{ steps.fetch_block.outputs.URL }} - fork-block-number: ${{ steps.fetch_block.outputs.BLOCK }} - - - name: Wait for IPFS - run: | - # Wait for IPFS to be ready - echo "Waiting for IPFS to be ready..." - timeout 60 bash -c 'until curl -s http://localhost:5001 > /dev/null; do sleep 2; done' - - - name: Start Graph Node - run: | - docker run -d \ - --name graphnode \ - -p 8000:8000 \ - -p 8020:8020 \ - -e POSTGRES_HOST=graphnode-postgres \ - -e POSTGRES_PORT=5432 \ - -e POSTGRES_USER=graphnode \ - -e POSTGRES_PASSWORD=password \ - -e POSTGRES_DB=graphnode-db \ - -e IPFS=http://localhost:5001 \ - -e ETHEREUM=bellecour:"${{ steps.fetch_block.outputs.URL }}" \ - -e GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER="${{ steps.fetch_block.outputs.BLOCK }}" \ - --health-cmd "nc -w 1 localhost 8020" \ - --health-interval 10s \ - --health-timeout 5s \ - --health-retries 5 \ - --health-start-period 30s \ - graphprotocol/graph-node:v0.37.0 - - - name: Wait for services - run: | - # Wait for blockchain-fork to be ready - echo "Waiting for blockchain-fork to be ready..." - timeout 60 bash -c 'until (echo >/dev/tcp/localhost/8545) &>/dev/null; do sleep 2; done' - - # Wait for graph-node to be ready - echo "Waiting for graph-node to be ready..." - timeout 60 bash -c 'until curl -s http://localhost:8020/graphql > /dev/null; do sleep 2; done' - - - name: Build and run subgraph deployer - run: | - cd test-stack - - # Build the deployer image - docker build -t poco-subgraph-deployer -f ./Dockerfile .. - - # Run the deployer container - docker run --network host \ - -e GRAPHNODE_URL=http://localhost:8020 \ - -e IPFS_URL=http://localhost:5001 \ - -e NETWORK_NAME=bellecour \ - poco-subgraph-deployer + compose-file: "./test-stack/docker-compose.yml" + env: + FORK_URL: "http://loclalhost:8545" + FORK_BLOCK: 33336357 + NETWORK_NAME: "bellecour" - name: Run integration tests run: npm run test:e2e From 4ec3980e0df445655abfc90f812d6d73a0a1af70 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 16:59:07 +0200 Subject: [PATCH 13/27] fix: update FORK_URL to use the correct endpoint for integration tests --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b866e51..3e2622c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: with: compose-file: "./test-stack/docker-compose.yml" env: - FORK_URL: "http://loclalhost:8545" + FORK_URL: "https://bellecour.iex.ec" FORK_BLOCK: 33336357 NETWORK_NAME: "bellecour" From 52e01013b8573a399cc54b27672fc4889a0ebf10 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 17:01:29 +0200 Subject: [PATCH 14/27] fix: uncomment steps for installing dependencies, checking format, building, and running unit tests in CI workflow --- .github/workflows/main.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e2622c..363a469 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,17 +28,17 @@ jobs: node-version: 20 cache: 'npm' - # - name: Install dependencies - # run: npm ci + - name: Install dependencies + run: npm ci - # - name: Check Format - # run: npm run check-format + - name: Check Format + run: npm run check-format - # - name: Build - # run: npm run build + - name: Build + run: npm run build - # - name: Run unit tests - # run: npm run test:unit + - name: Run unit tests + run: npm run test:unit # - name: Prepare local stack env # id: prepare From 9bcffbc7e328320da479952ca1165fe1ab28b025 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 17:21:43 +0200 Subject: [PATCH 15/27] fix: uncomment steps for preparing local stack environment and update FORK_BLOCK in test environment setup --- .github/workflows/main.yml | 10 +++++----- test-stack/prepare-test-env.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 363a469..e02a2f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,9 +40,9 @@ jobs: - name: Run unit tests run: npm run test:unit - # - name: Prepare local stack env - # id: prepare - # run: npx tsx ./test-stack/prepare-test-env.ts + - name: Prepare local stack env + id: prepare + run: npx tsx ./test-stack/prepare-test-env.ts # - name: Fetch genesis block number # id: fetch_block @@ -52,13 +52,13 @@ jobs: # echo "BLOCK=$BLOCK_NUMBER" >> $GITHUB_OUTPUT # echo "URL=$FORK_URL" >> $GITHUB_OUTPUT - - name: Docker Compose Action + - name: Start local stack uses: hoverkraft-tech/compose-action@v2.2.0 with: compose-file: "./test-stack/docker-compose.yml" env: FORK_URL: "https://bellecour.iex.ec" - FORK_BLOCK: 33336357 + FORK_BLOCK: 33336595 NETWORK_NAME: "bellecour" - name: Run integration tests diff --git a/test-stack/prepare-test-env.ts b/test-stack/prepare-test-env.ts index 9af0820..e962e0c 100644 --- a/test-stack/prepare-test-env.ts +++ b/test-stack/prepare-test-env.ts @@ -36,13 +36,13 @@ async function createEnvFiles(forkBlockNumber: number) { writeFileSync( '.env', `############ THIS FILE IS GENERATED ############ - # run "node prepare-test-env.js" to regenerate # - ################################################ +# run "node prepare-test-env.js" to regenerate # +################################################ - # blockchain node to use as the reference for the local fork - FORK_URL=${forkUrl} - # block number to fork from - FORK_BLOCK=${forkBlockNumber}`, +# blockchain node to use as the reference for the local fork +FORK_URL=${forkUrl} +# block number to fork from +FORK_BLOCK=${forkBlockNumber}`, ); } From c3bed0b99df3c7d345a95d72b54d0e6d5fba828f Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 17:45:13 +0200 Subject: [PATCH 16/27] fix: update fetch block step to source environment variables and use dynamic values for FORK_URL and FORK_BLOCK --- .github/workflows/main.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e02a2f2..1f378ab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,21 +44,20 @@ jobs: id: prepare run: npx tsx ./test-stack/prepare-test-env.ts - # - name: Fetch genesis block number - # id: fetch_block - # run: | - # BLOCK_NUMBER=$(cat /test-stack/FORK_BLOCK) - # FORK_URL=$(cat /test-stack/FORK_URL) - # echo "BLOCK=$BLOCK_NUMBER" >> $GITHUB_OUTPUT - # echo "URL=$FORK_URL" >> $GITHUB_OUTPUT + - name: Fetch genesis block number + id: fetch_block + run: | + source ./test-stack/.env + echo "BLOCK=$FORK_BLOCK" >> $GITHUB_OUTPUT + echo "URL=$FORK_URL" >> $GITHUB_OUTPUT - name: Start local stack uses: hoverkraft-tech/compose-action@v2.2.0 with: compose-file: "./test-stack/docker-compose.yml" env: - FORK_URL: "https://bellecour.iex.ec" - FORK_BLOCK: 33336595 + FORK_URL: ${{ steps.fetch_block.outputs.URL }} + FORK_BLOCK: ${{ steps.fetch_block.outputs.BLOCK }} NETWORK_NAME: "bellecour" - name: Run integration tests From e5999aed1977385e49f75067ceebdd7e73661ea4 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 17:51:03 +0200 Subject: [PATCH 17/27] fix: add NETWORK_NAME environment variable to prepare local stack environment step --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f378ab..729139f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,6 +43,8 @@ jobs: - name: Prepare local stack env id: prepare run: npx tsx ./test-stack/prepare-test-env.ts + env: + NETWORK_NAME: "bellecour" - name: Fetch genesis block number id: fetch_block From 51761db26ceee075d38631a0c54e21b8c4f308a1 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 17:55:53 +0200 Subject: [PATCH 18/27] fix: update fetch block step to source the correct environment file --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 729139f..28096e5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,7 +49,7 @@ jobs: - name: Fetch genesis block number id: fetch_block run: | - source ./test-stack/.env + source .env echo "BLOCK=$FORK_BLOCK" >> $GITHUB_OUTPUT echo "URL=$FORK_URL" >> $GITHUB_OUTPUT From 9e175446711f9d627afd53d1911ec75172c50708 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 18:00:40 +0200 Subject: [PATCH 19/27] fix: remove .idea directory from .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9e89143..6dbc95f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ subgraph.test.yaml test-stack/.env tests/.bin tests/.latest.json -.idea From a20ad2ddf7726d3f4f6a05216870164554cd5ecc Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 18:03:03 +0200 Subject: [PATCH 20/27] fix: reorder build step to occur before running unit tests --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28096e5..662ed19 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,12 +34,12 @@ jobs: - name: Check Format run: npm run check-format - - name: Build - run: npm run build - - name: Run unit tests run: npm run test:unit + - name: Build + run: npm run build + - name: Prepare local stack env id: prepare run: npx tsx ./test-stack/prepare-test-env.ts From 32f7059c38c92e98eefae2d1966d4a2dd414ef2a Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 18:03:18 +0200 Subject: [PATCH 21/27] fix: reorder steps to run unit tests after build in CI workflow --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 662ed19..28096e5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,12 +34,12 @@ jobs: - name: Check Format run: npm run check-format - - name: Run unit tests - run: npm run test:unit - - name: Build run: npm run build + - name: Run unit tests + run: npm run test:unit + - name: Prepare local stack env id: prepare run: npx tsx ./test-stack/prepare-test-env.ts From 2ee27cd0e848284f500db6f1ac63a9337c909d8f Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 18:04:34 +0200 Subject: [PATCH 22/27] fix: move NETWORK_NAME environment variable to the job level in CI workflow --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28096e5..67aa9d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,8 @@ concurrency: jobs: build-and-test: runs-on: ubuntu-latest + env: + NETWORK_NAME: "bellecour" steps: - name: Checkout @@ -43,8 +45,6 @@ jobs: - name: Prepare local stack env id: prepare run: npx tsx ./test-stack/prepare-test-env.ts - env: - NETWORK_NAME: "bellecour" - name: Fetch genesis block number id: fetch_block @@ -60,7 +60,6 @@ jobs: env: FORK_URL: ${{ steps.fetch_block.outputs.URL }} FORK_BLOCK: ${{ steps.fetch_block.outputs.BLOCK }} - NETWORK_NAME: "bellecour" - name: Run integration tests run: npm run test:e2e From d9c816748da5331fe4e5b0bc4663617fa8adfc48 Mon Sep 17 00:00:00 2001 From: Robin Le Caignec <72495599+Le-Caignec@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:12:08 +0200 Subject: [PATCH 23/27] Update test-stack/prepare-test-env.ts Co-authored-by: Zied Guesmi <26070035+zguesmi@users.noreply.github.com> --- test-stack/prepare-test-env.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-stack/prepare-test-env.ts b/test-stack/prepare-test-env.ts index e962e0c..ea597e9 100644 --- a/test-stack/prepare-test-env.ts +++ b/test-stack/prepare-test-env.ts @@ -36,7 +36,7 @@ async function createEnvFiles(forkBlockNumber: number) { writeFileSync( '.env', `############ THIS FILE IS GENERATED ############ -# run "node prepare-test-env.js" to regenerate # +# run "npx tsx prepare-test-env.ts" to regenerate # ################################################ # blockchain node to use as the reference for the local fork From b660ee11a663f4651146f90ce2bf8c316d9b003e Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Fri, 25 Apr 2025 12:14:43 +0200 Subject: [PATCH 24/27] fix: update changelog for integration tests migration to GitHub Actions --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9030d04..3b4e401 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## vNEXT -- Remove unused files (#42) +- Migrate integration tests from Jenkins to GitHub Actions. (#44) +- Remove unused files to streamline the repository. (#42) - Rewrite Jenkins CI for future migration (#36, #37) - Add a modern test stack, agnostic to the forked network. (#38) - Add a section in the README to explain how to use the Docker-based subgraph deployer. (#38) From 124a15bb7159e0a99688e93e5964b2a0575106cd Mon Sep 17 00:00:00 2001 From: Robin Le Caignec <72495599+Le-Caignec@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:21:06 +0200 Subject: [PATCH 25/27] fix: streamline test stack preparation in CI workflow (#46) --- .github/workflows/main.yml | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 67aa9d9..87d6118 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,24 +42,8 @@ jobs: - name: Run unit tests run: npm run test:unit - - name: Prepare local stack env - id: prepare - run: npx tsx ./test-stack/prepare-test-env.ts - - - name: Fetch genesis block number - id: fetch_block - run: | - source .env - echo "BLOCK=$FORK_BLOCK" >> $GITHUB_OUTPUT - echo "URL=$FORK_URL" >> $GITHUB_OUTPUT - - - name: Start local stack - uses: hoverkraft-tech/compose-action@v2.2.0 - with: - compose-file: "./test-stack/docker-compose.yml" - env: - FORK_URL: ${{ steps.fetch_block.outputs.URL }} - FORK_BLOCK: ${{ steps.fetch_block.outputs.BLOCK }} + - name: Prepare test stack + run: npm run start-test-stack - name: Run integration tests run: npm run test:e2e From cebad13e95962555c0a626d45b78b6aca7cac12a Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Fri, 25 Apr 2025 12:21:34 +0200 Subject: [PATCH 26/27] fix: remove NETWORK_NAME environment variable from job level in CI workflow --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 87d6118..9a104ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,8 +17,6 @@ concurrency: jobs: build-and-test: runs-on: ubuntu-latest - env: - NETWORK_NAME: "bellecour" steps: - name: Checkout From 874e4c0f0247880a5d585fef8debd07c240c2640 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Fri, 25 Apr 2025 12:28:01 +0200 Subject: [PATCH 27/27] fix: update .env generation message in prepare-test-env script --- test-stack/prepare-test-env.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test-stack/prepare-test-env.ts b/test-stack/prepare-test-env.ts index ea597e9..db57d21 100644 --- a/test-stack/prepare-test-env.ts +++ b/test-stack/prepare-test-env.ts @@ -35,14 +35,14 @@ async function createEnvFiles(forkBlockNumber: number) { console.log('Creating .env file for docker-compose test-stack'); writeFileSync( '.env', - `############ THIS FILE IS GENERATED ############ -# run "npx tsx prepare-test-env.ts" to regenerate # -################################################ - -# blockchain node to use as the reference for the local fork -FORK_URL=${forkUrl} -# block number to fork from -FORK_BLOCK=${forkBlockNumber}`, + '############ THIS FILE IS GENERATED ############\n' + + '# run "node prepare-test-env.js" to regenerate #\n' + + '################################################\n' + + '\n' + + '# blockchain node to use as the reference for the local fork\n' + + `FORK_URL=${forkUrl}\n` + + '# block number to fork from\n' + + `FORK_BLOCK=${forkBlockNumber}\n`, ); }