1
0
Fork 0
mirror of https://github.com/imjasonh/apidiff-action synced 2026-07-06 22:52:43 +00:00
No description
Find a file
dependabot[bot] 5b3fc151be
build(deps): bump actions/setup-node in the github-actions group (#27)
Bumps the github-actions group with 1 update: [actions/setup-node](https://github.com/actions/setup-node).


Updates `actions/setup-node` from 5 to 6
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-20 03:33:40 +00:00
.github build(deps): bump actions/setup-node in the github-actions group (#27) 2025-10-20 03:33:40 +00:00
.husky Add husky pre-commit hook 2025-07-29 18:05:10 -04:00
dist chore: update dist 2025-08-08 22:48:38 +00:00
lib chore: add legacy eslint config for fallback 2025-08-08 18:48:17 -04:00
scripts refactor: simplify dist management to match GitHub Actions template 2025-07-30 09:53:16 -04:00
test Merge pull request #17 from imjasonh/vmc2tn-codex/find-and-fix-a-bug 2025-08-08 18:50:19 -04:00
testdata Fix lint errors and formatting 2025-07-29 17:07:15 -04:00
.eslintrc.cjs chore: add legacy eslint config for fallback 2025-08-08 18:48:17 -04:00
.gitignore Prepare to commit dist/index.js 2025-07-30 08:55:35 -04:00
.node-version Configure Node.js v20 for local development 2025-07-30 09:13:03 -04:00
.nvmrc Configure Node.js v20 for local development 2025-07-30 09:13:03 -04:00
.pre-commit-config.yaml refactor: simplify dist management to match GitHub Actions template 2025-07-30 09:53:16 -04:00
.prettierrc Fix lint errors and formatting 2025-07-29 17:07:15 -04:00
action.yml Fix lint errors and formatting 2025-07-29 17:07:15 -04:00
CLAUDE.md Enforce Node 20 in pre-commit hooks 2025-07-30 09:22:44 -04:00
CONTRIBUTING.md docs: document automatic dist updates 2025-07-30 10:16:17 -04:00
eslint.config.mjs chore: add legacy eslint config for fallback 2025-08-08 18:48:17 -04:00
index.js Fix lint errors and formatting 2025-07-29 17:07:15 -04:00
LICENSE Initial commit 2025-07-29 10:24:36 -04:00
package-lock.json build(deps-dev): bump lint-staged in the development-dependencies group (#26) 2025-10-13 03:38:06 +00:00
package.json build(deps-dev): bump lint-staged in the development-dependencies group (#26) 2025-10-13 03:38:06 +00:00
README.md Update README.md 2025-07-29 17:41:16 -04:00

apidiff-action

A GitHub Action that detects breaking API changes in Go code and comments on pull requests. This action uses the official golang.org/x/exp/cmd/apidiff tool to analyze API compatibility.

Features

  • 🔍 Automatically detects breaking API changes in pull requests
  • 💬 Comments on PRs with detailed change reports
  • Identifies both breaking and compatible changes
  • 🚫 Can fail CI builds when breaking changes are detected
  • 📊 Provides summary statistics in action outputs

Usage

Add this action to your workflow:

name: API Compatibility Check
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  apidiff:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write # Required for commenting on PRs
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Required to access base commit

      - uses: actions/setup-go@v5
        with:
          go-version: 'stable'

      - uses: imjasonh/apidiff-action@v1
        with:
          fail-on-breaking: true

Inputs

Input Description Default
working-directory Directory to run apidiff in .
fail-on-breaking Whether to fail the action if breaking changes are detected true
comment-on-pr Whether to comment on the PR with results true
token GitHub token for commenting on PRs ${{ github.token }}

Outputs

Output Description
has-breaking-changes Whether breaking changes were detected (true/false)
breaking-count Number of breaking changes found
compatible-count Number of compatible changes found

Example PR Comment

The action will comment on your PR with a formatted report:

API Compatibility Check Results

Summary

Type Count
Breaking changes 1
Compatible changes 3

⚠️ This PR contains breaking API changes!

Details

github.com/example/mypackage

Breaking changes

  • (*Client).DoSomething: changed from func(string) error to func(context.Context, string) error

Compatible changes

  • NewOption: added
  • WithTimeout: added
  • DefaultTimeout: added

Example in action: https://github.com/imjasonh/apidiff-action/pull/3

Advanced Usage

Continue on breaking changes

To get notified about breaking changes without failing the build:

- uses: imjasonh/apidiff-action@v1
  with:
    fail-on-breaking: false

Check specific directory

To check a specific package or module:

- uses: imjasonh/apidiff-action@v1
  with:
    working-directory: ./api

Use outputs in subsequent steps

- uses: imjasonh/apidiff-action@v1
  id: apidiff
  with:
    fail-on-breaking: false

- name: Handle breaking changes
  if: steps.apidiff.outputs.has-breaking-changes == 'true'
  run: |
    echo "Found ${{ steps.apidiff.outputs.breaking-count }} breaking changes"
    # Add custom handling here

How it works

This action:

  1. Installs the official apidiff tool from golang.org/x/exp/cmd/apidiff
  2. Runs it to compare the base and head commits of your PR
  3. Parses the output to identify breaking and compatible changes
  4. Creates or updates a comment on the PR with the results
  5. Optionally fails the build if breaking changes are detected

The underlying apidiff tool implements the compatibility rules from the Go 1 compatibility guarantee, checking for changes that would cause client code to stop compiling.

License

This action is available under the Apache License 2.0.