From e272db5e4626160cf452ca168d8e7943e3e5c5ab Mon Sep 17 00:00:00 2001 From: Yorick Downe Date: Fri, 4 Aug 2023 02:41:37 +0000 Subject: [PATCH] Better CI --- .github/check-service.sh | 25 ++++++------ .github/{test.exp => test-ethd-config.exp} | 2 +- .github/workflows/test-ethd.yml | 22 +++++++++++ .github/workflows/test-grafana.yml | 40 ++++++++------------ .github/workflows/test-lighthouse-reth.yml | 31 +++++++-------- .github/workflows/test-lodestar-erigon.yml | 31 +++++++-------- .github/workflows/test-nimbus-nethermind.yml | 28 ++++++-------- .github/workflows/test-prysm-geth.yml | 31 +++++++-------- .github/workflows/test-teku-besu.yml | 28 ++++++-------- 9 files changed, 114 insertions(+), 124 deletions(-) rename .github/{test.exp => test-ethd-config.exp} (99%) create mode 100644 .github/workflows/test-ethd.yml diff --git a/.github/check-service.sh b/.github/check-service.sh index 07a8a505..c226805b 100755 --- a/.github/check-service.sh +++ b/.github/check-service.sh @@ -1,18 +1,19 @@ #!/usr/bin/env bash -APP_NAME=$1 -TIMEOUT=${2:-60} # Default timeout is 60 seconds if not provided +__service=$1 -# Give service a chance to start, and also to go into "Restarting" status -sleep "${TIMEOUT}" +__containerID=$(docker-compose ps -q "${__service}") -STATUS=$(docker-compose ps --services --filter "status=running" | grep "${APP_NAME}") +__restart_count=$(docker inspect --format '{{ .RestartCount }}' "$__containerID") +__running=$(docker inspect --format '{{ .State.Running }}' "$__containerID") -if [ -n "$STATUS" ]; then - echo "$APP_NAME is running." - exit 0 +if [ "$__running" != "true" ] || [ "$__restart_count" -gt 0 ]; 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 - -echo "$APP_NAME is either not started or restarting" -docker-compose ps | grep "${APP_NAME}" -exit 1 diff --git a/.github/test.exp b/.github/test-ethd-config.exp similarity index 99% rename from .github/test.exp rename to .github/test-ethd-config.exp index 160cc7a3..2c31808b 100755 --- a/.github/test.exp +++ b/.github/test-ethd-config.exp @@ -137,7 +137,7 @@ proc no-grafana {} { } set timeout 5 -spawn ../ethd config +spawn ./ethd config # Check for the command-line argument if {$argc > 0} { diff --git a/.github/workflows/test-ethd.yml b/.github/workflows/test-ethd.yml new file mode 100644 index 00000000..9b2e1b9f --- /dev/null +++ b/.github/workflows/test-ethd.yml @@ -0,0 +1,22 @@ +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 + - name: Test ethd config + run: expect ./.github/test-ethd-config.exp diff --git a/.github/workflows/test-grafana.yml b/.github/workflows/test-grafana.yml index 8550f6b2..71bd2d58 100644 --- a/.github/workflows/test-grafana.yml +++ b/.github/workflows/test-grafana.yml @@ -17,8 +17,7 @@ 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 @@ -26,35 +25,26 @@ jobs: 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 diff --git a/.github/workflows/test-lighthouse-reth.yml b/.github/workflows/test-lighthouse-reth.yml index 3163e66c..235808e8 100644 --- a/.github/workflows/test-lighthouse-reth.yml +++ b/.github/workflows/test-lighthouse-reth.yml @@ -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 @@ -30,17 +29,15 @@ 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 @@ -48,14 +45,12 @@ jobs: 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 diff --git a/.github/workflows/test-lodestar-erigon.yml b/.github/workflows/test-lodestar-erigon.yml index 057dc152..14c1f621 100644 --- a/.github/workflows/test-lodestar-erigon.yml +++ b/.github/workflows/test-lodestar-erigon.yml @@ -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 @@ -30,17 +29,15 @@ 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 @@ -48,14 +45,12 @@ jobs: 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 diff --git a/.github/workflows/test-nimbus-nethermind.yml b/.github/workflows/test-nimbus-nethermind.yml index 59331c76..f0b15939 100644 --- a/.github/workflows/test-nimbus-nethermind.yml +++ b/.github/workflows/test-nimbus-nethermind.yml @@ -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 Nimbus/Nethermind run: | source ./.github/helper.sh @@ -30,14 +29,13 @@ jobs: var=FEE_RECIPIENT set_value_in_env - name: Start Nimbus/Nethermind - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Nimbus - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Nethermind - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution - name: Set Nimbus/Nethermind w/ VC run: | source ./.github/helper.sh @@ -45,14 +43,12 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Nimbus/Nethermind - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Nimbus CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Nimbus VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Nethermind - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution diff --git a/.github/workflows/test-prysm-geth.yml b/.github/workflows/test-prysm-geth.yml index dbc89c7c..7fe85eb9 100644 --- a/.github/workflows/test-prysm-geth.yml +++ b/.github/workflows/test-prysm-geth.yml @@ -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 Prysm/Geth run: | source ./.github/helper.sh @@ -30,17 +29,15 @@ jobs: var=FEE_RECIPIENT set_value_in_env - name: Start Prysm/Geth - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Prysm CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Prysm 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 Prysm/Geth w/ VC run: | source ./.github/helper.sh @@ -48,14 +45,12 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Prysm/Geth - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Prysm CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Prysm 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 diff --git a/.github/workflows/test-teku-besu.yml b/.github/workflows/test-teku-besu.yml index d0476019..22da6609 100644 --- a/.github/workflows/test-teku-besu.yml +++ b/.github/workflows/test-teku-besu.yml @@ -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 Teku/Besu run: | source ./.github/helper.sh @@ -30,14 +29,13 @@ jobs: var=FEE_RECIPIENT set_value_in_env - name: Start Teku/Besu - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Teku - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Besu - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution - name: Set Teku/Besu w/ VC run: | source ./.github/helper.sh @@ -45,14 +43,12 @@ jobs: var=COMPOSE_FILE set_value_in_env - name: Start Teku/Besu - run: | - ./ethd up + run: ./ethd up + - name: Pause for 30 seconds + run: sleep 30 - name: Test Teku CL - run: | - ./.github/check-service.sh consensus + run: ./.github/check-service.sh consensus - name: Test Teku VC - run: | - ./.github/check-service.sh validator + run: ./.github/check-service.sh validator - name: Test Besu - run: | - ./.github/check-service.sh execution + run: ./.github/check-service.sh execution