Skip to content

Commit

Permalink
github: Add linting for github workflows and markdown files
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Bryant <[email protected]>
  • Loading branch information
russellb committed Apr 26, 2024
1 parent 2de5c71 commit 6d6915e
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint GitHub Actions workflows
on:
push:
branches:
- "main"
paths:
- '.github/**'
pull_request:
branches:
- "main"
paths:
- '.github/**'

defaults:
run:
shell: bash

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download actionlint
id: get_actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) 1.6.27
- name: Check workflow files
run: PATH=".:$PATH" actionlint -color
23 changes: 23 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: docs

on:
push:
branches: ["main"]
paths:
- '**/*.md'
- '.markdownlint-cli2.yaml'
pull_request:
branches: ["main"]
paths:
- '**/*.md'
- '.markdownlint-cli2.yaml'

jobs:
markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: markdownlint-cli2-action
uses: DavidAnson/markdownlint-cli2-action@v15
with:
globs: '**/*.md'
15 changes: 15 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
config:
line-length: false
no-emphasis-as-header: false
first-line-heading: false
code-block-style: false
no-duplicate-header: false
single-trailing-newline: false
globs:
- "**/*.md"
ignores:
- "pkg"
- "**/node_modules/*"
- "**/node_modules/**"
- ".tox/**"
- "venv/**"
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.PHONY: help
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

#
# If you want to see the full commands, run:
# NOISY_BUILD=y make
#
ifeq ($(NOISY_BUILD),)
ECHO_PREFIX=@
CMD_PREFIX=@
PIPE_DEV_NULL=> /dev/null 2> /dev/null
else
ECHO_PREFIX=@\#
CMD_PREFIX=
PIPE_DEV_NULL=
endif

.PHONY: md-lint
md-lint: ## Lint markdown files
$(ECHO_PREFIX) printf " %-12s ./...\n" "[MD LINT]"
$(CMD_PREFIX) podman run --rm -v $(CURDIR):/workdir --security-opt label=disable docker.io/davidanson/markdownlint-cli2:v0.6.0 > /dev/null

0 comments on commit 6d6915e

Please sign in to comment.