image-forge/.gitea/workflows/testscript
2024-12-16 15:35:10 +03:00

73 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#$1 - ${{ needs.build-process.outputs.branch }}
#$2 - ${{ needs.build-process.outputs.org }}
#$3 - ${{ needs.build-process.outputs.url }}
#$4 - ${{ needs.build-process.outputs.repo }}
#$5 - ${{ gitea.workspace }}
branch=${1:-"sisyphus"}
org=${2:-"alt"}
url=${3:-"gitea.basealt.ru"}
repo=${4:-"alt"}
wosp=${5:-"."}
errors=''
haserr=false
for IM in $(ls $wosp/org/$org/ | xargs)
do
echo "image=$IM"
if test -f $wosp/org/$org/$IM/test
then
test=$(cat $wosp/org/$org/$IM/test)
else test=''
fi
echo "test script=$test"
imgpath="$repo/$branch/$IM:latest"
entrypoint='/bin/sh'
command="echo empty_command"
if [ -n "$test" ]; then
command="podman run --rm --entrypoint=\"$entrypoint\" $url/$imgpath -c \"$test\""
else
if [[ "$IM" == distroless-toybox ]]; then
command="podman run --rm $url/$imgpath toysh -c true"
fi
if [ "$IM" = distroless-true ]; then
command="podman run --rm $url/$imgpath \"true\""
fi
if [ "$IM" = distroless-gotop ]; then
command="podman run --rm $url/$imgpath \"--version\""
fi
if [ "$IM" = flannel-cni-plugin ]; then
command="podman run --rm $url/$imgpath \"/flannel\""
fi
if [ "$IM" == pause ]; then
command="podman run --rm $url/$imgpath \"/pause\" \"-v\""
fi
fi
echo $command
eval $command 2>$IM.log || haserr=true
echo "podman rmi --all"
podman rmi --all
if [ "$haserr" ]
then
if [[ -n $(cat $IM.log) ]]
then errors="TEST ERROR OF IMAGE $IM: $(cat $IM.log); $errors"
else errors="TEST ERROR OF IMAGE $IM: test returned empty error, but exit status was nozero; $errors"
fi
fi
haserr=false
done
echo "$errors"
if [ -n "$errors" ]
then haserr=true
fi
echo "ERR=$haserr" > haserr.log
echo $errors > errors.log