11name : Cyr2Lat CI
2- on : [ push, pull_request ]
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ paths :
7+ - ' **/*.php'
8+ - ' composer.*'
9+ - ' package.json'
10+ - ' yarn.lock'
11+ - ' .yarnrc.yml'
12+ - ' babel.config.json'
13+ - ' eslint.config.cjs'
14+ - ' postcss.config.js'
15+ - ' webpack.config.js'
16+ - ' assets/**'
17+ - ' src/**'
18+ - ' tests/**'
19+ - ' readme.txt'
20+ - ' .github/scripts/**'
21+ - ' .github/workflows/**'
22+ pull_request :
23+ paths :
24+ - ' **/*.php'
25+ - ' composer.*'
26+ - ' package.json'
27+ - ' yarn.lock'
28+ - ' .yarnrc.yml'
29+ - ' babel.config.json'
30+ - ' eslint.config.cjs'
31+ - ' postcss.config.js'
32+ - ' webpack.config.js'
33+ - ' assets/**'
34+ - ' src/**'
35+ - ' tests/**'
36+ - ' readme.txt'
37+ - ' .github/scripts/**'
38+ - ' .github/workflows/**'
39+
40+ permissions :
41+ actions : read
42+ contents : read
43+
344concurrency :
4- group : ${{ github.ref }}
45+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github. ref }}
546 cancel-in-progress : true
647
748jobs :
8- cs_and_tests :
9- strategy :
10- matrix :
11- os : [ ubuntu-latest ]
12- php-version : [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
49+ phpcs :
50+ name : PHPCS
51+ runs-on : ubuntu-latest
52+
53+ if : >-
54+ github.event_name != 'push' ||
55+ !contains(github.event.head_commit.message || '', '[skip ci]')
1356
1457 env :
15- wp-directory : wordpress
1658 wp-plugin-directory : wordpress/wp-content/plugins/cyr2lat
17- DB_HOST : localhost
18- DB_NAME : cyr2lat-7-tests
19- DB_USER : root
20- DB_PASSWORD : root
21- DB_TABLE_PREFIX : wptests_
22- WP_URL : https://test.test
23- WP_DOMAIN : test.test
24- WP_ADMIN_USERNAME : admin
25- WP_ADMIN_PASSWORD : admin
26- WP_ADMIN_EMAIL : admin@test.test
27-
28- runs-on : ${{ matrix.os }}
29-
30- name : PHP ${{ matrix.php-version }} on ${{ matrix.os }}
3159
3260 steps :
3361 - name : Checkout code
34- uses : actions/checkout@v6
62+ uses : actions/checkout@v7
3563 with :
3664 path : ${{ env.wp-plugin-directory }}
65+ persist-credentials : false
3766
38- - name : Update changelog
39- if : ${{ matrix.php-version == '8.5' }}
40- working-directory : ${{ env.wp-plugin-directory }}
41- run : .github/scripts/update-changelog.sh
42-
43- - name : Setup PHP
67+ - name : Setup PHP 8.5
4468 uses : shivammathur/setup-php@v2
4569 with :
46- php-version : ${{ matrix.php-version }}
70+ php-version : ' 8.5 '
4771 extensions : json, mysqli, mbstring, zip
72+ ini-values : register_argc_argv=On
4873
4974 - name : Install dependencies with caching
5075 uses : ramsey/composer-install@v4
5176 with :
5277 working-directory : ${{ env.wp-plugin-directory }}
5378
5479 - name : Run code sniffer
55- if : ${{ matrix.php-version == '8.5' }}
5680 working-directory : ${{ env.wp-plugin-directory }}
5781 run : composer phpcs
5882
59- - name : Run ESLint and JEST
60- if : ${{ matrix.php-version == '8.4' }}
83+ js :
84+ name : JS lint and tests
85+ runs-on : ubuntu-latest
86+ needs : phpcs
87+
88+ env :
89+ wp-plugin-directory : wordpress/wp-content/plugins/cyr2lat
90+ YARN_ENABLE_IMMUTABLE_INSTALLS : false
91+
92+ steps :
93+ - name : Checkout code
94+ uses : actions/checkout@v7
95+ with :
96+ path : ${{ env.wp-plugin-directory }}
97+ persist-credentials : false
98+
99+ - name : Install JS dependencies
61100 working-directory : ${{ env.wp-plugin-directory }}
62101 run : |
63102 corepack enable
64- yarn set version stable
65- yarn
103+ yarn install --no-immutable
104+
105+ - name : Run ESLint
106+ working-directory : ${{ env.wp-plugin-directory }}
107+ run : |
66108 yarn dev
67109 yarn lint
68- yarn jest
110+
111+ - name : Run Jest
112+ working-directory : ${{ env.wp-plugin-directory }}
113+ run : yarn test
114+
115+ php_versions :
116+ name : Resolve PHP versions
117+ runs-on : ubuntu-latest
118+ needs : js
119+
120+ outputs :
121+ matrix : ${{ steps.resolve.outputs.matrix }}
122+
123+ env :
124+ FULL_PHP_MATRIX : >-
125+ ${{
126+ github.event_name == 'push' &&
127+ (
128+ github.ref_name == github.event.repository.default_branch ||
129+ contains(github.event.head_commit.message || '', '[all]')
130+ )
131+ }}
132+
133+ steps :
134+ - name : Resolve PHP versions
135+ id : resolve
136+ run : |
137+ if [ "$FULL_PHP_MATRIX" = "true" ]; then
138+ echo 'matrix=["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]' >> "$GITHUB_OUTPUT"
139+ else
140+ echo 'matrix=["7.4","8.5"]' >> "$GITHUB_OUTPUT"
141+ fi
142+
143+ unit :
144+ name : Unit tests on PHP ${{ matrix.php-version }}
145+ runs-on : ubuntu-latest
146+ needs : php_versions
147+
148+ strategy :
149+ matrix :
150+ php-version : ${{ fromJSON(needs.php_versions.outputs.matrix) }}
151+
152+ env :
153+ wp-plugin-directory : wordpress/wp-content/plugins/cyr2lat
154+
155+ steps :
156+ - name : Checkout code
157+ uses : actions/checkout@v7
158+ with :
159+ path : ${{ env.wp-plugin-directory }}
160+ persist-credentials : false
161+
162+ - name : Setup PHP
163+ uses : shivammathur/setup-php@v2
164+ with :
165+ php-version : ${{ matrix.php-version }}
166+ extensions : json, mysqli, mbstring, zip
167+ ini-values : register_argc_argv=On
168+
169+ - name : Install dependencies with caching
170+ uses : ramsey/composer-install@v4
171+ with :
172+ working-directory : ${{ env.wp-plugin-directory }}
69173
70174 - name : Run unit tests
71175 working-directory : ${{ env.wp-plugin-directory }}
72- run : vendor/bin/phpunit
176+ run : composer unit
177+
178+ integration :
179+ name : WP integration tests on PHP ${{ matrix.php-version }}
180+ runs-on : ubuntu-latest
181+ needs : [ unit, php_versions ]
182+
183+ strategy :
184+ matrix :
185+ php-version : ${{ fromJSON(needs.php_versions.outputs.matrix) }}
186+
187+ env :
188+ wp-directory : wordpress
189+ wp-plugin-directory : wordpress/wp-content/plugins/cyr2lat
190+ DB_HOST : localhost
191+ DB_NAME : cyr2lat-tests
192+ DB_USER : test
193+ DB_PASSWORD : test
194+ DB_TABLE_PREFIX : wptests_
195+ WP_URL : https://test.test
196+ WP_DOMAIN : test.test
197+ WP_ADMIN_USERNAME : admin
198+ WP_ADMIN_PASSWORD : admin
199+ WP_ADMIN_EMAIL : admin@test.test
200+
201+ steps :
202+ - name : Checkout code
203+ uses : actions/checkout@v7
204+ with :
205+ path : ${{ env.wp-plugin-directory }}
206+ persist-credentials : false
207+
208+ - name : Setup PHP
209+ uses : shivammathur/setup-php@v2
210+ with :
211+ php-version : ${{ matrix.php-version }}
212+ extensions : json, mysqli, mbstring, zip
213+ ini-values : register_argc_argv=On
214+
215+ - name : Install dependencies with caching
216+ uses : ramsey/composer-install@v4
217+ with :
218+ working-directory : ${{ env.wp-plugin-directory }}
73219
74220 - name : Install WP CLI
75221 run : |
@@ -82,12 +228,14 @@ jobs:
82228 sudo mv wp-cli.phar wp-cli/wp
83229 echo "$GITHUB_WORKSPACE/wp-cli" >> "$GITHUB_PATH"
84230
85- - name : Start mysql
231+ - name : Start MySQL
86232 run : |
87233 echo '[mysqld]' | sudo tee -a /etc/mysql/my.cnf
88234 echo 'default_authentication_plugin=mysql_native_password' | sudo tee -a /etc/mysql/my.cnf
89235 sudo systemctl start mysql
236+ mysql -e "CREATE USER '${{ env.DB_USER }}'@'${{ env.DB_HOST }}' IDENTIFIED BY '${{ env.DB_PASSWORD }}'" -uroot -proot 2>/dev/null
90237 mysql -e "ALTER USER '${{ env.DB_USER }}'@'${{ env.DB_HOST }}' IDENTIFIED WITH mysql_native_password BY '${{ env.DB_PASSWORD }}'" -uroot -proot 2>/dev/null
238+ mysql -e "GRANT ALL PRIVILEGES ON *.* TO '${{ env.DB_USER }}'@'${{ env.DB_HOST }}'" -uroot -proot 2>/dev/null
91239 mysql -e 'FLUSH PRIVILEGES' -uroot -proot 2>/dev/null
92240
93241 - name : Install WordPress
@@ -105,3 +253,27 @@ jobs:
105253 - name : Run integration tests
106254 working-directory : ${{ env.wp-plugin-directory }}
107255 run : composer integration
256+
257+ update_changelog :
258+ name : Update Changelog
259+ runs-on : ubuntu-latest
260+ needs : integration
261+
262+ if : github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
263+
264+ permissions :
265+ contents : write
266+
267+ env :
268+ wp-plugin-directory : wordpress/wp-content/plugins/cyr2lat
269+
270+ steps :
271+ - name : Checkout code
272+ uses : actions/checkout@v7
273+ with :
274+ path : ${{ env.wp-plugin-directory }}
275+ ref : ${{ github.ref }}
276+
277+ - name : Update changelog
278+ working-directory : ${{ env.wp-plugin-directory }}
279+ run : .github/scripts/update-changelog.sh
0 commit comments