@@ -13,6 +13,23 @@ then
exit 1
fi
+# Helper functions
+setenv () {
+ varmode=
+ case "$1" in
+ --*)
+ varmode=$1
+ shift
+ ;;
+ esac
+
+ key=$1
+ val=$2
+ shift 2
+
+ eval "export $key=\"$val\""
+}
+
check_unignored_build_artifacts ()
{
! git ls-files --other --exclude-standard --error-unmatch \
@@ -24,7 +41,7 @@ check_unignored_build_artifacts ()
}
# GitHub Action doesn't set TERM, which is required by tput
-export TERM=${TERM:-dumb}
+setenv TERM ${TERM:-dumb}
# Clear MAKEFLAGS that may come from the outside world.
MAKEFLAGS=
@@ -34,23 +51,23 @@ then
CI_TYPE=github-actions
CC="${CC:-gcc}"
- export GIT_PROVE_OPTS="--timer --jobs 10"
+ setenv --test GIT_PROVE_OPTS "--timer --jobs 10"
GIT_TEST_OPTS="--verbose-log -x"
MAKEFLAGS="$MAKEFLAGS --jobs=10"
test Windows != "$RUNNER_OS" ||
GIT_TEST_OPTS="--no-chain-lint --no-bin-wrappers $GIT_TEST_OPTS"
- export GIT_TEST_OPTS
+ setenv --test GIT_TEST_OPTS "$GIT_TEST_OPTS"
else
echo "Could not identify CI type" >&2
env >&2
exit 1
fi
-export DEVELOPER=1
-export DEFAULT_TEST_TARGET=prove
-export GIT_TEST_CLONE_2GB=true
-export SKIP_DASHED_BUILT_INS=YesPlease
+setenv --build DEVELOPER 1
+setenv --test DEFAULT_TEST_TARGET prove
+setenv --test GIT_TEST_CLONE_2GB true
+setenv --build SKIP_DASHED_BUILT_INS YesPlease
case "$runs_on_pool" in
ubuntu-latest)
@@ -66,7 +83,7 @@ ubuntu-latest)
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python2"
fi
- export GIT_TEST_HTTPD=true
+ setenv --test GIT_TEST_HTTPD true
;;
macos-latest)
if [ "$jobname" = osx-gcc ]
@@ -89,9 +106,9 @@ linux-musl)
MAKEFLAGS="$MAKEFLAGS GIT_TEST_UTF8_LOCALE=C.UTF-8"
;;
linux-leaks)
- export SANITIZE=leak
- export GIT_TEST_PASSING_SANITIZE_LEAK=true
+ setenv --build SANITIZE leak
+ setenv --test GIT_TEST_PASSING_SANITIZE_LEAK true
;;
esac
-export MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
+setenv --all MAKEFLAGS "$MAKEFLAGS CC=${CC:-cc}"
@@ -9,33 +9,33 @@ export MAKE_TARGETS="all test"
case "$jobname" in
linux-gcc)
- export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+ setenv --test GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME main
;;
linux-TEST-vars)
- export GIT_TEST_SPLIT_INDEX=yes
- export GIT_TEST_MERGE_ALGORITHM=recursive
- export GIT_TEST_FULL_IN_PACK_ARRAY=true
- export GIT_TEST_OE_SIZE=10
- export GIT_TEST_OE_DELTA_SIZE=5
- export GIT_TEST_COMMIT_GRAPH=1
- export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1
- export GIT_TEST_MULTI_PACK_INDEX=1
- export GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=1
- export GIT_TEST_ADD_I_USE_BUILTIN=1
- export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
- export GIT_TEST_WRITE_REV_INDEX=1
- export GIT_TEST_CHECKOUT_WORKERS=2
+ setenv --test GIT_TEST_SPLIT_INDEX yes
+ setenv --test GIT_TEST_MERGE_ALGORITHM recursive
+ setenv --test GIT_TEST_FULL_IN_PACK_ARRAY true
+ setenv --test GIT_TEST_OE_SIZE 10
+ setenv --test GIT_TEST_OE_DELTA_SIZE 5
+ setenv --test GIT_TEST_COMMIT_GRAPH 1
+ setenv --test GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS 1
+ setenv --test GIT_TEST_MULTI_PACK_INDEX 1
+ setenv --test GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP 1
+ setenv --test GIT_TEST_ADD_I_USE_BUILTIN 1
+ setenv --test GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME master
+ setenv --test GIT_TEST_WRITE_REV_INDEX 1
+ setenv --test GIT_TEST_CHECKOUT_WORKERS 2
;;
linux-clang)
- export GIT_TEST_DEFAULT_HASH=sha1
+ setenv --test GIT_TEST_DEFAULT_HASH sha1
;;
linux-sha256)
- export GIT_TEST_DEFAULT_HASH=sha256
+ setenv --test GIT_TEST_DEFAULT_HASH sha256
;;
pedantic)
# Don't run the tests; we only care about whether Git can be
# built.
- export DEVOPTS=pedantic
+ setenv --build DEVOPTS pedantic
export MAKE_TARGETS=all
;;
esac
Add and use a "setenv" wrapper to export the variables set in ci/lib.sh. For now this merely adds debugging information about what variables are set, but in a subsequent commit we'll expand this to set variables in $GITHUB_ENV instead of the environment, and thus carry variable settings between steps in a job. We'll also eventually be interested in what type of variable we're setting, and when it needs to be used, because we'll prominently expose what variables we set in what CI "step", so having only the ones we actually use will improve readability. To that end call the "setenv" function with optional "--build", "--test" and "--all" parameters to indicate whether they're needed for building, testing or both. We currently ignore this parameter, but will make use of it in a subsequent commit. Adding it here reduces the needless churn, as we won't need to change all these lines again for that subsequent change. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- ci/lib.sh | 39 ++++++++++++++++++++++++++++----------- ci/run-build-and-tests.sh | 34 +++++++++++++++++----------------- 2 files changed, 45 insertions(+), 28 deletions(-)