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
5 changes: 5 additions & 0 deletions .changeset/bright-turtles-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"reusable-apidiff-go-analysis": major
---

initial release
86 changes: 86 additions & 0 deletions .github/workflows/reusable-apidiff-go-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# GENERATED FILE - DO NOT EDIT DIRECTLY.
# Source: workflows/reusable-apidiff-go-analysis/reusable-apidiff-go-analysis.yml
# Edit the source under workflows/, then regenerate.

name: Reusable apidiff-go Analysis

on:
workflow_call:
inputs:
file-patterns:
description: 'File patterns to determine changed modules (newline separated)'
required: false # defaulted
type: string
default: |
**/*.go
**/go.mod
**/go.sum

module-patterns:
description: |
Module patterns to determine changed modules (newline separated)
- Prefix with "!" to exclude patterns
required: false # defaulted
type: string
default: |
**

enforce-compatible:
description: 'Whether to enforce compatibility (breaking changes will cause the workflow to fail)'
required: false # defaulted
type: boolean
default: false

permissions: {}

jobs:
changed-modules:
name: Determine Changed Modules
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
modules-json: ${{ steps.changed-modules.outputs.modules-json }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Changed modules
id: changed-modules
uses: smartcontractkit/.github/actions/changed-modules-go@changed-modules-go/v1
with:
file-patterns: ${{ inputs.file-patterns }}
module-patterns: ${{ inputs.module-patterns }}

analyze-api-changes:
if: ${{ needs.changed-modules.outputs.modules-json != '[]' }}
name: Analyze (${{ matrix.module }})
runs-on: ubuntu-latest
needs: changed-modules
permissions:
pull-requests: write
contents: read
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.changed-modules.outputs.modules-json) }}
steps:
- name: Checkout the repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: ${{ matrix.module }}/go.mod
cache: false

- uses: smartcontractkit/.github/actions/apidiff-go@apidiff-go/v2
with:
module-directory: ${{ matrix.module }}
enforce-compatible: ${{ inputs.enforce-compatible }}
post-comment: true
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions workflows/reusable-apidiff-go-analysis/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# reusable-apidiff-go-analysis
42 changes: 42 additions & 0 deletions workflows/reusable-apidiff-go-analysis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Reusable apidiff-go analysis

A simple reusable workflow wrapper around the `apidiff-go` resuable Github
Action for conditional api analysis on a per-module basis.

- https://github.com/smartcontractkit/.github/tree/main/actions/apidiff-go

## Usage

### Inputs

Inputs are passed directly to the associated action, see that actions
documentation for more details.

- `file-patterns`, `module-patterns` - see
[`changed-modules-go`](https://github.com/smartcontractkit/.github/tree/main/actions/changed-modules-go)
- ``enforce-compatible` - see
[`apidiff-go`](https://github.com/smartcontractkit/.github/tree/main/actions/apidiff-go)

```yaml
name: Analyze API Changes

on:
pull_request: {}

permissions: {}

jobs:
analysis:
uses: smartcontractkit/.github/.github/workflows/reusable-apidiff-go-analysis@<ref>
permissions:
pull-requests: write
contents: read
with: # note: showing default values of inputs
file-patterns: |
**/*.go
**/go.mod
**/go.sum
module-patterns: |
**
enforce-compatible: false
```
11 changes: 11 additions & 0 deletions workflows/reusable-apidiff-go-analysis/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "reusable-apidiff-go-analysis",
"version": "0.0.0",
"description": "",
"private": true,
"scripts": {},
"keywords": [],
"author": "@smartcontractkit",
"license": "MIT",
"packageManager": "pnpm@10.29.3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Reusable apidiff-go Analysis

on:
workflow_call:
inputs:
file-patterns:
description: 'File patterns to determine changed modules (newline separated)'
required: false # defaulted
type: string
default: |
**/*.go
**/go.mod
**/go.sum

module-patterns:
description: |
Module patterns to determine changed modules (newline separated)
- Prefix with "!" to exclude patterns
required: false # defaulted
type: string
default: |
**

enforce-compatible:
description: 'Whether to enforce compatibility (breaking changes will cause the workflow to fail)'
required: false # defaulted
type: boolean
default: false

permissions: {}

jobs:
changed-modules:
name: Determine Changed Modules
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
modules-json: ${{ steps.changed-modules.outputs.modules-json }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Changed modules
id: changed-modules
uses: smartcontractkit/.github/actions/changed-modules-go@changed-modules-go/v1
with:
file-patterns: ${{ inputs.file-patterns }}
module-patterns: ${{ inputs.module-patterns }}

analyze-api-changes:
if: ${{ needs.changed-modules.outputs.modules-json != '[]' }}
name: Analyze (${{ matrix.module }})
runs-on: ubuntu-latest
needs: changed-modules
permissions:
pull-requests: write
contents: read
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.changed-modules.outputs.modules-json) }}
steps:
- name: Checkout the repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: ${{ matrix.module }}/go.mod
cache: false

- uses: smartcontractkit/.github/actions/apidiff-go@apidiff-go/v2
with:
module-directory: ${{ matrix.module }}
enforce-compatible: ${{ inputs.enforce-compatible }}
post-comment: true
Loading