|
19 | 19 | permissions: |
20 | 20 | contents: read |
21 | 21 |
|
| 22 | + env: |
| 23 | + MYSQL_HOST: 127.0.0.1 |
| 24 | + MYSQL_TCP_PORT: 3306 |
| 25 | + WP_CLI_TEST_DBROOTUSER: root |
| 26 | + WP_CLI_TEST_DBROOTPASS: root |
| 27 | + WP_CLI_TEST_DBNAME: wp_cli_test |
| 28 | + WP_CLI_TEST_DBUSER: wp_cli_test |
| 29 | + WP_CLI_TEST_DBPASS: password1 |
| 30 | + WP_CLI_TEST_DBHOST: 127.0.0.1:3306 |
| 31 | + |
22 | 32 | steps: |
23 | 33 | - name: Checkout code |
24 | 34 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
|
45 | 55 | uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 |
46 | 56 | env: |
47 | 57 | COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} |
| 58 | + |
| 59 | + # Without a database the Behat runner silently falls back to SQLite, so the |
| 60 | + # agent's test runs are not the ones CI will do. Mirrors the setup in |
| 61 | + # reusable-functional.yml. |
| 62 | + - name: Check existence of behat.yml file |
| 63 | + id: check_behat_file |
| 64 | + run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT" |
| 65 | + |
| 66 | + - name: Setup MySQL Server |
| 67 | + if: steps.check_behat_file.outputs.files_exists == 'true' |
| 68 | + uses: shogo82148/actions-setup-mysql@62da9377d83991fce27b6ed2a397d3306121e41d # v1 |
| 69 | + with: |
| 70 | + mysql-version: '8.0' # Standard MySQL version for these tests |
| 71 | + auto-start: true |
| 72 | + root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }} |
| 73 | + user: ${{ env.WP_CLI_TEST_DBUSER }} |
| 74 | + password: ${{ env.WP_CLI_TEST_DBPASS }} |
| 75 | + |
| 76 | + - name: Remove system MySQL binary |
| 77 | + if: steps.check_behat_file.outputs.files_exists == 'true' |
| 78 | + run: sudo rm -f /usr/bin/mysql /usr/bin/mysqldump |
| 79 | + |
| 80 | + - name: Prepare test database |
| 81 | + if: steps.check_behat_file.outputs.files_exists == 'true' |
| 82 | + run: composer prepare-tests |
0 commit comments