Skip to content
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

Tests: Run tests using ubuntu-latest #88

Merged
merged 9 commits into from
Mar 12, 2025
4 changes: 2 additions & 2 deletions .env.dist.testing
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TEST_SITE_TABLE_PREFIX=wp_
TEST_SITE_ADMIN_USERNAME=admin
TEST_SITE_ADMIN_PASSWORD=password
TEST_SITE_WP_ADMIN_PATH=/wp-admin
WP_ROOT_FOLDER="/home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/wordpress"
WP_ROOT_FOLDER="/var/www/html"
WP_ENVIRONMENT_TYPE=local
TEST_DB_NAME=test
TEST_DB_HOST=localhost
Expand All @@ -17,7 +17,7 @@ TEST_TABLE_PREFIX=wp_
TEST_SITE_WP_URL=http://127.0.0.1
TEST_SITE_WP_DOMAIN=127.0.0.1
[email protected]
TEST_SITE_CONFIG_FILE="/home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/wordpress/wp-content/plugins/convertkit-wordpress-libraries/tests/_support/WpunitTesterConfig.php"
TEST_SITE_CONFIG_FILE="/var/www/html/wp-content/plugins/convertkit-wordpress-libraries/tests/_support/WpunitTesterConfig.php"
CONVERTKIT_API_BROADCAST_ID="8697158"
CONVERTKIT_API_CUSTOM_FIELD_ID="258240"
CONVERTKIT_API_FORM_ID="2765139"
Expand Down
37 changes: 23 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:

# Virtual Environment to use.
# @see: https://github.com/actions/virtual-environments
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

# Environment Variables.
# Accessible by using ${{ env.NAME }}
# Use ${{ secrets.NAME }} to include any GitHub Secrets in ${{ env.NAME }}
# The base folder will always be /home/runner/work/github-repo-name/github-repo-name
env:
ROOT_DIR: /home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/wordpress
PLUGIN_DIR: /home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/wordpress/wp-content/plugins/convertkit-wordpress-libraries
ROOT_DIR: /var/www/html
PLUGIN_DIR: /var/www/html/wp-content/plugins/convertkit-wordpress-libraries
DB_NAME: test
DB_USER: root
DB_PASS: root
Expand All @@ -51,6 +51,13 @@ jobs:

# Steps to install, configure and run tests
steps:
# Checkout Plugin to /home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/convertkit-wordpress-libraries
# We cannot checkout to ${{ env.PLUGIN_DIR }} as GitHub Actions require it be first placed in /home/runner/work/repo/repo
- name: Checkout Plugin
uses: actions/checkout@v4
with:
path: /home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/convertkit-wordpress-libraries

- name: Start MySQL
run: sudo systemctl start mysql.service

Expand All @@ -65,17 +72,15 @@ jobs:

# Some workflows checkout WordPress from GitHub, but that seems to bring a bunch of uncompiled files with it.
# Instead download from wordpress.org stable.
- name: Download WordPress
run: wget https://wordpress.org/wordpress-${{ matrix.wp-versions }}.tar.gz

- name: Extract WordPress
run: tar xfz wordpress-${{ matrix.wp-versions }}.tar.gz

# Checkout (copy) this repository's Plugin to this VM.
- name: Checkout Plugin
uses: actions/checkout@v4
with:
path: ${{ env.PLUGIN_DIR }}
- name: Download and Extract WordPress
run: |
sudo chown -R runner:docker /var/www/html
ls -la /var/www/html
cd /var/www/html
wget https://wordpress.org/wordpress-${{ matrix.wp-versions }}.tar.gz
tar xfz wordpress-${{ matrix.wp-versions }}.tar.gz
mv wordpress/* .
rm -rf wordpress wordpress-${{ matrix.wp-versions }}.tar.gz

# We install WP-CLI, as it provides useful commands to setup and install WordPress through the command line.
- name: Install WP-CLI
Expand All @@ -97,6 +102,10 @@ jobs:
working-directory: ${{ env.ROOT_DIR }}
run: wp-cli plugin install ${{ env.INSTALL_PLUGINS }}

# Move Plugin
- name: Move Plugin
run: mv /home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/convertkit-wordpress-libraries ${{ env.PLUGIN_DIR }}

# Install PHP version to run tests against.
- name: Install PHP
uses: shivammathur/setup-php@v2
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ parameters:

# Location of WordPress Plugins for PHPStan to scan, building symbols.
scanDirectories:
- /home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/wordpress/wp-content/plugins
- /var/www/html/wp-content/plugins

# Location of constants for PHPStan to scan, building symbols.
scanFiles:
- /home/runner/work/convertkit-wordpress-libraries/convertkit-wordpress-libraries/wordpress/wp-config.php
- /var/www/html/wp-config.php

# Don't report unmatched ignored errors on older PHP versions (7.2, 7.3)
reportUnmatchedIgnoredErrors: false
Expand Down
Loading