feat(markdown_lint): enable specifying the lint config path

!25
This commit is contained in:
2023-05-22 12:00:25 +09:30
parent bce7396d8b
commit 38d469007a
2 changed files with 6 additions and 2 deletions

View File

@ -4,10 +4,12 @@
variables:
MDLINT_PATHS: "**/*.md **/**/*.md **/**/**/*.md **/**/**/**/*.md **/**/**/**/**/**/*.md #CHANGELOG.md !gitlab-ci"
DEFAULT_ROOT_DIR: "./gitlab-ci"
MD_LINT_CONFIG-PATH: ""
before_script:
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/lint_markdown"
- if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=$DEFAULT_ROOT_DIR; else ROOT_DIR=$JOB_ROOT_DIR ; fi
- if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=$DEFAULT_ROOT_DIR; else ROOT_DIR=$JOB_ROOT_DIR; fi
- echo "[DEBUG] ROOT_DIR[$ROOT_DIR]"
- if [ "0$MD_LINT_CONFIG-PATH" != "0" ]; then cp "$MD_LINT_CONFIG-PATH/.markdownlint.json" $CI_PROJECT_DIR/.markdownlint.json; fi
- cp -f "$ROOT_DIR/validation/.markdownlint-cli2.jsonc" "$CI_PROJECT_DIR/.markdownlint-cli2.jsonc"
- npm install markdownlint-cli2 --global
- npm install markdownlint-cli2-formatter-junit --global
@ -15,7 +17,8 @@
- echo "[DEBUG] MDLINT_PATHS=$MDLINT_PATHS"
- markdownlint-cli2 $MDLINT_PATHS 1>&1 || EXITCODE=$?
- echo DEBUG EXITCODE[$EXITCODE]
- rm "$CI_PROJECT_DIR/.markdownlint-cli2.jsonc"
- rm -f "$CI_PROJECT_DIR/.markdownlint-cli2.jsonc"
- if [ "0$MD_LINT_CONFIG-PATH" != "0" ]; then rm -f "$CI_PROJECT_DIR/.markdownlint.json"; fi
- mv *.junit.xml "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/lint_markdown/markdown_lint.junit.xml"
artifacts:
expire_in: 24 hrs

View File

@ -41,6 +41,7 @@ Markdown Linting:
|:----:|:----|
| MDLINT_PATH | **Optional** specifies the path to lint. defaults to `"**/*.md"` |
| MDLINT_EXCLUDE_PATHS | **optional** Specifies the paths to exclude from linting. Defaults to `"!gitlab-ci"` |
| MD_LINT_CONFIG-PATH | **Optional** Specifies a path whenre the lint config file is. defaults to none. this variable enables you to specify a config that will be copied to the project root folder. ***Note:** if specified, the file will be deleted at the end of the linting job.*
## Job Workflow