diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index bf67592d8..e601fac63 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -13,3 +13,33 @@ on: jobs: test: uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main + + minimum-php-guard: + name: Minimum PHP guard - PHP ${{ matrix.php }} + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + php: ['5.6', '7.1'] + steps: + - name: Check out source code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up PHP environment + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2 + with: + php-version: '${{ matrix.php }}' + coverage: none + + - name: Check minimum PHP guard + run: | + if php php/boot-phar.php > stdout.txt 2> stderr.txt; then + echo 'Expected boot-phar.php to reject unsupported PHP version.' + exit 1 + fi + + test ! -s stdout.txt + printf 'Error: WP-CLI requires PHP 7.2.24 or newer. You are running version %s.\n' "$(php -r 'echo PHP_VERSION;')" > expected.txt + diff -u expected.txt stderr.txt diff --git a/php/boot-phar.php b/php/boot-phar.php index e5f94a262..d7215a90f 100644 --- a/php/boot-phar.php +++ b/php/boot-phar.php @@ -1,5 +1,7 @@