From 62edb444204ba82f7b7d96f1fcca7a872b53c062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Thu, 30 May 2024 22:32:21 +0200 Subject: [PATCH] ci: introduce composite actions (#131) * ci: add setup composite action * nit * ci: add monitor composite action * ci: debug * chore: nit * chore: nit * chore: clean up * chore: use kurtosis minor version * chore: nit * fix: kurtosis cli version * chore: nit * chore: nit * chore: rename action * chore: nit * chore: nit --- .../monitor-cdk-verified-batches/action.yml | 21 +++ .../batch_verification_monitor.sh | 0 .github/actions/setup-kurtosis-cdk/action.yml | 33 ++++ .github/workflows/deploy.yml | 175 ++++++------------ 4 files changed, 106 insertions(+), 123 deletions(-) create mode 100644 .github/actions/monitor-cdk-verified-batches/action.yml rename {scripts => .github/actions/monitor-cdk-verified-batches}/batch_verification_monitor.sh (100%) create mode 100644 .github/actions/setup-kurtosis-cdk/action.yml diff --git a/.github/actions/monitor-cdk-verified-batches/action.yml b/.github/actions/monitor-cdk-verified-batches/action.yml new file mode 100644 index 00000000..83372bd7 --- /dev/null +++ b/.github/actions/monitor-cdk-verified-batches/action.yml @@ -0,0 +1,21 @@ +--- +name: monitor-cdk-verified-batches +description: Check that batches are being verified in a CDK environment + +inputs: + verified_batches_target: + description: The minimum number of batches to be verified + required: false + default: '30' + timeout: + description: The script timeout in seconds + required: false + default: '600' # 10 minutes + +runs: + using: "composite" + steps: + - name: Check that batches are being verified + working-directory: .github/actions/monitor-cdk-verified-batches + shell: bash + run: ./batch_verification_monitor.sh ${{ inputs.verified_batches_target }} ${{ inputs.timeout }} diff --git a/scripts/batch_verification_monitor.sh b/.github/actions/monitor-cdk-verified-batches/batch_verification_monitor.sh similarity index 100% rename from scripts/batch_verification_monitor.sh rename to .github/actions/monitor-cdk-verified-batches/batch_verification_monitor.sh diff --git a/.github/actions/setup-kurtosis-cdk/action.yml b/.github/actions/setup-kurtosis-cdk/action.yml new file mode 100644 index 00000000..db18683f --- /dev/null +++ b/.github/actions/setup-kurtosis-cdk/action.yml @@ -0,0 +1,33 @@ +--- +name: kurtosis-cdk-setup +description: Install tools to deploy the CDK stack with Kurtosis + +inputs: + kurtosis-version: + description: The version of kurtosis + required: false + default: '0.89.12' # https://github.com/kurtosis-tech/kurtosis/releases + +runs: + using: "composite" + steps: + - 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=${{ inputs.kurtosis-version }} + 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 foundry + uses: foundry-rs/foundry-toolchain@v1 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 09dcb0a1..2c2096cc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,47 +10,26 @@ concurrency: group: deploy-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true -env: - KURTOSIS_VERSION: 0.89.3 - GO_VERSION: 1.21 - BATCH_VERIFICATION_MONITOR_TARGET: 30 - BATCH_VERIFICATION_MONITOR_TIMEOUT: 600 # 10 minutes - jobs: # Deploy the CDK environment in one step, with the gas token feature enabled. monolithic: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version: 1.21 cache-dependency-path: scripts/zkevm-config-diff/go.sum - # Install tools. - - name: Install kurtosis - 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=${{ env.KURTOSIS_VERSION }} - kurtosis analytics disable - - - name: Install yq - run: pip3 install yq - - - name: Install foundry - uses: foundry-rs/foundry-toolchain@v1 - - # Deploy components. - - name: Enable gas token feature - run: yq -Y --in-place '.args.zkevm_use_gas_token_contract = true' params.yml + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk - name: Deploy Kurtosis CDK package run: kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . - - name: Check that batches are being verified - working-directory: ./scripts - run: ./batch_verification_monitor.sh ${{ env.BATCH_VERIFICATION_MONITOR_TARGET }} ${{ env.BATCH_VERIFICATION_MONITOR_TIMEOUT }} + - name: Monitor verified batches + uses: ./.github/actions/monitor-cdk-verified-batches # Compare configs. - name: Dump configs @@ -76,21 +55,9 @@ jobs: steps: - uses: actions/checkout@v4 - # Install tools. - - name: Install kurtosis - 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=${{ env.KURTOSIS_VERSION }} - kurtosis analytics disable - - - name: Install yq - run: pip3 install yq - - - name: Install foundry - uses: foundry-rs/foundry-toolchain@v1 + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk - # Deploy components. - name: Disable all deployment steps run: yq -Y --in-place 'with_entries(if .value | type == "boolean" then .value = false else . end)' params.yml @@ -159,9 +126,8 @@ jobs: kurtosis run --enclave cdk-v1 --args-file params.yml . yq -Y --in-place '.apply_workload = false' params.yml # reset - - name: Check that batches are being verified - working-directory: ./scripts - run: ./batch_verification_monitor.sh ${{ env.BATCH_VERIFICATION_MONITOR_TARGET }} ${{ env.BATCH_VERIFICATION_MONITOR_TIMEOUT }} + - name: Monitor verified batches + uses: ./.github/actions/monitor-cdk-verified-batches # Deploy the CDK environment without specifying any parameter file. @@ -170,46 +136,43 @@ jobs: steps: - uses: actions/checkout@v4 - # Install tools. - - name: Install kurtosis - 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=${{ env.KURTOSIS_VERSION }} - kurtosis analytics disable - - - name: Install foundry - uses: foundry-rs/foundry-toolchain@v1 + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk # Deploy components. - name: Deploy Kurtosis CDK package run: kurtosis run --enclave cdk-v1 --image-download always . - - name: Check that batches are being verified - working-directory: ./scripts - run: ./batch_verification_monitor.sh ${{ env.BATCH_VERIFICATION_MONITOR_TARGET }} ${{ env.BATCH_VERIFICATION_MONITOR_TIMEOUT }} + - name: Monitor verified batches + uses: ./.github/actions/monitor-cdk-verified-batches - # Deploy the CDK environment against a local l1 chain with pre-deployed zkevm contracts. - pre-deployed-contracts: + # Deploy the CDK environment with the gas token feature enabled. + gas-token: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # Install tools. - - name: Install kurtosis - 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=${{ env.KURTOSIS_VERSION }} - kurtosis analytics disable + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk + + - name: Enable gas token feature + run: yq -Y --in-place '.args.zkevm_use_gas_token_contract = true' params.yml - - name: Install yq - run: pip3 install yq + - name: Deploy Kurtosis CDK package + run: kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . - - name: Install foundry - uses: foundry-rs/foundry-toolchain@v1 + - name: Monitor verified batches + uses: ./.github/actions/monitor-cdk-verified-batches + + # Deploy the CDK environment against a local l1 chain with pre-deployed zkevm contracts. + pre-deployed-contracts: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk - # Deploy components. - name: Deploy L1 and zkEVM contracts run: | # Disable all deployment steps. @@ -242,29 +205,17 @@ jobs: kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . + - name: Monitor verified batches + uses: ./.github/actions/monitor-cdk-verified-batches + # Deploy a standalone permisionless node against Sepolia. permisionless-node: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # Install tools. - - name: Install kurtosis - 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=${{ env.KURTOSIS_VERSION }} - kurtosis analytics disable - - - name: Install yq - run: pip3 install yq - - - name: Install foundry - uses: foundry-rs/foundry-toolchain@v1 - - # Deploy components. - - name: Only deploy the permisionless node - run: yq -Y --in-place 'with_entries(if .key == "deploy_zkevm_permissionless_node" then .value = true elif .value | type == "boolean" then .value = false else . end)' params.yml + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk - name: Configure permisionless node parameters run: | @@ -272,7 +223,11 @@ jobs: yq -Y --in-place '.args.genesis_file = "templates/permissionless-node/test-genesis.json"' params.yml - name: Deploy the permisionless node - run: kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . + run: | + # Disable all steps except permisionless node. + yq -Y --in-place 'with_entries(if .key == "deploy_zkevm_permissionless_node" then .value = true elif .value | type == "boolean" then .value = false else . end)' params.yml + + kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . # Deploy the CDK environment in rollup mode (data availability). rollup-da-mode: @@ -280,30 +235,17 @@ jobs: steps: - uses: actions/checkout@v4 - # Install tools. - - name: Install kurtosis - 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=${{ env.KURTOSIS_VERSION }} - kurtosis analytics disable - - - name: Install yq - run: pip3 install yq + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk - - name: Install foundry - uses: foundry-rs/foundry-toolchain@v1 - - # Deploy components. - name: Set rollup data availability mode run: yq -Y --in-place '.args.data_availability_mode = "rollup"' params.yml - name: Deploy Kurtosis CDK package run: kurtosis run --enclave cdk-v1 --image-download always . - - name: Check that batches are being verified - working-directory: ./scripts - run: ./batch_verification_monitor.sh ${{ env.BATCH_VERIFICATION_MONITOR_TARGET }} ${{ env.BATCH_VERIFICATION_MONITOR_TIMEOUT }} + - name: Monitor verified batches + uses: ./.github/actions/monitor-cdk-verified-batches # Deploy the CDK environment in cdk-validium mode (data availability). cdk-validium-da-mode: @@ -311,27 +253,14 @@ jobs: steps: - uses: actions/checkout@v4 - # Install tools. - - name: Install kurtosis - 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=${{ env.KURTOSIS_VERSION }} - kurtosis analytics disable - - - name: Install yq - run: pip3 install yq - - - name: Install foundry - uses: foundry-rs/foundry-toolchain@v1 + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk - # Deploy components. - name: Set cdk-validium data availability mode run: yq -Y --in-place '.args.data_availability_mode = "cdk-validium"' params.yml - name: Deploy Kurtosis CDK package run: kurtosis run --enclave cdk-v1 --image-download always . - - name: Check that batches are being verified - working-directory: ./scripts - run: ./batch_verification_monitor.sh ${{ env.BATCH_VERIFICATION_MONITOR_TARGET }} ${{ env.BATCH_VERIFICATION_MONITOR_TIMEOUT }} + - name: Monitor verified batches + uses: ./.github/actions/monitor-cdk-verified-batches