Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .github/workflows/test-breaking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ jobs:
i=1
while [ "$i" -le 7 ]; do
[ "$i" -gt 1 ] && printf ','
printf '{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets%s","section":"paths"}' "$i"
printf '{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets%s","section":"paths","fingerprint":"fp%s"}' "$i" "$i"
i=$((i+1))
done
printf ']'
Expand Down Expand Up @@ -433,10 +433,8 @@ jobs:
echo "$body"
for expected in \
'7 breaking changes in this pull request' \
'| severity | change | endpoint |' \
'API removed [' \
'https://www.oasdiff.com/checks/api-removed-without-deprecation' \
'GET /pets5' \
'| severity | change | endpoint | diff |' \
'| error | API removed | <code>GET /pets5</code> | [view](https://www.oasdiff.com/review/e/stub-id?highlight=fp5#k=stub-key) |' \
'<details><summary>2 more</summary>' \
'GET /pets6' \
'oasdiff Pro'
Expand Down Expand Up @@ -485,7 +483,7 @@ jobs:
esac
done
case "${fmt:-text}" in
json) printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths"}]' ;;
json) printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths","fingerprint":"abc123def456"}]' ;;
gha) echo "::error file=specs/base.yaml,line=11::API removed" ;;
open) echo "https://www.oasdiff.com/review/e/stub-id#k=stub-key" >&2 ;;
*) echo "1 changes: 1 error, 0 warning, 0 info" ;;
Expand Down Expand Up @@ -605,7 +603,7 @@ jobs:

cat > /tmp/stub/oasdiff <<'STUB'
#!/bin/sh
for a in "$@"; do [ "$a" = "json" ] && { printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths"}]'; exit 0; }; done
for a in "$@"; do [ "$a" = "json" ] && { printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths","fingerprint":"abc123def456"}]'; exit 0; }; done
for a in "$@"; do
if [ "$a" = "--open" ]; then
echo "$1" > /tmp/run/open-command
Expand Down Expand Up @@ -659,8 +657,8 @@ jobs:
for expected in \
'1 breaking change in this pull request' \
'status check on this pull request shows whether they are all approved' \
'| severity | change | endpoint |' \
'api-removed-without-deprecation' \
'| severity | change | endpoint | diff |' \
'| error | API removed | <code>GET /pets</code> | [view](https://www.oasdiff.com/review/ep/test-token-uuid?highlight=abc123def456#k=test-key) |' \
'Review and approve the changes'
do
case "$pro_body" in
Expand Down Expand Up @@ -696,7 +694,7 @@ jobs:
#!/bin/sh
for a in "$@"; do
case "$a" in
json) printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths"}]'; exit 0 ;;
json) printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths","fingerprint":"abc123def456"}]'; exit 0 ;;
githubactions) echo "::error file=specs/base.yaml,line=11::API removed"; exit 0 ;;
--open)
echo "oasdiff: opening review at https://www.oasdiff.com/review/ep/test-token-uuid#k=test-key" >&2
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test-changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
# on the args.
cat > /tmp/stub/oasdiff <<'STUB'
#!/bin/sh
for a in "$@"; do [ "$a" = "json" ] && { printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths"}]'; exit 0; }; done
for a in "$@"; do [ "$a" = "json" ] && { printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths","fingerprint":"abc123def456"}]'; exit 0; }; done
for a in "$@"; do
if [ "$a" = "--open" ]; then
echo 'Error: upload failed (HTTP 402): {"code":"subscription_expired","message":"Your oasdiff trial or subscription has expired. Renew at https://www.oasdiff.com/pricing to continue using oasdiff Pro.","upgrade_url":"https://www.oasdiff.com/pricing"}' >&2
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:

cat > /tmp/stub/oasdiff <<'STUB'
#!/bin/sh
for a in "$@"; do [ "$a" = "json" ] && { printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths"}]'; exit 0; }; done
for a in "$@"; do [ "$a" = "json" ] && { printf '[{"id":"api-removed-without-deprecation","text":"API removed","level":3,"operation":"GET","path":"/pets","section":"paths","fingerprint":"abc123def456"}]'; exit 0; }; done
for a in "$@"; do
if [ "$a" = "--open" ]; then
echo "oasdiff: opening review at https://www.oasdiff.com/review/ep/test-token-uuid#k=test-key" >&2
Expand Down Expand Up @@ -240,8 +240,8 @@ jobs:
for expected in \
'1 API change in this pull request' \
'status check on this pull request shows whether they are all approved' \
'| severity | change | endpoint |' \
'api-removed-without-deprecation' \
'| severity | change | endpoint | diff |' \
'API removed' \
'Review and approve the changes'
do
case "$pro_body" in
Expand Down Expand Up @@ -289,7 +289,7 @@ jobs:
printf ',{"id":"response-property-became-optional","text":"added @octocat [l](https://e.example) <b>","level":1,"operation":"POST","path":"/pets","section":"paths"}'
i=3
while [ "$i" -le 6 ]; do
printf ',{"id":"request-property-added","text":"added","level":1,"operation":"PUT","path":"/pets%s","section":"paths"}' "$i"
printf ',{"id":"request-property-added","text":"added","level":1,"operation":"PUT","path":"/pets%s","section":"paths","fingerprint":"fp%s"}' "$i" "$i"
i=$((i+1))
done
printf ']'
Expand Down Expand Up @@ -339,8 +339,8 @@ jobs:
echo "$body"
for expected in \
'6 API changes in this pull request' \
'api-removed-without-deprecation' \
'response-property-became-optional' \
'| severity | change | endpoint | diff |' \
'<code>PUT /pets3</code> | [view](https://www.oasdiff.com/review/e/stub-id?highlight=fp3#k=stub-key) |' \
'| error | ' \
'| info | ' \
'<details><summary>1 more</summary>' \
Expand Down
24 changes: 19 additions & 5 deletions breaking/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,25 @@ from_fork () {
# the rest collapse, up to $comment_rows_listed, since a changelog can run to
# thousands of changes and a GitHub comment is limited to 65,536 characters.
# $1: the json render of the comparison (Run 3).
# $2: the review URL. Each row links to its own change in the review, which
# opens on the side-by-side diff of that change.
comment_rows_shown=5
comment_rows_listed=50
review_comment_changes () {
changes_file="$1"
changes_review_url="${2:-}"
[ -s "$changes_file" ] || return 0

jq -r --argjson shown "$comment_rows_shown" --argjson listed "$comment_rows_listed" '
# The key is the URL's fragment, so the change goes in the query before it.
review_page="${changes_review_url%%#*}"
review_key="${changes_review_url#"$review_page"}"
case "$review_page" in
*\?*) review_page="${review_page}&highlight=" ;;
*) review_page="${review_page}?highlight=" ;;
esac

jq -r --argjson shown "$comment_rows_shown" --argjson listed "$comment_rows_listed" \
--arg page "$review_page" --arg key "$review_key" '
def severity: if . == 3 then "error" elif . == 2 then "warning" else "info" end;
def endpoint:
if (.operation // "") == "" then (.section // "") else .operation + " " + .path end;
Expand All @@ -108,9 +120,11 @@ review_comment_changes () {
| gsub("`"; "&#96;") | gsub("\\|"; "&#124;") | gsub("\\*"; "&#42;")
| gsub("_"; "&#95;") | gsub("://"; ":&#47;&#47;") | gsub("www\\."; "www&#46;")
| gsub("[\r\n]+"; " ");
def diff_link:
if $key == "" or (.fingerprint // "") == "" then "" else "[view](" + $page + (.fingerprint | @uri) + $key + ")" end;
def row: "| " + (.level | severity) + " | " + ((.text // "") | inert)
+ " [`" + .id + "`](https://www.oasdiff.com/checks/" + .id + ") | <code>" + (endpoint | inert) + "</code> |";
def header: "| severity | change | endpoint |", "| --- | --- | --- |";
+ " | <code>" + (endpoint | inert) + "</code> | " + diff_link + " |";
def header: "| severity | change | endpoint | diff |", "| --- | --- | --- | --- |";
sort_by([-.level, (.path // ""), (.operation // ""), .id]) as $all
| ($all | length) as $total
| header,
Expand Down Expand Up @@ -189,7 +203,7 @@ post_review_comment () {
body="${marker}
### ${comment_icon} ${heading}

$(review_comment_changes "${changes_json:-}")
$(review_comment_changes "${changes_json:-}" "$review_url")

[See them side by side, with the old and new spec](${review_url}) (the link expires in 7 days)

Expand Down Expand Up @@ -337,7 +351,7 @@ pro_comment () {

${status_line}

$(review_comment_changes "${changes_json:-}")
$(review_comment_changes "${changes_json:-}" "$review_url")

[Review and approve the changes](${review_url})

Expand Down
2 changes: 2 additions & 0 deletions false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
No changes
No changes
Loading