|
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 |
|
29 | 39 | id: check_composer_file |
30 | 40 | run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT" |
31 | 41 |
|
| 42 | + # Without a database the Behat runner silently falls back to SQLite, so the |
| 43 | + # agent's test runs are not the ones CI will do. Mirrors the setup in |
| 44 | + # reusable-functional.yml. |
| 45 | + - name: Check existence of behat.yml file |
| 46 | + id: check_behat_file |
| 47 | + run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT" |
| 48 | + |
| 49 | + # Not run in the background: Copilot code review builds its workflow from |
| 50 | + # these steps and failed validation while they used `background` and |
| 51 | + # `wait-all`. Also, the action unpacks its binaries with the system `tar`, |
| 52 | + # which fails to load libpcre2 while setup-php upgrades it with apt. |
| 53 | + - name: Setup MySQL Server |
| 54 | + if: steps.check_behat_file.outputs.files_exists == 'true' |
| 55 | + uses: shogo82148/actions-setup-mysql@13a38f2af408e58a0c80168fc620a63a15357339 # v1 |
| 56 | + with: |
| 57 | + mysql-version: '8.0' # Standard MySQL version for these tests |
| 58 | + auto-start: true |
| 59 | + root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }} |
| 60 | + user: ${{ env.WP_CLI_TEST_DBUSER }} |
| 61 | + password: ${{ env.WP_CLI_TEST_DBPASS }} |
| 62 | + |
32 | 63 | - name: Set up PHP environment |
33 | 64 | if: steps.check_composer_file.outputs.files_exists == 'true' |
34 | | - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2 |
| 65 | + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2 |
35 | 66 | with: |
36 | 67 | php-version: 'latest' |
37 | 68 | ini-values: zend.assertions=1, error_reporting=-1, display_errors=On |
|
45 | 76 | uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 |
46 | 77 | env: |
47 | 78 | COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} |
| 79 | + |
| 80 | + - name: Remove system MySQL binary |
| 81 | + if: steps.check_behat_file.outputs.files_exists == 'true' |
| 82 | + run: sudo rm -f /usr/bin/mysql /usr/bin/mysqldump |
| 83 | + |
| 84 | + - name: Prepare test database |
| 85 | + if: steps.check_behat_file.outputs.files_exists == 'true' |
| 86 | + run: composer prepare-tests |
0 commit comments