forked from openshift/hypershift
-
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.
Reduce API docs generation time by 97%
Optimize the API docs generation by disabling the use of Go modules when running the generation tool. This is a workaround for performance issues in the upstream libraries: - kubernetes/gengo#147 - kubernetes/code-generator#69 Before this workaround: make api-docs 93.87s user 171.98s system 426% cpu 1:02.30 total After the workaround: make api-docs 2.91s user 0.83s system 135% cpu 2.752 total The hack seems worth the 97% improvement for iterating on docs.
- Loading branch information
1 parent
2b961b5
commit c6ebf1f
Showing
2 changed files
with
29 additions
and
1 deletion.
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
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,28 @@ | ||
#!/bin/bash | ||
|
||
# This generation script sets up a fake GOPATH for docs generation | ||
# to work around performance issues in the upstream code generation | ||
# libraries. See: | ||
# | ||
# https://github.com/kubernetes/gengo/issues/147 | ||
# https://github.com/kubernetes/code-generator/issues/69 | ||
|
||
GEN_BIN="$1" | ||
REPO_ROOT_DIR="$2" | ||
|
||
FAKE_GOPATH="$(mktemp -d)" | ||
trap 'rm -rf ${FAKE_GOPATH}' EXIT | ||
|
||
FAKE_REPOPATH="${FAKE_GOPATH}/src/github.com/openshift/hypershift" | ||
mkdir -p "$(dirname "${FAKE_REPOPATH}")" && ln -s "${REPO_ROOT_DIR}" "${FAKE_REPOPATH}" | ||
|
||
export GOPATH="${FAKE_GOPATH}" | ||
export GO111MODULE="off" | ||
|
||
cd "${FAKE_REPOPATH}" | ||
|
||
GO111MODULE="off" GOPATH="${FAKE_GOPATH}" ${GEN_BIN} \ | ||
--config "${FAKE_REPOPATH}/docs/api-doc-gen/config.json" \ | ||
--template-dir "${FAKE_REPOPATH}/docs/api-doc-gen/templates" \ | ||
--api-dir ./api/v1alpha1 \ | ||
--out-file "${FAKE_REPOPATH}/docs/content/reference/api.md" |