Skip to content

Commit

Permalink
build: build swagger api bindings [DET-5056] (#2011)
Browse files Browse the repository at this point in the history
add steps to generate API bindings based on swagger spec for different languages
  • Loading branch information
hamidzr authored Feb 26, 2021
1 parent 33252c1 commit 5542e11
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 180 deletions.
32 changes: 15 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ commands:
steps:
- attach_workspace:
at: .
- run: make -C webui/api-ts-sdk get-deps-package
- run: make -C webui/api-ts-sdk build-package
- restore_cache:
keys:
- det-react-deps-v1dev3-{{ checksum "webui/react/package-lock.json" }}
Expand Down Expand Up @@ -952,19 +950,19 @@ jobs:
- run: make -C <<parameters.path>> build
- run: make -C <<parameters.path>> publish

build-and-package-ts-sdk:
build-bindings:
docker:
- image: cimg/openjdk:14.0.1
steps:
- checkout
- attach_workspace:
at: .
- run: make -C webui/api-ts-sdk get-deps-swagger
- run: make -C webui/api-ts-sdk build-swagger
- run: make -C bindings get-deps
- run: make -C bindings build
- persist_to_workspace:
root: .
paths:
- webui/api-ts-sdk/src
- bindings

upload-try-now-template:
docker:
Expand Down Expand Up @@ -1614,15 +1612,15 @@ workflows:
lint:
jobs:
- build-proto
- build-and-package-ts-sdk:
- build-bindings:
requires:
- build-proto
- lint-docs
- lint-python
- lint-go
- lint-react:
requires:
- build-and-package-ts-sdk
- build-bindings

test-cli:
jobs:
Expand All @@ -1642,12 +1640,12 @@ workflows:
jobs:
- test-unit-go
- build-proto
- build-and-package-ts-sdk:
- build-bindings:
requires:
- build-proto
- test-unit-react:
requires:
- build-and-package-ts-sdk
- build-bindings
- test-unit-harness
- test-unit-harness-tf2
- test-examples
Expand All @@ -1661,19 +1659,19 @@ workflows:
jobs:
- build-proto
- build-helm
- build-and-package-ts-sdk:
- build-bindings:
requires:
- build-proto
- build-react-preview:
requires:
- build-and-package-ts-sdk
- build-bindings
- build-react:
dev-mode: true
requires:
- build-and-package-ts-sdk
- build-bindings
- build-storybook:
requires:
- build-and-package-ts-sdk
- build-bindings
- build-docs:
requires:
- build-helm
Expand Down Expand Up @@ -1729,7 +1727,7 @@ workflows:

- test-e2e-webui:
requires:
- build-and-package-ts-sdk
- build-bindings
- package-and-push-system-local

- deploy:
Expand Down Expand Up @@ -2019,13 +2017,13 @@ workflows:
filters: *release-and-rc-filters
- build-proto:
filters: *release-and-rc-filters
- build-and-package-ts-sdk:
- build-bindings:
requires:
- build-proto
filters: *release-and-rc-filters
- build-react:
requires:
- build-and-package-ts-sdk
- build-bindings
context: determined-production
filters: *release-and-rc-filters
- build-docs:
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ get-deps:
$(MAKE) -C master $@
$(MAKE) -C agent $@
$(MAKE) -C proto $@
$(MAKE) -C bindings $@
$(MAKE) -C webui $@

.PHONY: package
Expand All @@ -27,6 +28,7 @@ build-master: build-webui build-docs
$(MAKE) -C master build
.PHONY: build-webui
build-webui: build-proto
$(MAKE) build-bindings
$(MAKE) -C webui build
.PHONY: build
build: build-master build-agent
Expand All @@ -35,7 +37,7 @@ build: build-master build-agent
clean-%:
$(MAKE) -C $(subst -,/,$*) clean
.PHONY: clean
clean: clean-tools clean-proto clean-common clean-harness clean-cli clean-deploy clean-examples clean-docs clean-webui clean-master clean-agent
clean: clean-tools clean-proto clean-common clean-harness clean-cli clean-deploy clean-examples clean-docs clean-webui clean-master clean-agent clean-bindings

.PHONY: check-%
check-%:
Expand Down
2 changes: 2 additions & 0 deletions bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deps/
build/
34 changes: 34 additions & 0 deletions bindings/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
SWAGGER_SPEC := ../proto/build/swagger/determined/api/v1/api.swagger.json
CODEGEN_BIN := swagger-codegen-cli-2.4.14.jar

.PHONY: all
all: get-deps
$(MAKE) build

.PHONY: get-deps
get-deps: deps/${CODEGEN_BIN}

deps/${CODEGEN_BIN}:
mkdir -p deps
curl https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.14/${CODEGEN_BIN} \
-o deps/${CODEGEN_BIN}

build/%: ${SWAGGER_SPEC} deps/${CODEGEN_BIN}
mkdir -p build/$*
java -jar deps/$(CODEGEN_BIN) generate -i ${SWAGGER_SPEC} \
-l $* -o build/$*
touch build/$*

.PHONY: build
build: build/typescript-fetch build/python

.PHONY: clean-deps
clean-deps:
rm -rf deps/

.PHONY: clean
clean:
rm -rf build/

.PHONY: clean-all
clean-all: clean clean-deps
2 changes: 1 addition & 1 deletion proto/src/determined/api/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ service Determined {
body: "*"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
tags: "Experiments"
tags: "Internal"
};
}
// Get the requested experiment.
Expand Down
17 changes: 4 additions & 13 deletions webui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ all:
$(MAKE) build

.PHONY: clean
clean: clean-react clean-tests clean-api-ts-sdk
clean: clean-react clean-tests
.PHONY: clean-%
clean-%:
$(MAKE) -C $* clean
Expand All @@ -22,22 +22,13 @@ check-%:
$(MAKE) -C $* check

.PHONY: get-deps
get-deps: build-api-ts-sdk
get-deps:
$(MAKE) -C react $@
$(MAKE) -C tests $@

.PHONY: build
build: build-react
.PHONY: build-proto
build-proto:
$(MAKE) -C ../proto build
.PHONY: build-api-ts-sdk
build-api-ts-sdk: build-proto
$(MAKE) -C api-ts-sdk get-deps
$(MAKE) -C api-ts-sdk build
.PHONY: build-%
build-%:
$(MAKE) -C $* build
build:
$(MAKE) -C react build

.PHONY: test
test: test-react test-tests
Expand Down
4 changes: 0 additions & 4 deletions webui/api-ts-sdk/.gitignore

This file was deleted.

40 changes: 0 additions & 40 deletions webui/api-ts-sdk/Makefile

This file was deleted.

63 changes: 0 additions & 63 deletions webui/api-ts-sdk/package-lock.json

This file was deleted.

20 changes: 0 additions & 20 deletions webui/api-ts-sdk/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions webui/api-ts-sdk/tsconfig.json

This file was deleted.

Loading

0 comments on commit 5542e11

Please sign in to comment.