|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# `evergreen validate` exits 0 even when it reports warnings, and it always writes to stdout, not |
| 4 | +# stderr. We want to fail on any warning except the specific pre-existing ones listed below, but |
| 5 | +# precious's ignore-stderr can't do that: it only looks at stderr, and it's all-or-nothing (matching |
| 6 | +# one pattern suppresses the whole output, not just that line). So we do the line-by-line filtering |
| 7 | +# here instead. |
| 8 | +# |
| 9 | +# Each accepted warning is matched exactly, by task name, rather than by a wildcard "defined but |
| 10 | +# not used" pattern. A new unused-task warning is a real problem to fix or explicitly allow here, |
| 11 | +# not something to pass silently just because it looks like the others. |
| 12 | + |
| 13 | +set -o pipefail |
| 14 | + |
| 15 | +TEMP_FILE=$(mktemp "${TMPDIR:-/tmp}/evergreen-validate.tmp.XXXXXXXXXX") |
| 16 | +trap 'rm -f "$TEMP_FILE"' EXIT |
| 17 | + |
| 18 | +# The tee lets us capture the output for filtering below while still printing it to the console, so |
| 19 | +# it shows up when precious is run in verbose mode. |
| 20 | +evergreen validate --file common.yml -p mongo-tools 2>&1 | tee "$TEMP_FILE" |
| 21 | +STATUS=${PIPESTATUS[0]} |
| 22 | + |
| 23 | +if [ "$STATUS" -ne 0 ]; then |
| 24 | + exit "$STATUS" |
| 25 | +fi |
| 26 | + |
| 27 | +if grep --quiet "is valid with warnings" "$TEMP_FILE"; then |
| 28 | + while IFS= read -r line; do |
| 29 | + case "$line" in |
| 30 | + "WARNING: task 'commit-queue-workaround' defined but not used by any variants; consider using or disabling") |
| 31 | + continue |
| 32 | + ;; |
| 33 | + "WARNING: task 'deliberate_fail_to_test_build_baron_context_rules' defined but not used by any variants; consider using or disabling") |
| 34 | + continue |
| 35 | + ;; |
| 36 | + "WARNING: task 't_resmoke_setup' defined but not used by any variants; consider using or disabling") |
| 37 | + continue |
| 38 | + ;; |
| 39 | + "WARNING: task 'generate_mongodump_fuzz_tasks' defined but not used by any variants; consider using or disabling") |
| 40 | + continue |
| 41 | + ;; |
| 42 | + *"is valid with warnings") |
| 43 | + continue |
| 44 | + ;; |
| 45 | + *) |
| 46 | + exit 1 |
| 47 | + ;; |
| 48 | + esac |
| 49 | + done <"$TEMP_FILE" |
| 50 | +fi |
0 commit comments