ci: unify setup of some environment variables

Both GitHub Actions and Azure Pipelines set up the environment variables GIT_TEST_OPTS, GIT_PROVE_OPTS and MAKEFLAGS. And while most values are actually the same, the setup is completely duplicate. With the upcoming support for GitLab CI this duplication would only extend even further. Unify the setup of those environment variables so that only the uncommon parts are separated. While at it, we also perform some additional small improvements: - We now always pass `--state=failed,slow,save` via GIT_PROVE_OPTS. It doesn't hurt on platforms where we don't persist the state, so this further reduces boilerplate. - When running on Windows systems we set `--no-chain-lint` and `--no-bin-wrappers`. Interestingly though, we did so _after_ already having exported the respective environment variables. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Nov 9, 2023 at 09:05 UTC 9f17bef9a6ead213ea62d399baa4c67e1e89398b
1 file changed +17 -10
ci/lib.sh
+17 -10
@@ -174,11 +174,8 @@ then
174 # among *all* phases)
175 cache_dir="$HOME/test-cache/$SYSTEM_PHASENAME"
176
177 - export GIT_PROVE_OPTS="--timer --jobs 10 --state=failed,slow,save"
178 - export GIT_TEST_OPTS="--verbose-log -x --write-junit-xml"
179 - MAKEFLAGS="$MAKEFLAGS --jobs=10"
180 - test windows_nt != "$CI_OS_NAME" ||
181 - GIT_TEST_OPTS="--no-chain-lint --no-bin-wrappers $GIT_TEST_OPTS"
177 + GIT_TEST_OPTS="--write-junit-xml"
178 + JOBS=10
179 elif test true = "$GITHUB_ACTIONS"
180 then
181 CI_TYPE=github-actions
@@ -198,17 +195,27 @@ then
195
196 cache_dir="$HOME/none"
197
201 - export GIT_PROVE_OPTS="--timer --jobs 10"
202 - export GIT_TEST_OPTS="--verbose-log -x --github-workflow-markup"
203 - MAKEFLAGS="$MAKEFLAGS --jobs=10"
204 - test windows != "$CI_OS_NAME" ||
205 - GIT_TEST_OPTS="--no-chain-lint --no-bin-wrappers $GIT_TEST_OPTS"
198 + GIT_TEST_OPTS="--github-workflow-markup"
199 + JOBS=10
200 else
201 echo "Could not identify CI type" >&2
202 env >&2
203 exit 1
204 fi
205
206 +MAKEFLAGS="$MAKEFLAGS --jobs=$JOBS"
207 +GIT_PROVE_OPTS="--timer --jobs $JOBS --state=failed,slow,save"
208 +
209 +GIT_TEST_OPTS="$GIT_TEST_OPTS --verbose-log -x"
210 +case "$CI_OS_NAME" in
211 +windows|windows_nt)
212 + GIT_TEST_OPTS="$GIT_TEST_OPTS --no-chain-lint --no-bin-wrappers"
213 + ;;
214 +esac
215 +
216 +export GIT_TEST_OPTS
217 +export GIT_PROVE_OPTS
218 +
219 good_trees_file="$cache_dir/good-trees"
220
221 mkdir -p "$cache_dir"