|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -u |
| 4 | + |
| 5 | +EMPTY=1 |
| 6 | + |
| 7 | +ADDED=$(diff --new-line-format='%L' --old-line-format='' --unchanged-line-format='' "$1" "$2") |
| 8 | +REMOVED=$(diff --new-line-format='' --old-line-format='%L' --unchanged-line-format='' "$1" "$2") |
| 9 | +TOTAL=$(cat "$2") |
| 10 | + |
| 11 | +STATS_OLD=$(grep -E '^STAT:' "$1" | sed -E 's/^STAT://') |
| 12 | +STATS_NEW=$(grep -E '^STAT:' "$2" | sed -E 's/^STAT://') |
| 13 | + |
| 14 | +STATS_DIFFED=$(diff --new-line-format='+%L' --old-line-format='-%L' --unchanged-line-format=' %L' <(echo "$STATS_OLD") <(echo "$STATS_NEW")) |
| 15 | + |
| 16 | +ADDED_DEPRECATIONS=$(grep -Pi '\b(deprecation|deprecated)\b' <<< "$ADDED") |
| 17 | +REMOVED_DEPRECATIONS=$(grep -Pi '\b(deprecation|deprecated)\b' <<< "$REMOVED") |
| 18 | +ADDED_WARNINGS=$(grep -Pi '\b(warn|warning)\b' <<< "$ADDED") |
| 19 | +REMOVED_WARNINGS=$(grep -Pi '\b(warn|warning)\b' <<< "$REMOVED") |
| 20 | + |
| 21 | +DEPRECATION_COUNT=$(grep -Pi '\b(deprecation|deprecated)\b' <<< "$TOTAL" | wc -l) |
| 22 | +WARNING_COUNT=$(grep -Pi '\b(warn|warning)\b' <<< "$TOTAL" | wc -l) |
| 23 | + |
| 24 | +if [ -z "$ADDED_DEPRECATIONS" ]; then |
| 25 | + # no new deprecations |
| 26 | + true |
| 27 | +else |
| 28 | + echo "⚠️ This PR introduces new deprecations:" |
| 29 | + echo |
| 30 | + echo '```' |
| 31 | + echo "$ADDED_DEPRECATIONS" |
| 32 | + echo '```' |
| 33 | + echo |
| 34 | + EMPTY=0 |
| 35 | +fi |
| 36 | + |
| 37 | +if [ -z "$ADDED_WARNINGS" ]; then |
| 38 | + # no new deprecations |
| 39 | + true |
| 40 | +else |
| 41 | + echo "⚠️ This PR introduces new warnings:" |
| 42 | + echo |
| 43 | + echo '```' |
| 44 | + echo "$ADDED_WARNINGS" |
| 45 | + echo '```' |
| 46 | + echo |
| 47 | + EMPTY=0 |
| 48 | +fi |
| 49 | + |
| 50 | +if grep "LIB BUILD FAILED" <<< "$TOTAL"; then |
| 51 | + echo '❌ Basic `dub build` failed! Please check your changes again.' |
| 52 | + echo |
| 53 | +elif grep "DCD BUILD FAILED" <<< "$TOTAL"; then |
| 54 | + echo '❌ `dub build` of DCD has failed with these changes! Please check your changes again.' |
| 55 | + echo |
| 56 | +else |
| 57 | + if [ -z "$REMOVED_DEPRECATIONS" ]; then |
| 58 | + # no removed deprecations |
| 59 | + true |
| 60 | + else |
| 61 | + echo "✅ This PR fixes following deprecations:" |
| 62 | + echo |
| 63 | + echo '```' |
| 64 | + echo "$REMOVED_DEPRECATIONS" |
| 65 | + echo '```' |
| 66 | + echo |
| 67 | + EMPTY=0 |
| 68 | + fi |
| 69 | + |
| 70 | + if [ -z "$REMOVED_WARNINGS" ]; then |
| 71 | + # no removed warnings |
| 72 | + true |
| 73 | + else |
| 74 | + echo "✅ This PR fixes following warnings:" |
| 75 | + echo |
| 76 | + echo '```' |
| 77 | + echo "$REMOVED_WARNINGS" |
| 78 | + echo '```' |
| 79 | + echo |
| 80 | + EMPTY=0 |
| 81 | + fi |
| 82 | + |
| 83 | + if [ $EMPTY == 1 ]; then |
| 84 | + echo "✅ PR OK, no changes in deprecations or warnings" |
| 85 | + echo |
| 86 | + fi |
| 87 | + |
| 88 | + echo "Total deprecations: $DEPRECATION_COUNT" |
| 89 | + echo |
| 90 | + echo "Total warnings: $WARNING_COUNT" |
| 91 | + echo |
| 92 | +fi |
| 93 | + |
| 94 | +if [ -z "$STATS_DIFFED" ]; then |
| 95 | + # no statistics? |
| 96 | + true |
| 97 | +else |
| 98 | + echo "Build statistics:" |
| 99 | + echo |
| 100 | + echo '```diff' |
| 101 | + echo "$STATS_DIFFED" |
| 102 | + echo '```' |
| 103 | + echo |
| 104 | +fi |
| 105 | + |
| 106 | +echo '<details>' |
| 107 | +echo |
| 108 | +echo '<summary>Full build output</summary>' |
| 109 | +echo |
| 110 | +echo '```' |
| 111 | +echo "$TOTAL" |
| 112 | +echo '```' |
| 113 | +echo |
| 114 | +echo '</details>' |
0 commit comments