Skip to content

Commit

Permalink
ci: generate crd docs (#448)
Browse files Browse the repository at this point in the history
Signed-off-by: realanna <[email protected]>
  • Loading branch information
RealAnna authored Apr 12, 2023
1 parent 01d81a0 commit cee89a3
Show file tree
Hide file tree
Showing 5 changed files with 2,433 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/validate-crd-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Validate CRD Docs
on:
pull_request:
branches:
- 'main'
defaults:
run:
shell: bash
jobs:
check-helm-docs:
name: Check crd documentation values
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Cache build tools
id: cache-build-tools
uses: actions/cache@v3
with:
path: ./bin
key: build-tools-${{ github.ref_name }}

- name: Check if crds.md is up to date
run: |
cp ./docs/crds.md ./docs/crds-old.md
make generate-crdocs
cd ./docs/
if ! cmp --quiet ./crds-old.md ./crds.md; then
echo "The crd values have changes that are not reflected in the documentation. Please use make generate-crdocs to re-generate the docs."
echo ""
echo "=========== Diff ==========="
diff -u ./crds-old.md ./crds.md
exit 1
else
echo ""
echo "CRDs documentation is correct!"
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ config/rendered/release.yaml
.tar.gz
config/manager/manager.yaml
config/manager/kustomization.yaml
tmpcrd.yaml
schemas
.vscode
of-agent
Expand Down
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ Which will result in building the operator image `docker.io/user1/myImgName:myTa
and deploying to your cluster. Please be aware that it is using the cluster your current kube-context is pointing to.

**Note:** All bash variables are optional, the default values are set and will result in an image `ghcr.io/openfeature/operator:latest`

### Autogenerated Documentation

Some part of the project docs may be autogenerated and require running a script.

#### CRDs Docs
If you modified or added crds to the project, then you should recreate the crds.md file. To do so run:

```
make generate-crdocs
```

12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ lint:
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
${GOPATH}/bin/golangci-lint run --deadline=3m --timeout=3m ./... # Run linters

.PHONY: generate-crdocs
generate-crdocs: kustomize crdocs
$(KUSTOMIZE) build config/crd > tmpcrd.yaml
$(CRDOC) --resources tmpcrd.yaml --output docs/crds.md

##@ Build

.PHONY: build
Expand Down Expand Up @@ -181,12 +186,14 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
HELM ?= $(LOCALBIN)/HELM
ENVTEST ?= $(LOCALBIN)/setup-envtest
CRDOC ?= $(LOCALBIN)/crdoc

## Tool Versions
# renovate: datasource=github-tags depName=kubernetes-sigs/kustomize
KUSTOMIZE_VERSION ?= v4.5.7
# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools
CONTROLLER_TOOLS_VERSION ?= v0.10.0
CRDOC_VERSION ?= v0.6.2

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand All @@ -200,6 +207,11 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
$(CONTROLLER_GEN): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

.PHONY: crdocs
crdocs: $(CRDOC) ## Download crdoc locally if necessary.
$(CRDOC): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install fybrik.io/crdoc@$(CRDOC_VERSION)

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
Expand Down
Loading

0 comments on commit cee89a3

Please sign in to comment.