From 6d6915e3dbe7c5613737b5b12da633851e089b0f Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 25 Apr 2024 21:19:31 -0400 Subject: [PATCH] github: Add linting for github workflows and markdown files Signed-off-by: Russell Bryant --- .github/workflows/actionlint.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/docs.yml | 23 +++++++++++++++++++++++ .markdownlint-cli2.yaml | 15 +++++++++++++++ Makefile | 22 ++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 .github/workflows/actionlint.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .markdownlint-cli2.yaml create mode 100644 Makefile diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml new file mode 100644 index 0000000..5862bbe --- /dev/null +++ b/.github/workflows/actionlint.yml @@ -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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..ecb12dd --- /dev/null +++ b/.github/workflows/docs.yml @@ -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' diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml new file mode 100644 index 0000000..21a628b --- /dev/null +++ b/.markdownlint-cli2.yaml @@ -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/**" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..182b307 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +.PHONY: help +help: + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\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