Skip to content

Commit 8a488bd

Browse files
avargitster
authored andcommitted
CI: narrow down variable definitions in --build and --test
In a preceding step the "setvar" function was made to take a "--build", "--test" or "--all" argument to indicate where the variables it sets were used. Let's make use of that by having the relevant parts of ".github/workflows/main.yml" invoke "ci/lib.sh" with those options. By doing this the set of variables shown in build-only steps will be fewer, which makes diagnosing anything going on there easier, as we won't have to look at a deluge of e.g. GIT_TEST_* variables. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1775c94 commit 8a488bd

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
steps:
8585
- uses: actions/checkout@v2
8686
- uses: git-for-windows/setup-git-for-windows-sdk@v1
87-
- run: ci/lib.sh
87+
- run: ci/lib.sh --build
8888
shell: bash
8989
- name: build
9090
shell: bash
@@ -122,7 +122,7 @@ jobs:
122122
shell: bash
123123
run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
124124
- uses: git-for-windows/setup-git-for-windows-sdk@v1
125-
- run: ci/lib.sh
125+
- run: ci/lib.sh --test
126126
shell: bash
127127
- name: select tests
128128
run: . /etc/profile && ci/select-test-slice.sh ${{matrix.nr}} 10
@@ -169,7 +169,7 @@ jobs:
169169
- name: copy dlls to root
170170
shell: cmd
171171
run: compat\vcbuild\vcpkg_copy_dlls.bat release
172-
- run: ci/lib.sh
172+
- run: ci/lib.sh --build
173173
shell: bash
174174
- name: generate Visual Studio solution
175175
shell: bash
@@ -211,7 +211,7 @@ jobs:
211211
- name: extract tracked files and build artifacts
212212
shell: bash
213213
run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
214-
- run: ci/lib.sh
214+
- run: ci/lib.sh --test
215215
shell: bash
216216
- name: select tests
217217
run: . /etc/profile && ci/select-test-slice.sh ${{matrix.nr}} 10
@@ -275,8 +275,9 @@ jobs:
275275
steps:
276276
- uses: actions/checkout@v2
277277
- run: ci/install-dependencies.sh
278-
- run: ci/lib.sh
278+
- run: ci/lib.sh --build
279279
- run: make
280+
- run: ci/lib.sh --test
280281
- run: make test
281282
if: success()
282283
- run: ci/print-test-failures.sh
@@ -310,8 +311,9 @@ jobs:
310311
steps:
311312
- uses: actions/checkout@v1
312313
- run: ci/install-dependencies.sh
313-
- run: ci/lib.sh
314+
- run: ci/lib.sh --build
314315
- run: make
316+
- run: ci/lib.sh --test
315317
- run: make test
316318
if: success() && matrix.vector.skip-tests != 'no'
317319
- run: ci/print-test-failures.sh
@@ -331,7 +333,7 @@ jobs:
331333
steps:
332334
- uses: actions/checkout@v2
333335
- run: ci/install-dependencies.sh
334-
- run: ci/lib.sh
336+
- run: ci/lib.sh --build
335337
- run: make ci-static-analysis
336338
sparse:
337339
needs: ci-config
@@ -352,7 +354,7 @@ jobs:
352354
- uses: actions/checkout@v2
353355
- name: Install other dependencies
354356
run: ci/install-dependencies.sh
355-
- run: ci/lib.sh
357+
- run: ci/lib.sh --build
356358
- run: make sparse
357359
documentation:
358360
name: documentation
@@ -364,7 +366,7 @@ jobs:
364366
steps:
365367
- uses: actions/checkout@v2
366368
- run: ci/install-dependencies.sh
367-
- run: ci/lib.sh
369+
- run: ci/lib.sh --build
368370
- run: make check-docs
369371
- run: "make doc > >(tee stdout.log) 2> >(tee stderr.raw >&2)"
370372
shell: bash

ci/lib.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ set -ex
55
. ${0%/*}/lib-ci-type.sh
66

77
# Starting assertions
8+
mode=$1
9+
if test -z "$mode"
10+
then
11+
echo "need a $0 mode, e.g. --build or --test"
12+
exit 1
13+
fi
14+
815
if test -z "$jobname"
916
then
1017
echo "must set a CI jobname" >&2
@@ -13,9 +20,14 @@ fi
1320

1421
# Helper functions
1522
setenv () {
23+
skip=
1624
varmode=
1725
case "$1" in
1826
--*)
27+
if test "$1" != "$mode" && test "$1" != "--all"
28+
then
29+
skip=t
30+
fi
1931
varmode=$1
2032
shift
2133
;;
@@ -25,6 +37,11 @@ setenv () {
2537
val=$2
2638
shift 2
2739

40+
if test -n "$skip"
41+
then
42+
return 0
43+
fi
44+
2845
if test -n "$GITHUB_ENV"
2946
then
3047
echo "$key=$val" >>"$GITHUB_ENV"

0 commit comments

Comments
 (0)