From a2099d19b4eafe7b196f496473e5045f5e73c6e8 Mon Sep 17 00:00:00 2001 From: Tuomo Tanskanen Date: Wed, 24 Jan 2024 12:40:28 +0200 Subject: [PATCH] add markdownlint-cli2 for linting markdown Signed-off-by: Tuomo Tanskanen --- .markdownlint-cli2.yaml | 9 +++++++++ README.md | 12 ++++++------ hack/markdownlint.sh | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 .markdownlint-cli2.yaml create mode 100755 hack/markdownlint.sh diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml new file mode 100644 index 0000000..7811fc6 --- /dev/null +++ b/.markdownlint-cli2.yaml @@ -0,0 +1,9 @@ +# Reference: https://github.com/DavidAnson/markdownlint-cli2#markdownlint-cli2yaml + +config: + ul-indent: + # Kramdown wanted us to have 3 earlier, tho this CLI recommends 2 or 4 + indent: 3 + +# Don't autofix anything, we're linting here +fix: false diff --git a/README.md b/README.md index 4b44131..678061b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -Metal3 Ironic Client Container -============================== +# Metal3 Ironic Client Container -This repo contains the files needed to build a container image with the Ironic CLI utilities, which are useful for debugging via Ironic APIs. +This repo contains the files needed to build a container image with the Ironic +CLI utilities, which are useful for debugging via Ironic APIs. -Description ------------ +## Description -When updated, builds are automatically triggered on https://quay.io/repository/metal3-io/ironic-client +When updated, builds are automatically triggered on +[Quay](https://quay.io/repository/metal3-io/ironic-client). diff --git a/hack/markdownlint.sh b/hack/markdownlint.sh new file mode 100755 index 0000000..5258d27 --- /dev/null +++ b/hack/markdownlint.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# markdownlint-cli2 has config file(s) named .markdownlint-cli2.yaml in the repo + +set -eux + +IS_CONTAINER="${IS_CONTAINER:-false}" +CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-podman}" + +# all md files, but ignore .github +if [ "${IS_CONTAINER}" != "false" ]; then + markdownlint-cli2 "**/*.md" "#.github" +else + "${CONTAINER_RUNTIME}" run --rm \ + --env IS_CONTAINER=TRUE \ + --volume "${PWD}:/workdir:ro,z" \ + --entrypoint sh \ + --workdir /workdir \ + docker.io/pipelinecomponents/markdownlint-cli2:0.9.0@sha256:71370df6c967bae548b0bfd0ae313ddf44bfad87da76f88180eff55c6264098c \ + /workdir/hack/markdownlint.sh "$@" +fi