Skip to content

Commit

Permalink
Improve CI (eth-educators#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne authored Aug 9, 2023
1 parent 91fb3a3 commit 06ef38c
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 126 deletions.
31 changes: 16 additions & 15 deletions .github/check-service.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#!/usr/bin/env bash

APP_NAME=$1
TIMEOUT=${2:-60} # Default timeout is 60 seconds if not provided
INTERVAL=5
__service=$1

while [ "${TIMEOUT}" -gt 0 ]; do
STATUS=$(docker-compose ps --services --filter "status=running" | grep "${APP_NAME}")
__containerID=$(docker-compose ps -q "${__service}")

if [ -n "$STATUS" ]; then
echo "$APP_NAME is running."
exit 0
fi
__initial_restart_count=$(docker inspect --format '{{ .RestartCount }}' "$__containerID")
__is_running=$(docker inspect --format '{{ .State.Running }}' "$__containerID")
sleep 10
__final_restart_count=$(docker inspect --format '{{ .RestartCount }}' "$__containerID")

sleep "${INTERVAL}"
TIMEOUT=$((TIMEOUT - INTERVAL))
done

echo "Timed out waiting for $APP_NAME to start."
exit 1
if [ "$__is_running" != "true" ] || [ "$__final_restart_count" -gt "$__initial_restart_count" ]; then
echo "$__service is either not running or continuously restarting"
docker-compose ps "${__service}"
docker-compose logs "${__service}"
exit 1
else
echo "$__service is running"
docker-compose ps "${__service}"
exit 0
fi
155 changes: 155 additions & 0 deletions .github/test-ethd-config.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/usr/bin/env expect

proc accept_default {} {
global spawn_id
send "\t\r"
}

proc yes {} {
global spawn_id
send "\r"
}

proc no {} {
global spawn_id
send "\t\r"
}

proc default-deployment {} {
global spawn_id
expect "Select Network"
accept_default

expect "Select deployment"
accept_default

expect "Select consensus"
accept_default

expect "Select execution"
accept_default
}

proc all-defaults {} {
global spawn_id
default-deployment

expect "Checkpoint Sync"
yes

expect "Configure checkpoint"
accept_default

expect "MEV Boost"
yes

expect "Configure MEV"
accept_default

expect "Grafana"
yes

expect "Configure rewards"
accept_default

expect "Configure Graffiti"
accept_default

expect EOF
}

proc no-checkpoint {} {
global spawn_id
default-deployment

expect "Checkpoint Sync"
no

expect "MEV Boost"
yes

expect "Configure MEV"
accept_default

expect "Grafana"
yes

expect "Configure rewards"
accept_default

expect "Configure Graffiti"
accept_default

expect EOF
}

proc no-mev {} {
global spawn_id
default-deployment

expect "Checkpoint Sync"
yes

expect "Configure checkpoint"
accept_default

expect "MEV Boost"
no

expect "Grafana"
yes

expect "Configure rewards"
accept_default

expect "Configure Graffiti"
accept_default

expect EOF
}

proc no-grafana {} {
global spawn_id
default-deployment

expect "Checkpoint Sync"
yes

expect "Configure checkpoint"
accept_default

expect "MEV Boost"
yes

expect "Configure MEV"
accept_default

expect "Grafana"
no

expect "Configure rewards"
accept_default

expect "Configure Graffiti"
accept_default

expect EOF
}

set timeout 5
spawn ./ethd config

# Check for the command-line argument
if {$argc > 0} {
set action [lindex $argv 0]
switch -- $action {
"all-defaults" all-defaults
"no-checkpoint" no-checkpoint
"no-mev" no-mev
"no-grafana" no-grafana
default { puts "Unknown action: $action"; exit 1 }
}
} else {
puts "No specific test specified, using all-defaults"
all-defaults
}
36 changes: 36 additions & 0 deletions .github/workflows/test-ethd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test ethd
run-name: Test ethd

on:
push:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
branches: [main]

jobs:
test-ethd:
if: |
contains(github.event.pull_request.labels.*.name, 'test-ethd') ||
contains(github.event.pull_request.labels.*.name, 'test-all') ||
github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Expect
run: sudo apt-get install -y expect whiptail
- name: Test ethd config defaults
run: expect ./.github/test-ethd-config.exp all-defaults
env:
TERM: xterm
- name: Test ethd config no checkpoint
run: expect ./.github/test-ethd-config.exp no-checkpoint
env:
TERM: xterm
- name: Test ethd config no mev
run: expect ./.github/test-ethd-config.exp no-mev
env:
TERM: xterm
- name: Test ethd config no grafana
run: expect ./.github/test-ethd-config.exp no-grafana
env:
TERM: xterm
40 changes: 15 additions & 25 deletions .github/workflows/test-grafana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,34 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Create .env file
run: |
cp default.env .env
run: cp default.env .env
- name: Set Lighthouse/Geth/Grafana
run: |
source ./.github/helper.sh
COMPOSE_FILE=lighthouse.yml:geth.yml:grafana.yml
var=COMPOSE_FILE
set_value_in_env
- name: Start Lighthouse/Geth/Grafana
run: |
./ethd up
run: ./ethd up
- name: Pause for 30 seconds
run: sleep 30
- name: Test Prometheus
run: |
./.github/check-service.sh prometheus
run: ./.github/check-service.sh prometheus
- name: Test metrics exporter
run: |
./.github/check-service.sh ethereum-metrics-exporter
run: ./.github/check-service.sh ethereum-metrics-exporter
- name: Test node exporter
run: |
./.github/check-service.sh node-exporter
- name: Test cryptowat exporter
run: |
./.github/check-service.sh cryptowat-exporter
run: ./.github/check-service.sh node-exporter
- name: Test blackbox exporter
run: |
./.github/check-service.sh blackbox-exporter
run: ./.github/check-service.sh blackbox-exporter
- name: Test json exporter
run: |
./.github/check-service.sh json-exporter
run: ./.github/check-service.sh json-exporter
- name: Test cryptowat exporter
run: ./.github/check-service.sh cryptowat-exporter
- name: Test cadvisor
run: |
./.github/check-service.sh cadvisor
run: ./.github/check-service.sh cadvisor
- name: Test promtail
run: |
./.github/check-service.sh promtail
run: ./.github/check-service.sh promtail
- name: Test Loki
run: |
./.github/check-service.sh loki
run: ./.github/check-service.sh loki
- name: Test Grafana
run: |
./.github/check-service.sh grafana
run: ./.github/check-service.sh grafana
31 changes: 13 additions & 18 deletions .github/workflows/test-lighthouse-reth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Create .env file
run: |
cp default.env .env
run: cp default.env .env
- name: Set Lighthouse/Reth
run: |
source ./.github/helper.sh
Expand All @@ -30,32 +29,28 @@ jobs:
var=FEE_RECIPIENT
set_value_in_env
- name: Start Lighthouse/Reth
run: |
./ethd up
run: ./ethd up
- name: Pause for 30 seconds
run: sleep 30
- name: Test Lighthouse CL
run: |
./.github/check-service.sh consensus
run: ./.github/check-service.sh consensus
- name: Test Lighthouse VC
run: |
./.github/check-service.sh validator
run: ./.github/check-service.sh validator
- name: Test Reth
run: |
./.github/check-service.sh execution
run: ./.github/check-service.sh execution
- name: Set Lighthouse/Reth w/ VC
run: |
source ./.github/helper.sh
COMPOSE_FILE=lighthouse-cl-only.yml:lighthouse-vc-only.yml:reth.yml
var=COMPOSE_FILE
set_value_in_env
- name: Start Lighthouse/Reth
run: |
./ethd up
run: ./ethd up
- name: Pause for 30 seconds
run: sleep 30
- name: Test Lighthouse CL
run: |
./.github/check-service.sh consensus
run: ./.github/check-service.sh consensus
- name: Test Lighthouse VC
run: |
./.github/check-service.sh validator
run: ./.github/check-service.sh validator
- name: Test Reth
run: |
./.github/check-service.sh execution
run: ./.github/check-service.sh execution
31 changes: 13 additions & 18 deletions .github/workflows/test-lodestar-erigon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Create .env file
run: |
cp default.env .env
run: cp default.env .env
- name: Set Lodestar/Erigon
run: |
source ./.github/helper.sh
Expand All @@ -30,32 +29,28 @@ jobs:
var=FEE_RECIPIENT
set_value_in_env
- name: Start Lodestar/Erigon
run: |
./ethd up
run: ./ethd up
- name: Pause for 30 seconds
run: sleep 30
- name: Test Lodestar CL
run: |
./.github/check-service.sh consensus
run: ./.github/check-service.sh consensus
- name: Test Lodestar VC
run: |
./.github/check-service.sh validator
run: ./.github/check-service.sh validator
- name: Test Geth
run: |
./.github/check-service.sh execution
run: ./.github/check-service.sh execution
- name: Set Lodestar/Erigon w/ VC
run: |
source ./.github/helper.sh
COMPOSE_FILE=lodestar-cl-only.yml:lodestar-vc-only.yml:erigon.yml
var=COMPOSE_FILE
set_value_in_env
- name: Start Lodestar/Erigon
run: |
./ethd up
run: ./ethd up
- name: Pause for 30 seconds
run: sleep 30
- name: Test Lodestar CL
run: |
./.github/check-service.sh consensus
run: ./.github/check-service.sh consensus
- name: Test Lodestar VC
run: |
./.github/check-service.sh validator
run: ./.github/check-service.sh validator
- name: Test Erigon
run: |
./.github/check-service.sh execution
run: ./.github/check-service.sh execution
Loading

0 comments on commit 06ef38c

Please sign in to comment.