From 87ec9dff019db4e68f3b356c77c653c49754854f Mon Sep 17 00:00:00 2001 From: Martin Paulucci Date: Thu, 28 Nov 2024 20:14:23 +0100 Subject: [PATCH] ci(core): standarize all CIs with required checks (#1334) **Motivation** Required checks in Github works in a weird way, it is based on the job name. So we will define a couple of required checks: - Lint - Test - Build Docker - Integration Test Each team will have one or more workflow, prepended with "ci_". There they need to define all the above jobs. If there are multiple jobs with the same name, they are all required. For the merge queue, we keep it minimal and aim only to avoid breaking changes that should be caught by the Rust compiler or linter. We don't want to run heavy integration tests since those will be run on the push event anyway. **Description** - Standardized ci workflows - Standardized job names - Simplified Hive to don't overuse makefiles (we don't need the build capabilities) - Added Integration Test job - Re-added ci-skipped workflow for documentation changes. --- .github/workflows/ci.yaml | 75 ------- .github/workflows/ci_l1.yaml | 203 ++++++++++++++++++ .github/workflows/ci_l2.yaml | 6 +- ...l2_contracts.yaml => ci_l2_contracts.yaml} | 8 +- .../{l2_prover_ci.yaml => ci_l2_prover.yaml} | 9 +- .github/workflows/ci_levm.yaml | 10 +- .github/workflows/ci_skipped.yaml | 37 ++++ .github/workflows/hive_coverage.yaml | 31 +-- .github/workflows/integration.yaml | 117 ---------- Makefile | 3 - 10 files changed, 275 insertions(+), 224 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/ci_l1.yaml rename .github/workflows/{l2_contracts.yaml => ci_l2_contracts.yaml} (87%) rename .github/workflows/{l2_prover_ci.yaml => ci_l2_prover.yaml} (90%) create mode 100644 .github/workflows/ci_skipped.yaml delete mode 100644 .github/workflows/integration.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 8e3cf7a5f2..0000000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,75 +0,0 @@ -name: CI -on: - push: - branches: ["main"] - merge_group: - pull_request: - branches: ["**"] - # paths-ignore: - # - "README.md" - # - "LICENSE" - # - "**/README.md" - # - "**/docs/**" - # - "crates/vm/levm/**" # We run this in a separate workflow - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -env: - RUST_VERSION: 1.81.0 - -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Rustup toolchain install - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_VERSION }} - components: rustfmt, clippy - - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 - - - name: Run cargo check - run: cargo check - - - name: Run cargo build - run: | - cargo build - - - name: Run cargo clippy - run: | - cargo clippy --all-targets --all-features --workspace --exclude ethrex-prover -- -D warnings - - - name: Run cargo fmt - run: | - cargo fmt --all -- --check - - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Rustup toolchain install - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_VERSION }} - - - name: Caching - uses: Swatinem/rust-cache@v2 - - - name: Download test vectors - run: | - make download-test-vectors - - - name: Run tests - run: | - make test diff --git a/.github/workflows/ci_l1.yaml b/.github/workflows/ci_l1.yaml new file mode 100644 index 0000000000..0a0292453b --- /dev/null +++ b/.github/workflows/ci_l1.yaml @@ -0,0 +1,203 @@ +name: L1 +on: + push: + branches: ["main"] + merge_group: + pull_request: + branches: ["**"] + paths-ignore: + - "README.md" + - "LICENSE" + - "**/README.md" + - "**/docs/**" + - "crates/vm/levm/**" # We run this in a separate workflow + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + RUST_VERSION: 1.81.0 + +jobs: + lint: + # "Lint" is a required check, don't change the name + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Rustup toolchain install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_VERSION }} + components: rustfmt, clippy + + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Run cargo check + run: cargo check + + - name: Run cargo build + run: | + cargo build + + - name: Run cargo clippy + run: | + cargo clippy --all-targets --all-features --workspace --exclude ethrex-prover -- -D warnings + + - name: Run cargo fmt + run: | + cargo fmt --all -- --check + + test: + # "Test" is a required check, don't change the name + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Rustup toolchain install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_VERSION }} + + - name: Caching + uses: Swatinem/rust-cache@v2 + + - name: Download test vectors + run: | + make download-test-vectors + + - name: Run tests + run: | + make test + + docker_build: + # "Build Docker" is a required check, don't change the name + name: Build Docker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + load: true + tags: ethrex + outputs: type=docker,dest=/tmp/ethrex_image.tar + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ethrex_image + path: /tmp/ethrex_image.tar + + run-assertoor: + name: Assertoor - Stability Check + runs-on: ubuntu-latest + needs: [docker_build] + if: ${{ github.event_name != 'merge_group' }} + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: ethrex_image + path: /tmp + + - name: Load image + run: | + docker load --input /tmp/ethrex_image.tar + + - name: Setup kurtosis testnet and run assertoor tests + uses: ethpandaops/kurtosis-assertoor-github-action@v1 + with: + kurtosis_version: "1.4.2" + ethereum_package_url: "github.com/lambdaclass/ethereum-package" + ethereum_package_branch: "ethrex-integration" + ethereum_package_args: "./test_data/network_params.yaml" + + run-hive: + name: Hive - ${{ matrix.name }} + runs-on: ubuntu-latest + needs: [docker_build] + if: ${{ github.event_name != 'merge_group' }} + strategy: + matrix: + include: + - name: "Rpc Compat tests" + simulation: ethereum/rpc-compat + test_pattern: /eth_chainId|eth_getTransactionByBlockHashAndIndex|eth_getTransactionByBlockNumberAndIndex|eth_getCode|eth_getStorageAt|eth_call|eth_getTransactionByHash|eth_getBlockByHash|eth_getBlockByNumber|eth_createAccessList|eth_getBlockTransactionCountByNumber|eth_getBlockTransactionCountByHash|eth_getBlockReceipts|eth_getTransactionReceipt|eth_blobGasPrice|eth_blockNumber|ethGetTransactionCount|debug_getRawHeader|debug_getRawBlock|debug_getRawTransaction|debug_getRawReceipts|eth_estimateGas|eth_getBalance|eth_sendRawTransaction|eth_getProof|eth_getLogs + - name: "Devp2p discv4 tests" + simulation: devp2p + test_pattern: discv4 + - name: "Devp2p snap tests" + simulation: devp2p + test_pattern: /AccountRange|StorageRanges|ByteCodes|TrieNodes + - name: "Devp2p eth tests" + simulation: devp2p + test_pattern: eth/Status|GetBlockHeaders|SimultaneousRequests|SameRequestID|ZeroRequestID|GetBlockBodies|MaliciousHandshake|MaliciousStatus|Transaction|InvalidTxs + - name: "Engine Auth and EC tests" + simulation: ethereum/engine + test_pattern: engine-(auth|exchange-capabilities)/ + - name: "Cancun Engine tests" + simulation: ethereum/engine + test_pattern: engine-cancun/Blob Transactions On Block 1|Blob Transaction Ordering, Single|Blob Transaction Ordering, Multiple Accounts|Replace Blob Transactions|Parallel Blob Transactions|ForkchoiceUpdatedV3 Modifies Payload ID on Different Beacon Root|NewPayloadV3 After Cancun|NewPayloadV3 Versioned Hashes|Incorrect BlobGasUsed|Bad Hash|ParentHash equals BlockHash|RPC:|in ForkchoiceState|Unknown|Invalid PayloadAttributes|Unique|ForkchoiceUpdated Version on Payload Request|Re-Execute Payload|In-Order Consecutive Payload|Multiple New Payloads|Valid NewPayload->|NewPayload with|Payload Build after|Build Payload with|Invalid Missing Ancestor ReOrg, StateRoot|Re-Org Back to|Re-org to Previously|Safe Re-Org to Side Chain|Transaction Re-Org, Re-Org Back In|Re-Org Back into Canonical Chain, Depth=5|Suggested Fee Recipient Test|PrevRandao Opcode|Invalid NewPayload, [^R][^e]|Fork ID Genesis=0, Cancun=0|Fork ID Genesis=0, Cancun=1|Fork ID Genesis=1, Cancun=0|Fork ID Genesis=1, Cancun=2, Shanghai=2 + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: ethrex_image + path: /tmp + + - name: Load image + run: | + docker load --input /tmp/ethrex_image.tar + + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Rustup toolchain install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_VERSION }} + + - name: Setup Go + uses: actions/setup-go@v3 + + - name: Setup Hive + run: make setup-hive + + - name: Run Hive Simulation + run: cd hive && ./hive --client ethrex --sim ${{ matrix.simulation }} --sim.limit "${{ matrix.test_pattern }}" --sim.parallelism 4 + + # The purpose of this job is to add it as a required check in GitHub so that we don't have to add every individual job as a required check + all-tests: + # "Integration Test" is a required check, don't change the name + name: Integration Test + runs-on: ubuntu-latest + needs: [run-assertoor, run-hive] + # Make sure this job runs even if the previous jobs failed or were skipped + if: ${{ always() && needs.run-assertoor.result != 'skipped' && needs.run-hive.result != 'skipped' }} + steps: + - name: Check if any job failed + run: | + if [ "${{ needs.run-assertoor.result }}" != "success" ]; then + echo "Job Assertoor failed" + exit 1 + fi + + if [ "${{ needs.run-hive.result }}" != "success" ]; then + echo "Job Hive failed" + exit 1 + fi diff --git a/.github/workflows/ci_l2.yaml b/.github/workflows/ci_l2.yaml index 037bbe1eca..fb79774efe 100644 --- a/.github/workflows/ci_l2.yaml +++ b/.github/workflows/ci_l2.yaml @@ -1,8 +1,7 @@ -name: CI (L2) +name: L2 on: push: branches: ["main"] - merge_group: pull_request: branches: ["**"] paths: @@ -17,7 +16,8 @@ env: jobs: test: - name: Test + # "Integration Test" is a required check, don't change the name + name: Integration Test runs-on: ubuntu-latest steps: - name: Checkout sources diff --git a/.github/workflows/l2_contracts.yaml b/.github/workflows/ci_l2_contracts.yaml similarity index 87% rename from .github/workflows/l2_contracts.yaml rename to .github/workflows/ci_l2_contracts.yaml index 6baa158944..3e60939218 100644 --- a/.github/workflows/l2_contracts.yaml +++ b/.github/workflows/ci_l2_contracts.yaml @@ -1,8 +1,7 @@ -name: L2 Contracts CI +name: L2 Contracts on: push: branches: ["main"] - merge_group: pull_request: branches: ["**"] paths: @@ -13,8 +12,9 @@ concurrency: cancel-in-progress: true jobs: - test_compilation: - name: Compile Contracts + test: + # "Test" is a required check, don't change the name + name: Test runs-on: ubuntu-latest steps: - name: Checkout sources diff --git a/.github/workflows/l2_prover_ci.yaml b/.github/workflows/ci_l2_prover.yaml similarity index 90% rename from .github/workflows/l2_prover_ci.yaml rename to .github/workflows/ci_l2_prover.yaml index c0a1e8d456..125d720d33 100644 --- a/.github/workflows/l2_prover_ci.yaml +++ b/.github/workflows/ci_l2_prover.yaml @@ -1,8 +1,7 @@ -name: L2 Prover CI +name: L2 Prover on: push: branches: ["main"] - merge_group: pull_request: branches: ["**"] paths: @@ -14,6 +13,7 @@ concurrency: jobs: lint: + # "Lint" is a required check, don't change the name name: Lint runs-on: ubuntu-latest strategy: @@ -32,8 +32,9 @@ jobs: - name: ${{ matrix.action.command }} Command run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }} - build_and_test: - name: Build and Test RISC-V zkVM program + test: + # "Test" is a required check, don't change the name + name: Test runs-on: ubuntu-latest steps: - name: Checkout sources diff --git a/.github/workflows/ci_levm.yaml b/.github/workflows/ci_levm.yaml index 8f22d994b7..6cbe532574 100644 --- a/.github/workflows/ci_levm.yaml +++ b/.github/workflows/ci_levm.yaml @@ -1,9 +1,8 @@ -name: CI LEVM +name: LEVM on: push: branches: ["main"] - merge_group: pull_request: branches: ["**"] paths: @@ -19,7 +18,8 @@ env: jobs: ef-test: - name: EF Tests + # "Integration Test" is a required check, don't change the name + name: Integration Test runs-on: ubuntu-latest steps: - name: Checkout sources @@ -43,7 +43,8 @@ jobs: cd crates/vm/levm make run-evm-ef-tests test: - name: Tests + # "Test" is a required check, don't change the name + name: Test runs-on: ubuntu-latest steps: - name: Checkout sources @@ -87,6 +88,7 @@ jobs: cd crates/vm/levm make revm-comparison lint: + # "Lint" is a required check, don't change the name name: Lint runs-on: ubuntu-latest steps: diff --git a/.github/workflows/ci_skipped.yaml b/.github/workflows/ci_skipped.yaml new file mode 100644 index 0000000000..c650d209bb --- /dev/null +++ b/.github/workflows/ci_skipped.yaml @@ -0,0 +1,37 @@ +name: CI Skipped +on: + pull_request: + branches: ["**"] + paths: + - 'README.md' + - 'LICENSE' + - "**/README.md" + - "**/docs/**" +jobs: + lint: + # "Lint" is a required check, don't change the name + name: Lint + runs-on: ubuntu-latest + if: false + steps: [run: true] + + test: + # "Test" is a required check, don't change the name + name: Test + runs-on: ubuntu-latest + if: false + steps: [run: true] + + docker-build: + # "Build Docker" is a required check, don't change the name + name: Build Docker + runs-on: ubuntu-latest + if: false + steps: [run: true] + + all-tests: + # "Integration Test" is a required check, don't change the name + name: Integration Test + runs-on: ubuntu-latest + if: false + steps: [run: true] diff --git a/.github/workflows/hive_coverage.yaml b/.github/workflows/hive_coverage.yaml index 3b0af973fc..7aa36ec2a5 100644 --- a/.github/workflows/hive_coverage.yaml +++ b/.github/workflows/hive_coverage.yaml @@ -16,18 +16,18 @@ jobs: strategy: matrix: include: - - simulation: rpc-compat - name: "Rpc Compat tests" - run_command: make run-hive-on-latest SIMULATION=ethereum/rpc-compat HIVE_EXTRA_ARGS="--sim.parallelism 4" - - simulation: devp2p - name: "Devp2p eth tests" - run_command: make run-hive-on-latest SIMULATION=devp2p HIVE_EXTRA_ARGS="--sim.parallelism 4" - - simulation: engine - name: "Cancun Engine tests" - run_command: make run-hive-on-latest SIMULATION=ethereum/engine HIVE_EXTRA_ARGS="--sim.parallelism 4" - - simulation: sync - name: "Sync tests" - run_command: make run-hive-on-latest SIMULATION=ethereum/sync HIVE_EXTRA_ARGS="--sim.parallelism 4" + - name: "Rpc Compat tests" + file_name: rpc-compat + simulation: ethereum/rpc-compat + - name: "Devp2p eth tests" + file_name: devp2p + simulation: devp2p + - name: "Cancun Engine tests" + file_name: engine + simulation: ethereum/engine + - name: "Sync tests" + file_name: sync + simulation: ethereum/sync steps: - name: Pull image @@ -41,14 +41,17 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 + - name: Setup Hive + run: make setup-hive + - name: Run Hive Simulation - run: ${{ matrix.run_command }} + run: cd hive && ./hive --client ethrex --sim ${{ matrix.simulation }} --sim.parallelism 4 continue-on-error: true - name: Upload results uses: actions/upload-artifact@v4 with: - name: ${{ matrix.simulation }}_logs + name: ${{ matrix.file_name }}_logs path: hive/workspace/logs/*-*.json hive-report: diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml deleted file mode 100644 index 234470ca01..0000000000 --- a/.github/workflows/integration.yaml +++ /dev/null @@ -1,117 +0,0 @@ -name: Integration Test -on: - push: - branches: ["main"] - merge_group: - pull_request: - branches: ["**"] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -env: - RUST_VERSION: 1.81.0 - -jobs: - docker_build: - name: Docker Build image - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile - load: true - tags: ethrex - outputs: type=docker,dest=/tmp/ethrex_image.tar - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: ethrex_image - path: /tmp/ethrex_image.tar - - run-assertoor: - name: Assertoor - Stability Check - runs-on: ubuntu-latest - needs: [docker_build] - steps: - - uses: actions/checkout@v4 - - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: ethrex_image - path: /tmp - - - name: Load image - run: | - docker load --input /tmp/ethrex_image.tar - - - name: Setup kurtosis testnet and run assertoor tests - uses: ethpandaops/kurtosis-assertoor-github-action@v1 - with: - kurtosis_version: "1.4.2" - ethereum_package_url: "github.com/lambdaclass/ethereum-package" - ethereum_package_branch: "ethrex-integration" - ethereum_package_args: "./test_data/network_params.yaml" - - run-hive: - name: Hive - ${{ matrix.name }} - runs-on: ubuntu-latest - needs: [docker_build] - strategy: - matrix: - include: - - simulation: rpc-compat - name: "Rpc Compat tests" - run_command: make run-hive-on-latest SIMULATION=ethereum/rpc-compat TEST_PATTERN="/eth_chainId|eth_getTransactionByBlockHashAndIndex|eth_getTransactionByBlockNumberAndIndex|eth_getCode|eth_getStorageAt|eth_call|eth_getTransactionByHash|eth_getBlockByHash|eth_getBlockByNumber|eth_createAccessList|eth_getBlockTransactionCountByNumber|eth_getBlockTransactionCountByHash|eth_getBlockReceipts|eth_getTransactionReceipt|eth_blobGasPrice|eth_blockNumber|ethGetTransactionCount|debug_getRawHeader|debug_getRawBlock|debug_getRawTransaction|debug_getRawReceipts|eth_estimateGas|eth_getBalance|eth_sendRawTransaction|eth_getProof|eth_getLogs" - - simulation: rpc-auth - name: "Engine Auth tests" - run_command: make run-hive-on-latest SIMULATION=ethereum/engine TEST_PATTERN="auth/engine-auth" - - simulation: discv4 - name: "Devp2p discv4 tests" - run_command: make run-hive-on-latest SIMULATION=devp2p TEST_PATTERN="discv4" - - simulation: snap - name: "Devp2p snap tests" - run_command: make run-hive-on-latest SIMULATION=devp2p TEST_PATTERN="/AccountRange|StorageRanges|ByteCodes|TrieNodes" - - simulation: eth - name: "Devp2p eth tests" - run_command: make run-hive-on-latest SIMULATION=devp2p TEST_PATTERN="eth/Status|GetBlockHeaders|SimultaneousRequests|SameRequestID|ZeroRequestID|GetBlockBodies|MaliciousHandshake|MaliciousStatus|Transaction|InvalidTxs" - - simulation: engine - name: "Engine Auth and EC tests" - run_command: make run-hive-on-latest SIMULATION=ethereum/engine TEST_PATTERN="engine-(auth|exchange-capabilities)/" - - simulation: engine-cancun - name: "Cancun Engine tests" - run_command: make run-hive-on-latest SIMULATION=ethereum/engine HIVE_EXTRA_ARGS="--sim.parallelism 4" TEST_PATTERN="engine-cancun/Blob Transactions On Block 1|Blob Transaction Ordering, Single|Blob Transaction Ordering, Multiple Accounts|Replace Blob Transactions|Parallel Blob Transactions|ForkchoiceUpdatedV3 Modifies Payload ID on Different Beacon Root|NewPayloadV3 After Cancun|NewPayloadV3 Versioned Hashes|Incorrect BlobGasUsed|Bad Hash|ParentHash equals BlockHash|RPC:|in ForkchoiceState|Unknown|Invalid PayloadAttributes|Unique|ForkchoiceUpdated Version on Payload Request|Re-Execute Payload|In-Order Consecutive Payload|Multiple New Payloads|Valid NewPayload->|NewPayload with|Payload Build after|Build Payload with|Invalid Missing Ancestor ReOrg, StateRoot|Re-Org Back to|Re-org to Previously|Safe Re-Org to Side Chain|Transaction Re-Org, Re-Org Back In|Re-Org Back into Canonical Chain, Depth=5|Suggested Fee Recipient Test|PrevRandao Opcode|Invalid NewPayload, [^R][^e]|Fork ID Genesis=0, Cancun=0|Fork ID Genesis=0, Cancun=1|Fork ID Genesis=1, Cancun=0|Fork ID Genesis=1, Cancun=2, Shanghai=2" - steps: - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: ethrex_image - path: /tmp - - - name: Load image - run: | - docker load --input /tmp/ethrex_image.tar - - - name: Checkout sources - uses: actions/checkout@v3 - - - name: Rustup toolchain install - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_VERSION }} - - - name: Setup Go - uses: actions/setup-go@v3 - - - name: Run Hive Simulation - run: ${{ matrix.run_command }} diff --git a/Makefile b/Makefile index 38367ba893..b2b09eb0be 100644 --- a/Makefile +++ b/Makefile @@ -97,9 +97,6 @@ TEST_PATTERN ?= / run-hive: build-image setup-hive ## 🧪 Run Hive testing suite cd hive && ./hive --sim $(SIMULATION) --client ethrex --sim.limit "$(TEST_PATTERN)" -run-hive-on-latest: setup-hive ## 🧪 Run Hive testing suite with the latest docker image - cd hive && ./hive --sim $(SIMULATION) --client ethrex --sim.limit "$(TEST_PATTERN)" $(HIVE_EXTRA_ARGS) - run-hive-debug: build-image setup-hive ## 🐞 Run Hive testing suite in debug mode cd hive && ./hive --sim $(SIMULATION) --client ethrex --sim.limit "$(TEST_PATTERN)" --docker.output