Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linting for RST and MD files #1287

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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 and markdownlint
run: |
pip install rstcheck
sudo gem install mdl

- name: Run rstcheck on all RST files
run: make checkrst

- name: Run mdl on all MD files
run: make checkmd
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand 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
Expand Down
Loading