Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2879

Extension Writers Discussion • Re: [Info] Using Github Actions to Test Extensions

$
0
0
If I may offer my 2 cents on the PR... PHP_VERSION and PHP_VERSIONS, although that very similar naming might be confusing.

Thanks for the effort on this though!
The test framework has been updated to address this!

TL;DR:
In our reusable GitHub Action, we define two PHP version settings:
  • PRIMARY_PHP_VERSION used for single-version tests (like EPV, MSSQL, SQLite, Windows)
  • PHP_VERSION_MATRIX used for running the full test matrix (MySQL/MariaDB and PostgreSQL)
You don’t always need both, but knowing when and how to set them can save you time and keep your test runs lean.

The default values are:

Code:

PRIMARY_PHP_VERSION: '7.2'PHP_VERSION_MATRIX: '["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]'
But for your needs, you would need to override them by setting these in your workflow like:

Code:

PRIMARY_PHP_VERSION: '8.0'PHP_VERSION_MATRIX: '["8.0", "8.1", "8.2", "8.3", "8.4"]'
If you’re wondering why there are two separate PHP options in the reusable workflow, here’s the nerdy explanation:

GitHub Actions doesn’t let you treat the version matrix as a typical array—so you can’t just grab the “first” entry dynamically. That means we need to manually define a “primary” PHP version for tests that are only meant to run once, not across every PHP version.

Why does that matter? Because running all tests across all PHP versions would be total overkill. For example, some tests like EPV (Extension PreValidator) only need to run against one PHP version. If we tried to run them against every version in the matrix, we’d end up with 100s of jobs per run!

So, we use the PHP version matrix only for the core database tests (MySQL/MariaDB and PostgreSQL). All other tests—like MSSQL, SQLite, and Windows—run on a single, defined PHP version.

How to Set PHP Versions for Your Extension

The default values are the same PHP versions phpBB is tested against. So most extensions should never need to set these variables. But for those extensions that do have stricter PHP version requirements than phpBB, here are a couple of common scenarios for choosing your PHP version strategy:

Scenario 1: Your extension supports only PHP 8.1+

Let’s say you’re using modern, non-backwards-compatible features.

Code:

PRIMARY_PHP_VERSION: '8.1'PHP_VERSION_MATRIX: '["8.1", "8.2", "8.3", "8.4"]'
In this case:
  • The matrix should include all versions you support
  • The primary PHP version is usually the first in that list (but you can choose any supported version)
Scenario 2: Your extension supports 7.2–8.4, but you’re a PHP 8 fan

If you’re sticking with phpBB’s full support range but you’d prefer EPV and other single-version tests to run on PHP 8 instead of the default 7.2:

Code:

PRIMARY_PHP_VERSION: '8.4'
You can skip setting PHP_VERSION_MATRIX here—it will default to ["7.2", ..., "8.4"]. This approach lets you nudge the single-version tests toward your preferred PHP version without affecting the full compatibility matrix.

Statistics: Posted by MattF — Sun May 04, 2025 4:23 pm



Viewing all articles
Browse latest Browse all 2879

Trending Articles