diff --git a/action.yml b/action.yml index ab4eff4..173b150 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,10 @@ inputs: org: description: Which organization the breakpoint is associated with required: false + trunk-launcher-quiet: + description: Debug of launcher + required: false + default: 1 trunk-path: description: Path to Trunk Launcher. If not provided, we'll look for it the repo root, `.trunk/bin` and @@ -57,4 +61,4 @@ runs: TRUNK_TOKEN: ${{ inputs.trunk-token }} SHELL: ${{ inputs.shell }} GH_TOKEN: ${{ github.token }} - TRUNK_LAUNCHER_QUIET: 1 + TRUNK_LAUNCHER_QUIET: ${{ inputs.trunk-launcher-quiet }} diff --git a/trunk b/trunk index 8c0dd8e..b4562c8 100755 --- a/trunk +++ b/trunk @@ -8,6 +8,9 @@ set -euo pipefail +# DO NOT LAND +echo -e "Hello from the trunk launcher" + readonly TRUNK_LAUNCHER_VERSION="1.2.6" # warning: this line is auto-updated readonly SUCCESS_MARK="\033[0;32m✔\033[0m" @@ -36,22 +39,30 @@ readonly PLATFORM PLATFORM_UNDERSCORE="${KERNEL}_${MACHINE}" readonly PLATFORM_UNDERSCORE +echo -e "Stop point 1" + # https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences # [nF is "cursor previous line" and moves to the beginning of the nth previous line # [0K is "erase display" and clears from the cursor to the end of the screen readonly CLEAR_LAST_MSG="\033[1F\033[0K" +echo -e "Stop point 1.1" + if [[ ! -z ${CI:-} && "${CI}" = true && -z ${TRUNK_LAUNCHER_QUIET:-} ]]; then TRUNK_LAUNCHER_QUIET=1 else TRUNK_LAUNCHER_QUIET=${TRUNK_LAUNCHER_QUIET:-${TRUNK_QUIET:-false}} fi +echo -e "Stop point 1.2" + readonly TRUNK_LAUNCHER_DEBUG -if [[ ${TRUNK_LAUNCHER_QUIET} != false ]]; then - exec 3>&1 4>&2 &>/dev/null -fi +echo -e "Stop point 1.3" + +echo -e "TRUNK_LAUNCHER_QUIET: ${TRUNK_LAUNCHER_QUIET}" + +echo -e "Stop point 1.4" TRUNK_CACHE="${TRUNK_CACHE:-}" if [[ -n ${TRUNK_CACHE} ]]; then @@ -61,10 +72,15 @@ elif [[ -n ${XDG_CACHE_HOME:-} ]]; then else TRUNK_CACHE="${HOME}/.cache/trunk" fi + +echo -e "Stop point 2" + readonly TRUNK_CACHE readonly CLI_DIR="${TRUNK_CACHE}/cli" mkdir -p "${CLI_DIR}" +echo -e "Stop point 3" + # platform check readonly MINIMUM_MACOS_VERSION="10.15" check_darwin_version() { @@ -94,6 +110,8 @@ else exit 1 fi +echo -e "Stop point 4" + TRUNK_TMPDIR="${TMPDIR}/trunk-$( set -e id -u @@ -113,6 +131,8 @@ cleanup() { } trap 'cleanup $?' EXIT +echo -e "Stop point 5" + # e.g. 2022-02-16-20-40-31-0800 dt_str() { date +"%Y-%m-%d-%H-%M-%S%z"; } @@ -165,6 +185,8 @@ awk_test() { } awk_test +echo -e "Stop point 6" + readonly CURL_FLAGS="${CURL_FLAGS:- -vvv --max-time 120 --retry 3 --fail}" readonly WGET_FLAGS="${WGET_FLAGS:- --verbose --tries=3 --limit-rate=10M}" TMP_DOWNLOAD_LOG="${TRUNK_TMPDIR}/download-$( @@ -228,6 +250,8 @@ else } fi +echo -e "Stop point 7" + download_url() { local url="${1}" local output_to="${2}" @@ -279,6 +303,8 @@ else } fi +echo -e "Stop point 8" + ############################################################################### # # # CLI resolution functions # @@ -436,10 +462,14 @@ if [[ -n ${LATEST_FILE:-} ]]; then mv -n "${LATEST_FILE}" "${TOOL_DIR}/version" >/dev/null 2>&1 || true fi +echo -e "Stop point 9" + # NOTE: exec will overwrite the process image, so trap will not catch the exit signal. # Therefore, run cleanup manually here. cleanup 0 +echo -e "Running ${TOOL_DIR}/trunk $@"; + exec \ env TRUNK_LAUNCHER_VERSION="${TRUNK_LAUNCHER_VERSION}" \ env TRUNK_LAUNCHER_PATH="${BASH_SOURCE[0]}" \