-
Notifications
You must be signed in to change notification settings - Fork 13
150 lines (120 loc) · 4.72 KB
/
Copy pathci.yml
File metadata and controls
150 lines (120 loc) · 4.72 KB
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
name: CI for Plugin Boilerplate
on: [push]
# Cancel any in-progress runs for the same branch when a new push lands.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Disable all permissions by default; grant minimal permissions per job.
permissions: {}
# wp-env mounts the working tree at wp-content/plugins/<basename>, so check out into
# a directory named to match the slug used in composer.json's "integration" script.
defaults:
run:
working-directory: plugin-slug
jobs:
lint:
name: Lint and code standards
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: plugin-slug
persist-credentials: false
- name: Setup PHP 8.4
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: '8.4'
coverage: none
tools: composer:v2
extensions: mbstring # Just enough to keep phpunit happy when installing Composer dependencies.
- name: Validate composer.json
run: composer validate --no-check-lock
- name: Install Composer dependencies
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
with:
working-directory: plugin-slug
composer-options: --prefer-dist --no-progress --no-suggest
# Needed as runs-on: system doesn't have xml-lint by default.
- name: Lint .phpcs.xml.dist
uses: ChristophWurst/xmllint-action@7c54ff113fc0f6d4588a15cb4dfe31b6ecca5212 # v1.2.1
with:
xml-file: ./plugin-slug/.phpcs.xml.dist
xml-schema-file: ./plugin-slug/vendor/squizlabs/php_codesniffer/phpcs.xsd
# Needed as runs-on: system doesn't have xml-lint by default.
- name: Lint phpunit.xml.dist
uses: ChristophWurst/xmllint-action@7c54ff113fc0f6d4588a15cb4dfe31b6ecca5212 # v1.2.1
with:
xml-file: ./plugin-slug/phpunit.xml.dist
xml-schema-file: ./plugin-slug/vendor/phpunit/phpunit/phpunit.xsd
- name: Lint PHP files
run: bin/php-lint
- name: Run PHPCS
run: composer cs
test:
name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
# Lowest supported PHP with lowest supported WordPress.
- php: '8.4'
wordpress: '6.9'
# Latest supported PHP with the latest WordPress.
- php: '8.5'
wordpress: 'master'
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: plugin-slug
persist-credentials: false
- name: Setup Node.js (for wp-env)
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 'lts/*'
- name: Cache npm registry for wp-env
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.npm
key: ${{ runner.os }}-npm-wp-env-${{ hashFiles('plugin-slug/.wp-env.json') }}
restore-keys: |
${{ runner.os }}-npm-wp-env-
- name: Install wp-env
run: npm install -g @wordpress/env
- name: Setup PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
php-version: ${{ matrix.php }}
coverage: pcov
tools: composer:v2
# https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions
extensions: curl, dom, exif, fileinfo, hash, json, mbstring, mysqli, libsodium, openssl, pcre, imagick, xml, zip
- name: Install Composer dependencies
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
with:
working-directory: plugin-slug
composer-options: --prefer-dist --no-progress --no-suggest
- name: Setup Problem Matchers for PHPUnit
env:
RUNNER_TOOL_CACHE: ${{ runner.tool_cache }}
run: echo "::add-matcher::${RUNNER_TOOL_CACHE}/phpunit.json"
- name: Run unit tests
run: composer unit
- name: Run infection tests
run: composer infection
continue-on-error: true
- name: Start wp-env
run: wp-env start
env:
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wordpress }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
- name: Run integration tests
run: composer integration