Skip to content

Commit

Permalink
test: split sim tests to multiple jobs (#6437)
Browse files Browse the repository at this point in the history
* Reuse build actions

* Split sim tests to multiple jobs

* Improve sim test build time with cache

* Lint edited files

---------

Co-authored-by: Nico Flaig <nflaig@protonmail.com>
  • Loading branch information
nazarhussain and nflaig committed Feb 16, 2024
1 parent d01c542 commit 17b4fde
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 178 deletions.
58 changes: 58 additions & 0 deletions .github/actions/setup-and-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Setup and build the repo"
description: "A task to reuse setup steps during multiple jobs"
inputs:
node:
description: Node version
required: true

runs:
using: "composite"
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{inputs.node}}
check-latest: true
cache: yarn

- name: Node.js version
id: node
shell: bash
run: echo "v8CppApiVersion=$(node --print "process.versions.modules")" >> $GITHUB_OUTPUT

- name: Restore build
uses: actions/cache/restore@v4
id: cache-build-restore
with:
path: |
node_modules
packages/*/node_modules
lib/
packages/*/lib
packages/*/.git-data.json
key: ${{ runner.os }}-node-${{ inputs.node }}-${{ github.sha }}

- name: Install & build
if: steps.cache-build-restore.outputs.cache-hit != 'true'
shell: bash
run: yarn install --frozen-lockfile && yarn build

- name: Build
if: steps.cache-build-restore.outputs.cache-hit == 'true'
shell: bash
run: yarn build

- name: Check Build
shell: bash
run: yarn check-build

- name: Cache build artifacts
uses: actions/cache@master
with:
path: |
node_modules
packages/*/node_modules
lib/
packages/*/lib
packages/*/.git-data.json
key: ${{ runner.os }}-node-${{ inputs.node }}-${{ github.sha }}
157 changes: 118 additions & 39 deletions .github/workflows/test-sim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,84 +17,163 @@ on:
required: false
default: ""
genesisDelaySlots:
description: 'Number of slots delay before genesis'
description: "Number of slots delay before genesis"
required: true
type: number
default: 40

jobs:
tests-sim:
name: Sim tests
build:
name: Build
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
# <common-build> - Uses YAML anchors in the future
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: "./.github/actions/setup-and-build"
with:
node-version: 20
check-latest: true
cache: yarn
- name: Node.js version
id: node
run: echo "v8CppApiVersion=$(node --print "process.versions.modules")" >> $GITHUB_OUTPUT
- name: Restore dependencies
uses: actions/cache@master
id: cache-deps
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-${{ steps.node.outputs.v8CppApiVersion }}-${{ hashFiles('**/yarn.lock', '**/package.json') }}
- name: Install & build
if: steps.cache-deps.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile && yarn build
- name: Build
run: yarn build
if: steps.cache-deps.outputs.cache-hit == 'true'
# </common-build>
node: 20

- name: Load env variables
sim-test-multifork:
name: Multifork sim test
needs: build
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
# <common-build> - Uses YAML anchors in the future
- uses: actions/checkout@v4
- uses: "./.github/actions/setup-and-build"
with:
node: 20
- name: Load env variables
uses: ./.github/actions/dotenv

- name: Download required docker images before running tests
run: |
docker pull ${{env.GETH_DOCKER_IMAGE}}
docker pull ${{env.LIGHTHOUSE_DOCKER_IMAGE}}
docker pull ${{env.NETHERMIND_DOCKER_IMAGE}}
- name: Sim tests multifork
run: DEBUG='${{github.event.inputs.debug}}' yarn test:sim:multifork
working-directory: packages/cli
env:
env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}
- name: Upload debug log test files for "packages/cli"
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: sim-test-multifork-logs
path: packages/cli/test-logs

sim-test-endpoints:
name: Endpoint sim tests
needs: build
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
# <common-build> - Uses YAML anchors in the future
- uses: actions/checkout@v4
- uses: "./.github/actions/setup-and-build"
with:
node: 20
- name: Load env variables
uses: ./.github/actions/dotenv
- name: Download required docker images before running tests
run: |
docker pull ${{env.GETH_DOCKER_IMAGE}}
docker pull ${{env.LIGHTHOUSE_DOCKER_IMAGE}}
docker pull ${{env.NETHERMIND_DOCKER_IMAGE}}
- name: Sim tests endpoints
run: DEBUG='${{github.event.inputs.debug}}' yarn test:sim:endpoints
working-directory: packages/cli
env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}
env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}
- name: Upload debug log test files for "packages/cli"
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: sim-test-endpoints-logs
path: packages/cli/test-logs

sim-test-deneb:
name: Deneb sim tests
needs: build
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
# <common-build> - Uses YAML anchors in the future
- uses: actions/checkout@v4
- uses: "./.github/actions/setup-and-build"
with:
node: 20
- name: Load env variables
uses: ./.github/actions/dotenv
- name: Download required docker images before running tests
run: |
docker pull ${{env.GETH_DOCKER_IMAGE}}
docker pull ${{env.LIGHTHOUSE_DOCKER_IMAGE}}
docker pull ${{env.NETHERMIND_DOCKER_IMAGE}}
- name: Sim tests deneb
run: DEBUG='${{github.event.inputs.debug}}' yarn test:sim:deneb
working-directory: packages/cli
env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}
env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}
- name: Upload debug log test files for "packages/cli"
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: sim-test-deneb-logs
path: packages/cli/test-logs

sim-test-eth-backup-provider:
name: Eth backup provider sim tests
needs: build
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
# <common-build> - Uses YAML anchors in the future
- uses: actions/checkout@v4
- uses: "./.github/actions/setup-and-build"
with:
node: 20
- name: Load env variables
uses: ./.github/actions/dotenv
- name: Download required docker images before running tests
run: |
docker pull ${{env.GETH_DOCKER_IMAGE}}
docker pull ${{env.LIGHTHOUSE_DOCKER_IMAGE}}
docker pull ${{env.NETHERMIND_DOCKER_IMAGE}}
- name: Sim tests backup eth provider
run: DEBUG='${{github.event.inputs.debug}}' yarn test:sim:backup_eth_provider
working-directory: packages/cli
env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}
env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}
- name: Upload debug log test files for "packages/cli"
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: sim-test-eth-backup-provider-logs
path: packages/cli/test-logs

sim-test-mixed-clients:
name: Mixed clients sim tests
needs: build
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
# <common-build> - Uses YAML anchors in the future
- uses: actions/checkout@v4
- uses: "./.github/actions/setup-and-build"
with:
node: 20
- name: Load env variables
uses: ./.github/actions/dotenv
- name: Download required docker images before running tests
run: |
docker pull ${{env.GETH_DOCKER_IMAGE}}
docker pull ${{env.LIGHTHOUSE_DOCKER_IMAGE}}
docker pull ${{env.NETHERMIND_DOCKER_IMAGE}}
- name: Sim tests mixed client
run: DEBUG='${{github.event.inputs.debug}}' yarn test:sim:mixedclient
working-directory: packages/cli
env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}

env:
GENESIS_DELAY_SLOTS: ${{github.event.inputs.genesisDelaySlots}}
- name: Upload debug log test files for "packages/cli"
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: debug-test-logs-cli
name: sim-test-mixed-clients-logs
path: packages/cli/test-logs

0 comments on commit 17b4fde

Please sign in to comment.