From f7c5cc573582e38405d1ffeea5b8c76efd334c3c Mon Sep 17 00:00:00 2001 From: Nick Osborn Date: Thu, 9 Jun 2022 07:17:00 +0800 Subject: [PATCH 1/5] Add 'config' input, deprecate 'config_file' input --- .github/workflows/ci.yml | 6 +++--- README.md | 34 +++++++++++++++++++--------------- action.yml | 4 ++++ entrypoint.sh | 4 +++- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd3354f..02639d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: id: expect-failure uses: ./ with: - config_file: .markdownlintrc + config: .markdownlintrc files: . rules: examples/rules/custom.js continue-on-error: true @@ -42,14 +42,14 @@ jobs: - name: Test ignore_files uses: ./ with: - config_file: .markdownlintrc + config: .markdownlintrc files: . ignore_files: examples/ignore/* rules: examples/rules/custom.js - name: Test ignore_path uses: ./ with: - config_file: .markdownlintrc + config: .markdownlintrc files: . ignore_path: examples/.markdownlintignore rules: examples/rules/custom.js diff --git a/README.md b/README.md index 988808a..093dc56 100644 --- a/README.md +++ b/README.md @@ -10,25 +10,29 @@ A GitHub Action that performs style checking and linting for Markdown/CommonMark Basic usage with all options enabled: ```yaml - - - name: markdownlint-cli - uses: nosborn/github-action-markdown-cli@v3.0.1 - with: - files: . - config_file: .markdownlint.yaml - ignore_files: examples/ignore/* - ignore_path: examples/.markdownlintignore - rules: examples/rules/custom.js - +- name: markdownlint-cli + uses: nosborn/github-action-markdown-cli@v3.0.1 + with: + files: . + config: .markdownlint.yaml + ignore_files: examples/ignore/* + ignore_path: examples/.markdownlintignore + rules: examples/rules/custom.js ``` ## Inputs -* `files` - what to process (files, directories, globs) -* `config_file` (optional) - configuration file (JSON or YAML) -* `ignore_files` (optional) - files to ignore/exclude (file, directory, glob) -* `ignore_path` (optional) - path to file with ignore pattern(s) -* `rules` (optional) - custom rule files (file, directory, glob, package) +- `files` - what to process (files, directories, globs) +- `config` (optional) - configuration file (JSON or YAML) +- `ignore_files` (optional) - files to ignore/exclude (file, directory, glob) +- `ignore_path` (optional) - path to file with ignore pattern(s) +- `rules` (optional) - custom rule files (file, directory, glob, package) + +### Deprecated inputs + +These inputs are still available but will be removed in a future major version. + +- `config_file` (optional) - configuration file (JSON or YAML) - superseded by `config` ## License diff --git a/action.yml b/action.yml index 668b685..c538559 100644 --- a/action.yml +++ b/action.yml @@ -4,9 +4,13 @@ author: Nick Osborn description: Style checker and lint tool for Markdown/CommonMark files. inputs: + config: + description: configuration file (JSON or YAML) + required: false config_file: description: configuration file (JSON or YAML) required: false + deprecationMessage: Please use 'config' instead. files: description: files, directories, or globs required: true diff --git a/entrypoint.sh b/entrypoint.sh index 8df3306..4d3d0db 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,9 @@ #!/bin/sh +: "${INPUT_CONFIG:=${INPUT_CONFIG_FILE:-}}" + MARKDOWNLINT=markdownlint -MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG_FILE:+ -c ${INPUT_CONFIG_FILE}}" +MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG:+ -c ${INPUT_CONFIG}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_FILES:+ -i ${INPUT_IGNORE_FILES}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}" From e01e07387d36b2591c07112985f46ea9cbf174a9 Mon Sep 17 00:00:00 2001 From: Nick Osborn Date: Thu, 9 Jun 2022 07:31:41 +0800 Subject: [PATCH 2/5] Add 'ignore' input, deprecate 'ignore_files' input --- .github/workflows/ci.yml | 9 ++++++++- README.md | 5 +++-- action.yml | 4 ++++ entrypoint.sh | 3 ++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02639d9..23ad4d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,14 @@ jobs: - if: ${{ steps.expect-failure.outcome != 'failure' }} run: | exit 1 - - name: Test ignore_files + - name: Test ignore + uses: ./ + with: + config: .markdownlintrc + files: . + ignore: examples/ignore/* + rules: examples/rules/custom.js + - name: Test ignore_files deprecation uses: ./ with: config: .markdownlintrc diff --git a/README.md b/README.md index 093dc56..8e92773 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Basic usage with all options enabled: with: files: . config: .markdownlint.yaml - ignore_files: examples/ignore/* + ignore: examples/ignore/* ignore_path: examples/.markdownlintignore rules: examples/rules/custom.js ``` @@ -24,7 +24,7 @@ Basic usage with all options enabled: - `files` - what to process (files, directories, globs) - `config` (optional) - configuration file (JSON or YAML) -- `ignore_files` (optional) - files to ignore/exclude (file, directory, glob) +- `ignore` (optional) - files to ignore/exclude (file, directory, glob) - `ignore_path` (optional) - path to file with ignore pattern(s) - `rules` (optional) - custom rule files (file, directory, glob, package) @@ -33,6 +33,7 @@ Basic usage with all options enabled: These inputs are still available but will be removed in a future major version. - `config_file` (optional) - configuration file (JSON or YAML) - superseded by `config` +- `ignore_files` (optional) - files to ignore/exclude (file, directory, glob) - superseded by `ignore` ## License diff --git a/action.yml b/action.yml index c538559..e12ef25 100644 --- a/action.yml +++ b/action.yml @@ -14,9 +14,13 @@ inputs: files: description: files, directories, or globs required: true + ignore: + description: files to ignore/exclude + required: false ignore_files: description: files to ignore/exclude required: false + deprecationMessage: Please use 'ignore' instead. ignore_path: description: path to file with ignore pattern(s) required: false diff --git a/entrypoint.sh b/entrypoint.sh index 4d3d0db..57a4c5d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,11 @@ #!/bin/sh : "${INPUT_CONFIG:=${INPUT_CONFIG_FILE:-}}" +: "${INPUT_IGNORE:=${INPUT_IGNORE_FILES:-}}" MARKDOWNLINT=markdownlint MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG:+ -c ${INPUT_CONFIG}}" -MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_FILES:+ -i ${INPUT_IGNORE_FILES}}" +MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE:+ -i ${INPUT_IGNORE}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}" From 39b4586eef7032efccb40b19986163029d0e11e0 Mon Sep 17 00:00:00 2001 From: Nick Osborn Date: Thu, 9 Jun 2022 08:35:26 +0800 Subject: [PATCH 3/5] Make entrypoint.sh more robust --- entrypoint.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 57a4c5d..768c220 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,8 @@ #!/bin/sh +set -o errexit +set -o nounset + : "${INPUT_CONFIG:=${INPUT_CONFIG_FILE:-}}" : "${INPUT_IGNORE:=${INPUT_IGNORE_FILES:-}}" @@ -9,15 +12,15 @@ MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE:+ -i ${INPUT_IGNORE}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}" -PROBLEM_MATCHER="$(mktemp -p "${GITHUB_WORKSPACE}")" +PROBLEM_MATCHER="$(mktemp -p "${GITHUB_WORKSPACE:?}")" trap 'rm -f "${PROBLEM_MATCHER}"' EXIT -cp /markdownlint-problem-matcher.json "${PROBLEM_MATCHER:?}" || exit -echo "::add-matcher::${PROBLEM_MATCHER:?}" +cp /markdownlint-problem-matcher.json "${PROBLEM_MATCHER}" || exit +echo "::add-matcher::${PROBLEM_MATCHER}" # shellcheck disable=SC2086 -${MARKDOWNLINT} ${INPUT_FILES} -readonly RC=$? +${MARKDOWNLINT} ${INPUT_FILES:?} || readonly rc=$? echo '::remove-matcher owner=markdownlint::' -exit ${RC} +# shellcheck disable=SC2248 +exit ${rc:-} From 7877fa11d4cf6e0eabee5a3718c43f2c4983e17c Mon Sep 17 00:00:00 2001 From: Nick Osborn Date: Thu, 9 Jun 2022 08:40:21 +0800 Subject: [PATCH 4/5] Add 'dot' input --- README.md | 2 ++ action.yml | 5 +++++ entrypoint.sh | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 8e92773..4f6ba87 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Basic usage with all options enabled: with: files: . config: .markdownlint.yaml + dot: true ignore: examples/ignore/* ignore_path: examples/.markdownlintignore rules: examples/rules/custom.js @@ -24,6 +25,7 @@ Basic usage with all options enabled: - `files` - what to process (files, directories, globs) - `config` (optional) - configuration file (JSON or YAML) +- `dot` (optional) - if `true`, include files/folders with a dot (for example `.github`) - `ignore` (optional) - files to ignore/exclude (file, directory, glob) - `ignore_path` (optional) - path to file with ignore pattern(s) - `rules` (optional) - custom rule files (file, directory, glob, package) diff --git a/action.yml b/action.yml index e12ef25..d059bf3 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,11 @@ inputs: description: configuration file (JSON or YAML) required: false deprecationMessage: Please use 'config' instead. + dot: + description: > + if 'true', include files/folders with a dot (for example '.github') + required: false + default: false files: description: files, directories, or globs required: true diff --git a/entrypoint.sh b/entrypoint.sh index 768c220..a5feaab 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,6 +8,10 @@ set -o nounset MARKDOWNLINT=markdownlint MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG:+ -c ${INPUT_CONFIG}}" +# shellcheck disable=SC2312 +[ "$(echo "${INPUT_DOT:?}" | tr '[:upper:]' '[:lower:]')" = true ] && { + MARKDOWNLINT="${MARKDOWNLINT} --dot" +} MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE:+ -i ${INPUT_IGNORE}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}" From 9bf5acb566a12e40799659cda5f2d2e7ed2bbdd4 Mon Sep 17 00:00:00 2001 From: Nick Osborn Date: Thu, 9 Jun 2022 08:43:34 +0800 Subject: [PATCH 5/5] Add 'disable' and 'enable' inputs --- README.md | 4 ++++ action.yml | 6 ++++++ entrypoint.sh | 2 ++ 3 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 4f6ba87..5eb9b05 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,9 @@ Basic usage with all options enabled: with: files: . config: .markdownlint.yaml + disable: MD013 MD041 dot: true + enable: MD013 MD041 ignore: examples/ignore/* ignore_path: examples/.markdownlintignore rules: examples/rules/custom.js @@ -25,7 +27,9 @@ Basic usage with all options enabled: - `files` - what to process (files, directories, globs) - `config` (optional) - configuration file (JSON or YAML) +- `disable` (optional) - disable certain rules, for example `MD013 MD041` - `dot` (optional) - if `true`, include files/folders with a dot (for example `.github`) +- `enable` (optional) - enable certain rules, for example `MD013 MD041` - `ignore` (optional) - files to ignore/exclude (file, directory, glob) - `ignore_path` (optional) - path to file with ignore pattern(s) - `rules` (optional) - custom rule files (file, directory, glob, package) diff --git a/action.yml b/action.yml index d059bf3..02a6d40 100644 --- a/action.yml +++ b/action.yml @@ -11,11 +11,17 @@ inputs: description: configuration file (JSON or YAML) required: false deprecationMessage: Please use 'config' instead. + disable: + description: enable certain rules, for example 'MD013 MD041' + required: false dot: description: > if 'true', include files/folders with a dot (for example '.github') required: false default: false + enable: + description: enable certain rules, for example 'MD013 MD041' + required: false files: description: files, directories, or globs required: true diff --git a/entrypoint.sh b/entrypoint.sh index a5feaab..5311003 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,10 +8,12 @@ set -o nounset MARKDOWNLINT=markdownlint MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG:+ -c ${INPUT_CONFIG}}" +MARKDOWNLINT="${MARKDOWNLINT}${INPUT_DISABLE:+ --disable ${INPUT_DISABLE:?}}" # shellcheck disable=SC2312 [ "$(echo "${INPUT_DOT:?}" | tr '[:upper:]' '[:lower:]')" = true ] && { MARKDOWNLINT="${MARKDOWNLINT} --dot" } +MARKDOWNLINT="${MARKDOWNLINT}${INPUT_ENABLE:+ --enable ${INPUT_ENABLE:?}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE:+ -i ${INPUT_IGNORE}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}" MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}"