From 911e28c396d6a0aa675e433cd6d19f708dabda9c Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 12 May 2024 13:30:21 -0400 Subject: [PATCH] ci(docs): Require up-to-date function docs Signed-off-by: Dave Henderson --- .github/workflows/docs.yml | 23 +++++++++++++++++++++++ Makefile | 5 ++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..7ce346d99 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,23 @@ +name: Docs Checks +on: + pull_request: + branches: [ main ] + +jobs: + check-func-docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install gomplate + run: | + docker create --name gomplate hairyhenderson/gomplate + docker cp gomplate:/gomplate . + sudo mv gomplate /usr/local/bin + - name: Make sure function docs are up-to-date + run: | + make --always-make gen-func-docs + git diff --exit-code + if [ $? -ne 0 ]; then + echo "Function docs are out of date. Please run 'make gen-func-docs' locally and commit the changes." + exit 1 + fi diff --git a/Makefile b/Makefile index c370f90c4..30eb427e9 100644 --- a/Makefile +++ b/Makefile @@ -213,6 +213,9 @@ gen-docs: docs/themes/hugo-theme-relearn docs/content/functions/%.md: docs-src/content/functions/%.yml docs-src/content/functions/func_doc.md.tmpl gomplate -d data=$< -f docs-src/content/functions/func_doc.md.tmpl -o $@ +# run the above target for all files found in docs-src/content/functions/*.yml +gen-func-docs: $(shell find docs-src/content/functions -name "*.yml" | sed -e 's#docs-src#docs#' -e 's#\.yml#\.md#') + # this target doesn't usually get used - it's mostly here as a reminder to myself # hint: make sure CLOUDCONVERT_API_KEY is set ;) gomplate.png: gomplate.svg @@ -224,6 +227,6 @@ lint: ci-lint: @golangci-lint run --verbose --max-same-issues=0 --max-issues-per-linter=0 --out-format=github-actions -.PHONY: gen-changelog clean test build-x build-release build test-integration-docker gen-docs lint clean-images clean-containers docker-images test-remote-windows integration testbins-windows +.PHONY: gen-changelog clean test build-x build-release build test-integration-docker gen-docs lint clean-images clean-containers docker-images test-remote-windows integration testbins-windows gen-func-docs .DELETE_ON_ERROR: .SECONDARY: