|
| 1 | +name: Functional testing |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + php: |
| 6 | + type: string |
| 7 | + required: true |
| 8 | + wp: |
| 9 | + type: string |
| 10 | + required: true |
| 11 | + dbtype: |
| 12 | + type: string |
| 13 | + required: false |
| 14 | + default: 'mysql' |
| 15 | + mysql: |
| 16 | + type: string |
| 17 | + required: false |
| 18 | + default: '' |
| 19 | + object_cache: |
| 20 | + type: string |
| 21 | + required: false |
| 22 | + default: 'none' |
| 23 | + coverage: |
| 24 | + type: boolean |
| 25 | + required: false |
| 26 | + default: false |
| 27 | + os: |
| 28 | + type: string |
| 29 | + required: false |
| 30 | + default: 'ubuntu-22.04' |
| 31 | + |
| 32 | +permissions: |
| 33 | + contents: read |
| 34 | + |
| 35 | +jobs: |
| 36 | + functional: |
| 37 | + name: PHP ${{ inputs.php }} | WP ${{ inputs.wp }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.dbtype == 'mariadb' && 'MariaDB' || 'MySQL' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}${{ inputs.coverage && ' (with coverage)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }} |
| 38 | + runs-on: ${{ inputs.os || 'ubuntu-22.04' }} |
| 39 | + |
| 40 | + continue-on-error: ${{ inputs.dbtype == 'sqlite' || inputs.dbtype == 'mariadb' || inputs.php == 'nightly' }} |
| 41 | + |
| 42 | + env: |
| 43 | + MYSQL_HOST: 127.0.0.1 |
| 44 | + MYSQL_TCP_PORT: 3306 |
| 45 | + WP_CLI_TEST_DBROOTUSER: root |
| 46 | + WP_CLI_TEST_DBROOTPASS: root |
| 47 | + WP_CLI_TEST_DBNAME: wp_cli_test |
| 48 | + WP_CLI_TEST_DBUSER: wp_cli_test |
| 49 | + WP_CLI_TEST_DBPASS: password1 |
| 50 | + WP_CLI_TEST_DBHOST: 127.0.0.1:3306 |
| 51 | + WP_CLI_TEST_OBJECT_CACHE: ${{ inputs.object_cache }} |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Check out source code |
| 55 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 56 | + |
| 57 | + - name: Install Ghostscript |
| 58 | + if: ${{ inputs.os == 'ubuntu-22.04' || inputs.os == '' }} |
| 59 | + run: | |
| 60 | + sudo apt-get update |
| 61 | + sudo apt-get install ghostscript -y |
| 62 | +
|
| 63 | + - name: Set up PHP environment |
| 64 | + uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2 |
| 65 | + with: |
| 66 | + php-version: '${{ inputs.php }}' |
| 67 | + ini-values: zend.assertions=1, error_reporting=-1, display_errors=On |
| 68 | + extensions: gd, imagick, mysql, zip, pdo_sqlite |
| 69 | + coverage: ${{ inputs.coverage && 'xdebug' || 'none' }} |
| 70 | + tools: composer |
| 71 | + env: |
| 72 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Change ImageMagick policy to allow pdf->png conversion. |
| 75 | + if: ${{ inputs.os == 'ubuntu-22.04' || inputs.os == '' }} |
| 76 | + run: | |
| 77 | + sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml |
| 78 | +
|
| 79 | + - name: Install Composer dependencies & cache dependencies |
| 80 | + uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v3 |
| 81 | + env: |
| 82 | + COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} |
| 83 | + |
| 84 | + # MySQL 8.4 requires explicit loading of mysql_native_password plugin |
| 85 | + - name: Determine MySQL authentication configuration |
| 86 | + id: mysql-config |
| 87 | + if: ${{ inputs.dbtype != 'sqlite' && inputs.mysql == 'mysql-8.4' }} |
| 88 | + run: | |
| 89 | + echo "auth-config<<EOF" >> $GITHUB_OUTPUT |
| 90 | + echo "mysql_native_password=ON" >> $GITHUB_OUTPUT |
| 91 | + echo "authentication_policy=mysql_native_password," >> $GITHUB_OUTPUT |
| 92 | + echo "EOF" >> $GITHUB_OUTPUT |
| 93 | +
|
| 94 | + - name: Setup MySQL Server |
| 95 | + id: setup-mysql |
| 96 | + if: ${{ inputs.dbtype != 'sqlite' }} |
| 97 | + uses: shogo82148/actions-setup-mysql@840178c12b07a58353c6312be784c23b63756eea # v1 |
| 98 | + with: |
| 99 | + mysql-version: ${{ inputs.mysql }} |
| 100 | + auto-start: true |
| 101 | + root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }} |
| 102 | + user: ${{ env.WP_CLI_TEST_DBUSER}} |
| 103 | + password: ${{ env.WP_CLI_TEST_DBPASS}} |
| 104 | + # Fall back to legacy configuration for MySQL 5.6, 5.7, 8.0 and MariaDB. |
| 105 | + my-cnf: | |
| 106 | + ${{ steps.mysql-config.outputs.auth-config || 'default_authentication_plugin=mysql_native_password' }} |
| 107 | + ${{ inputs.dbtype == 'mariadb' && '[client]' || '' }} |
| 108 | + ${{ inputs.dbtype == 'mariadb' && 'disable-ssl-verify-server-cert' || '' }} |
| 109 | +
|
| 110 | + - name: Prepare test database |
| 111 | + if: ${{ inputs.dbtype != 'sqlite' }} |
| 112 | + run: composer prepare-tests |
| 113 | + |
| 114 | + - name: Check Behat environment |
| 115 | + env: |
| 116 | + WP_VERSION: '${{ inputs.wp }}' |
| 117 | + WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype || 'mysql' }} |
| 118 | + WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock' |
| 119 | + WP_CLI_TEST_DEBUG_BEHAT_ENV: 1 |
| 120 | + run: composer behat |
| 121 | + |
| 122 | + - name: Run Behat |
| 123 | + env: |
| 124 | + WP_VERSION: '${{ inputs.wp }}' |
| 125 | + WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype || 'mysql' }} |
| 126 | + WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock' |
| 127 | + WP_CLI_TEST_COVERAGE: ${{ inputs.coverage }} |
| 128 | + BEHAT_ARGS: ${{ format( '{0}', runner.debug && '--format=pretty' ) }} |
| 129 | + run: | |
| 130 | + composer behat -- $BEHAT_ARGS || composer behat-rerun -- $BEHAT_ARGS |
| 131 | +
|
| 132 | + - name: Retrieve list of coverage files |
| 133 | + id: coverage_files |
| 134 | + if: ${{ inputs.coverage }} |
| 135 | + run: | |
| 136 | + FILES=$(find "$GITHUB_WORKSPACE/build/logs" -path '*.*' | paste -s -d "," -) |
| 137 | + echo "files=$FILES" >> $GITHUB_OUTPUT |
| 138 | +
|
| 139 | + - name: Upload code coverage report |
| 140 | + if: ${{ inputs.coverage }} |
| 141 | + uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3 |
| 142 | + with: |
| 143 | + # Because somehow providing `directory: build/logs` doesn't work for these files |
| 144 | + files: ${{ steps.coverage_files.outputs.files }} |
| 145 | + flags: feature |
| 146 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments