script: move forced test to precommit hook
NOTE: run setup.sh script to update the hooks * commit message after building and testing * pushing tags does not run builds and tests
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
.clang_complete
|
.clang_complete
|
||||||
.ycm_extra_conf.py
|
.ycm_extra_conf.py
|
||||||
.ycm_extra_conf.pyc
|
.ycm_extra_conf.pyc
|
||||||
|
coati.coatiproject
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
Makefile
|
Makefile
|
||||||
/__pycache__/
|
/__pycache__/
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ case ${ans:=y} in [yY]*) ;; *) exit ;; esac
|
|||||||
|
|
||||||
echo "Run this script as root"
|
echo "Run this script as root"
|
||||||
|
|
||||||
rm /usr/bin/Coati
|
rm /usr/bin/coati
|
||||||
rm /usr/share/mime/packages/coati-mime.xml
|
rm /usr/share/mime/packages/coati-mime.xml
|
||||||
rm /usr/share/applications/coati.desktop
|
rm /usr/share/applications/coati.desktop
|
||||||
rm /usr/share/icons/coati.png
|
rm /usr/share/icons/coati.png
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||||
MY_PATH=`dirname "$0"`
|
MY_PATH=$SCRIPT_DIR/..
|
||||||
MY_PATH=../$MY_PATH
|
|
||||||
|
|
||||||
cat ${MY_PATH}/EULA.txt
|
cat ${MY_PATH}/EULA.txt
|
||||||
echo "Agree to the EULA"
|
echo "Agree to the EULA"
|
||||||
|
|||||||
@@ -3,9 +3,84 @@
|
|||||||
ABORT="\033[31mAbort:\033[00m"
|
ABORT="\033[31mAbort:\033[00m"
|
||||||
SUCCESS="\033[32mSuccess:\033[00m"
|
SUCCESS="\033[32mSuccess:\033[00m"
|
||||||
INFO="\033[33mInfo:\033[00m"
|
INFO="\033[33mInfo:\033[00m"
|
||||||
|
FAIL="\033[31mFail:\033[00m"
|
||||||
|
PASS="\033[32mPass:\033[00m"
|
||||||
|
|
||||||
BRANCH_NAME=$(git symbolic-ref -q --short HEAD)
|
BRANCH_NAME=$(git symbolic-ref -q --short HEAD)
|
||||||
|
|
||||||
|
ROOTDIR=$(pwd)
|
||||||
|
|
||||||
|
# Determine current platform
|
||||||
|
PLATFORM='unknown'
|
||||||
|
if [ "$(uname)" == "Darwin" ]; then
|
||||||
|
PLATFORM='MacOS'
|
||||||
|
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
||||||
|
PLATFORM='Linux'
|
||||||
|
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
|
||||||
|
PLATFORM='Windows'
|
||||||
|
fi
|
||||||
|
|
||||||
|
function build {
|
||||||
|
echo -e $INFO Building $1 \($2\)
|
||||||
|
cmake --build build/$2 --target $1 > /dev/null
|
||||||
|
#output to commandline for debugging
|
||||||
|
#cmake --build build/$2 --target $1
|
||||||
|
if [ $? -eq 0 ]
|
||||||
|
then
|
||||||
|
echo -e $PASS Building $1 \($2\) passed
|
||||||
|
else
|
||||||
|
echo -e $FAIL Building $1 \($2\) failed
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_type {
|
||||||
|
echo -e $INFO Starting with buildtype: $1
|
||||||
|
if [ "$PLATFORM" == "Windows" ]
|
||||||
|
then
|
||||||
|
echo -e $INFO Builing the Coati VS Solution
|
||||||
|
cmake --build build --config $1 > /dev/null
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
echo -e $FAIL At least one build or test failed, no push to $branch
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
build Coati $1
|
||||||
|
build Coati_trial $1
|
||||||
|
build Coati_test $1
|
||||||
|
build Coati_license_generator $1
|
||||||
|
run_tests $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_tests {
|
||||||
|
echo -e $INFO Run $1 Tests
|
||||||
|
|
||||||
|
cd bin/test
|
||||||
|
echo $1/Coati_test
|
||||||
|
$1/Coati_test
|
||||||
|
if [ $? -eq 0 ]
|
||||||
|
then
|
||||||
|
echo -e $PASS $1 Tests passed
|
||||||
|
else
|
||||||
|
echo -e $FAIL $1 Tests failed
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cd $ROOTDIR
|
||||||
|
}
|
||||||
|
|
||||||
|
#testing before commiting to a publish branch
|
||||||
|
if [[ $BRANCH_NAME =~ ^_publish_.*_$ ]]
|
||||||
|
then
|
||||||
|
echo Try to publish
|
||||||
|
echo Run builds and test
|
||||||
|
echo This will take a while
|
||||||
|
build_type Release
|
||||||
|
echo -e $PASS All builds and tests passed
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z $BRANCH_NAME ]
|
if [ -z $BRANCH_NAME ]
|
||||||
then
|
then
|
||||||
echo -e $ABORT "You are not on any branch."
|
echo -e $ABORT "You are not on any branch."
|
||||||
|
|||||||
@@ -1,82 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This hook enforces to run builds and test when pushed to the $protected_branch
|
|
||||||
|
|
||||||
proteced_branches=("forced_tests" "master")
|
|
||||||
|
|
||||||
#proteced_branch='master'
|
|
||||||
current_branch=$(git symbolic-ref -q --short HEAD)
|
current_branch=$(git symbolic-ref -q --short HEAD)
|
||||||
|
|
||||||
remote="$1"
|
|
||||||
url="$2"
|
|
||||||
|
|
||||||
FAIL="\033[31mFail:\033[00m"
|
FAIL="\033[31mFail:\033[00m"
|
||||||
PASS="\033[32mPass:\033[00m"
|
PASS="\033[32mPass:\033[00m"
|
||||||
INFO="\033[33mInfo:\033[00m"
|
INFO="\033[33mInfo:\033[00m"
|
||||||
|
|
||||||
ROOTDIR=$(pwd)
|
|
||||||
|
|
||||||
# Determine current platform
|
|
||||||
PLATFORM='unknown'
|
|
||||||
if [ "$(uname)" == "Darwin" ]; then
|
|
||||||
PLATFORM='MacOS'
|
|
||||||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
|
||||||
PLATFORM='Linux'
|
|
||||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
|
|
||||||
PLATFORM='Windows'
|
|
||||||
fi
|
|
||||||
|
|
||||||
function build {
|
|
||||||
echo -e $INFO Building $1 \($2\)
|
|
||||||
cmake --build build/$2 --target $1 > /dev/null
|
|
||||||
#output to commandline for debugging
|
|
||||||
#cmake --build build/$2 --target $1
|
|
||||||
if [ $? -eq 0 ]
|
|
||||||
then
|
|
||||||
echo -e $PASS Building $1 \($2\) passed
|
|
||||||
else
|
|
||||||
echo -e $FAIL Building $1 \($2\) failed
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_type {
|
|
||||||
echo -e $INFO Starting with buildtype: $1
|
|
||||||
if [ "$PLATFORM" == "Windows" ]
|
|
||||||
then
|
|
||||||
echo -e $INFO Builing the Coati VS Solution
|
|
||||||
cmake --build build --config $1 > /dev/null
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
echo -e $FAIL At least one build or test failed, no push to $branch
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
build Coati $1
|
|
||||||
build Coati_trial $1
|
|
||||||
build Coati_test $1
|
|
||||||
build Coati_license_generator $1
|
|
||||||
run_tests $1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function run_tests {
|
|
||||||
echo -e $INFO Run $1 Tests
|
|
||||||
|
|
||||||
cd bin/test
|
|
||||||
echo $1/Coati_test
|
|
||||||
$1/Coati_test
|
|
||||||
if [ $? -eq 0 ]
|
|
||||||
then
|
|
||||||
echo -e $PASS $1 Tests passed
|
|
||||||
else
|
|
||||||
echo -e $FAIL $1 Tests failed
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
cd $ROOTDIR
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#handle delete remote branches
|
#handle delete remote branches
|
||||||
while read local_ref lorem_sha remote_ref remote_sha
|
while read local_ref lorem_sha remote_ref remote_sha
|
||||||
do
|
do
|
||||||
@@ -84,7 +13,7 @@ do
|
|||||||
then
|
then
|
||||||
if [ "$remote_ref" == "refs/heads/master" ]
|
if [ "$remote_ref" == "refs/heads/master" ]
|
||||||
then
|
then
|
||||||
echo "seriously dont delete the master"
|
echo -e $FAIL seriously dont delete the master
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "delete remote branch $remote_ref"
|
echo "delete remote branch $remote_ref"
|
||||||
@@ -93,28 +22,5 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# handle push --tags
|
|
||||||
while read -d $'\0' arg ; do
|
|
||||||
if [[ "$arg" == '--tags' ]] ; then
|
|
||||||
echo "pushing tags"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done < /proc/$PPID/cmdline
|
|
||||||
|
|
||||||
|
|
||||||
for branch in "${proteced_branches[@]}"
|
|
||||||
do
|
|
||||||
if [ $current_branch == $branch ]
|
|
||||||
then
|
|
||||||
echo Try to push to $branch
|
|
||||||
echo Run builds and test
|
|
||||||
echo This will take a while
|
|
||||||
# build_type Debug
|
|
||||||
build_type Release
|
|
||||||
echo -e $PASS All builds and tests passed pushing to $branch
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user