properly tail log and check build result

This commit is contained in:
Cat Flynn 2021-02-01 18:00:00 +00:00
parent b5e904c835
commit e681a3f306
3 changed files with 43 additions and 13 deletions

View File

@ -35,7 +35,7 @@ cleanup-build:
CLEANUP_PATH: $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN/$CI_PROJECT_NAME-build-$CI_PIPELINE_ID
script:
- echo "cleaning up build directory"
- rm -r $CLEANUP_PATH
- rm -r $CLEANUP_PATH $CLEANUP_PATH.tmp
dependencies:
- build

View File

@ -3,7 +3,7 @@
# $1 UNITY_VERSION
unityversion=$1
editorlogpath="$HOME/Library/Logs/Unity/Editor.log"
editorlogpath="$(pwd)/Editor.log"
editorpath="/Applications/Unity/Hub/Editor/$unityversion/Unity.app"
# remove previous Editor.log
@ -21,16 +21,39 @@ open -g $editorpath --args \
-logFile $editorlogpath \
-projectPath "$(pwd)/game"
# wait for unity to exit
while pgrep -x Unity > /dev/null
# use a safe directory that is automatically removed by the shell when the script exists
work="$(mktemp -d)" || exit $?
trap "rm -rf '$work'" exit
# default exit code
echo 1 > $work/exitcode
# start tail in a subshell and store its pid, then read line by line to determine build result
(tail -n 1 -f $editorlogpath &
jobs -p %% > "$work/tail.pid"
) | while read line
do
sleep 1
echo "${line}"
# check for build success
if [[ $line == *":: ktyl.build completed with code 0"* ]]; then
echo 0 > $work/exitcode
fi
# check for exit
# TODO: ideally we should have a better indicator than the package manager's shutdown message
if [[ $line == *"[Package Manager] Server::Kill -- Server was shutdown"* ]]; then
echo "exit loop"
break
fi
done
if [ -f $editorlogpath ]; then
echo "build completed, dumping log"
cat $editorlogpath
echo "TODO: check result of build by looking at the last few lines"
else
echo "no editor log to dump?"
fi
# kill zombie tail process
kill $(<"$work/tail.pid")
exitcode=$(cat $work/exitcode)
echo "exit $exitcode"
exit $exitcode
# vim: tabstop=4 shiftwidth=4 expandtab

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEditor.Compilation;
using UnityEngine;
namespace Ktyl.Util
@ -44,7 +46,12 @@ namespace Ktyl.Util
target = BuildTarget.StandaloneWindows64
};
BuildPipeline.BuildPlayer(options);
var report = BuildPipeline.BuildPlayer(options);
var result = report.summary.result;
if (result == BuildResult.Succeeded)
{
Debug.Log(":: ktyl.build completed with code 0");
}
// TODO: post-process
}