Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Allow to set launcher to not quiet #46

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
36 changes: 33 additions & 3 deletions trunk
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -94,6 +110,8 @@ else
exit 1
fi

echo -e "Stop point 4"

TRUNK_TMPDIR="${TMPDIR}/trunk-$(
set -e
id -u
Expand All @@ -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"; }

Expand Down Expand Up @@ -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-$(
Expand Down Expand Up @@ -228,6 +250,8 @@ else
}
fi

echo -e "Stop point 7"

download_url() {
local url="${1}"
local output_to="${2}"
Expand Down Expand Up @@ -279,6 +303,8 @@ else
}
fi

echo -e "Stop point 8"

###############################################################################
# #
# CLI resolution functions #
Expand Down Expand Up @@ -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]}" \
Expand Down