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
28 changes: 28 additions & 0 deletions .github/workflows/test-breaking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,34 @@ jobs:
exit 1
fi

oasdiff_breaking_exclude_elements_ignored:
runs-on: ubuntu-latest
name: Test exclude-elements is warned about, not applied
env:
OASDIFF_ACTION_TEST_EXPECTED_OUTPUT: "1 changes: 1 error, 0 warning, 0 info"
steps:
- name: checkout
uses: actions/checkout@v7
# oasdiff breaking has no --exclude-elements flag, so forwarding the input
# would fail the run. The action only warns.
- name: Running breaking action with exclude-elements
id: test_exclude_elements
continue-on-error: true
uses: ./breaking
with:
base: 'specs/base.yaml'
revision: 'specs/revision-breaking.yaml'
exclude-elements: 'endpoints'
- name: Assert the run was unaffected
env:
ACTUAL_OUTPUT: ${{ steps.test_exclude_elements.outputs.breaking }}
run: |
output="$ACTUAL_OUTPUT"
if [ "$output" != "$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT" ]; then
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' (exclude-elements must be ignored, not forwarded) but got '$output'" >&2
exit 1
fi

oasdiff_breaking_unresolved_ref:
runs-on: ubuntu-latest
name: Test a failed comparison is not reported as clean
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
| `composed` | `false` | Run in [composed mode](https://github.com/oasdiff/oasdiff/blob/main/docs/COMPOSED.md), comparing globs of spec files |
| `allow-external-refs` | `false` | Resolve external `$ref`s. Off by default to prevent SSRF on untrusted pull requests; set `true` if your spec references external URLs you trust |

These inputs describe the run, with one exception: `fail-on` is policy, and is an input so that a workflow can block a merge without a second file. How oasdiff judges the API is configuration, and it goes in [`.oasdiff.yaml`](#configuring-with-oasdiffyaml): the severity that fails the job, ignore files, severity levels, `flatten-allof`, `exclude-elements`, `filter-extension`, `include-path-params`, the deprecation windows, and every other oasdiff flag. The inputs of those names that earlier versions documented still work.
These inputs describe the run, with one exception: `fail-on` is policy, and is an input so that a workflow can block a merge without a second file. How oasdiff judges the API is configuration, and it goes in [`.oasdiff.yaml`](#configuring-with-oasdiffyaml): the severity that fails the job, ignore files, severity levels, `flatten-allof`, `filter-extension`, `include-path-params`, the deprecation windows, and every other oasdiff flag. The inputs of those names that earlier versions documented still work.

### Generate a changelog

Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
| `fail-on-diff` | `false` | Fail with exit code 1 if any difference is found | `true`, `false` |
| `format` | `yaml` | Output format | `yaml`, `json`, `text` |
| `include-path-params` | `false` | Include path parameter names in endpoint matching | `true`, `false` |
| `exclude-elements` | `''` | Exclude certain kinds of changes from the output | `endpoints`, `request`, `response` (comma-separated) |
| `exclude-elements` | `''` | Exclude certain kinds of changes from the output | `description`, `endpoints`, `examples`, `extensions`, `summary`, `tags`, `title` (comma-separated) |
| `filter-extension` | `''` | Exclude paths and operations with an OpenAPI Extension matching this expression | regex |
| `composed` | `false` | Run in composed mode | `true`, `false` |
| `flatten-allof` | `false` | Merge allOf subschemas into a single schema before diff | `true`, `false` |
Expand Down Expand Up @@ -187,7 +187,7 @@ For a non-blocking, report-only run, leave `fail-on` and set `continue-on-error:

## Configuring with `.oasdiff.yaml`

Action inputs cover what a run needs: which specs to compare and the tokens. Everything about how oasdiff judges the API (the severity that fails the job, ignore files, severity levels, exclusions, deprecation windows) goes in `.oasdiff.yaml`, where every oasdiff flag works and the same file gives you the same answer when you run oasdiff locally.
Action inputs cover what a run needs: which specs to compare and the tokens. Everything about how oasdiff judges the API (the severity that fails the job, ignore files, severity levels, deprecation windows) goes in `.oasdiff.yaml`, where every oasdiff flag works and the same file gives you the same answer when you run oasdiff locally.

The `breaking`, `changelog` and `diff` actions automatically pick up a `.oasdiff.yaml` file from the root of your checked-out repository. This lets you keep CLI-flag-shaped configuration in source control instead of repeating the same `with:` block in every workflow file.

Expand All @@ -196,10 +196,6 @@ Drop a `.oasdiff.yaml` next to your spec:
```yaml
# .oasdiff.yaml
fail-on: ERR
exclude-elements:
- description
- title
- summary
err-ignore: ./oasdiff-err-ignore.txt
severity-levels: ./oasdiff-levels.txt
```
Expand All @@ -212,6 +208,8 @@ response-non-success-status-removed err
api-tag-removed none
```

`exclude-elements` and `exclude-extensions` apply to the `diff` action only. The `breaking`, `changelog` and `pr-comment` actions compare the specs in full, so that excluding part of a spec cannot remove a change from the report. To turn a check off there, set its level to `none`.

The actions read this file from the runner's `$GITHUB_WORKSPACE` (which `actions/checkout` populates), so no extra steps are needed.

**Precedence**: action `with:` inputs override `.oasdiff.yaml` values, which override built-in defaults. Setting `fail-on: ERR` in YAML and leaving the action's `fail-on:` input empty applies the YAML value; setting both lets the action input win.
Expand Down
2 changes: 1 addition & 1 deletion breaking/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inputs:
description: 'Consider minimum sunset period for deprecation of stable API endpoints'
required: false
exclude-elements:
description: 'Exclude certain kinds of changes'
description: 'Ignored: the checks compare the specs in full. To turn a check off, set its level to none in a severity levels file'
required: false
default: ''
filter-extension:
Expand Down
4 changes: 2 additions & 2 deletions breaking/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ run_breaking () {
flags="$flags --deprecation-days-stable $deprecation_days_stable"
fi
if [ -n "$exclude_elements" ]; then
flags="$flags --exclude-elements $exclude_elements"
echo "::warning::oasdiff: 'exclude-elements' is ignored, breaking and changelog compare the specs in full. To turn a check off, add 'severity-levels: <file>' to .oasdiff.yaml, listing the check id with level 'none'."
fi
if [ -n "$filter_extension" ]; then
flags="$flags --filter-extension $filter_extension"
Expand Down Expand Up @@ -659,7 +659,7 @@ run_changelog () {
flags="$flags --include-path-params"
fi
if [ -n "$exclude_elements" ]; then
flags="$flags --exclude-elements $exclude_elements"
echo "::warning::oasdiff: 'exclude-elements' is ignored, breaking and changelog compare the specs in full. To turn a check off, add 'severity-levels: <file>' to .oasdiff.yaml, listing the check id with level 'none'."
fi
if [ -n "$filter_extension" ]; then
flags="$flags --filter-extension $filter_extension"
Expand Down
2 changes: 1 addition & 1 deletion changelog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inputs:
required: false
default: 'false'
exclude-elements:
description: 'Exclude certain kinds of changes'
description: 'Ignored: the checks compare the specs in full. To turn a check off, set its level to none in a severity levels file'
required: false
default: ''
filter-extension:
Expand Down
2 changes: 1 addition & 1 deletion pr-comment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inputs:
required: false
default: 'false'
exclude-elements:
description: 'Exclude certain kinds of changes'
description: 'Ignored: the checks compare the specs in full. To turn a check off, set its level to none in a severity levels file'
required: false
default: ''
composed:
Expand Down
2 changes: 1 addition & 1 deletion pr-comment/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if [ "$include_path_params" = "true" ]; then
flags="$flags --include-path-params"
fi
if [ -n "$exclude_elements" ]; then
flags="$flags --exclude-elements $exclude_elements"
echo "::warning::oasdiff: 'exclude-elements' is ignored, breaking and changelog compare the specs in full. To turn a check off, add 'severity-levels: <file>' to .oasdiff.yaml, listing the check id with level 'none'."
fi
if [ "$composed" = "true" ]; then
flags="$flags -c"
Expand Down
Loading