This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
155 lines (132 loc) · 4.87 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
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
name: Coding Standards
on:
push:
branches:
- develop
pull_request:
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 with warnings suppressed.
# - Runs PHPCS on the `tests` directory without warnings suppressed.
phpcs:
name: PHP coding standards
runs-on: ubuntu-latest
if: ${{ github.repository == 'ClassicPress/ClassicPress-v2' || github.event_name == 'pull_request' }}
steps:
- name: Checkout repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: composer, cs2pr
- name: Log debug information
run: |
php --version
composer --version
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--no-progress --no-ansi --no-interaction"
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Log PHPCS debug information
run: phpcs -i
- name: Run PHPCS on all Core files
run: phpcs -q -n --report=checkstyle | cs2pr
- name: Check test suite files for warnings
run: phpcs tests -q -n --report=checkstyle | cs2pr
# Runs the pre-commit checks.
#
# Performs the following steps:
# - Checks out the repository.
# - Installs NodeJS.
# - Sets up caching for NPM.
# - Logs debug information.
# - Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Run the ClassicPress pre-commit checks (JSHint, no uncommitted
# modifications to generated files).
precommit:
name: Pre-commit checks
runs-on: ubuntu-latest
if: ${{ github.repository == 'ClassicPress/ClassicPress-v2' || github.event_name == 'pull_request' }}
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
steps:
- name: Checkout repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: Read .nvmrc
run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
id: nvmrc
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: '${{ steps.nvmrc.outputs.NVMRC }}'
- name: Cache NodeJS modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Set up PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: 7.4
ini-values: mysql.default_host=127.0.0.1,mysql.default_port=3306,mysql.default_socket=/var/run/mysqld/mysqld.sock
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--no-progress --no-ansi --no-interaction"
- name: Install PHPUnit
run: |
wget -O phpunit https://phar.phpunit.de/phpunit-8.phar
chmod +x phpunit
sudo mv phpunit /usr/bin/
- name: Enable, start and initialise MySQL
run: |
sudo systemctl enable mysql.service
sudo systemctl start mysql.service
mysql -u root -proot < tools/local-env/mysql-init.sql
mysql -u root -proot -e "SHOW DATABASES"
- name: Show debug information
run: |
set +e
set -x
npm --version
node --version
curl --version
git --version
svn --version
php --version
phpunit --version
composer --version
grunt --version
mysql --version
- name: Install dependencies
run: npx install-changed --install-command="npm ci"
- name: Create ClassicPress config file for tests
run: |
cp wp-tests-config-sample.php wp-tests-config.php
sed -i 's/youremptytestdbnamehere/classicpress_develop_tests/g' wp-tests-config.php
sed -i 's/yourusernamehere/root/g' wp-tests-config.php
sed -i 's/yourpasswordhere/root/g' wp-tests-config.php
- name: Run pre-commit checks
run: grunt precommit:verify