PHP Tests #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow | |
name: PHP Tests | |
on: # yamllint disable-line rule:truthy | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- 'src/**' | |
- 'includes/**' | |
- 'tests/**' | |
- 'composer.json' | |
- '.github/workflows/tests.yml' | |
push: | |
paths: | |
- 'includes/**' | |
- 'tests/**' | |
- 'composer.json' | |
branches: | |
- "main" | |
- "develop" | |
jobs: | |
test-php: | |
strategy: | |
matrix: | |
php_version: ['8.3'] | |
core: [ '6.7' ] | |
name: UNIT - WP ${{ matrix.core }} php@${{ matrix.php_version }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php_version }} | |
ini-file: development | |
coverage: none | |
- name: Get Composer Cache Directory | |
id: composer-cache | |
run: | | |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Override PHP version in composer.json | |
run: composer config platform.php ${{ matrix.php_version }} | |
- name: Composer install | |
run: composer install -o | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.11.*' | |
cache: npm | |
- name: Install JS dependencies | |
run: npm ci | |
- name: Launch environment | |
run: WP_ENV_PHP_VERSION=${{ matrix.php_version }} WP_ENV_CORE=WordPress/WordPress#${{ matrix.core }} npm run env:start-ci | |
- name: Bash | |
run: npm run env run tests-wordpress bash && ls -lah && cd / && ls -lah && cd tmp/ && ls -lah | |
- name: Get Wordpress Version | |
run: npm run env:cli wp core version | |
- name: Updates dependencies for tests | |
run: npm run env run tests-wordpress composer update -- -W --working-dir=/var/www/html/wp-content/plugins/wc-bretagne-2024/ | |
- name: Update Yoast dependencies | |
run: npm run env run tests-wordpress composer update -- --dev yoast/phpunit-polyfills -W --working-dir=/var/www/html/wp-content/plugins/wc-bretagne-2024/ | |
- name: Compile CSS/JS | |
run: npm run build | |
- name: Test PHP | |
run: npm run test:php |