Skip to content

Commit

Permalink
ci: add markdown linting pipeline (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
mowies authored Feb 13, 2023
1 parent 6adff0a commit 6434be9
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 28 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/check-links.yaml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/markdown-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Markdown checks

on:
push:
branches:
- 'main'
- '[0-9]+.[1-9][0-9]*.x'
paths:
- '**.md'
pull_request:
branches:
- 'main'
- '[0-9]+.[1-9][0-9]*.x'
paths:
- '**.md'

defaults:
run:
shell: bash

jobs:
markdown-link-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
config-file: '.github/mlc_config.json'
use-verbose-mode: true
use-quiet-mode: true
folder-path: 'examples,docs'
file-path: 'README.md'

markdown-lint:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Run TOC generation
run: |
FILES=`find . -type f -name '*.md' -not -path './.github/*' -not -path './node_modules/*' | sort`
for f in $FILES; do
if grep -q '<!-- tocstop -->' $$f; then
echo "Checking TOC for ${f}";
npx markdown-toc --no-first-h1 --no-stripHeadingTags -i ${f} || exit 1;
else
echo Skipping ${f};
fi;
done
- name: Check TOC
run: |
git diff --exit-code '*.md' || (echo "Table of Contents is out of date. Please update the following files: $(git diff --name-status --exit-code)" && exit 1)
- name: Lint Markdown files
run: make markdownlint
2 changes: 2 additions & 0 deletions .github/workflows/validate-helm-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
pull_request:
branches:
- 'main'
paths:
- 'helm/**'
defaults:
run:
shell: bash
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ build-deploy-certmanager:

.PHONY: build-deploy-dev-environment
build-deploy-dev-environment: build-deploy-certmanager build-deploy-operator build-deploy-scheduler

markdownlint:
docker run -v $(CURDIR):/workdir --rm ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" --config "/workdir/docs/markdownlint-rules.yaml" --ignore "/workdir/CHANGELOG.md"

markdownlint-fix:
docker run -v $(CURDIR):/workdir --rm ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" --config "/workdir/docs/markdownlint-rules.yaml" --fix --ignore "/workdir/CHANGELOG.md"
17 changes: 15 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,27 @@ For already existing documentation versions directly edit them from https://gith

To verify your changes to the dev documentations you can use the makefile:

````
```
cd lifecycle-toolkit/docs
make clone
make build
make server
````
```

After the server is running on http://localhost:1314/docs-dev.
Any modification in the docs folder will be reflected on the server under the dev revision.
You can modify the content in realtime to verify the correct behaviour of links and such.

### Markdown linting
To check your markdown files for linter errors, run the following from the repo root:

```
make markdownlint
```

To use the auto-fix option, run:

```
make markdownlint-fix
```
3 changes: 3 additions & 0 deletions docs/markdownlint-rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
line-length:
line_length: 120
tables: false

0 comments on commit 6434be9

Please sign in to comment.