From 892cf88c8d259acb530db0cdd424a172c15f2fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Krupa=20=28paulfantom=29?= Date: Tue, 10 May 2022 11:14:05 +0200 Subject: [PATCH] *: add docs formatter and checker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Krupa (paulfantom) --- .github/workflows/go.yml | 16 ++++++++++++++++ .mdox.validate.yaml | 6 ++++++ Makefile | 14 ++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 .mdox.validate.yaml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ee4fa29870..de1eb287df 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -85,3 +85,19 @@ jobs: go generate ./... git diff --exit-code + docs: + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + + - name: Set up Go ${{ env.golang-version }} + uses: actions/setup-go@v3.0.0 + with: + go-version: ${{ env.golang-version }} + + - name: download mdox + run: go install -a github.com/bwplotka/mdox@latest + + - run: make check-docs + diff --git a/.mdox.validate.yaml b/.mdox.validate.yaml new file mode 100644 index 0000000000..65f363609d --- /dev/null +++ b/.mdox.validate.yaml @@ -0,0 +1,6 @@ +version: 1 + +validators: + # Ignore localhost links. + - regex: 'localhost' + type: "ignore" \ No newline at end of file diff --git a/Makefile b/Makefile index 19a76b9ac5..82c437f878 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,8 @@ GIT_COMMIT ?= $(shell git rev-list -1 HEAD) GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) LOCAL_DOCKER_BASE := local/dev_promscale_extension GHCR_DOCKER_BASE := ghcr.io/timescale/dev_promscale_extension +MDOX_BIN=mdox +MDOX_VALIDATE_CONFIG= .PHONY: build build: generate @@ -50,5 +52,17 @@ generate-helm: deploy/helm-chart/templates/prometheus-rule.yaml deploy/helm-chart/templates/prometheus-rule.yaml: ./scripts/generate-helm-alerts.sh +MDOX_VALIDATE_CONFIG?=.mdox.validate.yaml +MD_FILES_TO_FORMAT=$(shell find -type f -name '*.md') +.PHONY: docs +docs: + @echo ">> formatting and local/remote links" + $(MDOX_BIN) fmt --soft-wraps -l --links.validate.config-file=$(MDOX_VALIDATE_CONFIG) $(MD_FILES_TO_FORMAT) + +.PHONY: check-docs +check-docs: + @echo ">> checking formatting and local/remote links" + $(MDOX_BIN) fmt --soft-wraps --check -l --links.validate.config-file=$(MDOX_VALIDATE_CONFIG) $(MD_FILES_TO_FORMAT) + .PHONY: all all: build test go-fmt go-lint