Skip to content
Snippets Groups Projects

Add test coverage support with kcov

Merged Massimo Zugno requested to merge rogueai/mkinitcpio:kcov into master
Files
2
+ 26
9
stages:
stages:
- check
- check
check:
.pacman_install:
stage: check
before_script:
before_script:
# NOTE: Install latest archlinux-keyring before upgrading system. In the
# NOTE: Install latest archlinux-keyring before upgrading system. In the
# future this should not be needed anymore when we can guarantee a valid
# future this should not be needed anymore when we can guarantee a valid
# keyring for longer:
# keyring for longer:
# https://gitlab.archlinux.org/archlinux/archlinux-keyring/-/issues/4
# https://gitlab.archlinux.org/archlinux/archlinux-keyring/-/issues/4
- echo -e "\e[0Ksection_start:`date +%s`:pacman[collapsed=true]\r\e[0KInstalling ShellCheck"
- echo -e "\e[0Ksection_start:`date +%s`:pacman[collapsed=true]\r\e[0KInstalling dependencies"
- pacman -Sy --needed --noconfirm archlinux-keyring
- pacman -Sy --needed --noconfirm archlinux-keyring
- pacman --noconfirm -Syu --needed git make shellcheck
- pacman --noconfirm -Syu --needed bash-bats bash-bats-assert bash-bats-support git jq kcov lzop make shellcheck
- echo -e "\e[0Ksection_end:`date +%s`:pacman\r\e[0K"
- echo -e "\e[0Ksection_end:`date +%s`:pacman\r\e[0K"
 
 
check:
 
stage: check
 
extends: .pacman_install
script:
script:
- make shellcheck
- make shellcheck
test:
test:
stage: check
stage: check
before_script:
extends: .pacman_install
- echo -e "\e[0Ksection_start:`date +%s`:pacman[collapsed=true]\r\e[0KInstalling bats"
- pacman -Sy --needed --noconfirm archlinux-keyring
- pacman --noconfirm -Syu --needed git make bash-bats bash-bats-assert bash-bats-support lzop
- echo -e "\e[0Ksection_end:`date +%s`:pacman\r\e[0K"
script:
script:
- make --silent check BATS_ARGS='-F junit' > bats-report.xml
- make --silent check BATS_ARGS='-F junit' > bats-report.xml
artifacts:
artifacts:
reports:
reports:
junit: bats-report.xml
junit: bats-report.xml
 
 
coverage:
 
stage: check
 
extends: .pacman_install
 
coverage: '/Percent covered\s+\d+\.\d+/'
 
script:
 
- make coverage 2>/dev/null
 
- jq -r '. |
 
["Percent covered", .percent_covered],
 
["Covered lines", .covered_lines],
 
["Total lines", .total_lines],
 
["Percent low", .percent_low],
 
["Percent high", .percent_high] | @tsv' coverage/bats.*/coverage.json
 
artifacts:
 
reports:
 
coverage_report:
 
coverage_format: cobertura
 
path: coverage/bats.*/cobertura.xml
Loading