From 131e8f8792765eb9ea08f159649c67781232ae8f Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Tue, 9 Mar 2021 17:30:48 +0000 Subject: [PATCH 1/4] detect failed unity launch and retry --- ci/build.sh | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 7827da7..084f68a 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -12,28 +12,50 @@ echo "removing previous editor log..." echo "starting build using unity v$unityversion..." -# launch unity in batch mode -open -g $editorpath --args \ - -batchmode \ - -quit \ - -nographics \ - -developmentBuild \ - -executeMethod "Ktyl.Util.BuildCommand.Run" \ - -logFile $editorlogpath \ - -projectPath "$(pwd)/game" +unitypid=-1 + +launch_unity () { + # launch unity in batch mode + open -g $editorpath --args \ + -batchmode \ + -quit \ + -nographics \ + -developmentBuild \ + -executeMethod "Ktyl.Util.BuildCommand.Run" \ + -logFile $editorlogpath \ + -projectPath "$(pwd)/game" + + unitypid=`pgrep -n Unity` + echo "launched unity ($pid)" +} + +launch_unity -# wait for editor log to exist tries=60 count=0 while [ ! -f $editorlogpath ] do + if ps -p $unitypid > /dev/null + then + echo "unity ok ($unitypid)" + else + echo "unity is no longer running - trying again" + + # reset launch attempts + count=0 + launch_unity + + continue + fi + + # wait a second sleep 1 # decrement count=`expr $count + 1` if [ $count -eq $tries ] ; then - echo "early timeout - $tries seconds elapsed since launch attempt" + echo "early timeout - $tries seconds elapsed since last launch attempt" exit 1 fi done From d3a1905f1ee4f718f2d1f471732a1aeb5f7f34fe Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Tue, 9 Mar 2021 17:35:28 +0000 Subject: [PATCH 2/4] fix typo --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 084f68a..fdffd03 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -26,7 +26,7 @@ launch_unity () { -projectPath "$(pwd)/game" unitypid=`pgrep -n Unity` - echo "launched unity ($pid)" + echo "launched unity ($unitypid)" } launch_unity From af9708ebe960ca8614186e5da069f4b969eeeffd Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Tue, 9 Mar 2021 17:37:43 +0000 Subject: [PATCH 3/4] bump time limit, improve wait message --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index fdffd03..db4329e 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -31,13 +31,13 @@ launch_unity () { launch_unity -tries=60 +tries=120 count=0 while [ ! -f $editorlogpath ] do if ps -p $unitypid > /dev/null then - echo "unity ok ($unitypid)" + echo "waiting for unity ($unitypid)" else echo "unity is no longer running - trying again" From 8a92302834b279cc18d701d2d2f90f0dd9bd30b5 Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Wed, 10 Mar 2021 13:00:33 +0000 Subject: [PATCH 4/4] copy readme to build dir --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 276a001..43f0334 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,7 @@ build: - echo "cloned to $GIT_CLONE_PATH" - chmod +x ./ci/build.sh - ./ci/build.sh $UNITY_VERSION + - cp ./readme.txt $BUILD_DIR artifacts: name: $CI_PROJECT_NAME-$CI_PIPELINE_ID