|
| 1 | +name: "Copilot Setup Steps" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + paths: |
| 7 | + - .github/workflows/copilot-setup-steps.yml |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - .github/workflows/copilot-setup-steps.yml |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +jobs: |
| 16 | + copilot-setup-steps: |
| 17 | + name: Setup environment |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 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 | + |
| 32 | + steps: |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 35 | + with: |
| 36 | + persist-credentials: false |
| 37 | + |
| 38 | + - name: Check existence of composer.json file |
| 39 | + id: check_composer_file |
| 40 | + run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT" |
| 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 | + |
| 63 | + - name: Set up PHP environment |
| 64 | + if: steps.check_composer_file.outputs.files_exists == 'true' |
| 65 | + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2 |
| 66 | + with: |
| 67 | + php-version: 'latest' |
| 68 | + ini-values: zend.assertions=1, error_reporting=-1, display_errors=On |
| 69 | + coverage: 'none' |
| 70 | + tools: composer,cs2pr |
| 71 | + env: |
| 72 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Install Composer dependencies & cache dependencies |
| 75 | + if: steps.check_composer_file.outputs.files_exists == 'true' |
| 76 | + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 |
| 77 | + env: |
| 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