Skip to content

Commit

Permalink
verbose fsenv logging
Browse files Browse the repository at this point in the history
  • Loading branch information
humbletim committed Sep 17, 2022
1 parent 39c8ac8 commit 863c2b2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
38 changes: 27 additions & 11 deletions .github/fsenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,35 @@ set -eu

# function wrapper to avoid leaking variables when "sourced" into other scripts
function _fsenv() {
local os
if [[ ${RUNNER_OS+x} ]] ; then
case $RUNNER_OS in
Windows) os=windows ;;
Linux) os=linux ;;
esac
fi
if [[ ! ${os+x} ]] ; then
case `uname -s` in
MINGW*) os=windows ;;
*) os=linux ;;
esac
fi

# setenv <name> [default-value]
# exports the named variable and emits a key="value" to stdout
# (a no-op when both the variable doesn't exist and no default is specified)
function setenv() {
if [[ ! ${!1+x} ]] ; then
if [[ $# -lt 2 ]] ; then return 0 ; fi
if [[ $# -lt 2 ]] ; then
echo "# setenv($1) -- no-op" >&2
return 0
fi
# var not present assign to default and export
echo "# setenv($1,$2)" >&2
printf -v "${1}" "%s" "${2}"
fi
eval "export ${1}"
echo "# export($1)" >&2
[[ ${os} == linux ]] && eval "export ${1}"
emitvar "$@"
}

Expand All @@ -38,18 +56,14 @@ function _fsenv() {

setenv GHA_TEST_WITH_SPACES "testing \"1\" 2 3...tab\t."

if [[ ! ${os+x} ]] ; then
case `uname -s` in
MINGW*) setenv os windows ;;
*) setenv os linux ;;
esac
fi
if [[ ! ${GITHUB_WORKSPACE+x} ]] ; then
case `uname -s` in
MINGW*) local GITHUB_WORKSPACE=$(pwd -W) ;;
*) local GITHUB_WORKSPACE=$PWD ;;
esac
fi
echo "os=$os"

setenv _3P_UTILSDIR ${GITHUB_WORKSPACE}/.github/3p

############################################################################
Expand Down Expand Up @@ -122,9 +136,11 @@ function _fsenv() {
unset _fsenv
}

if (return 0 2>/dev/null) ; then
# fsenv.sh was sourced ; export only
_fsenv > /dev/null
if [[ ! ${GITHUB_ACTIONS+x} ]] ; then
if (return 0 2>/dev/null) ; then
# fsenv.sh was sourced ; export only
_fsenv > /dev/null
fi
elif [[ -n $# ]] ; then
# fsenv.sh was passed subcommands ; export and execute
_fsenv > /dev/null
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/CompileWindows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
- name: Preset ENV
shell: bash
run: |
echo =============================================================
.github/fsenv.sh
echo =============================================================
.github/fsenv.sh | tee -a $GITHUB_ENV
if [[ ! ${GITHUB_ACTIONS+x} ]] ; then #dev
set -ea && source <( .github/fsenv.sh ) && set +ea && test -n "$VIEWER_CHANNEL" -a -n "$FSBUILD_DIR" -a -n "$AUTOBUILD_VSVER" #dev
Expand Down

0 comments on commit 863c2b2

Please sign in to comment.