Skip to content

Commit 429e4c3

Browse files
committed
GH Actions: add basic QA workflow
* Lint Yaml files, including linting GH action workflows for common issues. * Lint markdown for consistent code style. * Check markdown files against broken links. * Check spelling in the files. Includes documenting what is being checked for via configuration files. This also ensures that most checks can be run locally by contributors. Refs: * https://github.com/DavidAnson/markdownlint-cli2/ * https://github.com/DavidAnson/markdownlint/ * https://yamllint.readthedocs.io/ * https://github.com/rhysd/actionlint * https://github.com/lycheeverse/lychee-action * https://github.com/streetsidesoftware/cspell-action
1 parent 8f2e1b2 commit 429e4c3

File tree

5 files changed

+282
-0
lines changed

5 files changed

+282
-0
lines changed

.cspell.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json
2+
version: '0.2'
3+
language: en-GB
4+
readonly: true
5+
6+
useGitignore: true
7+
8+
dictionaries:
9+
- php
10+
11+
patterns:
12+
- name: markdown_code_block
13+
pattern: |
14+
/
15+
^(\s*`{3,})[a-z]+ # match the ``` with a language modifier
16+
[\s\S]*? # the block of code
17+
^\1 # end of the block
18+
/gmx
19+
- name: markdown_inline_code
20+
pattern: /(\s*`)[^`\n]{3,}`/gmx
21+
22+
languageSettings:
23+
- languageId: markdown
24+
ignoreRegExpList:
25+
- markdown_code_block
26+
- markdown_inline_code
27+
28+
words:
29+
# Generic "good" words.
30+
- PHP_CodeSniffer
31+
- phpcs
32+
- phpcbf
33+
- Allman
34+
- Analyzer
35+
- anymore
36+
- csslint
37+
- docblocks
38+
- gitblame
39+
- Joomla
40+
- nowdocs
41+
- Squiz
42+
- SquizLabs
43+
44+
# Used in "gitblame" report.
45+
- jsmith
46+
- jblogs
47+
- pdeveloper
48+
- jscript
49+
- toogood

.github/workflows/basic-qa.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CS
2+
3+
on:
4+
# Run on all pushes and on all pull requests.
5+
push:
6+
pull_request:
7+
# Allow manually triggering the workflow.
8+
workflow_dispatch:
9+
10+
# Do NOT cancels all previous workflow runs for the same branch that have not yet completed.
11+
concurrency:
12+
# The concurrency group contains the workflow name and the branch name.
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
yamllint:
18+
name: 'Lint Yaml'
19+
uses: PHPCSStandards/.github/.github/workflows/reusable-yamllint.yml@main
20+
with:
21+
strict: true
22+
23+
markdownlint:
24+
name: 'Lint Markdown'
25+
uses: PHPCSStandards/.github/.github/workflows/reusable-markdownlint.yml@main
26+
27+
linkcheck:
28+
name: "Check links"
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
- name: Restore lychee cache
36+
uses: actions/cache@v4
37+
with:
38+
path: .lycheecache
39+
key: cache-lychee-${{ github.sha }}
40+
restore-keys: cache-lychee-
41+
42+
- name: Link Checker
43+
uses: lycheeverse/lychee-action@v2
44+
with:
45+
args: --cache --max-cache-age 1w --verbose "./**/*.md"
46+
format: markdown
47+
token: ${{ secrets.GITHUB_TOKEN }}
48+
fail: true
49+
50+
spellcheck:
51+
name: Spellcheck
52+
# Config file: .cspell.yml
53+
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
60+
- name: Spellcheck
61+
id: spellcheck
62+
continue-on-error: true
63+
uses: streetsidesoftware/cspell-action@v7
64+
with:
65+
# Define glob patterns to filter the files to be checked. Use a new line between patterns to define multiple patterns.
66+
files: '**/*.md'
67+
root: '.'
68+
suggestions: true
69+
# Notification level for annotations. Allowed values are: warning, error, none
70+
inline: warning
71+
treat_flagged_words_as_errors: true
72+
# Determines if the action should be failed if any spelling issues are found.
73+
strict: true
74+
# Limit the files checked to the ones in the pull request or push.
75+
incremental_files_only: false
76+
77+
# Note: if less issues than expected were found, these numbers should be updated in the PR which fixes the issues!
78+
- name: Fail the build when more spelling issues were found than expected
79+
if: ${{ always() && ( steps.spellcheck.outputs.number_of_issues != 5 || steps.spellcheck.outputs.number_of_files_with_issues != 3 ) }}
80+
run: exit 1

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
.lycheecache
12
_wiki/
3+
node_modules/

.markdownlint-cli2.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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+
14+
# Show found files on stdout (only valid at root).
15+
showFound: true
16+
17+
# Define glob expressions to ignore.
18+
ignores:
19+
20+
# Disable inline config comments.
21+
noInlineConfig: true
22+
23+
# Disable progress on stdout (only valid at root).
24+
noProgress: false
25+
26+
# Adjust the configuration for some built-in rules.
27+
# For full information on the options and defaults, see:
28+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
29+
config:
30+
######################
31+
# Disable a few rules.
32+
######################
33+
# MD014/commands-show-output : Dollar signs used before commands without showing output.
34+
MD014: false
35+
# MD028/no-blanks-blockquote : Blank line inside blockquote.
36+
MD028: false
37+
# MD031/blanks-around-fences - Fenced code blocks should be surrounded by blank lines.
38+
MD031: false
39+
# MD032/blanks-around-lists - Lists should be surrounded by blank lines.
40+
MD032: false
41+
# MD036/no-emphasis-as-heading : Emphasis used instead of a heading.
42+
# Disabled as this is used as a "hack" to exclude select headers from the automatic Table of Contents creation.
43+
MD036: false
44+
# MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading.
45+
MD041: false
46+
47+
##############################
48+
# Customize a few other rules.
49+
##############################
50+
# MD003/heading-style/header-style - Heading style.
51+
MD003:
52+
# Heading style - Always use hashes.
53+
style: "atx"
54+
55+
# MD007/ul-indent - Unordered list indentation.
56+
MD007:
57+
indent: 4
58+
# Whether to indent the first level of the list.
59+
start_indented: false
60+
61+
# MD012/no-multiple-blanks - Multiple consecutive blank lines.
62+
MD012:
63+
maximum: 2
64+
65+
# MD013/line-length - Line length.
66+
MD013:
67+
# Number of characters. No need for being too fussy.
68+
line_length: 1000
69+
# Number of characters for headings.
70+
heading_line_length: 100
71+
# Number of characters for code blocks.
72+
code_block_line_length: 120
73+
# Include code blocks.
74+
code_blocks: false
75+
# Stern length checking (applies to tables, code blocks etc which have their own max line length).
76+
stern: true
77+
78+
# MD022/blanks-around-headings : Headings should be surrounded by blank lines.
79+
MD022:
80+
# Blank lines above heading.
81+
lines_above: [2, 1, 1, 1, 1]
82+
# Blank lines below heading.
83+
lines_below: [1, 1, 1, -1, -1]
84+
85+
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content.
86+
MD024:
87+
# Only check sibling headings.
88+
siblings_only: true
89+
90+
# MD026/no-trailing-punctuation : Trailing punctuation in heading.
91+
MD026:
92+
# Punctuation characters
93+
punctuation: ".,;。,;:!"
94+
95+
# MD033/no-inline-html - Inline HTML.
96+
MD033:
97+
# Allowed elements.
98+
allowed_elements:
99+
- div
100+
- p
101+
- a
102+
103+
# MD044/proper-names - Proper names should have the correct capitalization.
104+
MD044:
105+
# List of proper names.
106+
names: ["PHP_CodeSniffer", "CodeSniffer", "PHPCSUtils", "PHPCSExtra", "PHPUnit", "Xdebug"]
107+
# Include code blocks.
108+
code_blocks: false
109+
110+
# MD046/code-block-style - Code block style.
111+
MD046:
112+
style: "fenced"
113+
114+
# MD048/code-fence-style - Code fence style.
115+
MD048:
116+
style: "backtick"
117+
118+
# MD049/emphasis-style - Emphasis style should be consistent.
119+
MD049:
120+
style: "underscore"
121+
122+
# MD050/strong-style - Strong style should be consistent.
123+
MD050:
124+
style: "asterisk"
125+
126+
# MD055/table-pipe-style : Table pipe style.
127+
MD055:
128+
# Table pipe style.
129+
style: "leading_and_trailing"

.yamllint.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Details on the default config:
2+
# https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration
3+
extends: default
4+
5+
yaml-files:
6+
- '*.yaml'
7+
- '*.yml'
8+
- '.yamllint'
9+
10+
# Rule documentation: https://yamllint.readthedocs.io/en/stable/rules.html
11+
rules:
12+
colons:
13+
max-spaces-after: -1 # Disabled to allow aligning of values.
14+
comments:
15+
min-spaces-from-content: 1
16+
comments-indentation: {}
17+
document-start:
18+
present: false
19+
line-length:
20+
max: 145
21+
truthy:
22+
allowed-values: ["true", "false", "on", "off"]

0 commit comments

Comments
 (0)