-
Notifications
You must be signed in to change notification settings - Fork 83
Functional tests for WP-CLI commands #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
38539a5
Functional tests for WP-CLI commands
swissspidy f1d74f7
Fix workflow file
swissspidy a264a44
Install deps first
swissspidy b9031a6
db fixes
swissspidy afe2f3d
Fix slug
swissspidy 6f0d116
Fix phpunit config
swissspidy 6f79a9e
Fix workflow
swissspidy 1786528
rm file
swissspidy 6322696
No password
swissspidy 5604232
try not to set env vars
swissspidy 7379f45
Switch back to mysql & manually start it
swissspidy b2abf9c
Replace `set-output`
swissspidy 4f614e7
Fix db env vars
swissspidy bce25bf
Set `BEHAT_FEATURES_FOLDER` centrally
swissspidy e4a896d
Fix indent
swissspidy 78e49f2
Fix code coverage
swissspidy 041b3ab
Merge branch 'trunk' into add/cli-tests
swissspidy 894457f
Merge branch 'trunk' into add/cli-tests
swissspidy 75700f7
Update matrix
swissspidy 4b544ff
Merge branch 'trunk' into add/cli-tests
swissspidy fc4ce76
Update matrix
swissspidy 07b94a6
Merge branch 'trunk' into add/cli-tests
swissspidy 4e52cc6
Merge branch 'trunk' into add/cli-tests
swissspidy 584fab6
Merge branch 'trunk' into add/cli-tests
swissspidy ea3287c
Merge branch 'trunk' into add/cli-tests
swissspidy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| name: Behat Testing | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - trunk | ||
| - 'release/**' | ||
| # Only run if PHP-related files changed. | ||
| paths: | ||
| - '.github/workflows/behat-test.yml' | ||
| - '**.php' | ||
| - '**.feature' | ||
| - 'behat.yml' | ||
| - 'composer.json' | ||
| - 'composer.lock' | ||
| pull_request: | ||
| branches: | ||
| - trunk | ||
| - 'release/**' | ||
| - 'feature/**' | ||
| # Only run if PHP-related files changed. | ||
| paths: | ||
| - '.github/workflows/behat-test.yml' | ||
| - '**.php' | ||
| - '**.feature' | ||
| - 'behat.yml' | ||
| - 'composer.json' | ||
| - 'composer.lock' | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
|
||
| jobs: | ||
| behat-test: | ||
| name: PHP ${{ matrix.php }} - WP ${{ matrix.wordpress }}${{ matrix.experimental && ' (experimental)' || '' }} | ||
| runs-on: ubuntu-latest | ||
| continue-on-error: ${{ matrix.experimental == true }} | ||
| timeout-minutes: 20 | ||
| services: | ||
| mysql: | ||
| image: mysql:8.0 | ||
| ports: | ||
| - 3306/tcp | ||
| options: >- | ||
| --health-cmd "mysqladmin ping" | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 3 | ||
| -e MYSQL_ROOT_PASSWORD=root | ||
| -e MYSQL_DATABASE=wp_cli_test | ||
| --entrypoint sh mysql:8.0 | ||
| -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" | ||
|
|
||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| php: | ||
| - '7.0' | ||
| - '7.1' | ||
| - '7.2' | ||
| - '7.3' | ||
| - '7.4' | ||
| - '8.1' | ||
| - '8.2' | ||
| wordpress: [ 'latest' ] | ||
| include: | ||
| - php: '8.0' | ||
| wordpress: 'latest' | ||
| coverage: true | ||
| - php: '8.0' | ||
| wordpress: '6.3' | ||
| - php: '8.2' | ||
| wordpress: 'trunk' | ||
| experimental: true | ||
| - php: '8.3' | ||
| wordpress: 'trunk' | ||
| experimental: true | ||
| env: | ||
| WP_ENV_PHP_VERSION: ${{ matrix.php }} | ||
| WP_ENV_CORE: ${{ matrix.wordpress == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wordpress ) }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| extensions: mysql | ||
| tools: composer | ||
| php-version: ${{ matrix.php }} | ||
| coverage: ${{ matrix.coverage && 'xdebug' || 'none' }} | ||
| ini-values: pcov.directory=.,pcov.exclude=~(vendor|tests)~ | ||
|
|
||
| - name: Install PHP dependencies | ||
| uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 | ||
| with: | ||
| composer-options: '--prefer-dist' | ||
|
|
||
| - name: Make Composer packages available globally | ||
| run: | | ||
| echo "${PWD}/vendor/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Install WP-CLI | ||
| run: | | ||
| curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | ||
| chmod +x wp-cli.phar | ||
| mkdir -p bin | ||
| mv wp-cli.phar bin/wp | ||
| echo "WP_CLI_BIN_DIR=${PWD}/bin" >> $GITHUB_ENV | ||
|
|
||
| - name: Update PHPUnit to get latest php-code-coverage library | ||
| if: ${{ matrix.coverage == true }} | ||
| # phpunit/phpunit has to be updated as the one in use provides an older version of phpunit/php-code-coverage, | ||
| # but we need the v9.x branch. | ||
| # It cannot be removed, as it is a requirement of wp-cli/wp-cli-tests as well. | ||
| run: | | ||
| composer require --dev --ignore-platform-reqs --update-with-all-dependencies phpunit/phpunit | ||
|
|
||
| - name: Start MySQL server | ||
| run: sudo systemctl start mysql | ||
|
|
||
| - name: Configure DB environment | ||
| run: | | ||
| echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV | ||
| echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV | ||
| echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV | ||
| echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV | ||
| echo "WP_CLI_TEST_DBNAME=wp_cli_test" >> $GITHUB_ENV | ||
| echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV | ||
| echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV | ||
| echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Prepare test database | ||
| run: composer prepare-behat-tests | ||
|
|
||
| - name: Check Behat environment | ||
| run: composer behat | ||
| env: | ||
| WP_CLI_TEST_DEBUG_BEHAT_ENV: 1 | ||
|
|
||
| - name: Run tests | ||
| env: | ||
| BEHAT_CODE_COVERAGE: ${{ matrix.coverage }} | ||
| run: composer behat || composer behat-rerun | ||
|
|
||
| - name: Retrieve list of coverage files | ||
| id: coverage_files | ||
| if: ${{ matrix.coverage == true }} | ||
| run: | | ||
| FILES=$(ls -d -1 "$GITHUB_WORKSPACE/build/logs/clover-behat/"*.* | paste --serial --delimiters=",") | ||
| test -n "$FILES" | ||
| echo "Coverage files: $FILES" | ||
| echo "files=$FILES" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Upload code coverage report | ||
| if: ${{ matrix.coverage }} | ||
| uses: codecov/codecov-action@v3 | ||
| with: | ||
| files: ${{ steps.coverage_files.outputs.files }} | ||
| flags: feature | ||
| fail_ci_if_error: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| default: | ||
| suites: | ||
| default: | ||
| contexts: | ||
| - WordPress\Plugin_Check\Behat_Utils\FeatureContext | ||
| paths: | ||
| - tests/behat/features |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.