refactor test script

This commit is contained in:
Nadezhda Fedorova 2024-12-16 14:55:51 +03:00 committed by Надежда Краснобородько
parent 78daf7d9bb
commit ff20da92a8

View File

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