Merge branch 'mymaster'
All checks were successful
Full building alt images / build-process (push) Successful in 3m14s
Full building alt images / test-process (push) Successful in 1m50s

This commit is contained in:
Nadezhda Fedorova 2024-04-17 20:01:53 +03:00
commit 04bf7f182d
2 changed files with 61 additions and 28 deletions

View File

@ -0,0 +1,57 @@
#!/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 }}
errors=''
haserr=false
for IM in $(ls $5/org/$2/ | xargs)
do
echo "image=$IM"
if test -f $5/org/$2/$IM/test
then
test=$(cat $5/org/$2/$IM/test)
else test=''
fi
echo "test script=$test"
imgpath="$2/$IM:$1"
if [[ $2 == 'k8s' ]]
then imgpath="$2-$1/$IM:latest"
fi
if [[ $test != '' ]]
then podman run --rm --entrypoint="/bin/sh" $3/$4/$imgpath -c "$test" 2>$IM.log || haserr=true
else
if [[ $IM = 'distroless-true' ]]; then
echo "podman run --rm $3/$4/$imgpath \"true\""
podman run --rm $URL/$REPO/$imgpath "true" 2>$IM.log || haserr=true
fi
if [[ $IM = 'distroless-gotop' ]]; then
echo "podman run --rm $3/$4/$imgpath \"--version\""
podman run --rm $3/$4/$imgpath "--version" 2>$IM.log || haserr=true
fi
fi
echo "podman rmi --all"
podman rmi --all
if [ "$haserr" = true ]
then
if [[ $(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 [[ $errors != '' ]]
then haserr=true
fi
echo "ERR=$haserr" > errors.log

View File

@ -106,39 +106,15 @@ jobs:
id: test-script
continue-on-error: true
run: |
errors=""
haserr=false
for IM in $(ls ${{ gitea.workspace }}/org/$ORG/ | xargs); do \
echo "image=$IM"; \
if test -f ${{ gitea.workspace }}/org/$ORG/$IM/test; \
then test=$(cat ${{ gitea.workspace }}/org/$ORG/$IM/test); \
else test=''; fi; \
echo "test script=$test"; \
imgpath="$ORG/$IM:$BR"; \
if [[ $ORG == 'k8s' ]]; then imgpath="$ORG-$BR/$IM:latest"; fi; \
if [[ $test != '' ]]; then podman run --rm --entrypoint="/bin/sh" $URL/$REPO/$imgpath -c "$test" 2>$IM.log || haserr=true ; \
else \
if [[ $IM = 'distroless-true' ]]; then podman run --rm $URL/$REPO/$imgpath "true" 2>$IM.log || haserr=true ; fi; \
if [[ $IM = 'distroless-gotop' ]]; then podman run --rm $URL/$REPO/$imgpath "--version" 2>$IM.log || haserr=true ; fi; \
fi; \
echo "podman rmi --all"; \
podman rmi --all; \
if [ "$haserr" = true ]; then if [[ $(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 [[ $errors != '' ]]; then haserr=true; fi
echo "ERR=$haserr" >> ${GITHUB_ENV}
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $WS
cat errors.log >> ${GITHUB_ENV}
echo "test process finished"
env:
BR: ${{ needs.build-process.outputs.branch }}
ORG: ${{ needs.build-process.outputs.org }}
URL: ${{ needs.build-process.outputs.url }}
REPO: ${{ needs.build-process.outputs.repo }}
WS: ${{ gitea.workspace }}
- name: Send notification if test crashed
if: ${{ env.ERR == 'true' || steps.test-script.outcome == 'failure' }}
run: |
@ -152,4 +128,4 @@ jobs:
T: ${{ secrets.TOKEN }}
BR: ${{ needs.build-process.outputs.branch }}
URL: ${{ gitea.server_url }}
REPO: ${{ needs.build-process.outputs.repo }}
REPO: ${{ needs.build-process.outputs.repo }}