Skip to content

Commit 86b9c38

Browse files
container verify GitHub workflow (#7239)
Container verification step in release process automated with the container verify GitHub workflow. New workflow is triggered at the end of the release workflow which will check the release container images starts successfully. Verification test only checks container starts and reach the Ethereum main loop Signed-off-by: Chaminda Divitotawela <cdivitotawela@gmail.com>
1 parent aef9389 commit 86b9c38

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
##
3+
## Copyright contributors to Hyperledger Besu.
4+
##
5+
## Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
6+
## the License. You may obtain a copy of the License at
7+
##
8+
## http://www.apache.org/licenses/LICENSE-2.0
9+
##
10+
## Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11+
## an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
## specific language governing permissions and limitations under the License.
13+
##
14+
## SPDX-License-Identifier: Apache-2.0
15+
##
16+
17+
CONTAINER_NAME=${CONTAINER_NAME:-besu}
18+
VERSION=${VERSION}
19+
TAG=${TAG}
20+
CHECK_LATEST=${CHECK_LATEST}
21+
RETRY=${RETRY:-10}
22+
SLEEP=${SLEEP:-5}
23+
24+
# Helper function to throw error
25+
log_error() {
26+
echo "::error $1"
27+
exit 1
28+
}
29+
30+
# Check container is in running state
31+
_RUN_STATE=$(docker inspect --type=container -f={{.State.Status}} ${CONTAINER_NAME})
32+
if [[ "${_RUN_STATE}" != "running" ]]
33+
then
34+
log_error "container is not running"
35+
fi
36+
37+
# Check for specific log message in container logs to verify besu started
38+
_SUCCESS=false
39+
while [[ ${_SUCCESS} != "true" && $RETRY -gt 0 ]]
40+
do
41+
docker logs ${CONTAINER_NAME} | grep -q "Ethereum main loop is up" && {
42+
_SUCCESS=true
43+
continue
44+
}
45+
echo "Waiting for the besu to start. Remaining retries $RETRY ..."
46+
RETRY=$(expr $RETRY - 1)
47+
sleep $SLEEP
48+
done
49+
50+
# Log entry does not present after all retries, fail the script with a message
51+
if [[ ${_SUCCESS} != "true" ]]
52+
then
53+
docker logs --tail=100 ${CONTAINER_NAME}
54+
log_error "could not find the log message 'Ethereum main loop is up'"
55+
else
56+
echo "Besu container started and entered main loop"
57+
fi
58+
59+
# For the latest tag check the version match
60+
if [[ ${TAG} == "latest" && ${CHECK_LATEST} == "true" ]]
61+
then
62+
_VERSION_IN_LOG=$(docker logs ${CONTAINER_NAME} | grep "#" | grep "Besu version" | cut -d " " -f 4 | sed 's/\s//g')
63+
echo "Extracted version from logs [$_VERSION_IN_LOG]"
64+
if [[ "$_VERSION_IN_LOG" != "${VERSION}" ]]
65+
then
66+
log_error "version [$_VERSION_IN_LOG] extracted from container logs does not match the expected version [${VERSION}]"
67+
else
68+
echo "Latest Besu container version matches"
69+
fi
70+
fi
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: container verify
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Besu version'
8+
required: true
9+
verify-latest-version:
10+
description: 'Check latest container version'
11+
required: false
12+
type: choice
13+
default: "true"
14+
options:
15+
- "true"
16+
- "false"
17+
18+
jobs:
19+
verify:
20+
timeout-minutes: 4
21+
strategy:
22+
matrix:
23+
combination:
24+
- tag: ${{ inputs.version }}
25+
platform: ''
26+
runner: ubuntu-latest
27+
- tag: ${{ inputs.version }}-amd64
28+
platform: 'linux/amd64'
29+
runner: ubuntu-latest
30+
- tag: latest
31+
platform: ''
32+
runner: ubuntu-latest
33+
- tag: ${{ inputs.version }}-arm64
34+
platform: ''
35+
runner: besu-arm64
36+
runs-on: ${{ matrix.combination.runner }}
37+
env:
38+
CONTAINER_NAME: besu-check
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
42+
43+
- name: Start container
44+
run: |
45+
PLATFORM_OPT=""
46+
[[ x${{ matrix.combination.platform }} != 'x' ]] && PLATFORM_OPT="--platform ${{ matrix.combination.platform }}"
47+
docker run -d $PLATFORM_OPT --name ${{ env.CONTAINER_NAME }} hyperledger/besu:${{ matrix.combination.tag }}
48+
49+
- name: Verify besu container
50+
run: bash .github/workflows/BesuContainerVerify.sh
51+
env:
52+
TAG: ${{ matrix.combination.tag }}
53+
VERSION: ${{ inputs.version }}
54+
CHECK_LATEST: ${{ inputs.verify-latest-version }}
55+
56+
- name: Stop container
57+
run: docker stop ${{ env.CONTAINER_NAME }}

.github/workflows/release.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,17 @@ jobs:
265265
run: ./gradlew "-Prelease.releaseVersion=${{ github.event.release.name }}" "-PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }}" dockerUploadRelease
266266
- name: Docker manifest
267267
run: ./gradlew "-Prelease.releaseVersion=${{ github.event.release.name }}" "-PdockerOrgName=${{ env.registry }}/${{ secrets.DOCKER_ORG }}" manifestDockerRelease
268+
269+
verifyContainer:
270+
needs: dockerPromoteX64
271+
runs-on: ubuntu-22.04
272+
permissions:
273+
contents: read
274+
actions: write
275+
steps:
276+
- name: Checkout
277+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
278+
- name: Trigger container verify
279+
run: echo '{"version":"${{ github.event.release.name }}","verify-latest-version":"true"}' | gh workflow run container-verify.yml --json
280+
env:
281+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)