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
| name: WordPress Plugin Integration Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: # Allow manual triggering | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| integration-test: | |
| name: Run WordPress Integration Tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php-version: ['7.4', '8.0', '8.1', '8.2'] | |
| wordpress-version: ['latest', '6.3', '6.2', '6.1', '6.0', '5.9'] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| extensions: mbstring, intl, mysqli, zip | |
| tools: composer:v2 | |
| coverage: none | |
| - name: Install Composer dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Setup WordPress Core for PHPMailer availability | |
| run: | | |
| # Download WordPress directly (avoiding SHA-256 verification issues) | |
| mkdir -p /tmp/wordpress | |
| curl -s https://wordpress.org/wordpress-${{ matrix.wordpress-version == 'latest' && '6.4.1' || matrix.wordpress-version }}.zip -o /tmp/wordpress.zip | |
| unzip -q /tmp/wordpress.zip -d /tmp | |
| # Create WordPress tests directory structure | |
| mkdir -p /tmp/wordpress-tests-lib/includes | |
| # Ensure PHPMailer is available for the tests | |
| if [[ "${{ matrix.wordpress-version }}" != "5.9" ]]; then | |
| cp -r /tmp/wordpress/wp-includes/PHPMailer /tmp/wordpress-tests-lib/includes/ || true | |
| cp /tmp/wordpress/wp-includes/class-phpmailer.php /tmp/wordpress-tests-lib/includes/class-wp-phpmailer.php || true | |
| fi | |
| # Create database for tests | |
| mysql -e "CREATE DATABASE IF NOT EXISTS wordpress_test;" -uroot -proot | |
| - name: WordPress Plugin Integration Test | |
| uses: holyhope/[email protected] | |
| with: | |
| php_version: ${{ matrix.php-version }} | |
| wordpress_version: ${{ matrix.wordpress-version }} | |
| plugin_slug: 'simple-wp-optimizer' | |
| phpunit_config: 'phpunit.xml' | |
| - name: Add labels to any PRs | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| github.rest.issues.addLabels({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: ['automated', 'documentation', 'plugin update'] | |
| }) |