mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
ci: make it easier to find failed tests' logs in the GitHub workflow
When investigating a test failure, the time that matters most is the time it takes from getting aware of the failure to displaying the output of the failing test case. You currently have to know a lot of implementation details when investigating test failures in the CI runs. The first step is easy: the failed job is marked quite clearly, but when opening it, the failed step is expanded, which in our case is the one running `ci/run-build-and-tests.sh`. This step, most notably, only offers a high-level view of what went wrong: it prints the output of `prove` which merely tells the reader which test script failed. The actually interesting part is in the detailed log of said failed test script. But that log is shown in the CI run's step that runs `ci/print-test-failures.sh`. And that step is _not_ expanded in the web UI by default. It is even marked as "successful", which makes it very easy to miss that there is useful information hidden in there. Let's help the reader by showing the failed tests' detailed logs in the step that is expanded automatically, i.e. directly after the test suite failed. This also helps the situation where the _build_ failed and the `print-test-failures` step was executed under the assumption that the _test suite_ failed, and consequently failed to find any failed tests. An alternative way to implement this patch would be to source `ci/print-test-failures.sh` in the `handle_test_failures` function to show these logs. However, over the course of the next few commits, we want to introduce some grouping which would be harder to achieve that way (for example, we do want a leaner, and colored, preamble for each failed test script, and it would be trickier to accommodate the lack of nested groupings in GitHub workflows' output). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b95181cf82
commit
08dccc8fc1
4 changed files with 27 additions and 14 deletions
12
.github/workflows/main.yml
vendored
12
.github/workflows/main.yml
vendored
|
@ -119,10 +119,6 @@ jobs:
|
||||||
- name: test
|
- name: test
|
||||||
shell: bash
|
shell: bash
|
||||||
run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
|
run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
|
||||||
- name: ci/print-test-failures.sh
|
|
||||||
if: failure()
|
|
||||||
shell: bash
|
|
||||||
run: ci/print-test-failures.sh
|
|
||||||
- name: Upload failed tests' directories
|
- name: Upload failed tests' directories
|
||||||
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
|
@ -204,10 +200,6 @@ jobs:
|
||||||
env:
|
env:
|
||||||
NO_SVN_TESTS: 1
|
NO_SVN_TESTS: 1
|
||||||
run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
|
run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
|
||||||
- name: ci/print-test-failures.sh
|
|
||||||
if: failure()
|
|
||||||
shell: bash
|
|
||||||
run: ci/print-test-failures.sh
|
|
||||||
- name: Upload failed tests' directories
|
- name: Upload failed tests' directories
|
||||||
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
|
@ -261,8 +253,6 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: ci/install-dependencies.sh
|
- run: ci/install-dependencies.sh
|
||||||
- run: ci/run-build-and-tests.sh
|
- run: ci/run-build-and-tests.sh
|
||||||
- run: ci/print-test-failures.sh
|
|
||||||
if: failure()
|
|
||||||
- name: Upload failed tests' directories
|
- name: Upload failed tests' directories
|
||||||
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
|
@ -292,8 +282,6 @@ jobs:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- run: ci/install-docker-dependencies.sh
|
- run: ci/install-docker-dependencies.sh
|
||||||
- run: ci/run-build-and-tests.sh
|
- run: ci/run-build-and-tests.sh
|
||||||
- run: ci/print-test-failures.sh
|
|
||||||
if: failure()
|
|
||||||
- name: Upload failed tests' directories
|
- name: Upload failed tests' directories
|
||||||
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
|
|
23
ci/lib.sh
23
ci/lib.sh
|
@ -78,6 +78,10 @@ check_unignored_build_artifacts () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_failed_tests () {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# GitHub Action doesn't set TERM, which is required by tput
|
# GitHub Action doesn't set TERM, which is required by tput
|
||||||
export TERM=${TERM:-dumb}
|
export TERM=${TERM:-dumb}
|
||||||
|
|
||||||
|
@ -123,6 +127,25 @@ then
|
||||||
CI_JOB_ID="$GITHUB_RUN_ID"
|
CI_JOB_ID="$GITHUB_RUN_ID"
|
||||||
CC="${CC_PACKAGE:-${CC:-gcc}}"
|
CC="${CC_PACKAGE:-${CC:-gcc}}"
|
||||||
DONT_SKIP_TAGS=t
|
DONT_SKIP_TAGS=t
|
||||||
|
handle_failed_tests () {
|
||||||
|
mkdir -p t/failed-test-artifacts
|
||||||
|
echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
|
||||||
|
|
||||||
|
for test_exit in t/test-results/*.exit
|
||||||
|
do
|
||||||
|
test 0 != "$(cat "$test_exit")" || continue
|
||||||
|
|
||||||
|
test_name="${test_exit%.exit}"
|
||||||
|
test_name="${test_name##*/}"
|
||||||
|
printf "\\e[33m\\e[1m=== Failed test: ${test_name} ===\\e[m\\n"
|
||||||
|
cat "t/test-results/$test_name.out"
|
||||||
|
|
||||||
|
trash_dir="t/trash directory.$test_name"
|
||||||
|
cp "t/test-results/$test_name.out" t/failed-test-artifacts/
|
||||||
|
tar czf t/failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
cache_dir="$HOME/none"
|
cache_dir="$HOME/none"
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,8 @@ esac
|
||||||
make
|
make
|
||||||
if test -n "$run_tests"
|
if test -n "$run_tests"
|
||||||
then
|
then
|
||||||
make test
|
make test ||
|
||||||
|
handle_failed_tests
|
||||||
fi
|
fi
|
||||||
check_unignored_build_artifacts
|
check_unignored_build_artifacts
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ esac
|
||||||
|
|
||||||
make --quiet -C t T="$(cd t &&
|
make --quiet -C t T="$(cd t &&
|
||||||
./helper/test-tool path-utils slice-tests "$1" "$2" t[0-9]*.sh |
|
./helper/test-tool path-utils slice-tests "$1" "$2" t[0-9]*.sh |
|
||||||
tr '\n' ' ')"
|
tr '\n' ' ')" ||
|
||||||
|
handle_failed_tests
|
||||||
|
|
||||||
check_unignored_build_artifacts
|
check_unignored_build_artifacts
|
||||||
|
|
Loading…
Reference in a new issue