This directory contains scripts for detecting and reporting API changes using oasdiff.
Main script that compares OpenAPI specifications against the master branch.
Usage:
# From the repo root
./scripts/api-diff/api-diff.sh [--fail-on-breaking] [filename.yaml]
# Check all xero*.yaml files
./scripts/api-diff/api-diff.sh
# Check a single file
./scripts/api-diff/api-diff.sh xero_accounting.yaml
# Fail on breaking changes (CI mode)
./scripts/api-diff/api-diff.sh --fail-on-breakingEnvironment Variables:
OASDIFF_DOCKER_IMAGE- Docker image to use (default:tufin/oasdiff:latest)BASE_BRANCH- Branch to compare against (default:origin/master)
Unit tests for the branch logic pattern matching used in GitHub Actions.
Usage:
./scripts/api-diff/api-diff.test.shTests validate that:
- Branches containing
breakinganywhere in the name are correctly identified - Other branches are handled with breaking change enforcement
These scripts are integrated into the GitHub Actions workflow at .github/workflows/api-diff.yml:
- test-branch-logic job - Runs unit tests
- api-diff job - Runs API diff checks with conditional breaking change enforcement
The GitHub Actions workflow automatically adjusts its behavior based on branch names:
Allow Breaking Changes:
- Any branch containing
breakingin the name - Examples:
breaking-api-v2,feature-breaking-change,api-breaking-update - The
--fail-on-breakingflag is NOT passed to the script
Fail on Breaking Changes:
- All other branches (main, master, develop, feature branches, etc.)
- The
--fail-on-breakingflag IS passed to the script - Build will fail if breaking changes are detected
This allows developers to explicitly signal when they're working on breaking changes by including breaking in their branch name.
The oasdiff tool has some non-deterministic behavior due to unordered map iteration in Go:
- Error counts (breaking changes) are consistent and reliable
- Warning counts may vary by ~2-3% between runs on identical inputs
- This is acceptable for CI purposes as breaking change detection remains accurate
For more details, see the oasdiff documentation.