Giter Site home page Giter Site logo

go-apidiff's Introduction

go-apidiff

Check API compatibility between different revisions of a Go project

go-apidiff is dependent on Go's built-in package listing and type parsing, and can therefore be unreliable in certain situations. For example, if you're working outside of $GOPATH on a project that supports Go modules at the new commit, but not the old commit, you may not get accurate results.

GitHub Action

Inputs

base-ref

Base reference for API compatibility comparison (default: origin/${GITHUB_BASE_REF})

version

Version of go-apidiff to use (default: latest)

compare-imports

Compare exported API differences in the imports of the repo (default: false)

print-compatible

Print compatible API changes (default: true)

repo-path

Path to root of git repository to compare (default: current working directory)

skip-cache

Skip automatic caching of go module directories (default: false)

Outputs

(none)

Example usage

name: go-apidiff
on: [ pull_request ]
jobs:
  go-apidiff:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - uses: actions/setup-go@v2
      with:
        go-version: 1.18
    - uses: joelanford/go-apidiff@main

Local Installation

To install into $GOPATH/bin, run the following:

$ go install github.com/joelanford/go-apidiff@latest

Usage

$ go-apidiff --help
go-apidiff compares API compatibility of different commits of a Go repository.

By default, it compares just the module itself and prints only incompatible
changes. However it can be configured to print compatible changes and to search
for API incompatibilities in the dependency changes of the repository.

When used with just one argument, the passed argument is used for oldCommit,
and HEAD is used for newCommit."

Usage:
  go-apidiff <oldCommit> [newCommit] [flags]

Flags:
      --compare-imports    Compare exported API differences of the imports in the repo.
  -h, --help               help for go-apidiff
      --print-compatible   Print compatible API changes
      --repo-path string   Path to root of git repository to compare (default "/home/myuser/myproject")

Example output

$ GO111MODULE=off go get golang.org/x/exp
$ cd $GOPATH/src/golang.org/x/exp/apidiff
$ go-apidiff --repo-path=../ 81c71964d733d2e3e2375a315c0e2fd4d162adc4 --print-compatible

golang.org/x/exp/apidiff
  Incompatible changes:
  - Report.Compatible: removed
  - Report.Incompatible: removed
  Compatible changes:
  - Change: added
  - Report.Changes: added

go-apidiff's People

Contributors

acumino avatar alexeldeib avatar joelanford avatar viveklak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.