Rearchitecting testing to have extended tests in pre-commit & minimal tests during CI/CD

This commit is contained in:
DarkFeather 2023-10-03 13:01:50 -05:00
parent d53fd90185
commit fb9de15de0
Signed by: DarkFeather
GPG Key ID: 1CC1E3F4ED06F296
4 changed files with 27 additions and 6 deletions

View File

@ -21,7 +21,7 @@ install: ${list} MaatIcon.png
for i in ${systemdList}; do install -m 0644 -o root $$i ${pkgdir}/usr/lib/systemd/system; done for i in ${systemdList}; do install -m 0644 -o root $$i ${pkgdir}/usr/lib/systemd/system; done
clean: clean:
cat .gitignore | sudo xargs rm -Rf git clean -fx && git clean -fd
uninstall: uninstall:
for i in ${list}; do rm -Rf ${installDir}/$$i; done for i in ${list}; do rm -Rf ${installDir}/$$i; done
@ -29,7 +29,10 @@ uninstall:
rmdir -p ${pkgdir}${serverRoot}/src rmdir -p ${pkgdir}${serverRoot}/src
rmdir -p ${pkgdir}${serverRoot}/pkg rmdir -p ${pkgdir}${serverRoot}/pkg
test: clean test:
./maat -h | grep -c Usage 1>/dev/null
extendedtest: clean
sudo ./maat -u $$USER -T sudo ./maat -u $$USER -T
test -d src test -d src
test -d src/ascii-invaders test -d src/ascii-invaders

View File

@ -28,7 +28,7 @@ validpgpkeys=()
prepare() { prepare() {
git pull git pull
make -C .. test && make -C .. clean make -C .. test
} }
build() { build() {

21
maat
View File

@ -83,7 +83,8 @@ function BuildRepo() {
git clone "$repo" git clone "$repo"
fi fi
cd "$repodir" cd "$repodir"
git reset --hard origin &>/dev/null git clean -fd
git clean -fx
output="$(git pull 2>&1)" output="$(git pull 2>&1)"
if [ -n "$incremental" ] && [ $( echo "$output" | grep -c 'Already up to date.' ) -eq 1 ]; then if [ -n "$incremental" ] && [ $( echo "$output" | grep -c 'Already up to date.' ) -eq 1 ]; then
return; return;
@ -150,12 +151,26 @@ timeout="90s"
# Stat tracking # Stat tracking
starttime=`date +%s` starttime=`date +%s`
function usage() {
### Show helptext
# param retcode: what to exit
retcode="$1"
cat <<EOM
Usage: $0
$0 -T # Extended testing
$0 -b homedir -c aurconf -u user -t timeout
Add -s to skip patching or -v for verbosity.
EOM
exit $retcode
}
# Parse arguments # Parse arguments
while getopts 'b:c:hil:st:Tu:v' OPTION; do while getopts 'b:c:hil:st:Tu:v' OPTION; do
case "${OPTION}" in case "${OPTION}" in
b) homedir="${OPTARG}" ;; b) homedir="${OPTARG}" ;;
c) aurconf="${OPTARG}" ;; c) aurconf="${OPTARG}" ;;
h) Usage; exit 0 ;; h) usage; exit 0 ;;
i) incremental=1 ;; i) incremental=1 ;;
l) cmdstring="$0"; for arg in $@; do if [ "$arg" != "-l" ] && [ "$arg" != "${OPTARG}" ]; then cmdstring="$cmdstring \"${arg}\""; fi; done; exec /bin/bash -c "$cmdstring | tee -a \"${OPTARG}\""; ;; l) cmdstring="$0"; for arg in $@; do if [ "$arg" != "-l" ] && [ "$arg" != "${OPTARG}" ]; then cmdstring="$cmdstring \"${arg}\""; fi; done; exec /bin/bash -c "$cmdstring | tee -a \"${OPTARG}\""; ;;
s) skipPatching=1 ;; s) skipPatching=1 ;;
@ -163,7 +178,7 @@ while getopts 'b:c:hil:st:Tu:v' OPTION; do
T) export MAATTESTINGVAR=1; exec $0 -l ./testing.log -u "$deprivuser" -v -s -c <(echo https://aur.archlinux.org/ascii-invaders.git) -b . ;; T) export MAATTESTINGVAR=1; exec $0 -l ./testing.log -u "$deprivuser" -v -s -c <(echo https://aur.archlinux.org/ascii-invaders.git) -b . ;;
u) deprivuser="${OPTARG}" ;; u) deprivuser="${OPTARG}" ;;
v) set -x ;; v) set -x ;;
*) usage; exit 1 ;; *) echo "Internal GitOps CI/CD Pipeline"; usage 1 ;;
esac esac
done done

View File

@ -0,0 +1,3 @@
#!/bin/bash
make extendedtest