From 4c109b5829b849b0010fe6a0a51b6683d1ef3a48 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 22 Apr 2024 15:58:15 +0200 Subject: [PATCH 1/3] Adding CI config to run integration tests Created two jobs: - Run Hardhat Node to run in the background - Run Integration Tests to run tests against forked mainnet --- .github/workflows/solidity.yaml | 32 ++++++++++++++++++++++++++++++++ solidity/hardhat.config.ts | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/solidity.yaml b/.github/workflows/solidity.yaml index 818e93d59..14e72aa31 100644 --- a/.github/workflows/solidity.yaml +++ b/.github/workflows/solidity.yaml @@ -115,6 +115,38 @@ jobs: - name: Test run: pnpm run test --no-compile + solidity-integration-test: + needs: [solidity-build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up pnpm + uses: pnpm/action-setup@v3 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version-file: "solidity/.nvmrc" + cache: "pnpm" + + - name: Install Dependencies + run: pnpm install --prefer-offline --frozen-lockfile + + - name: Download Build Artifacts + uses: actions/download-artifact@v4 + with: + name: solidity-build + path: solidity/ + + - name: Run Hardhat Node + run: | + npx hardhat node --no-deploy --fork ${{ secrets.MAINNET_CHAIN_API_URL }} --fork-block-number 19680873 & + while [[ -z $(lsof -i :8545 -t) ]]; do echo "Waiting for port 8545 to be open..."; sleep 10; done + + - name: Run Integration Tests + run: pnpm run test:integration --no-compile + solidity-deploy-dry-run: needs: [solidity-build] runs-on: ubuntu-latest diff --git a/solidity/hardhat.config.ts b/solidity/hardhat.config.ts index 1e52823fa..e8648507f 100644 --- a/solidity/hardhat.config.ts +++ b/solidity/hardhat.config.ts @@ -30,7 +30,7 @@ const config: HardhatUserConfig = { tags: ["allowStubs"], }, integration: { - url: "http://localhost:8545", + url: "http://127.0.0.1:8545", tags: ["allowStubs"], }, sepolia: { From 77ebe8771e8a19d57d8dd65671489ecf071dee68 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 26 Apr 2024 10:31:44 +0200 Subject: [PATCH 2/3] Using pnpm node:forking to launch hardhad node with forked mainnet --- .github/workflows/solidity.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/solidity.yaml b/.github/workflows/solidity.yaml index a2af4fc9b..918a34f4c 100644 --- a/.github/workflows/solidity.yaml +++ b/.github/workflows/solidity.yaml @@ -141,7 +141,7 @@ jobs: - name: Run Hardhat Node run: | - npx hardhat node --no-deploy --fork ${{ secrets.MAINNET_CHAIN_API_URL }} --fork-block-number 19680873 & + MAINNET_RPC_URL=${{ secrets.MAINNET_CHAIN_API_URL }} pnpm node:forking & while [[ -z $(lsof -i :8545 -t) ]]; do echo "Waiting for port 8545 to be open..."; sleep 10; done - name: Run Integration Tests From 9029aab7e41e69657f4a3c125d0f03a5276612ae Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 26 Apr 2024 10:52:10 +0200 Subject: [PATCH 3/3] Extracting MAINNET_RPC_URL to env config section --- .github/workflows/solidity.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/solidity.yaml b/.github/workflows/solidity.yaml index 918a34f4c..879d1e664 100644 --- a/.github/workflows/solidity.yaml +++ b/.github/workflows/solidity.yaml @@ -140,8 +140,10 @@ jobs: path: solidity/ - name: Run Hardhat Node + env: + MAINNET_RPC_URL: ${{ secrets.MAINNET_CHAIN_API_URL }} run: | - MAINNET_RPC_URL=${{ secrets.MAINNET_CHAIN_API_URL }} pnpm node:forking & + pnpm node:forking & while [[ -z $(lsof -i :8545 -t) ]]; do echo "Waiting for port 8545 to be open..."; sleep 10; done - name: Run Integration Tests