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