Skip to content

Commit

Permalink
[CMSP-606] PHP 8.3 compatibility (#9)
Browse files Browse the repository at this point in the history
* add a matrix to test multiple php versions php compat

* revise lint script to run php and phpcs

* set code style (lint) to run on matrix
we're going to need to refactor the other tests to not use the terminus-plugin-test image so we can use different php versions...this is the first one.

* use checkout v3

* if we're running tests on php 7.4, run a composer update

* update terminus 3 tests for matrix

* set the php version as an env variable

* use the php version in the md name

* update the CI test md name, too

* echo the PHP version in the test

* move the "editing" echo out of the subshell
we don't want that in the ~/.ssh/config

* install bats before running bats tests

* add a note for our future selves

* update the cleanup step

* debug the failing test

* add matrix to php unit tests

* delete any un-deleted ci- environment

* don't run unit tests on 7.4
the tests actually require php 8.x

* bump dependencies

* just be generally more verbose

* fuzzy match with the PHP VERSION

* attempt to debug the failing test (again)

* this line doesn't do anything

* note the version in the last echo
¯\_(ツ)_/¯

* export FS_TEST and CI_TEST so we can use them later

* set FS_TEST_ENV and SITE_ENV based on FS_TEST and CI_TEST

* remove debug

* these aren't getting exported to the functional tests, so drop them

* set the env names based on build_num and php_version

* strip the period from the php version for cleanup

* also strip the period out of the php version for tests
  • Loading branch information
jazzsequence authored Oct 26, 2023
1 parent c5658a0 commit 642cdac
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 91 deletions.
9 changes: 6 additions & 3 deletions .bin/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/bash
set -ex

PHP_VERSION=$(echo "$PHP_VERSION" | tr -d '.')
# Nuke any lingering multidev environments from orbit.
for ENV in $(terminus multidev:list --field=Name --format=list "$TERMINUS_SITE"); do
if [[ "$ENV" == ci-"$BUILD_NUM" || "$ENV" == localtests || "$ENV" == fs-* ]]; then
terminus multidev:delete --delete-branch --yes "${TERMINUS_SITE}"."${ENV}"
if [[ "$ENV" =~ ^ci-.*-"$PHP_VERSION" || "$ENV" == localtests || "$ENV" =~ ^fs-.*-"$PHP_VERSION" ]]; then
echo "Deleting $ENV."
terminus multidev:delete --delete-branch --yes "${TERMINUS_SITE}"."${ENV}"
fi
done

echo "✅ Done!"
29 changes: 17 additions & 12 deletions .bin/setup.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#!/bin/bash
set -e

TERMINUS_PLUGINS_DIR=.. terminus list -n remote
echo "Running PHP $PHP_VERSION tests..."

PHP_VER="$PHP_VERSION"
PHP_VERSION=$(echo "$PHP_VERSION" | tr -d '.')
FS_TEST="fs-${BUILD_NUM}-${PHP_VERSION}"
CI_TEST="ci-${BUILD_NUM}-${PHP_VERSION}"

# Update Terminus to the latest version.
terminus self:update

# Set the fs-test number. If the build number is > 999, we need to trim the -test- out of the middle.
if [ "$BUILD_NUM" -gt 999 ]; then
FS_TEST="fs-${BUILD_NUM}"
else
FS_TEST="fs-test-${BUILD_NUM}"
fi

echo "Logging in with a machine token:"
terminus auth:login -n --machine-token="$TERMINUS_TOKEN"
terminus whoami
terminus multidev:create "$TERMINUS_SITE".dev ci-"$BUILD_NUM"
terminus connection:set "$TERMINUS_SITE".ci-"$BUILD_NUM" git
echo "Creating multidev environments for testing."
terminus multidev:create "$TERMINUS_SITE".dev "$CI_TEST"
terminus connection:set "$TERMINUS_SITE"."$CI_TEST" git
# Set up the environment for filesystem tests.
terminus multidev:create "$TERMINUS_SITE".dev "$FS_TEST"
terminus connection:set "$TERMINUS_SITE"."$FS_TEST" sftp
echo "✅ Created $CI_TEST and $FS_TEST."

# Check if ~/.ssh directory exists
if [ ! -d ~/.ssh ]; then
Expand All @@ -34,12 +34,17 @@ if [ ! -f ~/.ssh/config ]; then
chmod 600 ~/.ssh/config
fi

echo "Editing the ~/.ssh/config file"
{
echo "Editing the ~/.ssh/config file"
echo "Host *"
echo " StrictHostKeyChecking no"
echo " LogLevel ERROR"
echo " UserKnownHostsFile /dev/null"
} >> ~/.ssh/config
echo "✅ Done!"

echo "When PHP 8.3 is available on the platform, we will update the pantheon.yml to set the multidev environment to $PHP_VER to validate that the command runs on the platform with the approprate PHP version. For now, we're only running the command on whatever PHP version the fixture site is running."

terminus wp "$TERMINUS_SITE"."$FS_TEST" -- plugin install hello-dolly

terminus wp "$TERMINUS_SITE"."$FS_TEST" -- plugin install hello-dolly
echo "✅ Done setting up $PHP_VER environments!"
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ jobs:
phpcompatibility:
runs-on: ubuntu-latest
name: PHP Compatibility
strategy:
matrix:
php-version: [7.4, 8.3]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: PHPCompatibility
uses: pantheon-systems/phpcompatibility-action@v1
with:
test-versions: 7.4-
test-versions: ${{ matrix.php-version }}-
60 changes: 44 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,46 @@ env:
jobs:
unit:
runs-on: ubuntu-latest
container:
image: quay.io/pantheon-public/terminus-plugin-test:4.x-php8.0
options: --user root
name: Unit Tests
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
- name: Install Dependencies
run: composer install
run: |
composer install
- name: Unit Tests
run: composer test
terminus-3:
needs: unit
runs-on: ubuntu-latest
container:
image: quay.io/pantheon-public/terminus-plugin-test:4.x-php8.0
options: --user root
strategy:
matrix:
php: [7.4, 8.3]
name: Terminus 3 Functional Tests
env:
TERMINUS_SITE: terminus-addons-installer-plugin
TERMINUS_TOKEN: ${{ secrets.TERMINUS_TOKEN }}
BUILD_NUM: ${{ github.run_number }}
PHP_VERSION: ${{ matrix.php }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Install Terminus
run: |
echo "💻 Installing Terminus from phar on Linux..."
curl -L "https://github.com/pantheon-systems/terminus/releases/latest/download/terminus.phar" -o terminus
chmod +x terminus
sudo mv terminus /usr/local/bin/
# Test that terminus works...
terminus --version
- name: Install SSH key
uses: webfactory/ssh-agent@d4b9b8ff72958532804b70bbe600ad43b36d5f2e
with:
Expand All @@ -43,22 +58,35 @@ jobs:
- name: Install plugin
run: |
terminus self:plugin:install ${GITHUB_WORKSPACE}
if [[ "${{ matrix.php }}" == "7.4" ]]; then
composer update
fi
composer install
- name: Install BATS
uses: mig4/setup-bats@v1
- name: Functional Tests
run: composer functional
- name: Cleanup
if: always()
run: ./.bin/cleanup.sh
code-style:
runs-on: ubuntu-latest
container:
image: quay.io/pantheon-public/terminus-plugin-test:4.x-php8.2
options: --user root
name: Code Style
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.4, 8.3]
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Dependencies
run: composer install
run: |
if [[ "${{ matrix.php }}" == "7.4" ]]; then
composer update
fi
composer install
- name: Code Style
run: composer cs
run: composer lint
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
"scripts": {
"cs": "phpcs --standard=PSR2 -n src",
"cbf": "phpcbf --standard=PSR2 -n src",
"lint": "find src -name '*.php' -print0 | xargs -0 -n1 php -l",
"phplint": "find src -name '*.php' -print0 | xargs -0 -n1 php -l",
"lint": [
"@phplint",
"@cs"
],
"unit": "phpunit --colors=always tests",
"functional": [
"Composer\\Config::disableProcessTimeout",
Expand Down
Loading

0 comments on commit 642cdac

Please sign in to comment.