go.uber.org/yarpc@v1.72.1/etc/bin/generate-cover-ignore.sh (about) 1 #!/bin/bash 2 3 # This file generates the .nocover files and the ignore directories in .codecov.yml. 4 # 5 # It uses the following logic: 6 # 7 # - Add every directory that contains a generated go file 8 # - Add every directory and subdirectory in IGNORE_DIRS (in helpers.sh) 9 # - Remove every directory (but not subdirectory) in WHITELIST (in helpers.sh) 10 11 set -euo pipefail 12 13 DIR="$(cd "$(dirname "${0}")/../.." && pwd)" 14 source "${DIR}/etc/bin/helpers.sh" 15 cd "${DIR}" 16 17 remove_existing_nocover_files() { 18 find . -name \.nocover | sed 's/^\.\///' | grep -v -e '^vendor/' | xargs rm 19 } 20 21 add_nocover_files() { 22 for d in $@; do 23 touch "${d}/.nocover" 24 done 25 } 26 27 generate_codecov_file() { 28 local tmpfile="$(mktemp)" 29 head -$(grep -n ^ignore: .codecov.yml | cut -f 1 -d :) .codecov.yml > "${tmpfile}" 30 for d in $@; do 31 echo " - /${d}/" >> ${tmpfile} 32 done 33 mv "${tmpfile}" .codecov.yml 34 } 35 36 dirs="$(cover_ignore_dirs)" 37 38 remove_existing_nocover_files 39 add_nocover_files ${dirs} 40 generate_codecov_file ${dirs}