-
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (94 loc) · 3.2 KB
/
coding-standards.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
name: Coding Standards
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
paths:
# Any change to a PHP or Markdown file should run checks.
- '**.php'
- '**.md'
# These files configure NPM. Changes could affect the outcome.
- 'package*.json'
# These files configure Composer. Changes could affect the outcome.
- 'composer.*'
# This file configures Markdownlint. Changes could affect the outcome.
- '.markdownlint.json'
# This file configures PHPCS. Changes could affect the outcome.
- 'phpcs.xml'
# Changes to workflow files should always verify all workflows are successful.
- '.github/workflows/*.yml'
# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:
jobs:
# Runs PHP coding standards checks.
#
# Violations are reported inline with annotations.
#
# Performs the following steps:
# - Checks out the repository.
# - Sets up PHP.
# - Logs debug information.
# - Installs Composer dependencies (use cache if possible).
# - Make Composer packages available globally.
# - Logs PHP_CodeSniffer debug information.
# - Runs PHPCS on the full codebase.
phpcs:
name: PHP coding standards
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@2.30.4
with:
php-version: '7.4' # Results are the same across all versions, check only in the last stable version.
coverage: none
tools: cs2pr
env:
fail-fast: false
- name: Log debug information
run: |
php --version
composer --version
- name: Check syntax error in sources
run: find -L . -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Log PHPCS debug information
run: composer phpcs-i
- name: Run the PHP code sniffer
continue-on-error: true
run: phpcs --report-full --report-checkstyle=./phpcs-report.xml
- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml
# Runs the Markdown coding standards checks.
#
# Performs the following steps:
# - Checks out the repository.
# - Installs NodeJS 16 with caching for NPM.
# - Logs updated debug information.
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
md-cs:
name: MD coding standards
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 16
cache: npm
- name: Log debug information
run: |
npm --version
node --version
- name: Install Dependencies
run: npm ci
- name: Run Markdown Lint
run: npm run lint:md:docs