From 75e3760f2ef80c565f25d6159a7bbe33fffb84d6 Mon Sep 17 00:00:00 2001 From: jo Date: Sun, 6 Feb 2022 15:39:09 +0100 Subject: [PATCH] ci: setup docs prose linting with vale - only deploy if prose lint passes - rework styles download - add vale anotations matcher - set MinAlertLevel to warning - add website pages to the prose linter - do not fail on docs linting --- .github/annotations/vale.json | 18 +++++++++++++++ .github/vale/styles/.gitignore | 4 ++++ .github/vale/styles/LibreTime/NameCasing.yml | 6 +++++ .github/vale/styles/Makefile | 18 +++++++++++++++ .github/vale/styles/Vocab/Docs/accept.txt | 0 .github/vale/styles/Vocab/Docs/reject.txt | 0 .github/workflows/website.yml | 24 ++++++++++++++++++++ .vale.ini | 7 ++++++ Makefile | 4 ++++ 9 files changed, 81 insertions(+) create mode 100644 .github/annotations/vale.json create mode 100644 .github/vale/styles/.gitignore create mode 100644 .github/vale/styles/LibreTime/NameCasing.yml create mode 100644 .github/vale/styles/Makefile create mode 100644 .github/vale/styles/Vocab/Docs/accept.txt create mode 100644 .github/vale/styles/Vocab/Docs/reject.txt create mode 100644 .vale.ini diff --git a/.github/annotations/vale.json b/.github/annotations/vale.json new file mode 100644 index 000000000..961a2c24e --- /dev/null +++ b/.github/annotations/vale.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "severity": "error", + "pattern": [ + { + "regexp": "^([^:]+):(\\d+):(\\d+):([^:]+):(.*)$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ], + "owner": "vale-error" + } + ] +} diff --git a/.github/vale/styles/.gitignore b/.github/vale/styles/.gitignore new file mode 100644 index 000000000..6d8c9b57f --- /dev/null +++ b/.github/vale/styles/.gitignore @@ -0,0 +1,4 @@ +* +!Makefile +!LibreTime +!Vocab diff --git a/.github/vale/styles/LibreTime/NameCasing.yml b/.github/vale/styles/LibreTime/NameCasing.yml new file mode 100644 index 000000000..8fd7e4933 --- /dev/null +++ b/.github/vale/styles/LibreTime/NameCasing.yml @@ -0,0 +1,6 @@ +extends: substitution +message: Consider using '%s' +level: warning +ignorecase: false +swap: + Libretime: LibreTime diff --git a/.github/vale/styles/Makefile b/.github/vale/styles/Makefile new file mode 100644 index 000000000..4265030a4 --- /dev/null +++ b/.github/vale/styles/Makefile @@ -0,0 +1,18 @@ +.PHONY: all + +SHELL = bash + +%.zip: + wget -q $(URL) -O $@ + +Google.zip: URL=https://github.com/errata-ai/Google/releases/latest/download/Google.zip +Microsoft.zip: URL=https://github.com/errata-ai/Microsoft/releases/latest/download/Microsoft.zip + +%: %.zip + unzip -qq $< + touch $@ + +STYLES := ./Microsoft ./Google +STYLES_ZIP := $(addsuffix .zip,$(STYLES)) + +all: $(STYLES) diff --git a/.github/vale/styles/Vocab/Docs/accept.txt b/.github/vale/styles/Vocab/Docs/accept.txt new file mode 100644 index 000000000..e69de29bb diff --git a/.github/vale/styles/Vocab/Docs/reject.txt b/.github/vale/styles/Vocab/Docs/reject.txt new file mode 100644 index 000000000..e69de29bb diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index eef56a21e..1fdf7a63e 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -10,12 +10,36 @@ on: pull_request: jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vale + run: | + sudo pip3 install gh-release-install + sudo gh-release-install \ + errata-ai/vale \ + vale_{version}_Linux_64-bit.tar.gz --extract vale \ + /usr/local/bin/vale + + - name: Add annotations matchers + run: | + echo "::add-matcher::.github/annotations/vale.json" + + - name: Run Vale + run: | + make -C .github/vale/styles + vale --output line docs website/src/pages || true + deploy: name: Deploy runs-on: ubuntu-latest concurrency: group: ${{ github.workflow }}-${{ github.ref }} + needs: [lint] + steps: - uses: actions/checkout@v2 diff --git a/.vale.ini b/.vale.ini new file mode 100644 index 000000000..1a3f9a4b7 --- /dev/null +++ b/.vale.ini @@ -0,0 +1,7 @@ +StylesPath = .github/vale/styles +MinAlertLevel = warning + +Vocab = Docs + +[*.md] +BasedOnStyles = Vale, Google, Microsoft, LibreTime diff --git a/Makefile b/Makefile index 6e98b8605..d971a63a2 100644 --- a/Makefile +++ b/Makefile @@ -37,3 +37,7 @@ tarball: VERSION # Only clean subdirs clean: git clean -xdf */ + +docs-lint: + $(MAKE) -C .github/vale/styles + vale docs website/src/pages