Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#!/usr/bin/env bash 2 3# This script is meant to be used to mark failing hydra builds as broken in the meta attrs 4# To use the script, you should pass the list of failing attrs as arguments to the script. 5# 6# Example: `cat failing-attrs | xargs ./pkgs/common-updater/scripts/mark-broken` 7# 8# Generating a list of failing attrs: (this should be improved at a later date) 9# - Go to the most recent hydra evaluation with all builds completed 10# - Select the "builds still failing" tab 11# - Highlight and select all packages, should be prefixed with `nixpkgs.` 12# - Use regex and editor foo to leave only the attr names 13# - Use the above example command to then execute the script 14# 15# OTHER NOTES: 16# - The `denyFileList` and `denyAttrList` will likely need to be updated slightly 17# to align with the conventions used in nixpkgs at execution time 18# - Any attrs which failed for any reason will be written to `failed-marks.txt`. 19# Those attrs will likely need manual attention as disablement will likely be conditional. 20 21scriptName=mark-broken # do not use the .wrapped name 22 23failMark() { 24 local attr=$1 25 shift 1 26 27 echo "$attr: $@" >&2 28 echo $attr >> failed-marks.txt 29} 30 31usage() { 32 echo "Usage: $scriptName <attrs>" 33} 34 35if (( "${#@}" < 1 )); then 36 echo "$scriptName: Too few arguments" 37 usage 38 exit 1 39fi 40 41# in case we resolve to an auto-generated file, just skip these entries 42denyFileList=( 43 node-packages.nix # node, it will mark all node packages as broken 44 generic-builder.nix # haskell, it will mark all haskell packages as broken 45) 46 47# ignore older versions of parameterized packages sets, these likely need 48# to be conditionally disabled 49denyAttrList=( 50 python27Packages 51 python37Packages 52 libsForQt512 53 linuxPackages_ 54 rubyPackages_ 55) 56 57function attemptToMarkBroken() { 58 local attr=$1 59 60 # skip likely to be noisy attrs 61 for badAttr in ${denyAttrList[@]};do 62 if [[ $attr =~ $badAttr ]]; then 63 failMark $attr "attr contained $badAttr, skipped." 64 return 65 fi 66 done 67 68 nixFile=$(nix-instantiate --eval --json -E "with import ./. {}; (builtins.unsafeGetAttrPos \"description\" $attr.meta).file" 2>/dev/null | jq -r .) 69 if [[ ! -f "$nixFile" ]]; then 70 failMark $attr "Couldn't locate correct file" 71 return 72 fi 73 74 # skip files which are auto-generated 75 for filename in ${denyFileList[@]};do 76 if [[ "$filename" == $(basename $nixFile) ]]; then 77 failMark $attr "filename matched $filename, skipped." 78 return 79 fi 80 done 81 82 # Insert broken attribute 83 sed -i.bak "$nixFile" -r \ 84 -e "/^\s*broken\s*=.*$/d" \ 85 -e "s/(\s*)meta\s*=.*\{/&\n\1 broken = true;/" 86 87 if cmp -s "$nixFile" "$nixFile.bak"; then 88 mv "$nixFile.bak" "$nixFile" 89 failMark $attr "Does it have a meta attribute?" 90 return 91 fi 92 93 # broken should evaluate to true in any case now 94 markedSuccessfully=$(nix-instantiate --eval -E "with import ./. {}; $attr.meta.broken") 95 if [[ "$markedSuccessfully" != "true" ]]; then 96 mv "$nixFile.bak" "$nixFile" 97 failMark $attr "$attr.meta.broken doesn't evaluate to true." 98 return 99 fi 100 101 rm -f "$nixFile.bak" 102} 103 104for attr in $@; do 105 attemptToMarkBroken $attr 106done