1
1
#! /bin/sh
2
2
set -e
3
3
4
+ source $GITHUB_WORKSPACE /common/common.sh
5
+
4
6
readonly base=" $1 "
5
7
readonly revision=" $2 "
6
8
readonly fail_on_diff=" $3 "
@@ -10,31 +12,32 @@ readonly deprecation_days_beta="$6"
10
12
readonly deprecation_days_stable=" $7 "
11
13
readonly exclude_elements=" $8 "
12
14
readonly composed=" $9 "
15
+ readonly output_to_file=" ${10} "
13
16
14
- echo " running oasdiff breaking... base: $base , revision: $revision , fail_on_diff: $fail_on_diff , include_checks: $include_checks , include_path_params: $include_path_params , deprecation_days_beta: $deprecation_days_beta , deprecation_days_stable: $deprecation_days_stable , exclude_elements: $exclude_elements "
17
+ echo " running oasdiff breaking... base: $base , revision: $revision , fail_on_diff: $fail_on_diff , include_checks: $include_checks , include_path_params: $include_path_params , deprecation_days_beta: $deprecation_days_beta , deprecation_days_stable: $deprecation_days_stable , exclude_elements: $exclude_elements , composed: $composed , output_to_file: $output_to_file "
15
18
16
19
# Build flags to pass in command
17
20
flags=" "
18
21
if [ " $fail_on_diff " = " true" ]; then
19
- flags=" ${ flags} --fail-on WARN"
22
+ flags=" $flags --fail-on WARN"
20
23
fi
21
24
if [ " $include_path_params " = " true" ]; then
22
- flags=" ${ flags} --include-path-params"
25
+ flags=" $flags --include-path-params"
23
26
fi
24
27
if [ -n " $include_checks " ]; then
25
- flags=" ${ flags} --include-checks $include_checks "
28
+ flags=" $flags --include-checks $include_checks "
26
29
fi
27
30
if [ -n " $deprecation_days_beta " ]; then
28
- flags=" ${ flags} --deprecation-days-beta $deprecation_days_beta "
31
+ flags=" $flags --deprecation-days-beta $deprecation_days_beta "
29
32
fi
30
33
if [ -n " $deprecation_days_stable " ]; then
31
- flags=" ${ flags} --deprecation-days-stable $deprecation_days_stable "
34
+ flags=" $flags --deprecation-days-stable $deprecation_days_stable "
32
35
fi
33
- if [ " $exclude_elements " != " " ]; then
34
- flags=" ${ flags} --exclude-elements ${ exclude_elements} "
36
+ if [ -n " $exclude_elements " ]; then
37
+ flags=" $flags --exclude-elements $exclude_elements "
35
38
fi
36
39
if [ " $composed " = " true" ]; then
37
- flags=" ${ flags} -c"
40
+ flags=" $flags -c"
38
41
fi
39
42
echo " flags: $flags "
40
43
@@ -46,32 +49,25 @@ echo "flags: $flags"
46
49
# {delimiter}
47
50
# see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
48
51
delimiter=$( cat /proc/sys/kernel/random/uuid | tr -d ' -' )
49
- echo " breaking<<$delimiter " >> $GITHUB_OUTPUT
52
+ echo " breaking<<$delimiter " >> " $GITHUB_OUTPUT "
50
53
51
54
if [ -n " $flags " ]; then
52
- output=$( oasdiff breaking " $base " " $revision " $flags | head -n 1 )
55
+ output=$( oasdiff breaking " $base " " $revision " $flags )
53
56
else
54
- output=$( oasdiff breaking " $base " " $revision " | head -n 1 )
57
+ output=$( oasdiff breaking " $base " " $revision " )
55
58
fi
56
59
57
60
if [ -n " $output " ]; then
58
- # github-action limits output to 1MB
59
- # we count bytes because unicode has multibyte characters
60
- size=$( echo " $output " | wc -c)
61
- if [ " $size " -ge " 1000000" ]; then
62
- echo " WARN: breaking exceeds the 1MB limit, truncating output..." >&2
63
- output=$( echo " $output " | head -c 1000000)
64
- fi
65
- echo " $output " >> $GITHUB_OUTPUT
61
+ write_output " $( echo " $output " | head -n 1) " " $output "
66
62
else
67
- echo " No breaking changes" >> $GITHUB_OUTPUT
63
+ write_output " No breaking changes"
68
64
fi
69
65
70
- echo " $delimiter " >> $GITHUB_OUTPUT
66
+ echo " $delimiter " >> " $GITHUB_OUTPUT "
71
67
72
68
# *** github action step output ***
73
69
74
70
# Updating GitHub Action summary with formatted output
75
- flags=" ${ flags} --format githubactions"
71
+ flags=" $flags --format githubactions"
76
72
# Writes the summary to log and updates GitHub Action summary
77
73
oasdiff breaking " $base " " $revision " $flags
0 commit comments