Skip to content

bump: oasdiff v1.23.0 #289

bump: oasdiff v1.23.0

bump: oasdiff v1.23.0 #289

Workflow file for this run

name: changelog
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
oasdiff_changelog:
runs-on: ubuntu-latest
name: Test generation of changelog
env:
OASDIFF_ACTION_TEST_EXPECTED_OUTPUT: "21 changes: 2 error, 4 warning, 15 info"
steps:
- name: checkout
uses: actions/checkout@v7
- name: Running changelog action
id: test_changelog
uses: ./changelog
with:
base: https://raw.githubusercontent.com/oasdiff/oasdiff/main/data/openapi-test1.yaml
revision: https://raw.githubusercontent.com/oasdiff/oasdiff/main/data/openapi-test3.yaml
output-to-file: "changelog.txt"
- name: Test changelog action output
run: |
output=$(echo "${{steps.test_changelog.outputs.changelog}}" | head -n 1)
if [[ "${output}" != "${OASDIFF_ACTION_TEST_EXPECTED_OUTPUT}" ]]; then
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' but got '${output}'" >&2
exit 1
fi
- name: Test changelog action output to file
run: |
if [ ! -s changelog.txt ]; then
echo "Changelog file doesn't exist or is empty"
exit 1
fi
output=$(cat changelog.txt | head -n 1)
if [[ "${output}" != "${OASDIFF_ACTION_TEST_EXPECTED_OUTPUT}" ]]; then
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' but got '${output}'" >&2
exit 1
fi
oasdiff_changelog_composed:
runs-on: ubuntu-latest
name: Test changelog action with composed option
steps:
- name: checkout
uses: actions/checkout@v7
- name: Running changelog action with composed option
id: test_changelog_composed
uses: ./changelog
with:
base: 'specs/glob/base/*.yaml'
revision: 'specs/glob/revision/*.yaml'
composed: true
- name: Test changelog action output
run: |
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
output=$(cat <<-$delimiter
${{ steps.test_changelog_composed.outputs.changelog }}
$delimiter
)
if [[ ! "$output" =~ "1 changes: 1 error, 0 warning, 0 info" ]]; then
echo "Expected '1 changes: 1 error, 0 warning, 0 info', instead got '$output'" >&2
exit 1
fi
oasdiff_changelog_yaml_config_level:
runs-on: ubuntu-latest
name: Test changelog action picks up level from .oasdiff.yaml
steps:
- name: checkout
uses: actions/checkout@v7
- name: Drop .oasdiff.yaml at repo root
run: |
cat > .oasdiff.yaml <<EOF
level: ERR
EOF
- name: Running changelog action without level input
id: test_yaml_level
uses: ./changelog
with:
base: https://raw.githubusercontent.com/oasdiff/oasdiff/main/data/openapi-test1.yaml
revision: https://raw.githubusercontent.com/oasdiff/oasdiff/main/data/openapi-test3.yaml
- name: Assert level filter from .oasdiff.yaml suppressed warning/info findings
run: |
# Without the YAML, the same specs produce "21 changes: 2 error, 4 warning, 15 info".
# With level: ERR in YAML, only the 2 errors should remain.
output=$(echo "${{ steps.test_yaml_level.outputs.changelog }}" | head -n 1)
if [[ "$output" != "2 changes: 2 error, 0 warning, 0 info" ]]; then
echo "Expected '2 changes: 2 error, 0 warning, 0 info' (level: ERR from .oasdiff.yaml) but got '$output'" >&2
exit 1
fi
changelog_pro_expired_trial_warns_without_failing:
runs-on: ubuntu-latest
name: Test changelog Pro path surfaces an expired-trial 402 without failing
# When the tenant's trial/subscription has lapsed, the authenticated --open
# upload returns HTTP 402 subscription_expired, which the CLI surfaces as
# "upload failed (HTTP 402): {...}". The Pro path should show a graceful
# "trial expired" warning + step summary and NOT fail the job, instead of
# the generic "verify the oasdiff-token" warning (misleading: the token is
# fine, the plan lapsed).
steps:
- uses: actions/checkout@v7
- name: Stub oasdiff (402 subscription_expired on --open), run entrypoint
run: |
set -euo pipefail
mkdir -p /tmp/stub /tmp/run
# The entrypoint invokes oasdiff three times: the changes probe
# (--fail-on=INFO -> exit 1 means changes exist), the user-facing
# render, and the authenticated --open upload. Branch on the args.
cat > /tmp/stub/oasdiff <<'STUB'
#!/bin/sh
for a in "$@"; do [ "$a" = "--fail-on=INFO" ] && exit 1; 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
exit 1
fi
done
echo "1 changes: 1 error, 0 warning, 0 info"
STUB
chmod +x /tmp/stub/oasdiff
export GITHUB_REF=refs/pull/123/merge
export GITHUB_REPOSITORY=acme/widgets
export GITHUB_SHA=deadbeef
export GITHUB_OUTPUT=/tmp/run/gh-output; : > "$GITHUB_OUTPUT"
export GITHUB_STEP_SUMMARY=/tmp/run/step-summary; : > "$GITHUB_STEP_SUMMARY"
cat > /tmp/run/event.json <<EVT
{"pull_request":{"head":{"sha":"deadbeef"},"base":{"sha":"baadcafe"}}}
EVT
export GITHUB_EVENT_PATH=/tmp/run/event.json
export PATH=/tmp/stub:$PATH
set +e
out=$(./changelog/entrypoint.sh \
'b' 'r' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 'stub-oasdiff-token' 2>&1)
rc=$?
set -e
echo "--- entrypoint output ---"; echo "$out"
echo "--- exit code: $rc ---"
echo "--- step summary ---"; cat "$GITHUB_STEP_SUMMARY"
if [ "$rc" -ne 0 ]; then
echo "FAIL: expected exit 0 (warn-don't-fail), got $rc" >&2
exit 1
fi
if ! echo "$out" | grep -q "::warning title=oasdiff trial or subscription expired::"; then
echo "FAIL: missing expired-trial warning annotation" >&2
exit 1
fi
if ! grep -q "oasdiff trial or subscription expired" "$GITHUB_STEP_SUMMARY"; then
echo "FAIL: expired-trial step summary not written" >&2
exit 1
fi
if echo "$out" | grep -q "verify the oasdiff-token"; then
echo "FAIL: fell through to the generic upload-failed warning" >&2
exit 1
fi
echo "PASS"
changelog_pro_happy_path_posts_comment_and_status:
runs-on: ubuntu-latest
name: Test changelog Pro path posts the review comment and sets the gate
# Companion to changelog_pro_expired_trial_warns_without_failing: the success
# path. Stubs oasdiff (changes present; --open prints a /review/ep URL +
# "review status: pending") and curl (GitHub API: empty comment list, then
# 2xx for the comment + status POSTs). Asserts the Pro review comment is
# posted, the oasdiff commit status is set, and the review URL reaches the
# step summary. Guards the core Pro funnel action behavior in CI without the
# full prod e2e.
steps:
- uses: actions/checkout@v7
- name: Stub oasdiff + curl (Pro success), run entrypoint
run: |
set -euo pipefail
mkdir -p /tmp/stub /tmp/run
cat > /tmp/stub/oasdiff <<'STUB'
#!/bin/sh
for a in "$@"; do [ "$a" = "--fail-on=INFO" ] && exit 1; 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
echo "oasdiff: review status: pending" >&2
exit 0
fi
done
echo "1 changes: 1 error, 0 warning, 0 info"
STUB
chmod +x /tmp/stub/oasdiff
# The POST calls carry -w %{http_code}; return a 2xx. The comment-list
# GET has no such flag; return an empty JSON array so jq finds no
# existing comment and the entrypoint POSTs a new one.
cat > /tmp/stub/curl <<'STUB'
#!/bin/sh
for a in "$@"; do case "$a" in *"%{http_code}"*) echo "201"; exit 0 ;; esac; done
echo "[]"
STUB
chmod +x /tmp/stub/curl
export GITHUB_REF=refs/pull/123/merge
export GITHUB_REPOSITORY=acme/widgets
export GITHUB_SHA=deadbeef
export GITHUB_OUTPUT=/tmp/run/out; : > "$GITHUB_OUTPUT"
export GITHUB_STEP_SUMMARY=/tmp/run/summary; : > "$GITHUB_STEP_SUMMARY"
cat > /tmp/run/event.json <<EVT
{"pull_request":{"head":{"sha":"deadbeef"},"base":{"sha":"baadcafe"}}}
EVT
export GITHUB_EVENT_PATH=/tmp/run/event.json
export PATH=/tmp/stub:$PATH
set +e
out=$(./changelog/entrypoint.sh \
'b' 'r' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 'gh-token' 'oasdiff-token' 2>&1)
rc=$?
set -e
echo "--- output ---"; echo "$out"
echo "--- step summary ---"; cat "$GITHUB_STEP_SUMMARY"
if [ "$rc" -ne 0 ]; then echo "FAIL: expected exit 0, got $rc" >&2; exit 1; fi
if ! echo "$out" | grep -q "oasdiff: posted the Pro review comment."; then
echo "FAIL: Pro review comment not posted" >&2; exit 1
fi
if ! echo "$out" | grep -q "set the 'oasdiff' commit status to 'pending'"; then
echo "FAIL: commit status not set" >&2; exit 1
fi
if ! grep -q 'review/ep/test-token-uuid' "$GITHUB_STEP_SUMMARY"; then
echo "FAIL: review URL not in step summary" >&2; exit 1
fi
echo "PASS"