-
-
Notifications
You must be signed in to change notification settings - Fork 7
215 lines (178 loc) · 7.31 KB
/
basics.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: CS
on:
# Run on all pushes and on all pull requests.
# Prevent the build from running when there are only irrelevant changes.
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
checkcs:
name: 'Basic CS and QA checks'
runs-on: ubuntu-latest
env:
XMLLINT_INDENT: ' '
# - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI.
COMPOSER_ROOT_VERSION: '1.99.99'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 'latest'
coverage: none
tools: cs2pr
# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- name: Validate Composer installation
run: composer validate --no-check-all --strict
- name: 'Composer: adjust dependencies'
run: |
# The sniff stage doesn't run the unit tests, so no need for PHPUnit.
composer remove --no-update --dev phpunit/phpunit --no-scripts
# Using PHPCS `master` as an early detection system for bugs upstream.
composer require --no-update squizlabs/php_codesniffer:"dev-master"
# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Install xmllint
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libxml2-utils
# Show XML violations inline in the file diff.
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
- name: Enable showing XML issues inline
uses: korelstar/xmllint-problem-matcher@v1
# Validate the XML file.
# @link http://xmlsoft.org/xmllint.html
- name: Validate rulesets against schema
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
# Check the code-style consistency of the XML file.
- name: Check XML code style
run: diff -B ./PHPCSUtils/ruleset.xml <(xmllint --format "./PHPCSUtils/ruleset.xml")
# Check the code-style consistency of the PHP files.
- name: Check PHP code style
id: phpcs
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml
phpstan:
name: "PHPStan"
runs-on: "ubuntu-latest"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 'latest'
coverage: none
tools: phpstan
# Install dependencies and handle caching in one go.
# Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Run PHPStan
run: phpstan analyse
markdownlint:
name: 'Lint Markdown'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# This action also handles the caching of the dependencies.
# https://github.com/actions/setup-node
- name: Set up node and enable caching of dependencies
uses: actions/setup-node@v4
with:
node-version: '16'
# @link https://github.com/DavidAnson/markdownlint-cli2
# @link https://github.com/DavidAnson/markdownlint
- name: Install Markdownlint CLI2
run: npm install -g markdownlint-cli2
# @link https://github.com/marketplace/actions/problem-matcher-for-markdownlint-cli
- name: Enable showing issue in PRs
uses: xt0rted/markdownlint-problem-matcher@v3
- name: Check markdown with CLI2
run: markdownlint-cli2
remark:
name: 'QA Markdown'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up node and enable caching of dependencies
uses: actions/setup-node@v4
with:
node-version: '16'
# To make the command available on CLI, it needs to be installed globally.
- name: Install Remark CLI globally
run: npm install --global remark-cli --foreground-scripts true --fund false
# To allow for creating a custom config which references rules which are included
# in the presets, without having to install all rules individually, a local install
# works best (and installing the presets in the first place, of course).
#
# Note: the first group of packages are all part of the mono "Remark lint" repo.
# The second group of packages (heading-whitespace and down) are additional
# "external" rules/plugins.
- name: Install Remark rules locally
run: >
npm install --foreground-scripts true --fund false
remark-lint
remark-gfm
remark-preset-lint-consistent
remark-preset-lint-recommended
remark-preset-lint-markdown-style-guide
remark-lint-checkbox-content-indent
remark-lint-linebreak-style
remark-lint-no-dead-urls
remark-lint-no-duplicate-defined-urls
remark-lint-no-empty-url
remark-lint-no-heading-like-paragraph
remark-lint-no-reference-like-url
remark-lint-no-unneeded-full-reference-image
remark-lint-no-unneeded-full-reference-link
remark-lint-strikethrough-marker
remark-lint-heading-whitespace
remark-lint-list-item-punctuation
remark-lint-match-punctuation
remark-lint-no-hr-after-heading
remark-lint-are-links-valid-duplicate
remark-validate-links
- name: Run Remark-lint
run: remark . --frail
# @link https://github.com/reviewdog/action-remark-lint
- name: Show Remark-lint annotations in PR
if: ${{ failure() && github.event_name == 'pull_request' }}
uses: reviewdog/action-remark-lint@v5
with:
fail_on_error: true
install_deps: false
level: info
reporter: github-pr-check
yamllint:
name: 'Lint Yaml'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Yamllint on all yaml files in repo
run: yamllint . --format colored --strict
- name: Pipe Yamllint results on to GH for inline display
if: ${{ failure() }}
run: yamllint . --format github --strict