|
9 | 9 | paths: |
10 | 10 | - .github/workflows/copilot-setup-steps.yml |
11 | 11 |
|
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
12 | 15 | jobs: |
13 | 16 | copilot-setup-steps: |
| 17 | + name: Setup environment |
14 | 18 | runs-on: ubuntu-latest |
15 | 19 | permissions: |
16 | 20 | contents: read |
17 | 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 | + |
18 | 32 | steps: |
19 | 33 | - name: Checkout code |
20 | | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 34 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 35 | + with: |
| 36 | + persist-credentials: false |
21 | 37 |
|
22 | 38 | - name: Check existence of composer.json file |
23 | 39 | id: check_composer_file |
24 | 40 | run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT" |
25 | 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 | + |
26 | 63 | - name: Set up PHP environment |
27 | 64 | if: steps.check_composer_file.outputs.files_exists == 'true' |
28 | | - uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2 |
| 65 | + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2 |
29 | 66 | with: |
30 | 67 | php-version: 'latest' |
31 | 68 | ini-values: zend.assertions=1, error_reporting=-1, display_errors=On |
|
36 | 73 |
|
37 | 74 | - name: Install Composer dependencies & cache dependencies |
38 | 75 | if: steps.check_composer_file.outputs.files_exists == 'true' |
39 | | - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v3 |
| 76 | + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 |
40 | 77 | env: |
41 | 78 | COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} |
42 | | - with: |
43 | | - # Bust the cache at least once a month - output format: YYYY-MM. |
44 | | - custom-cache-suffix: $(date -u "+%Y-%m") |
| 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