From 7b289aa04440a7aa8f4804e7bdc8070b689bc068 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 16 Sep 2023 11:26:34 +0200 Subject: [PATCH 1/3] Add workflow for rstcheck and mdl. Signed-off-by: Felix Fontein --- .github/workflows/docs.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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..14f11280e --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +name: "Docs" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + # Only consider changes to documentation + paths: + - '**/*.md' + - '**/*.rst' + - '**/*.txt' + schedule: + - cron: '25 6 * * 3' + +permissions: + contents: read + +jobs: + documentation: + name: Lint RST and MD files + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + + - name: Install rstcheck + run: pip install rstcheck + + - name: Run rstcheck on all RST files + run: rstcheck $(find -name '*.rst') + + - name: Install markdownlint + run: sudo gem install mdl + + - name: Run mdl on all MD files + run: mdl $(find -name '*.md') From 3697768a81a8a1e260fa7d91333b7eaca7651067 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 16 Sep 2023 22:38:17 +0200 Subject: [PATCH 2/3] Add checkdocs, checkrst, and checkmd make targets. Signed-off-by: Felix Fontein --- .github/workflows/docs.yml | 13 ++++++------- Makefile | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 14f11280e..fc3916fe0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -25,14 +25,13 @@ jobs: - name: Checkout code uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - - name: Install rstcheck - run: pip install rstcheck + - name: Install rstcheck and markdownlint + run: | + pip install rstcheck + sudo gem install mdl - name: Run rstcheck on all RST files - run: rstcheck $(find -name '*.rst') - - - name: Install markdownlint - run: sudo gem install mdl + run: make checkrst - name: Run mdl on all MD files - run: mdl $(find -name '*.md') + run: make checkmd diff --git a/Makefile b/Makefile index a8e417941..d0e22c059 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,9 @@ SYFT_VERSION ?= v0.87.0 GORELEASER := $(BIN_DIR)/goreleaser GORELEASER_VERSION ?= v1.20.0 +RSTCHECK := $(shell command -v rstcheck) +MARKDOWNLINT := $(shell command -v mdl) + export PATH := $(BIN_DIR):$(PATH) .PHONY: all @@ -45,6 +48,22 @@ vendor: vet: $(GO) vet ./... + +.PHONY: checkdocs +checkdocs: checkrst checkmd + +.PHONY: checkrst +RST_FILES=$(shell find . -name '*.rst' | grep -v /vendor/ | sort) +checkrst: $(RST_FILES) + @if [ "$(RSTCHECK)" == "" ]; then echo "Need rstcheck to lint RST files. Install rstcheck from your system package repository or from PyPI (https://pypi.org/project/rstcheck/)."; exit 1; fi + $(RSTCHECK) --report-level warning $^ + +.PHONY: checkmd +MD_FILES=$(shell find . -name '*.md' | grep -v /vendor/ | sort) +checkmd: $(MD_FILES) + @if [ "$(MARKDOWNLINT)" == "" ]; then echo "Need markdownlint to lint RST files. Install markdownlint from your system package repository or from https://github.com/markdownlint/markdownlint."; exit 1; fi + $(MARKDOWNLINT) $^ + .PHONY: test test: vendor gpg --import pgp/sops_functional_tests_key.asc 2>&1 1>/dev/null || exit 0 From eb1f4ec24f2b75f38299ebb5f1c74f22e68c10bc Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 16 Sep 2023 22:38:30 +0200 Subject: [PATCH 3/3] Add section in CONTRIBUTING.md on docs changes. Signed-off-by: Felix Fontein --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 885e14376..947dcfd48 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,6 +9,11 @@ and instructions if you are thinking of helping with the development of SOPS. how to install Go [here](https://go.dev/doc/install) - Clone the Git repository and switch into SOPS's directory. - Run the tests with `make test`. They should all pass. +- If you modify documentation (RST or MD files), run `make checkdocs` to run + [rstcheck](https://pypi.org/project/rstcheck/) and + [markdownlint](https://github.com/markdownlint/markdownlint). These should also + pass. If you need help in fixing issues, create a pull request (see below) and + ask for help. - Fork the project on GitHub. - Add your fork to Git's remotes: - If you use SSH authentication: