Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDO-2918] Remove uncalled v1 code; add API diff checker action #191

Merged
merged 15 commits into from
Jun 21, 2023
88 changes: 88 additions & 0 deletions .github/workflows/sherlock-api-diff.yaml
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
6 changes: 6 additions & 0 deletions .github/workflows/sherlock-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ jobs:
quay.io/goswagger/swagger:${GO_SWAGGER_VERSION} \
generate client -f /local/sherlock/docs/swagger.json -A sherlock --default-scheme=https -m client/models -c client

- name: Tidy Go client library dependencies
if: ${{ github.event_name == 'push' }}
working-directory: sherlock-go-client
run: go mod tidy

- name: Generate Typescript client library
if: ${{ github.event_name == 'push' }}
run: |
Expand Down Expand Up @@ -215,6 +220,7 @@ jobs:
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: image
message: |
Published image from ${{ github.event.pull_request.head.sha }} (merge ${{ github.sha }}):

Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/sherlock-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ jobs:
directory: ["sherlock", "go-shared", "sherlock-webhook-proxy"]
steps:
- uses: actions/checkout@v3
- name: golangci-lint

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: ${{ matrix.directory }}/go.mod

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
Expand All @@ -39,11 +45,15 @@ jobs:
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true
# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
29 changes: 4 additions & 25 deletions sherlock-webhook-proxy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,29 @@ go 1.19
require (
github.com/GoogleCloudPlatform/functions-framework-go v1.7.4
github.com/broadinstitute/sherlock/sherlock-go-client v0.0.0
github.com/go-openapi/runtime v0.26.0
github.com/go-openapi/strfmt v0.21.7
github.com/go-playground/webhooks/v6 v6.1.0
google.golang.org/api v0.114.0

)

replace github.com/broadinstitute/sherlock/sherlock-go-client => ../sherlock-go-client

require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.19.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/functions v1.13.0 // indirect
cloud.google.com/go/logging v1.7.0 // indirect
cloud.google.com/go/longrunning v0.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/cloudevents/sdk-go/v2 v2.14.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/runtime v0.26.0 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -48,21 +37,11 @@ require (
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
go.mongodb.org/mongo-driver v1.11.3 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230323212658-478b75c54725 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)