Travis CI: folded output/default tracebacks (#1331)

* Moved the `script` and `after_failure` sections of `.travis.yml`
  to extra files in a new `.travis/` folder
* Copy paste `.travis/common.sh` from Alpine's aport. They have neat
  formatting functions in there for folding
* Add a folding block around each script that gets called
* Use native tracebacks in pytest. These are the same as we see when
  pmbootstrap crashes usually, instead of printing out the entire
  function that causes an error. I think this makes the error output
  easier to read.
This commit is contained in:
Oliver Smith 2018-03-14 20:32:47 +00:00 committed by GitHub
parent 49e15b322c
commit f75ac13a4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 99 additions and 8 deletions

View file

@ -9,15 +9,10 @@ install:
- sudo apt install shellcheck qemu-system-x86
- pip install flake8 pytest-cov python-coveralls
script:
- test/static_code_analysis.sh
- yes "" | ./pmbootstrap.py init
- ./pmbootstrap.py kconfig_check
- test/check_checksums.py --build
- test/testcases_fast.sh --all
- .travis/travis_script.sh
after_success:
- coveralls
after_failure:
- cat ~/.local/var/pmbootstrap/log.txt
- cat ~/.local/var/pmbootstrap/log_testsuite.txt
- .travis/travis_after_failure.sh
notifications:
- email: false

45
.travis/common.sh Normal file
View file

@ -0,0 +1,45 @@
# Source: .travis/common.sh from Alpine's aports repo
die() {
print -s1 -c1 "$@\n" 1>&2
exit 1
}
# Marks start of named folding section for Travis and prints title.
fold_start() {
local name="$1"
local title="$2"
printf "\ntravis_fold:start:$name "
print -s1 -c6 "> $title\n"
}
# Marks end of the named folding section.
fold_end() {
local name="$1"
printf "travis_fold:end:$name\n"
}
# Prints formatted and colored text.
print() {
local style=0
local fcolor=9
local opt; while getopts 's:c:' opt; do
case "$opt" in
s) style="$OPTARG";;
c) fcolor="$OPTARG";;
esac
done
shift $(( OPTIND - 1 ))
local text="$@"
printf "\033[${style};3${fcolor}m$text\033[0m"
}
title() {
printf '\n'
print -s1 -c6 "==> $@\n"
}

18
.travis/travis_after_failure.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/sh -e
# Go to pmbootstrap folder
DIR="$(cd "$(dirname "$0")" && pwd -P)"
cd "$DIR/.."
# Functions for pretty Travis output
. .travis/common.sh
# pmbootstrap log
fold_start "log.1" "pmbootstrap log"
cat ~/.local/var/pmbootstrap/log.txt
fold_end "log.1"
# Testsuite log
fold_start "log.2" "Testsuite log"
cat ~/.local/var/pmbootstrap/log_testsuite.txt
fold_end "log.2"

33
.travis/travis_script.sh Executable file
View file

@ -0,0 +1,33 @@
#!/bin/sh -e
# Go to pmbootstrap folder
DIR="$(cd "$(dirname "$0")" && pwd -P)"
cd "$DIR/.."
# Functions for pretty Travis output
. .travis/common.sh
# Static code analysis
fold_start "static_analysis" "Static code analysis"
test/static_code_analysis.sh
fold_end "static_analysis"
# pmbootstrap init
fold_start "init" "pmbootstrap init"
yes "" | ./pmbootstrap.py init
fold_end "init"
# pmbootstrap kconfig_check
fold_start "kconfig_check" "pmbootstrap kconfig_check"
./pmbootstrap.py kconfig_check
fold_end "kconfig_check"
# pmbootstrap build --strict
fold_start "build" "pmbootstrap build --strict"
test/check_checksums.py --build
fold_end "build"
# Testsuite
fold_start "testsuite" "Testsuite and code coverage"
test/testcases_fast.sh --all
fold_end "testsuite"

View file

@ -35,4 +35,4 @@ done
# Run enabled testcases with coverage enabled
# shellcheck disable=SC2086
pytest --cov=pmb $enabled
pytest --cov=pmb $enabled --tb=native