Skip to content

Commit 30b3148

Browse files
authored
Merge pull request #450 from PHPCSStandards/feature/ghactions-add-markdown-lint-qa-jobs
GH Actions: add markdown lint + QA jobs
2 parents 8f4eb98 + 349e72a commit 30b3148

File tree

6 files changed

+270
-12
lines changed

6 files changed

+270
-12
lines changed

.gitattributes

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production/
66
# https://blog.madewithlove.be/post/gitattributes/
77
#
8-
.github/ export-ignore
9-
scripts/ export-ignore
10-
.cspell.json export-ignore
11-
.gitattributes export-ignore
12-
.gitignore export-ignore
13-
.yamllint.yml export-ignore
14-
phpcs.xml.dist export-ignore
15-
phpstan.neon.dist export-ignore
16-
phpunit.xml.dist export-ignore
8+
.github/ export-ignore
9+
scripts/ export-ignore
10+
.cspell.json export-ignore
11+
.gitattributes export-ignore
12+
.gitignore export-ignore
13+
.markdownlint-cli2.yaml export-ignore
14+
.remarkignore export-ignore
15+
.remarkrc export-ignore
16+
.yamllint.yml export-ignore
17+
phpcs.xml.dist export-ignore
18+
phpstan.neon.dist export-ignore
19+
phpunit.xml.dist export-ignore
1720

1821
#
1922
# Declare files that should always have CRLF line endings on checkout.

.github/workflows/validate.yml

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: Validate
22

33
on:
44
# Run on all pushes and on all pull requests.
5-
# Prevent the build from running when there are only irrelevant changes.
65
push:
7-
paths-ignore:
8-
- '**.md'
96
pull_request:
7+
# Also run this workflow every Monday at 6:00 (to make sure the broken link check runs regularly).
8+
schedule:
9+
- cron: '0 6 * * 1'
1010
# Allow manually triggering the workflow.
1111
workflow_dispatch:
1212

@@ -78,3 +78,87 @@ jobs:
7878
- name: Pipe Yamllint results on to GH for inline display
7979
if: ${{ failure() }}
8080
run: yamllint . --format github --strict
81+
82+
markdownlint:
83+
name: 'Lint Markdown'
84+
runs-on: ubuntu-latest
85+
86+
# Don't run the cronjob in this workflow on forks.
87+
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'PHPCSStandards')
88+
89+
steps:
90+
- name: Checkout code
91+
uses: actions/checkout@v4
92+
93+
# @link https://github.com/marketplace/actions/problem-matcher-for-markdownlint-cli
94+
- name: Enable showing issue in PRs
95+
uses: xt0rted/markdownlint-problem-matcher@v3
96+
97+
# @link https://github.com/marketplace/actions/markdownlint-cli2-action
98+
- name: Check markdown with CLI2
99+
uses: DavidAnson/markdownlint-cli2-action@v16
100+
101+
remark:
102+
name: 'QA Markdown'
103+
runs-on: ubuntu-latest
104+
105+
# Don't run the cronjob in this workflow on forks.
106+
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'PHPCSStandards')
107+
108+
steps:
109+
- name: Checkout code
110+
uses: actions/checkout@v4
111+
112+
- name: Set up node and enable caching of dependencies
113+
uses: actions/setup-node@v4
114+
with:
115+
node-version: "20"
116+
117+
# To make the command available on CLI, it needs to be installed globally.
118+
- name: Install Remark CLI globally
119+
run: npm install --global remark-cli --foreground-scripts true --fund false
120+
121+
# To allow for creating a custom config which references rules which are included
122+
# in the presets, without having to install all rules individually, a local install
123+
# works best (and installing the presets in the first place, of course).
124+
#
125+
# Note: the first group of packages are all part of the mono "Remark lint" repo.
126+
# The second group of packages (heading-whitespace and down) are additional
127+
# "external" rules/plugins.
128+
- name: Install Remark rules locally
129+
run: >
130+
npm install --foreground-scripts true --fund false
131+
remark-lint
132+
remark-gfm
133+
remark-preset-lint-consistent
134+
remark-preset-lint-recommended
135+
remark-preset-lint-markdown-style-guide
136+
remark-lint-checkbox-content-indent
137+
remark-lint-linebreak-style
138+
remark-lint-no-dead-urls
139+
remark-lint-no-duplicate-defined-urls
140+
remark-lint-no-empty-url
141+
remark-lint-no-heading-like-paragraph
142+
remark-lint-no-reference-like-url
143+
remark-lint-no-unneeded-full-reference-image
144+
remark-lint-no-unneeded-full-reference-link
145+
remark-lint-strikethrough-marker
146+
remark-lint-heading-whitespace
147+
remark-lint-list-item-punctuation
148+
remark-lint-match-punctuation
149+
remark-lint-no-hr-after-heading
150+
remark-lint-are-links-valid-duplicate
151+
remark-validate-links
152+
153+
- name: Run Remark-lint
154+
run: remark . --frail
155+
156+
# @link https://github.com/reviewdog/action-remark-lint
157+
- name: Show Remark-lint annotations in PR
158+
if: ${{ failure() && github.event_name == 'pull_request' }}
159+
uses: reviewdog/action-remark-lint@v5
160+
with:
161+
fail_on_error: true
162+
install_deps: false
163+
level: info
164+
reporter: github-pr-check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/vendor/
88
composer.lock
99
phpstan.neon
10+
/node_modules/

.markdownlint-cli2.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#
2+
# Configuration file for MarkdownLint-CLI2.
3+
#
4+
# Example file with all options:
5+
# https://github.com/DavidAnson/markdownlint-cli2/blob/main/test/markdownlint-cli2-yaml-example/.markdownlint-cli2.yaml
6+
# Example file with all rules:
7+
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
8+
#
9+
10+
# Define glob expressions to use (only valid at root).
11+
globs:
12+
- "**/*.md"
13+
- ".github/**/*.md"
14+
15+
# Show found files on stdout (only valid at root)
16+
showFound: true
17+
18+
# Define glob expressions to ignore.
19+
ignores:
20+
- "node_modules/"
21+
- "vendor/"
22+
23+
# Disable inline config comments.
24+
noInlineConfig: true
25+
26+
# Disable progress on stdout (only valid at root).
27+
noProgress: false
28+
29+
# Adjust the configuration for some built-in rules.
30+
# For full information on the options and defaults, see:
31+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
32+
config:
33+
######################
34+
# Disable a few rules.
35+
######################
36+
# MD031/blanks-around-fences - Fenced code blocks should be surrounded by blank lines.
37+
MD031: false
38+
# MD032/blanks-around-lists - Lists should be surrounded by blank lines.
39+
MD032: false
40+
41+
##############################
42+
# Customize a few other rules.
43+
##############################
44+
# MD003/heading-style/header-style - Heading style.
45+
MD003:
46+
# Heading style - Always use hashes.
47+
style: "atx"
48+
49+
# MD007/ul-indent - Unordered list indentation.
50+
MD007:
51+
indent: 4
52+
# Whether to indent the first level of the list.
53+
start_indented: false
54+
55+
# MD012/no-multiple-blanks - Multiple consecutive blank lines.
56+
MD012:
57+
maximum: 2
58+
59+
# MD013/line-length - Line length.
60+
MD013:
61+
# Number of characters. No need for being too fussy.
62+
line_length: 1000
63+
# Number of characters for headings.
64+
heading_line_length: 100
65+
# Number of characters for code blocks.
66+
code_block_line_length: 100
67+
# Stern length checking (applies to tables, code blocks etc which have their own max line length).
68+
stern: true
69+
70+
# MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md
71+
MD022:
72+
# Blank lines above heading
73+
lines_above: [2, 1, 1, 1, 1]
74+
# Blank lines below heading
75+
lines_below: [1, 1, -1, -1, -1]
76+
77+
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content.
78+
MD024:
79+
# Only check sibling headings.
80+
siblings_only: true
81+
82+
# MD033/no-inline-html - Inline HTML.
83+
MD033:
84+
# Allowed elements.
85+
allowed_elements:
86+
- div
87+
88+
# MD044/proper-names - Proper names should have the correct capitalization.
89+
MD044:
90+
# List of proper names.
91+
names: ["PHP", "PHP_CodeSniffer", "CodeSniffer", "PHPUnit", "Xdebug"]
92+
# Include code blocks.
93+
code_blocks: false
94+
95+
# MD046/code-block-style - Code block style
96+
MD046:
97+
style: "fenced"
98+
99+
# MD048/code-fence-style - Code fence style
100+
MD048:
101+
style: "backtick"
102+
103+
# MD049/emphasis-style - Emphasis style should be consistent
104+
MD049:
105+
style: "underscore"
106+
107+
# MD050/strong-style - Strong style should be consistent
108+
MD050:
109+
style: "asterisk"

.remarkignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore rules for Remark.
2+
# Docs: https://github.com/unifiedjs/unified-engine/blob/HEAD/doc/ignore.md
3+
4+
/node_modules/
5+
/vendor/

.remarkrc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"plugins": [
3+
"remark-gfm",
4+
["remark-lint-checkbox-character-style", "consistent"],
5+
["remark-lint-checkbox-content-indent", "consistent"],
6+
"remark-lint-definition-spacing",
7+
"remark-lint-file-extension",
8+
["remark-lint-linebreak-style", "unix"],
9+
["remark-lint-link-title-style", "\""],
10+
["remark-lint-ordered-list-marker-style", "."],
11+
[
12+
"remark-lint-no-dead-urls",
13+
{
14+
"skipUrlPatterns": [
15+
"^https?://github\\.com/PHPCSStandards/PHP_CodeSniffer/compare/[0-9\\.]+?\\.{3}[0-9\\.]+",
16+
"^https?://github\\.com/[A-Za-z0-9-]+"
17+
]
18+
}
19+
],
20+
"remark-lint-no-duplicate-defined-urls",
21+
"remark-lint-no-duplicate-definitions",
22+
"remark-lint-no-empty-url",
23+
"remark-lint-no-file-name-consecutive-dashes",
24+
["remark-lint-no-file-name-irregular-characters", "\\.a-zA-Z0-9-_"],
25+
"remark-lint-no-file-name-outer-dashes",
26+
"remark-lint-no-heading-like-paragraph",
27+
"remark-lint-no-literal-urls",
28+
"remark-lint-no-reference-like-url",
29+
"remark-lint-no-shortcut-reference-image",
30+
"remark-lint-no-table-indentation",
31+
[
32+
"remark-lint-no-undefined-references",
33+
{
34+
"allow": [
35+
"!NOTE",
36+
"!TIP",
37+
"!IMPORTANT",
38+
"!WARNING",
39+
"!CAUTION",
40+
"'Status: triage', 'Type: bug'",
41+
"'Status: triage', 'Type: enhancement'"
42+
]
43+
}
44+
],
45+
"remark-lint-no-unneeded-full-reference-image",
46+
"remark-lint-no-unneeded-full-reference-link",
47+
"remark-lint-no-unused-definitions",
48+
["remark-lint-strikethrough-marker", "~~"],
49+
"remark-lint-heading-whitespace",
50+
"remark-lint-list-item-punctuation",
51+
"remark-lint-match-punctuation",
52+
"remark-lint-no-hr-after-heading",
53+
"remark-lint-are-links-valid-duplicate",
54+
"remark-validate-links"
55+
]
56+
}

0 commit comments

Comments
 (0)