generated from broadinstitute/golang-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* remove v1, add api diff checker * markdown instead of html * touch * ls * what * tweak lint * better? * message * better linting * this time * fix * fix dependencies * fix comment one last time * concurrency * whoops
- Loading branch information
1 parent
ac944c9
commit a9f01fa
Showing
53 changed files
with
115 additions
and
5,472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: API Diff | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- ".github/workflows/sherlock-api-diff.yaml" | ||
- "sherlock/**" | ||
- "!sherlock/docs/**" | ||
- "go-shared/**" | ||
|
||
concurrency: | ||
# Don't run this workflow concurrently on the same branch | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
# For PRs, don't wait for completion of existing runs, cancel them instead | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
api-diff: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: "read" | ||
# Make comments | ||
pull-requests: "write" | ||
steps: | ||
- name: Checkout Base | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.base_ref }} | ||
path: base | ||
persist-credentials: false | ||
|
||
- name: Checkout Head | ||
uses: actions/checkout@v3 | ||
with: | ||
# Technically superfluous but clearer to be explicit | ||
ref: ${{ github.head_ref }} | ||
path: head | ||
persist-credentials: false | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: head/sherlock/go.mod | ||
|
||
- name: Set up Swag | ||
working-directory: head | ||
run: go install github.com/swaggo/swag/cmd/swag@latest | ||
|
||
- name: Generate Swagger source | ||
working-directory: head | ||
run: make generate-swagger | ||
|
||
- name: Create output directory | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
run: mkdir output | ||
|
||
- name: Generate diff | ||
run: | | ||
docker run --rm -t \ | ||
-v "$(pwd)/base/sherlock/docs:/specs/base:ro" \ | ||
-v "$(pwd)/head/sherlock/docs:/specs/head:ro" \ | ||
-v "$(pwd)/output:/output" \ | ||
openapitools/openapi-diff:latest \ | ||
--log INFO \ | ||
${{ (github.actor == 'dependabot[bot]' && '--fail-on-changed') || '--markdown /output/diff.md' }} \ | ||
/specs/base/swagger.yaml \ | ||
/specs/head/swagger.yaml | ||
- name: Check diff | ||
id: check-diff | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
run: | | ||
if [[ -z $(grep '[^[:space:]]' output/diff.md) ]] ; then | ||
echo present=false | ||
else | ||
echo present=true | ||
fi | ||
- name: Comment diff | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: api-diff | ||
path: ${{ (steps.check-diff.outputs.present == 'true' && 'output/diff.md') || '' }} | ||
message: | | ||
No API changes detected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.