From 8830cdd08cfc09a6037b4178fb7258807cd22735 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 6 May 2020 06:53:25 +0530 Subject: [PATCH] Add support for self-hosted darwin runners --- dist/index.js | 34 +++++++--------------------------- src/scripts/darwin.sh | 28 +++++++++++++++++++++------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/dist/index.js b/dist/index.js index d76268c8..7ce31cb5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -354,20 +354,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const os = __importStar(__webpack_require__(87)); -const events = __importStar(__webpack_require__(614)); -const child = __importStar(__webpack_require__(129)); -const path = __importStar(__webpack_require__(622)); -const io = __importStar(__webpack_require__(1)); -const ioUtil = __importStar(__webpack_require__(672)); +const os = __webpack_require__(87); +const events = __webpack_require__(614); +const child = __webpack_require__(129); +const path = __webpack_require__(622); +const io = __webpack_require__(1); +const ioUtil = __webpack_require__(672); /* eslint-disable @typescript-eslint/unbound-method */ const IS_WINDOWS = process.platform === 'win32'; /* @@ -811,12 +804,6 @@ class ToolRunner extends events.EventEmitter { resolve(exitCode); } }); - if (this.options.input) { - if (!cp.stdin) { - throw new Error('child process missing stdin'); - } - cp.stdin.end(this.options.input); - } }); }); } @@ -2883,15 +2870,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const tr = __importStar(__webpack_require__(9)); +const tr = __webpack_require__(9); /** * Exec a command. * Output will be streamed to the live console. diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index e701f5e9..137da343 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -178,15 +178,14 @@ update_formulae() { # Function to setup PHP >=5.6 setup_php() { action=$1 - if [ "$version" = "8.0" ]; then - update_formulae - fi export HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew tap shivammathur/homebrew-php - if [ "$version" = "5.6" ] || [ "$version" = "7.0" ]; then - brew install https://raw.githubusercontent.com/shivammathur/homebrew-php/master/Formula/icu4c.rb --force + if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then + brew unlink php@"$version" + else + if [ "$version" = "8.0" ]; then update_formulae; fi + brew "$action" shivammathur/php/php@"$version" fi - brew "$action" shivammathur/php/php@"$version" brew link --force --overwrite php@"$version" } @@ -198,7 +197,22 @@ nodot_version=${1/./} old_versions="5.[3-5]" tool_path_dir="/usr/local/bin" existing_version=$(php-config --version 2>/dev/null | cut -c 1-3) -[[ -z "${update}" ]] && update='false' || update="${update}" +[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}" +[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}" +[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}" +[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}" + +if [ "$runner" = "self-hosted" ]; then + if [[ "$version" =~ $old_versions ]]; then + add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner" + exit 1 + fi + if [[ $(command -v brew) == "" ]]; then + step_log "Setup Brew" + curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash -s >/dev/null 2>&1 + add_log "$tick" "Brew" "Installed Homebrew" + fi +fi # Setup PHP step_log "Setup PHP"