From 62dc664090eb870903a69cc10b703f4ce243379e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 27 Feb 2019 22:48:37 +0100 Subject: [PATCH] ci: avoid running pod while there's another instance running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski Signed-off-by: Igor Mandrigin --- Makefile | 2 ++ ci/mobile.groovy | 46 +-------------------------------------------- scripts/wait-for.sh | 26 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 45 deletions(-) create mode 100755 scripts/wait-for.sh diff --git a/Makefile b/Makefile index 6f81f6c2f6..1b63f47da4 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,8 @@ prepare-ios: $(STATUS_GO_IOS_ARCH) ##@prepare Install and prepare iOS-specific d yarn install --frozen-lockfile unzip -q -o "$(STATUS_GO_IOS_ARCH)" -d "$(RCTSTATUS_DIR)" ifeq ($(OS),Darwin) + # CocoaPods are trash and can't handle other pod instances running at the same time + ./scripts/wait-for.sh pod 240 cd ios && pod install endif diff --git a/ci/mobile.groovy b/ci/mobile.groovy index deb69e749d..3b811128b7 100644 --- a/ci/mobile.groovy +++ b/ci/mobile.groovy @@ -2,37 +2,6 @@ cmn = load 'ci/common.groovy' ios = load 'ci/ios.groovy' android = load 'ci/android.groovy' -def wait(lockFile) { - /* Crude wait for a lock file to disappear */ - def maxAttempts = 20 - def success = false - for (i = 0; i <= maxAttempts; i++) { - rval = fileExists(lockFile) - if (!rval) { - return - } - sleep 10 - } - error("Failed to acquire lock: ${lockFile}") -} - -def podUpdate() { - /** - * This is awful BUT multiple jobs running on the same host can - * clash when trying to update the CocoaPods maste repo. - * We could set CP_REPOS_DIR, but the would result in - * multiple ~3GB directories all over the place and would be slow. - **/ - def lockFile = "${env.HOME}/.cocoapods.lock" - try { - wait(lockFile) - sh "touch ${lockFile}" - sh 'pod update --silent --no-ansi' - } finally { - sh "rm -f ${lockFile}" - } -} - def prep(type = 'nightly') { cmn.doGitRebase() /* ensure that we start from a known state */ @@ -52,21 +21,8 @@ def prep(type = 'nightly') { } /* install ruby dependencies */ sh 'bundle install --quiet' - /* node deps and status-go download */ + /* node deps, pods, and status-go download */ sh "make prepare-${env.BUILD_PLATFORM}" - /* generate ios/StatusIm.xcworkspace */ - if (env.BUILD_PLATFORM == 'ios') { - dir('ios') { - try { - sh 'pod install --silent' - } catch (Exception ex) { - println "pod installation failed, trying to upgrade the repo" - /* only if pod install fails, we try to upgrade the repo */ - podUpdate() - sh 'pod install --silent' - } - } - } } def leinBuild(platform) { diff --git a/scripts/wait-for.sh b/scripts/wait-for.sh new file mode 100755 index 0000000000..4626ca5a4b --- /dev/null +++ b/scripts/wait-for.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -e + +PROC_NAME=${1} +TIMEOUT=${2:-600} +SLEEP_SEC=5 +STEPS=$((TIMEOUT / SLEEP_SEC)) + +if [[ -z ${PROC_NAME} ]]; then + echo "No process name specified!" >&2 + exit 1 +fi + +for ((i = 0; i < ${STEPS}; i += 1)); do + if pgrep ${PROC_NAME} > /dev/null; then + echo "Process found. Sleeping ${SLEEP_SEC}..." >&2 + sleep ${SLEEP_SEC} + else + echo "Process '${PROC_NAME}' gone." >&2 + exit 0 + fi +done + +echo "Timeout reached! (${TIMEOUT}s) Process still up: ${PROC_NAME}" >&2 +exit 1