-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·101 lines (89 loc) · 3.42 KB
/
entrypoint.sh
File metadata and controls
executable file
·101 lines (89 loc) · 3.42 KB
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
#!/bin/sh
set -e
readonly base="$1"
readonly revision="$2"
readonly fail_on="$3"
readonly include_checks="$4"
readonly include_path_params="$5"
readonly deprecation_days_beta="$6"
readonly deprecation_days_stable="$7"
readonly exclude_elements="$8"
readonly filter_extension="$9"
readonly composed="${10}"
readonly flatten_allof="${11}"
readonly output_to_file="${12}"
write_output () {
_write_output_output="$1"
if [ -n "$output_to_file" ]; then
_write_output_file_output="$2"
if [ -z "$_write_output_file_output" ]; then
_write_output_file_output=$_write_output_output
fi
echo "$_write_output_file_output" >> "$output_to_file"
fi
# github-action limits output to 1MB
# we count bytes because unicode has multibyte characters
size=$(echo "$_write_output_output" | wc -c)
if [ "$size" -ge "1000000" ]; then
echo "WARN: diff exceeds the 1MB limit, truncating output..." >&2
_write_output_output=$(echo "$_write_output_output" | head -c 1000000)
fi
echo "$_write_output_output" >>"$GITHUB_OUTPUT"
}
echo "running oasdiff breaking... base: $base, revision: $revision, fail_on: $fail_on, 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, filter_extension: $filter_extension, composed: $composed, flatten_allof: $flatten_allof, output_to_file: $output_to_file"
# Build flags to pass in command
flags=""
if [ "$include_path_params" = "true" ]; then
flags="$flags --include-path-params"
fi
if [ -n "$include_checks" ]; then
flags="$flags --include-checks $include_checks"
fi
if [ -n "$deprecation_days_beta" ]; then
flags="$flags --deprecation-days-beta $deprecation_days_beta"
fi
if [ -n "$deprecation_days_stable" ]; then
flags="$flags --deprecation-days-stable $deprecation_days_stable"
fi
if [ -n "$exclude_elements" ]; then
flags="$flags --exclude-elements $exclude_elements"
fi
if [ -n "$filter_extension" ]; then
flags="$flags --filter-extension $filter_extension"
fi
if [ "$composed" = "true" ]; then
flags="$flags -c"
fi
if [ "$flatten_allof" = "true" ]; then
flags="$flags --flatten-allof"
fi
echo "flags: $flags"
# Check for breaking changes
if [ -n "$flags" ]; then
breaking_changes=$(oasdiff breaking "$base" "$revision" $flags)
else
breaking_changes=$(oasdiff breaking "$base" "$revision")
fi
# Updating GitHub Action summary with formatted output
flags_with_githubactions="$flags --format githubactions"
# Writes the summary to log and updates GitHub Action summary
oasdiff breaking "$base" "$revision" $flags_with_githubactions
# *** GitHub Action step output ***
# Output name should be in the syntax of multiple lines:
# {name}<<{delimiter}
# {value}
# {delimiter}
# see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT"
if [ -n "$breaking_changes" ]; then
write_output "$(echo "$breaking_changes" | head -n 1)" "$breaking_changes"
else
write_output "No breaking changes"
fi
echo "$delimiter" >>"$GITHUB_OUTPUT"
# First output the changes (above) and then run oasdiff to check --fail-on
if [ -n "$fail_on" ]; then
flags="$flags --fail-on $fail_on"
oasdiff breaking "$base" "$revision" $flags > /dev/null
fi