From 312a7635090c01bf784bef15b5535cd76d0f85f3 Mon Sep 17 00:00:00 2001 From: krcroft Date: Sun, 5 Jan 2020 17:59:13 -0800 Subject: [PATCH] Verify Markdown documents in linting workflow Also re-order to perform shellcheck first because it requires the least installation work compared to pylint and markdownlint. The reason being if we're going to fail during shellcheck, then we fail faster (and leave heavier tasks for further down the line). --- .github/workflows/analysis.yml | 11 +++++++++-- scripts/verify-markdown.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 scripts/verify-markdown.sh diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 581cc9ce..813fc707 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -11,14 +11,21 @@ jobs: with: fetch-depth: 1 - run: sudo apt-get update + - name: Run shellcheck + run: ./scripts/verify-bash.sh - name: Install pylint run: | sudo apt-get install python3-setuptools sudo pip3 install pylint beautifulsoup4 html5lib - name: Run pylint run: ./scripts/verify-python.sh - - name: Run shellcheck - run: ./scripts/verify-bash.sh + - name: Install markdownlint + run: | + sudo apt-get install ruby + sudo gem install mdl + sudo chmod go-w /usr/share/rust/.cargo/bin + - name: Run markdownlint + run: ./scripts/verify-markdown.sh build_clang_static_analyser: name: Clang static analyzer diff --git a/scripts/verify-markdown.sh b/scripts/verify-markdown.sh new file mode 100755 index 00000000..f33c8810 --- /dev/null +++ b/scripts/verify-markdown.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright (C) 2020 Kevin Croft +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Based on `verify-bash.sh` by Patryk Obara +# Copyright (C) 2019 licensed GPL-2.0-or-later +# +# This script exists only to easily run mdl (markdownlint) on all +# *.md files in the repo. +# +# You can pass additional parameters to this script itself, e.g.: +# +# ./verify-markdown.sh --verbose --json + +set -euo pipefail + +list_markdown_files () { + git ls-files | grep '.md$' +} + +main () { + mdl --version + echo "Checking files:" + list_markdown_files + list_markdown_files | xargs -L 1000 mdl "$@" +} + +>&2 main "$@"