Skip to content

Update file(s) from "wp-cli/.github" #19

Update file(s) from "wp-cli/.github"

Update file(s) from "wp-cli/.github" #19

name: "Copilot Setup Steps"
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
permissions:
contents: read
jobs:
copilot-setup-steps:
name: Setup environment
runs-on: ubuntu-latest
permissions:
contents: read
env:
MYSQL_HOST: 127.0.0.1
MYSQL_TCP_PORT: 3306
WP_CLI_TEST_DBROOTUSER: root
WP_CLI_TEST_DBROOTPASS: root
WP_CLI_TEST_DBNAME: wp_cli_test
WP_CLI_TEST_DBUSER: wp_cli_test
WP_CLI_TEST_DBPASS: password1
WP_CLI_TEST_DBHOST: 127.0.0.1:3306
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check existence of composer.json file
id: check_composer_file
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
# Without a database the Behat runner silently falls back to SQLite, so the
# agent's test runs are not the ones CI will do. Mirrors the setup in
# reusable-functional.yml.
- name: Check existence of behat.yml file
id: check_behat_file
run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT"
# Downloading and starting the database server is the slowest part of the
# setup and it is independent of PHP and Composer, so it runs in the
# background and is waited for right before the test database is prepared.
- name: Setup MySQL Server
if: steps.check_behat_file.outputs.files_exists == 'true'
background: true
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
with:
mysql-version: '8.0' # Standard MySQL version for these tests
auto-start: true
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
user: ${{ env.WP_CLI_TEST_DBUSER }}
password: ${{ env.WP_CLI_TEST_DBPASS }}
- name: Set up PHP environment
if: steps.check_composer_file.outputs.files_exists == 'true'
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: 'latest'
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: 'none'
tools: composer,cs2pr
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Composer dependencies & cache dependencies
if: steps.check_composer_file.outputs.files_exists == 'true'
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
- name: Wait for the MySQL server
wait-all:
- name: Remove system MySQL binary
if: steps.check_behat_file.outputs.files_exists == 'true'
run: sudo rm -f /usr/bin/mysql /usr/bin/mysqldump
- name: Prepare test database
if: steps.check_behat_file.outputs.files_exists == 'true'
run: composer prepare-tests