From 73d4095fc2a9860aef24801e5b8e7ac79d657d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Fri, 29 Nov 2024 09:01:58 +0100 Subject: [PATCH] ci: re-enable cdk e2e tests (#400) * ci: enable cdk tests * fix: e2e tests * fix: issue with tests * ci: fix * ci: update workflow triggers and add timeout * fix: typo * test with full sha * ci: fix * ci: fix dir * ci: fix * ci: update go cache * chore: nit * ci: increase test timeouts * fix: run pessimistic tests only if the SP1 private key is available * docs: nit * test * ci: fix * ci: simplify workflow * ci: fix * fix: dir * fix: go cache * test: run cdk e2e tests in without-args repo * Revert "test: run cdk e2e tests in without-args repo" This reverts commit 7f5244a544ce37842e5c2d46af0f73e2ef06a042. * chore: nit * fix: attempt --- .github/workflows/cdk-e2e.yml | 101 ------------------------ .github/workflows/test.yml | 140 ++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 101 deletions(-) delete mode 100644 .github/workflows/cdk-e2e.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/cdk-e2e.yml b/.github/workflows/cdk-e2e.yml deleted file mode 100644 index cecb0ca9..00000000 --- a/.github/workflows/cdk-e2e.yml +++ /dev/null @@ -1,101 +0,0 @@ -# name: Test e2e -# on: -# pull_request: -# push: -# branches: [main] -# workflow_dispatch: {} - -# jobs: -# test-e2e: -# strategy: -# fail-fast: false -# matrix: -# go-version: [ 1.22.x ] -# goarch: [ "amd64" ] -# e2e-group: -# - "fork9-validium" -# - "fork11-rollup" -# - "fork12-validium" -# - "fork12-rollup" -# runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 - -# - name: Install Go -# uses: actions/setup-go@v5 -# with: -# go-version: ${{ matrix.go-version }} -# env: -# GOARCH: ${{ matrix.goarch }} - -# - name: Install kurtosis -# shell: bash -# run: | -# echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list -# sudo apt update -# sudo apt install kurtosis-cli=1.4.1 -# kurtosis version - -# - name: Disable kurtosis analytics -# shell: bash -# run: kurtosis analytics disable - -# - name: Install yq -# shell: bash -# run: | -# pip3 install yq -# yq --version - -# - name: Install polycli -# run: | -# POLYCLI_VERSION="v0.1.63" -# tmp_dir=$(mktemp -d) -# curl -L "https://github.com/0xPolygon/polygon-cli/releases/download/${POLYCLI_VERSION}/polycli_${POLYCLI_VERSION}_linux_amd64.tar.gz" | tar -xz -C "$tmp_dir" -# mv "$tmp_dir"/* /usr/local/bin/polycli -# rm -rf "$tmp_dir" -# sudo chmod +x /usr/local/bin/polycli -# /usr/local/bin/polycli version - -# - name: Install foundry -# uses: foundry-rs/foundry-toolchain@v1 - -# - name: checkout polygon-cdk -# uses: actions/checkout@v4 -# with: -# repository: 0xPolygon/cdk -# path: "cdk" -# ref: "v0.4.0-beta10" - -# - name: Build Docker -# run: make build-docker -# working-directory: ${{ github.workspace }}/cdk - -# - name: Setup Bats and bats libs -# uses: bats-core/bats-action@2.0.0 - -# - name: Test -# run: make test-e2e-${{ matrix.e2e-group }} -# working-directory: ./cdk/test -# env: -# KURTOSIS_FOLDER: ${{ github.workspace }} -# BATS_LIB_PATH: /usr/lib/ - -# - name: Dump enclave logs -# if: failure() -# run: kurtosis dump ./dump - -# - name: Generate archive name -# if: failure() -# run: | -# archive_name="dump_run_with_args_${{matrix.e2e-group}}_${{ github.run_id }}" -# echo "ARCHIVE_NAME=${archive_name}" >> "$GITHUB_ENV" -# echo "Generated archive name: ${archive_name}" -# kurtosis service exec cdk cdk-node-001 'cat /etc/cdk/cdk-node-config.toml' > ./dump/cdk-node-config.toml - -# - name: Upload logs -# if: failure() -# uses: actions/upload-artifact@v4 -# with: -# name: ${{ env.ARCHIVE_NAME }} -# path: ./dump diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..f9b8c08f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,140 @@ +--- +# A copy/paste of the cdk node e2e tests with small changes to make in work in the kurtosis-cdk repository. +# https://github.com/0xPolygon/cdk/blob/main/.github/workflows/test-e2e.yml +name: Test + +on: + pull_request: + push: + branches: [main] + +concurrency: + group: test-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + POLYCLI_VERSION: v0.1.64 + CDK_VERSION: a6422912423e05f8b1494a3959de000e992499f9 # https://github.com/0xPolygon/cdk/commit/a6422912423e05f8 + +jobs: + build-cdk-image: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + + - name: Checkout cdk repository + uses: actions/checkout@v4 + with: + repository: 0xPolygon/cdk + path: cdk + ref: ${{ env.CDK_VERSION }} + + - uses: actions/setup-go@v5 + with: + go-version: 1.22.x + cache-dependency-path: cdk/go.sum + + - name: Build cdk docker image + working-directory: cdk + run: make build-docker + + - name: Save cdk image to archive + run: docker save --output /tmp/cdk.tar cdk + + - name: Upload archive + uses: actions/upload-artifact@v4 + with: + name: cdk + path: /tmp/cdk.tar + + cdk-e2e-tests: + runs-on: ubuntu-latest + timeout-minutes: 45 + needs: build-cdk-image + strategy: + fail-fast: false + matrix: + e2e-group: + - "fork9-validium" + - "fork11-rollup" + - "fork12-validium" + - "fork12-rollup" + - "fork12-pessimistic" + steps: + - uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk + + - name: Install polycli + run: | + tmp_dir=$(mktemp -d) + curl -L "https://github.com/0xPolygon/polygon-cli/releases/download/${{ env.POLYCLI_VERSION }}/polycli_${{ env.POLYCLI_VERSION }}_linux_amd64.tar.gz" | tar -xz -C "$tmp_dir" + mv "$tmp_dir"/* /usr/local/bin/polycli + rm -rf "$tmp_dir" + sudo chmod +x /usr/local/bin/polycli + /usr/local/bin/polycli version + + - name: Checkout cdk repository + uses: actions/checkout@v4 + with: + repository: 0xPolygon/cdk + path: cdk + ref: ${{ env.CDK_VERSION }} + + - name: Setup bats + uses: bats-core/bats-action@3.0.0 + + - name: Download cdk archive + uses: actions/download-artifact@v4 + with: + name: cdk + path: /tmp + + - name: Load cdk image + run: | + docker load --input /tmp/cdk.tar + docker image ls -a + + - name: Run e2e tests + working-directory: cdk/test + run: make test-e2e-${{ matrix.e2e-group }} + # Some of the test environments, the pessimistic envs, require the SP1 private key. + # This check makes sure that such environments will be tested only if the necessary secrets + # are available, preventing failures on pull requests from forked repositories. + if: ${{ !contains(matrix.e2e-group, 'pessimistic') || (contains(matrix.e2e-group, 'pessimistic') && env.agglayer_prover_sp1_key) }} + env: + KURTOSIS_FOLDER: ${{ github.workspace }} + BATS_LIB_PATH: /usr/lib/ + agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }} + + - name: Dump enclave + if: failure() + run: kurtosis enclave dump cdk ./dump + + - name: Generate archive name + if: failure() + run: | + archive_name="dump_cdk_e2e_test_${{matrix.e2e-group}}_${{ github.run_id }}" + echo "ARCHIVE_NAME=${archive_name}" >> "$GITHUB_ENV" + echo "Generated archive name: ${archive_name}" + + - name: Upload logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARCHIVE_NAME }} + path: ./dump