From 3ca2b010d1efa0a06ef838e5d299a9ba567ffd08 Mon Sep 17 00:00:00 2001 From: Artyom Veremeenko Date: Mon, 2 Jun 2025 19:01:15 +0300 Subject: [PATCH 1/7] feat: docker image with integration tests and flow to build it --- .dockerignore | 30 ++++++++++++++ .../tests-integration-build-image.yml | 40 +++++++++++++++++++ Dockerfile | 25 ++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/tests-integration-build-image.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..5a568045af --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +.env + +artifacts/ +cache/ +coverage/ +node_modules/ +typechain-types/ + +docs/ +foundry/ +./*.md +foundry.toml +pyproject.toml + +test/* +!test/common +!test/deploy +!test/hooks +!test/integration +!test/suite + +deployed-*.json +upgrade-parameters-mainnet.json + +.husky/ +.github/ + +.idea/ +.vscode/ +.yarn/ diff --git a/.github/workflows/tests-integration-build-image.yml b/.github/workflows/tests-integration-build-image.yml new file mode 100644 index 0000000000..af5804b9ef --- /dev/null +++ b/.github/workflows/tests-integration-build-image.yml @@ -0,0 +1,40 @@ +name: Build and push integration tests image + +on: + push: + branches: + - feat/docker-tests + +permissions: + contents: read + packages: write + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push mainnet fork image + uses: docker/build-push-action@v6.1.0 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/lidofinance/core-integration-tests:${{ github.ref_name }} + build-args: | + HH_CONFIG=hardhat.config.mainnet-fork.ts diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..c60159138c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# syntax=docker/dockerfile:1 +# Build an image with core integration tests + +ARG NODE_VERSION=lts +FROM node:${NODE_VERSION}-alpine + +ENV NODE_ENV=production + +WORKDIR /app + +COPY . . + +RUN corepack enable \ + && corepack prepare "yarn@$(node -p "require('./package.json').packageManager.split('@')[1]")" --activate + +# Use bind mounts for yarn.lock and package.json only during dependency resolution +# Use a cache mount to speed up repeated dependency installs +RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \ + --mount=type=bind,source=package.json,target=package.json \ + --mount=type=bind,source=yarn.lock,target=yarn.lock \ + yarn install --immutable + +RUN yarn compile + +CMD ["yarn", "test:integration"] From 8203203abf13cbb6c616690d14b045c0e1b7cc92 Mon Sep 17 00:00:00 2001 From: Artyom Veremeenko Date: Mon, 2 Jun 2025 19:03:35 +0300 Subject: [PATCH 2/7] fix: docker image flow --- .github/workflows/tests-integration-build-image.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests-integration-build-image.yml b/.github/workflows/tests-integration-build-image.yml index af5804b9ef..a3a7ad791a 100644 --- a/.github/workflows/tests-integration-build-image.yml +++ b/.github/workflows/tests-integration-build-image.yml @@ -29,12 +29,10 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push mainnet fork image + - name: Build and push the image uses: docker/build-push-action@v6.1.0 with: context: . platforms: linux/amd64,linux/arm64 push: true - tags: ghcr.io/lidofinance/core-integration-tests:${{ github.ref_name }} - build-args: | - HH_CONFIG=hardhat.config.mainnet-fork.ts + tags: ghcr.io/lidofinance/core-integration-tests:latest From d735bddd63394f21dd1f485ccc14085eab78e905 Mon Sep 17 00:00:00 2001 From: Artyom Veremeenko Date: Mon, 2 Jun 2025 19:39:22 +0300 Subject: [PATCH 3/7] chore: temporarily run only one integration tests (for debug) --- test/integration/core/happy-path.integration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/core/happy-path.integration.ts b/test/integration/core/happy-path.integration.ts index 303dd40bbf..7d9c2c791a 100644 --- a/test/integration/core/happy-path.integration.ts +++ b/test/integration/core/happy-path.integration.ts @@ -20,7 +20,7 @@ import { LogDescriptionExtended } from "../../../lib/protocol/types"; const AMOUNT = ether("100"); -describe("Scenario: Protocol Happy Path", () => { +describe.only("Scenario: Protocol Happy Path", () => { let ctx: ProtocolContext; let snapshot: string; From 39d6edad4816574d293343ab7d1748bd5d91f460 Mon Sep 17 00:00:00 2001 From: Artyom Veremeenko Date: Mon, 2 Jun 2025 20:02:30 +0300 Subject: [PATCH 4/7] feat: update test-integration-mainnet.yml to use docker image --- .github/workflows/tests-integration-mainnet.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests-integration-mainnet.yml b/.github/workflows/tests-integration-mainnet.yml index f331df746c..fb28fb277c 100644 --- a/.github/workflows/tests-integration-mainnet.yml +++ b/.github/workflows/tests-integration-mainnet.yml @@ -49,9 +49,11 @@ jobs: env: RPC_URL: http://localhost:8555 - - name: Run integration tests - run: yarn test:integration - env: - LOG_LEVEL: debug - RPC_URL: http://localhost:8555 - NETWORK_STATE_FILE: deployed-mainnet-upgrade.json + - name: Run Core Integration Tests + run: | + docker run \ + --env RPC_URL=http://localhost:8555 \ + --env NETWORK_STATE_FILE=deployed-mainnet-upgrade.json \ + -v $(pwd)/deployed-mainnet-upgrade.json:/app/deployed-mainnet-upgrade.json \ + -it \ + ghcr.io/lidofinance/core-integration-tests:latest From 7ebc591cc69c9b75f32cf36d85690a686b52f798 Mon Sep 17 00:00:00 2001 From: Artyom Veremeenko Date: Mon, 2 Jun 2025 20:15:06 +0300 Subject: [PATCH 5/7] feat: docker image with integration tests and flow to build it --- ...uild-image.yml => tests-integration-build-image.yml.disabled} | 0 .github/workflows/tests-integration-mainnet.yml | 1 - 2 files changed, 1 deletion(-) rename .github/workflows/{tests-integration-build-image.yml => tests-integration-build-image.yml.disabled} (100%) diff --git a/.github/workflows/tests-integration-build-image.yml b/.github/workflows/tests-integration-build-image.yml.disabled similarity index 100% rename from .github/workflows/tests-integration-build-image.yml rename to .github/workflows/tests-integration-build-image.yml.disabled diff --git a/.github/workflows/tests-integration-mainnet.yml b/.github/workflows/tests-integration-mainnet.yml index fb28fb277c..49fef082a4 100644 --- a/.github/workflows/tests-integration-mainnet.yml +++ b/.github/workflows/tests-integration-mainnet.yml @@ -55,5 +55,4 @@ jobs: --env RPC_URL=http://localhost:8555 \ --env NETWORK_STATE_FILE=deployed-mainnet-upgrade.json \ -v $(pwd)/deployed-mainnet-upgrade.json:/app/deployed-mainnet-upgrade.json \ - -it \ ghcr.io/lidofinance/core-integration-tests:latest From 1f0beed3ba529a5b14cbd693786bd077439f8096 Mon Sep 17 00:00:00 2001 From: Artyom Veremeenko Date: Mon, 2 Jun 2025 20:21:10 +0300 Subject: [PATCH 6/7] feat: docker image with integration tests and flow to build it --- .github/workflows/tests-integration-mainnet.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests-integration-mainnet.yml b/.github/workflows/tests-integration-mainnet.yml index 49fef082a4..390724456b 100644 --- a/.github/workflows/tests-integration-mainnet.yml +++ b/.github/workflows/tests-integration-mainnet.yml @@ -52,7 +52,8 @@ jobs: - name: Run Core Integration Tests run: | docker run \ - --env RPC_URL=http://localhost:8555 \ + --env RPC_URL=http://host.docker.internal:8555 \ --env NETWORK_STATE_FILE=deployed-mainnet-upgrade.json \ + -i \ -v $(pwd)/deployed-mainnet-upgrade.json:/app/deployed-mainnet-upgrade.json \ ghcr.io/lidofinance/core-integration-tests:latest From bd33f69518349fc6da8075958905ca6f6a366cf2 Mon Sep 17 00:00:00 2001 From: Artyom Veremeenko Date: Mon, 2 Jun 2025 20:41:59 +0300 Subject: [PATCH 7/7] feat: docker image with integration tests and flow to build it --- .github/workflows/tests-integration-mainnet.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests-integration-mainnet.yml b/.github/workflows/tests-integration-mainnet.yml index 390724456b..f787170b26 100644 --- a/.github/workflows/tests-integration-mainnet.yml +++ b/.github/workflows/tests-integration-mainnet.yml @@ -54,6 +54,8 @@ jobs: docker run \ --env RPC_URL=http://host.docker.internal:8555 \ --env NETWORK_STATE_FILE=deployed-mainnet-upgrade.json \ + --add-host=host.docker.internal:host-gateway \ -i \ -v $(pwd)/deployed-mainnet-upgrade.json:/app/deployed-mainnet-upgrade.json \ ghcr.io/lidofinance/core-integration-tests:latest + # host.docker.internal:host-gateway is workaround for accessing host on linux