github.com/nilium/gitlab-runner@v12.5.0+incompatible/scripts/check_windows_failures (about) 1 #!/usr/bin/env bash 2 3 set -eo pipefail 4 5 borderTop() { 6 echo 7 echo "=========================================================================================================================" 8 } 9 10 borderBottom() { 11 echo "=========================================================================================================================" 12 echo 13 } 14 15 WINDOWS_VERSION=${WINDOWS_VERSION:-servercore1809} 16 17 testOutputDir="./.testoutput" 18 windowsTestOutputPattern="${testOutputDir}/*.windows.${WINDOWS_VERSION}.output.txt" 19 20 trackedFailuresFile="./ci/.test-failures.${WINDOWS_VERSION}.txt" 21 if [[ ! -f "${trackedFailuresFile}" ]]; then 22 touch "${trackedFailuresFile}" 23 fi 24 25 trackedFailuresCount=$(wc -l < "${trackedFailuresFile}") 26 27 existingFailures=() 28 newFailures=() 29 30 for file in ${windowsTestOutputPattern}; do 31 for failure in $(iconv -f utf-16 -t utf-8 "$file" | grep -Eo "\\--- FAIL: [^ ]+" | awk '{print $3}'); do 32 if grep "^${failure}$" "${trackedFailuresFile}" >/dev/null 2>&1; then 33 existingFailures+=("${failure}") 34 else 35 newFailures+=("${failure}") 36 fi 37 done 38 done 39 40 existingFailuresCount=${#existingFailures[@]} 41 newFailuresCount=${#newFailures[@]} 42 43 fixedFailuresCount=$((trackedFailuresCount - existingFailuresCount)) 44 45 borderTop 46 echo " Tracked failures: ${trackedFailuresCount}" 47 echo " Existing failures: ${existingFailuresCount}" 48 echo " New failures: ${newFailuresCount}" 49 echo " Fixed (?) failures: ${fixedFailuresCount}" 50 borderBottom 51 52 if [[ ${fixedFailuresCount} -gt -0 ]]; then 53 tmpFile="$(mktemp)" 54 updatedTrackedFailuresFile="${trackedFailuresFile}.updated" 55 56 touch "${updatedTrackedFailuresFile}" 57 58 cp "${trackedFailuresFile}" "${tmpFile}" 59 60 for failure in "${existingFailures[@]}"; do 61 echo "${failure}" >> "${updatedTrackedFailuresFile}" 62 63 grep -v "^${failure}$" "${tmpFile}" > "${tmpFile}.new" 64 mv "${tmpFile}.new" "${tmpFile}" 65 done 66 67 borderTop 68 echo " Tests that were probably fixed:" 69 echo 70 71 while read -r file; do 72 echo " - ${file}" 73 done < "${tmpFile}" 74 75 echo 76 echo " Please consider updating the tracked failures file" 77 echo " Updated version saved as artifact: ${updatedTrackedFailuresFile}" 78 borderBottom 79 80 rm "${tmpFile}" 81 fi 82 83 if [[ ${newFailuresCount} -gt 0 ]]; then 84 borderTop 85 echo " Windows tests created new failures:" 86 echo 87 88 for failure in "${newFailures[@]}"; do 89 echo " - ${failure}" 90 done 91 92 echo 93 echo " This is unacceptable! Fix the failures!" 94 echo " This job will not pass untill it's done!" 95 borderBottom 96 97 exit 1 98 fi 99 100 if [[ ${existingFailuresCount} -eq 0 ]]; then 101 borderTop 102 echo " All tests are fixed! Good job!" 103 echo " You can now update .gitlab-ci.yml file and remove this CI job." 104 borderBottom 105 106 exit 0 107 fi 108 109 if [[ ${fixedFailuresCount} -gt 0 ]]; then 110 borderTop 111 echo " It looks like you've fixed some Windows failures (probably)." 112 echo " KEEP GOING!" 113 borderBottom 114 115 exit 0 116 fi 117 118 borderTop 119 echo " It's not worse. But it could be better!" 120 echo " If you want to have some fun, chose one of the Windows" 121 echo " test failures and try to fix it!" 122 echo " And remember: Developers! Developers! Developers!" 123 borderBottom 124