|
| 1 | +name: QA |
| 2 | + |
| 3 | +on: [ push, pull_request ] |
| 4 | + |
| 5 | +env: |
| 6 | + COMPOSER_NO_INTERACTION: 1 |
| 7 | + WP_TESTS_DB_PASS: password |
| 8 | + wp-version: '*' |
| 9 | + |
| 10 | +jobs: |
| 11 | + coding-standards: |
| 12 | + name: Coding Standards (PHP ${{ matrix.php-version }}) |
| 13 | + |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + php-version: |
| 20 | + - 7.4 |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - uses: shivammathur/setup-php@v2 |
| 26 | + with: |
| 27 | + php-version: ${{ matrix.php-version }} |
| 28 | + extensions: bcmath, intl, mbstring, mysql |
| 29 | + ini-values: memory_limit=2048M |
| 30 | + tools: composer, phpcs |
| 31 | + coverage: none |
| 32 | + |
| 33 | + - name: Composer validation |
| 34 | + run: composer validate --strict |
| 35 | + |
| 36 | + # https://github.com/actions/cache/blob/master/examples.md#php---composer |
| 37 | + - name: Get Composer Cache Directory |
| 38 | + id: composer-cache |
| 39 | + run: | |
| 40 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 41 | + - uses: actions/cache@v2 |
| 42 | + with: |
| 43 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 44 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-composer- |
| 47 | +
|
| 48 | + - name: Require WordPress |
| 49 | + run: composer require --dev --no-update --no-progress --no-suggest roots/wordpress:${{ env.wp-version }} wp-phpunit/wp-phpunit:${{ env.wp-version }} |
| 50 | + |
| 51 | + - name: Install Composer dependencies |
| 52 | + run: composer update --no-progress --no-suggest |
| 53 | + |
| 54 | + - name: List Composer packages |
| 55 | + run: composer show |
| 56 | + |
| 57 | + - name: PHPLint |
| 58 | + run: composer run-script phplint |
| 59 | + |
| 60 | + - name: PHP Code Sniffer |
| 61 | + run: composer run-script phpcs |
| 62 | + |
| 63 | + - name: PHP Mess Detector |
| 64 | + continue-on-error: true |
| 65 | + run: composer run-script phpmd |
| 66 | + |
| 67 | + static-code-analysis: |
| 68 | + name: Static Code Analysis (PHP ${{ matrix.php-version }}) |
| 69 | + |
| 70 | + runs-on: ubuntu-latest |
| 71 | + |
| 72 | + strategy: |
| 73 | + matrix: |
| 74 | + php-version: |
| 75 | + - 7.4 |
| 76 | + |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v2 |
| 79 | + |
| 80 | + - uses: shivammathur/setup-php@v2 |
| 81 | + with: |
| 82 | + php-version: ${{ matrix.php-version }} |
| 83 | + extensions: bcmath, intl, mbstring, mysql |
| 84 | + ini-values: memory_limit=2048M |
| 85 | + tools: composer |
| 86 | + coverage: none |
| 87 | + |
| 88 | + # https://github.com/actions/cache/blob/master/examples.md#php---composer |
| 89 | + - name: Get Composer Cache Directory |
| 90 | + id: composer-cache |
| 91 | + run: | |
| 92 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 93 | + - uses: actions/cache@v2 |
| 94 | + with: |
| 95 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 96 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 97 | + restore-keys: | |
| 98 | + ${{ runner.os }}-composer- |
| 99 | +
|
| 100 | + - name: Install Composer dependencies |
| 101 | + run: composer update --no-progress --no-suggest |
| 102 | + |
| 103 | + - name: PHPStan static code analysis |
| 104 | + run: composer bin phpstan install && composer run-script phpstan |
| 105 | + |
| 106 | + tests: |
| 107 | + name: Tests — PHP ${{ matrix.php-version }} ${{ matrix.name }} |
| 108 | + |
| 109 | + runs-on: ubuntu-latest |
| 110 | + |
| 111 | + strategy: |
| 112 | + fail-fast: false |
| 113 | + matrix: |
| 114 | + include: |
| 115 | + # PHP Compatibility and WordPress Versions: https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/ |
| 116 | + - name: WP 5.6 |
| 117 | + php-version: 7.4 |
| 118 | + wp-version: 5.6.* |
| 119 | + - name: WP 5.5 |
| 120 | + php-version: 7.4 |
| 121 | + wp-version: 5.5.* |
| 122 | + # WordPress and PHP 7.4: https://make.wordpress.org/core/2019/10/11/wordpress-and-php-7-4/. |
| 123 | + - name: WP 5.4 |
| 124 | + php-version: 7.4 |
| 125 | + wp-version: 5.4.* |
| 126 | + - name: WP 5.3 |
| 127 | + php-version: 7.4 |
| 128 | + wp-version: 5.3.* |
| 129 | + # WordPress 5.2 (or lower) will trigger PHP 7.4 (or higher) errors. |
| 130 | + # @link https://make.wordpress.org/core/2019/10/11/wordpress-and-php-7-4/. |
| 131 | + - name: WP 5.2 |
| 132 | + php-version: 7.3 |
| 133 | + wp-version: 5.2.* |
| 134 | + - name: WP 5.1 |
| 135 | + php-version: 7.3 |
| 136 | + wp-version: 5.1.* |
| 137 | + - name: WP 5.0 |
| 138 | + php-version: 7.3 |
| 139 | + wp-version: 5.0.* |
| 140 | + - name: WP 4.9 |
| 141 | + php-version: 7.3 |
| 142 | + wp-version: 4.9.* |
| 143 | + # WordPress 4.8 (or lower) will trigger PHP 7.2 (or higher) errors. |
| 144 | + # @link https://make.wordpress.org/core/2018/10/15/wordpress-and-php-7-3/ |
| 145 | + # @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/ |
| 146 | + # @link https://make.wordpress.org/core/tag/4-9/?s=7.2 |
| 147 | + - name: WP 4.8 |
| 148 | + php-version: 7.1 |
| 149 | + wp-version: 4.8.* |
| 150 | + - name: WP 4.7 |
| 151 | + php-version: 7.1 |
| 152 | + wp-version: 4.7.* |
| 153 | + - name: Multisite |
| 154 | + php-version: 7.4 |
| 155 | + WP_MULTISITE: 1 |
| 156 | + - php-version: 7.4 |
| 157 | + - php-version: 7.3 |
| 158 | + - php-version: 7.2 |
| 159 | + - php-version: 7.1 |
| 160 | + - php-version: 7.0 |
| 161 | + - php-version: 5.6 |
| 162 | + |
| 163 | + services: |
| 164 | + mysql: |
| 165 | + image: mysql:5.7 |
| 166 | + env: |
| 167 | + MYSQL_ALLOW_EMPTY_PASSWORD: false |
| 168 | + MYSQL_ROOT_PASSWORD: password |
| 169 | + MYSQL_DATABASE: wp_phpunit_tests |
| 170 | + ports: |
| 171 | + - 3306/tcp |
| 172 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 173 | + |
| 174 | + steps: |
| 175 | + - uses: actions/checkout@v2 |
| 176 | + |
| 177 | + - uses: shivammathur/setup-php@v2 |
| 178 | + with: |
| 179 | + php-version: ${{ matrix.php-version }} |
| 180 | + extensions: bcmath, intl, mbstring, mysql |
| 181 | + ini-values: memory_limit=2048M |
| 182 | + tools: composer |
| 183 | + coverage: none |
| 184 | + |
| 185 | + # https://github.com/actions/cache/blob/master/examples.md#php---composer |
| 186 | + - name: Get Composer Cache Directory |
| 187 | + id: composer-cache |
| 188 | + run: | |
| 189 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 190 | + - uses: actions/cache@v2 |
| 191 | + with: |
| 192 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 193 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 194 | + restore-keys: | |
| 195 | + ${{ runner.os }}-composer- |
| 196 | +
|
| 197 | + - name: Start MySQL service |
| 198 | + run: sudo service mysql start |
| 199 | + |
| 200 | + - name: Require WordPress |
| 201 | + run: composer require --dev --no-update --no-progress --no-suggest roots/wordpress:${{ matrix.wp-version || env.wp-version }} wp-phpunit/wp-phpunit:${{ matrix.wp-version || env.wp-version }} |
| 202 | + |
| 203 | + - name: Install Composer dependencies |
| 204 | + run: composer update --no-progress --no-suggest |
| 205 | + |
| 206 | + - name: List Composer packages |
| 207 | + run: composer show |
| 208 | + |
| 209 | + - name: PHPLint |
| 210 | + run: composer run-script phplint |
| 211 | + |
| 212 | + - name: PHPUnit test suite |
| 213 | + env: |
| 214 | + WP_TESTS_DB_HOST: 127.0.0.1:${{ job.services.mysql.ports['3306'] }} |
| 215 | + run: composer run-script phpunit |
| 216 | + |
| 217 | + code-coverage: |
| 218 | + name: Code Coverage (PHP ${{ matrix.php-version }}) |
| 219 | + |
| 220 | + runs-on: ubuntu-latest |
| 221 | + |
| 222 | + strategy: |
| 223 | + fail-fast: false |
| 224 | + matrix: |
| 225 | + php-version: |
| 226 | + - 7.4 |
| 227 | + |
| 228 | + services: |
| 229 | + mysql: |
| 230 | + image: mysql:5.7 |
| 231 | + env: |
| 232 | + MYSQL_ALLOW_EMPTY_PASSWORD: false |
| 233 | + MYSQL_ROOT_PASSWORD: password |
| 234 | + MYSQL_DATABASE: wp_phpunit_tests |
| 235 | + ports: |
| 236 | + - 3306/tcp |
| 237 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 238 | + |
| 239 | + steps: |
| 240 | + - uses: actions/checkout@v2 |
| 241 | + |
| 242 | + - uses: shivammathur/setup-php@v2 |
| 243 | + with: |
| 244 | + php-version: ${{ matrix.php-version }} |
| 245 | + extensions: bcmath, intl, mbstring, mysql |
| 246 | + ini-values: memory_limit=2048M |
| 247 | + tools: composer |
| 248 | + coverage: xdebug |
| 249 | + |
| 250 | + # https://github.com/actions/cache/blob/master/examples.md#php---composer |
| 251 | + - name: Get Composer Cache Directory |
| 252 | + id: composer-cache |
| 253 | + run: | |
| 254 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 255 | + - uses: actions/cache@v2 |
| 256 | + with: |
| 257 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 258 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 259 | + restore-keys: | |
| 260 | + ${{ runner.os }}-composer- |
| 261 | +
|
| 262 | + - name: Start MySQL service |
| 263 | + run: sudo service mysql start |
| 264 | + |
| 265 | + - name: Require WordPress |
| 266 | + run: composer require --dev --no-update --no-progress --no-suggest roots/wordpress:${{ env.wp-version }} wp-phpunit/wp-phpunit:${{ env.wp-version }} |
| 267 | + |
| 268 | + - name: Install Composer dependencies |
| 269 | + run: composer update --no-progress --no-suggest |
| 270 | + |
| 271 | + - name: List Composer packages |
| 272 | + run: composer show |
| 273 | + |
| 274 | + - name: PHPLint |
| 275 | + run: composer run-script phplint |
| 276 | + |
| 277 | + - name: PHPUnit test suite |
| 278 | + env: |
| 279 | + WP_TESTS_DB_HOST: 127.0.0.1:${{ job.services.mysql.ports['3306'] }} |
| 280 | + run: composer run-script phpunit |
| 281 | + |
| 282 | + - name: Coveralls code coverage |
| 283 | + env: |
| 284 | + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 285 | + run: | |
| 286 | + composer run-script coveralls |
| 287 | + bash <(curl -s https://codecov.io/bash) |
| 288 | +
|
| 289 | + es-sass-linting: |
| 290 | + name: Scripts and Styles |
| 291 | + |
| 292 | + runs-on: ubuntu-latest |
| 293 | + |
| 294 | + steps: |
| 295 | + - uses: actions/checkout@v2 |
| 296 | + |
| 297 | + # https://github.com/actions/cache/blob/master/examples.md#macos-and-ubuntu |
| 298 | + - uses: actions/cache@v2 |
| 299 | + with: |
| 300 | + path: ~/.npm |
| 301 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 302 | + restore-keys: | |
| 303 | + ${{ runner.os }}-node- |
| 304 | +
|
| 305 | + - uses: actions/setup-node@v1 |
| 306 | + with: |
| 307 | + node-version: '12' |
| 308 | + |
| 309 | + - name: Install Node packages |
| 310 | + run: npm install |
| 311 | + |
| 312 | + - name: ESLint |
| 313 | + run: npm run-script eslint |
| 314 | + |
| 315 | + - name: Sass Lint |
| 316 | + run: npm run-script sass-lint |
0 commit comments