Configure MySQL authentication for CI tests #6
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
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| unit: | |
| name: Unit (PHP ${{ matrix.php }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['7.4', '8.1', '8.2', '8.3'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| tools: composer:v2 | |
| coverage: none | |
| - name: Install dependencies | |
| working-directory: plugins/basicrum | |
| run: composer install --no-interaction --prefer-dist | |
| - name: PHP syntax lint | |
| working-directory: plugins/basicrum | |
| run: composer lint:php | |
| - name: Coding standards | |
| working-directory: plugins/basicrum | |
| run: composer lint | |
| - name: Unit tests | |
| working-directory: plugins/basicrum | |
| run: ./vendor/bin/phpunit --configuration phpunit.xml | |
| integration: | |
| name: Integration (PHP ${{ matrix.php }}, WP ${{ matrix.wp }}) | |
| runs-on: ubuntu-latest | |
| needs: unit | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: root | |
| MYSQL_ROOT_HOST: '%' | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping -h localhost -proot" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - php: '7.4' | |
| wp: '6.0' | |
| - php: '8.2' | |
| wp: 'trunk' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| tools: composer:v2 | |
| coverage: none | |
| - name: Install dependencies | |
| working-directory: plugins/basicrum | |
| run: composer install --no-interaction --prefer-dist | |
| - name: Configure MySQL authentication | |
| run: | | |
| docker exec "${{ job.services.mysql.id }}" mysql --protocol=socket --user=root --password=root \ | |
| --execute="ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';" | |
| - name: Install WordPress test library | |
| run: | | |
| set -e | |
| sudo apt-get update | |
| sudo apt-get install -y default-mysql-client subversion | |
| bash tools/install-wp-tests.sh wordpress_test root root 127.0.0.1:3306 ${{ matrix.wp }} | |
| - name: Integration tests | |
| working-directory: plugins/basicrum | |
| env: | |
| WP_TESTS_DIR: /tmp/wordpress-tests-lib | |
| run: ./vendor/bin/phpunit --configuration phpunit-with-integration.xml |