Skip to content

Commit

Permalink
chore: Improvement for SDK generation (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
flemzord authored Dec 11, 2023
1 parent ff4c77c commit bea0e76
Show file tree
Hide file tree
Showing 905 changed files with 36,641 additions and 10,756 deletions.
24 changes: 12 additions & 12 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ speakeasy:
build-final-spec:
FROM core+base-image
RUN apk update && apk add yarn nodejs npm jq
WORKDIR /src/openapi
WORKDIR /src/libs/clients
RUN mkdir build
COPY openapi/base.yaml .
COPY openapi/package.* .
COPY libs/clients/base.yaml .
COPY libs/clients/package.* .
RUN npm install
WORKDIR /src/components
FOR c IN ledger payments
Expand All @@ -35,13 +35,13 @@ build-final-spec:
FOR c IN auth webhooks search wallets orchestration reconciliation
COPY ee/$c/openapi.yaml $c/openapi.yaml
END
WORKDIR /src/openapi
COPY openapi/openapi-merge.json .
WORKDIR /src/libs/clients
COPY libs/clients/openapi-merge.json .
RUN npm run build
LET VERSION=$(date +%Y%m%d)
RUN jq '.info.version = "v1.0.${VERSION}"' build/generate.json > build/generate-with-version.json
SAVE ARTIFACT build/generate-with-version.json
SAVE ARTIFACT build/generate-with-version.json AS LOCAL openapi/build/generate.json
SAVE ARTIFACT build/generate-with-version.json AS LOCAL libs/clients/build/generate.json

build-sdk:
BUILD --pass-args +build-final-spec # Force output of the final spec
Expand All @@ -50,18 +50,18 @@ build-sdk:
RUN apk update && apk add yq
COPY (+speakeasy/speakeasy) /bin/speakeasy
COPY (+build-final-spec/generate-with-version.json) final-spec.json
ARG LANG=go
COPY --dir openapi/templates/${LANG} sdks/${LANG}
RUN --secret SPEAKEASY_API_KEY speakeasy generate sdk -s ./final-spec.json -o ./sdks/${LANG} -l ${LANG}
SAVE ARTIFACT sdks/${LANG} AS LOCAL ./sdks/${LANG}
SAVE ARTIFACT sdks/${LANG}
COPY --dir libs/clients/go ./sdks/go
RUN --secret SPEAKEASY_API_KEY speakeasy generate sdk -s ./final-spec.json -o ./sdks/go -l go
RUN rm -rf ./libs/clients/go
SAVE ARTIFACT sdks/go AS LOCAL ./libs/clients/go
SAVE ARTIFACT sdks/go

goreleaser:
FROM core+builder-image
ARG --required components
ARG --required type
COPY . /src
COPY (+build-sdk/go --LANG=go) /src/sdks/go
COPY (+build-sdk/go --LANG=go) /src/libs/clients/go
WORKDIR /src/$type/$components
ARG mode=local
LET buildArgs = --clean
Expand Down
2 changes: 1 addition & 1 deletion components/fctl/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tests:

sources:
WORKDIR src
COPY --pass-args (stack+build-sdk/go --LANG=go) sdks/go
COPY --pass-args (stack+build-sdk/go) libs/clients/go
DO stack+INCLUDE_GO_LIBS --LOCATION libs/go-libs
WORKDIR /src/components/fctl
COPY go.* .
Expand Down
2 changes: 1 addition & 1 deletion components/fctl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ replace github.com/formancehq/fctl/membershipclient => ./membershipclient

replace github.com/spf13/cobra v1.6.1 => github.com/formancehq/cobra v0.0.0-20221112160629-60a6d6d55ef9

replace github.com/formancehq/formance-sdk-go => ../../sdks/go
replace github.com/formancehq/formance-sdk-go => ../../libs/clients/go
2 changes: 0 additions & 2 deletions components/fctl/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lL
github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0=
github.com/mattn/go-tty v0.0.4 h1:NVikla9X8MN0SQAqCYzpGyXv0jY7MNl3HOWD2dkle7E=
github.com/mattn/go-tty v0.0.4/go.mod h1:u5GGXBtZU6RQoKV8gY5W6UhMudbR5vXnUe7j3pxse28=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/muhlemmer/gu v0.3.1 h1:7EAqmFrW7n3hETvuAdmFmn4hS8W+z3LgKtrnow+YzNM=
github.com/muhlemmer/gu v0.3.1/go.mod h1:YHtHR+gxM+bKEIIs7Hmi9sPT3ZDUvTN/i88wQpZkrdM=
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
Expand Down Expand Up @@ -144,7 +143,6 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spyzhov/ajson v0.8.0/go.mod h1:63V+CGM6f1Bu/p4nLIN8885ojBdt88TbLoSFzyqMuVA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
2 changes: 1 addition & 1 deletion components/payments/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM core+base-image
sources:
WORKDIR src
DO stack+INCLUDE_GO_LIBS --LOCATION libs/go-libs
COPY --pass-args (stack+build-sdk/go --LANG=go) sdks/go
COPY --pass-args (stack+build-sdk/go) libs/clients/go
WORKDIR /src/components/payments
COPY go.* .
COPY --dir pkg cmd internal .
Expand Down
2 changes: 1 addition & 1 deletion ee/orchestration/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM core+base-image
sources:
WORKDIR src
DO stack+INCLUDE_GO_LIBS --LOCATION libs/go-libs
COPY --pass-args (stack+build-sdk/go --LANG=go) sdks/go
COPY --pass-args (stack+build-sdk/go) libs/clients/go
WORKDIR /src/ee/orchestration
COPY go.* .
COPY --dir pkg cmd internal .
Expand Down
2 changes: 1 addition & 1 deletion ee/orchestration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ require (

replace github.com/formancehq/stack/libs/go-libs => ../../libs/go-libs

replace github.com/formancehq/formance-sdk-go => ../../sdks/go
replace github.com/formancehq/formance-sdk-go => ../../libs/clients/go
2 changes: 1 addition & 1 deletion ee/reconciliation/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM core+base-image
sources:
WORKDIR src
DO stack+INCLUDE_GO_LIBS --LOCATION libs/go-libs
COPY --pass-args (stack+build-sdk/go --LANG=go) sdks/go
COPY --pass-args (stack+build-sdk/go) libs/clients/go
WORKDIR /src/ee/reconciliation
COPY go.* .
COPY --dir cmd internal .
Expand Down
2 changes: 1 addition & 1 deletion ee/reconciliation/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ require (

replace github.com/formancehq/stack/libs/go-libs => ../../libs/go-libs

replace github.com/formancehq/formance-sdk-go => ../../sdks/go
replace github.com/formancehq/formance-sdk-go => ../../libs/clients/go
2 changes: 1 addition & 1 deletion ee/wallets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang:1.20 AS builder
ARG APP_SHA
ARG VERSION
WORKDIR /src
COPY sdks/go /src/sdks/go
COPY libs/clients/go /src/libs/clients/go
COPY libs /src/libs
COPY components/wallets /src/ee/wallets
WORKDIR /src/ee/wallets
Expand Down
2 changes: 1 addition & 1 deletion ee/wallets/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM core+base-image
sources:
WORKDIR src
DO stack+INCLUDE_GO_LIBS --LOCATION libs/go-libs
COPY --pass-args (stack+build-sdk/go --LANG=go) sdks/go
COPY --pass-args (stack+build-sdk/go) libs/clients/go
WORKDIR /src/ee/wallets
COPY go.* .
COPY --dir pkg cmd .
Expand Down
2 changes: 1 addition & 1 deletion ee/wallets/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ require (

replace github.com/formancehq/stack/libs/go-libs => ../../libs/go-libs

replace github.com/formancehq/formance-sdk-go => ../../sdks/go
replace github.com/formancehq/formance-sdk-go => ../../libs/clients/go
1 change: 1 addition & 0 deletions libs/clients/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
File renamed without changes.
3 changes: 3 additions & 0 deletions openapi/base.yaml → libs/clients/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ x-tagGroups:
- name: Flows
tags:
- Orchestration
- name: Reconciliation
tags:
- Reconciliation

paths:
/versions:
Expand Down
2 changes: 2 additions & 0 deletions libs/clients/go/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This allows generated code to be indexed correctly
*.go linguist-generated=false
1 change: 1 addition & 0 deletions libs/clients/go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# .gitignore
Loading

1 comment on commit bea0e76

@vercel
Copy link

@vercel vercel bot commented on bea0e76 Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.