diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 361d3d43e..f4800e3c8 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -47,7 +47,7 @@ jobs: - name: Check documentation for CRDs run: | - make validate-and-gen-docs-crds + make generate-docs-crds DIFF_ON_DOCS=$(git diff --ignore-matching-lines='on git commit') if [ ! -z "$DIFF_ON_DOCS" ]; then echo "Please run 'make generate-docs-crds' locally, commit the updated crds docs, and push the change" @@ -56,4 +56,3 @@ jobs: - name: Build documentation using mkdocs run: make docs-build - diff --git a/Makefile b/Makefile index 7c498f13a..3aaed22cc 100644 --- a/Makefile +++ b/Makefile @@ -121,6 +121,7 @@ build.version: # Change how CRDs are generated for CSVs build.common: export NO_OB_OBC_VOL_GEN=true build.common: export MAX_DESC_LEN=0 +build.common: export SKIP_GEN_CRD_DOCS=true build.common: build.version helm.build mod.check crds gen-rbac @$(MAKE) go.init @$(MAKE) go.validate @@ -134,7 +135,6 @@ do.build.parallel: $(foreach p,$(PLATFORMS_TO_BUILD_FOR), do.build.platform.$(p) build: csv-clean build.common ## Only build for linux platform @$(MAKE) go.build PLATFORM=linux_$(GOHOSTARCH) @$(MAKE) -C images PLATFORM=linux_$(GOHOSTARCH) - @$(MAKE) generate-docs-crds build.all: build.common ## Build source code for all platforms. ifneq ($(GOHOSTARCH),amd64) @@ -193,6 +193,7 @@ csv-clean: ## Remove existing OLM files. crds: $(CONTROLLER_GEN) $(YQ) @echo Updating CRD manifests @build/crds/build-crds.sh $(CONTROLLER_GEN) $(YQ) + @GOBIN=$(GOBIN) build/crds/generate-crd-docs.sh gen-rbac: $(HELM) $(YQ) ## Generate RBAC from Helm charts @# output only stdout to the file; stderr for debugging should keep going to stderr @@ -217,10 +218,7 @@ docs-build: ## Build the documentation to the `site/` directory mkdocs build --strict generate-docs-crds: ## Build the documentation for CRD - @build/crds/generate-crd-docs.sh - -validate-and-gen-docs-crds: ## Force generation of CRD documentation - build/crds/generate-crd-docs.sh --force + @GOBIN=$(GOBIN) build/crds/generate-crd-docs.sh .PHONY: all build.common .PHONY: build build.all install test check vet fmt codegen mod.check clean distclean prune diff --git a/crd-docs-config.json b/build/crds/crd-docs-config.json similarity index 99% rename from crd-docs-config.json rename to build/crds/crd-docs-config.json index bdeefef44..a63ce1723 100644 --- a/crd-docs-config.json +++ b/build/crds/crd-docs-config.json @@ -25,4 +25,4 @@ "k8s.io/apimachinery/pkg/apis/": "Kubernetes " }, "markdownDisabled": false -} \ No newline at end of file +} diff --git a/build/crds/generate-crd-docs.sh b/build/crds/generate-crd-docs.sh index 4a444aee9..b533dc763 100755 --- a/build/crds/generate-crd-docs.sh +++ b/build/crds/generate-crd-docs.sh @@ -2,23 +2,24 @@ SCRIPT_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P) GEN_CRD_API_REFERENCE_DOC_VERSION=v0.3.0 -SCRIPT_CHECK_DOCS_DIFF=$(git diff --name-only --diff-filter=M | grep -Ec '/types\.go$') SPECIFICATION_FILE=Documentation/CRDs/specification.md install_generator() { - go install github.com/ahmetb/gen-crd-api-reference-docs@${GEN_CRD_API_REFERENCE_DOC_VERSION} + go install github.com/ahmetb/gen-crd-api-reference-docs@${GEN_CRD_API_REFERENCE_DOC_VERSION} } run_gen() { - if [[ "$SCRIPT_CHECK_DOCS_DIFF" -gt 0 || "$1" = "--force" ]]; then - echo "differences found in types.go, rebuilding specification.md" + if [[ $SKIP_GEN_CRD_DOCS = true ]]; then + echo "SKIP_GEN_CRD_DOCS is set, skipping CRD docs generation" + else + echo "rebuilding specification.md" install_generator - gen-crd-api-reference-docs \ - -config="${SCRIPT_ROOT}/crd-docs-config.json" \ - -template-dir="${SCRIPT_ROOT}/Documentation/gen-crd-api-reference-docs/template" \ - -api-dir="github.com/rook/rook/pkg/apis/ceph.rook.io" \ - -out-file="${SCRIPT_ROOT}/$SPECIFICATION_FILE" - fi + ${GOBIN}/gen-crd-api-reference-docs \ + -config="${SCRIPT_ROOT}/build/crds/crd-docs-config.json" \ + -template-dir="${SCRIPT_ROOT}/Documentation/gen-crd-api-reference-docs/template" \ + -api-dir="github.com/rook/rook/pkg/apis/ceph.rook.io" \ + -out-file="${SCRIPT_ROOT}/$SPECIFICATION_FILE" + fi } -run_gen "$@" \ No newline at end of file +run_gen