matrix-docker-test #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: matrix-docker-test | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Image tag of hyperledger/besu' | |
required: true | |
default: '24.5.4' | |
jobs: | |
verify: | |
strategy: | |
matrix: | |
combination: | |
- tag: ${{ inputs.tag }} | |
platform: '' | |
runner: ubuntu-latest | |
- tag: ${{ inputs.tag }}-amd64 | |
platform: 'linux/amd64' | |
runner: ubuntu-latest | |
- tag: latest | |
platform: '' | |
runner: ubuntu-latest | |
- tag: ${{ inputs.tag }}-amd64 | |
platform: '' | |
runner: ubuntu-latest | |
runs-on: ${{ matrix.combination.runner }} | |
env: | |
CONTAINER_NAME: besu-check | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Start container | |
run: | | |
PLATFORM_OPT="" | |
[[ x${{ matrix.combination.platform }} != 'x' ]] && PLATFORM_OPT="--platform ${{ matrix.combination.platform }}" | |
docker run -d $PLATFORM_OPT --name ${{ env.CONTAINER_NAME }} hyperledger/besu:${{ matrix.combination.tag }} | |
- name: Verify besu container | |
run: | | |
run_state=$(docker inspect --type=container -f={{.State.Status}} ${{ env.CONTAINER_NAME }}) | |
if [[ "x$run_state" != "xrunning" ]] | |
then | |
echo "::error container in not running" | |
exit 1 | |
fi | |
success=false | |
while [[ $success != "true" && $RETRY -gt 0 ]] | |
do | |
docker logs ${{ env.CONTAINER_NAME }} | grep -q "Ethereum main loop is up" && success=true | |
RETRY=$(expr $RETRY - 1) | |
echo "Waiting for the container to start. Remaining retries $RETRY ..." | |
sleep $SLEEP | |
done | |
if [[ $success != "true" ]] | |
then | |
docker ps -a | |
docker logs ${{ env.CONTAINER_NAME }} | |
echo "::error Could not find the log message 'Ethereum main loop is up'" | |
exit 1 | |
fi | |
if [[ ${{ matrix.combination.tag }} == "latest" ]] | |
then | |
version_in_log=$(docker logs ${{ env.CONTAINER_NAME }} | grep "#" | grep "Besu version" | cut -d " " -f 4 | sed 's/\s//g') | |
echo "Extracted version [$version_in_log]" | |
if [[ $version_in_log != ${{ inputs.tag }} ]] | |
echo "::error version [$version_in_log] extracted from container logs does not match the expected version" | |
fi | |
fi | |
docker stop ${{ env.CONTAINER_NAME }} > /dev/null | |
exit 0 | |
env: | |
SLEEP: 5 | |
RETRY: 10 | |