-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CMSP-678]: PHP 8.3 compatibility and code improvements
- Loading branch information
Showing
16 changed files
with
214 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,76 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: pantheon-systems/validate-readme-spacing@v1 | ||
- uses: pantheon-systems/validate-readme-spacing@v1 | ||
lint: | ||
name: PHPCS Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/vendor | ||
key: test-lint-dependencies-{{ checksum "composer.json" }} | ||
restore-keys: test-lint-dependencies-{{ checksum "composer.json" }} | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.3 | ||
- name: Install dependencies | ||
run: composer install -n --prefer-dist | ||
- name: Run PHPCS | ||
run: composer lint | ||
php8-compatibility: | ||
name: PHP 8.x Compatibility | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: pantheon-systems/phpcompatibility-action@dev | ||
with: | ||
paths: ${{ github.workspace }}/*.php ${{ github.workspace }}/inc/*.php | ||
test-versions: 8.0- | ||
wporg-validation: | ||
name: WP.org Plugin Validation | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: pantheon-systems/[email protected] | ||
with: | ||
type: 'plugin' | ||
test: | ||
needs: lint | ||
name: Test | ||
runs-on: ubuntu-latest | ||
services: | ||
mariadb: | ||
image: mariadb:10.5 | ||
strategy: | ||
matrix: | ||
php_version: [7.4, 8.2, 8.3] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php_version }} | ||
extensions: mysqli, zip, imagick | ||
- name: Start MySQL Service | ||
run: sudo systemctl start mysql | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/vendor | ||
key: test-dependencies-{{ checksum "composer.json" }} | ||
restore-keys: test-dependencies-{{ checksum "composer.json" }} | ||
- name: Install dependencies | ||
run: | | ||
if [ ${{ matrix.php_version }} = "7.4" ]; then | ||
composer update | ||
fi | ||
composer install | ||
- name: Run PHPUnit | ||
run: bash ./bin/phpunit-test.sh |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Shellcheck | ||
on: | ||
push: | ||
paths: | ||
- 'bin/*.sh' | ||
jobs: | ||
shellcheck: | ||
name: Shellcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Shellcheck | ||
run: find bin/ -name "*.sh" | grep -v "install-wp-tests.sh" | xargs shellcheck |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,6 @@ | |
# such that it can be run a second time if a step fails. | ||
### | ||
|
||
terminus whoami > /dev/null | ||
if [ $? -ne 0 ]; then | ||
echo "Terminus unauthenticated; assuming unauthenticated build" | ||
exit 0 | ||
fi | ||
|
||
if [ -z "$TERMINUS_SITE" ] || [ -z "$TERMINUS_ENV" ]; then | ||
echo "TERMINUS_SITE and TERMINUS_ENV environment variables must be set" | ||
exit 1 | ||
|
@@ -27,58 +21,58 @@ set -ex | |
### | ||
# Create a new environment for this particular test run. | ||
### | ||
terminus env:create $TERMINUS_SITE.dev $TERMINUS_ENV | ||
terminus env:wipe $SITE_ENV --yes | ||
terminus env:create "${TERMINUS_SITE}.dev" "$TERMINUS_ENV" | ||
terminus env:wipe "$SITE_ENV" --yes | ||
|
||
### | ||
# Get all necessary environment details. | ||
### | ||
PANTHEON_GIT_URL=$(terminus connection:info $SITE_ENV --field=git_url) | ||
PANTHEON_GIT_URL=$(terminus connection:info "$SITE_ENV" --field=git_url) | ||
PANTHEON_SITE_URL="$TERMINUS_ENV-$TERMINUS_SITE.pantheonsite.io" | ||
PREPARE_DIR="/tmp/$TERMINUS_ENV-$TERMINUS_SITE" | ||
BASH_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
### | ||
# Switch to git mode for pushing the files up | ||
### | ||
terminus connection:set $SITE_ENV git | ||
rm -rf $PREPARE_DIR | ||
git clone -b $TERMINUS_ENV $PANTHEON_GIT_URL $PREPARE_DIR | ||
terminus connection:set "$SITE_ENV" git | ||
rm -rf "$PREPARE_DIR" | ||
git clone -b "$TERMINUS_ENV" "$PANTHEON_GIT_URL" "$PREPARE_DIR" | ||
|
||
### | ||
# Add the copy of this plugin itself to the environment | ||
### | ||
rm -rf $PREPARE_DIR/wp-content/plugins/wp-native-php-sessions | ||
cd $BASH_DIR/.. | ||
rsync -av --exclude='vendor/' --exclude='node_modules/' --exclude='tests/' ./* $PREPARE_DIR/wp-content/plugins/wp-native-php-sessions | ||
rm -rf $PREPARE_DIR/wp-content/plugins/wp-native-php-sessions/.git | ||
rm -rf "$PREPARE_DIR"/wp-content/plugins/wp-native-php-sessions | ||
cd "$BASH_DIR"/.. | ||
rsync -av --exclude='vendor/' --exclude='node_modules/' --exclude='tests/' ./* "$PREPARE_DIR"/wp-content/plugins/wp-native-php-sessions | ||
rm -rf "$PREPARE_DIR"/wp-content/plugins/wp-native-php-sessions/.git | ||
|
||
### | ||
# Add the debugging plugin to the environment | ||
### | ||
rm -rf $PREPARE_DIR/wp-content/mu-plugins/sessions-debug.php | ||
cp $BASH_DIR/fixtures/sessions-debug.php $PREPARE_DIR/wp-content/mu-plugins/sessions-debug.php | ||
rm -rf "$PREPARE_DIR"/wp-content/mu-plugins/sessions-debug.php | ||
cp "$BASH_DIR"/fixtures/sessions-debug.php "$PREPARE_DIR"/wp-content/mu-plugins/sessions-debug.php | ||
|
||
### | ||
# Push files to the environment | ||
### | ||
cd $PREPARE_DIR | ||
cd "$PREPARE_DIR" | ||
git add wp-content | ||
git config user.email "[email protected]" | ||
git config user.name "Pantheon" | ||
git commit -m "Include WP Native PHP Sessions and its configuration files" | ||
git push | ||
|
||
# Sometimes Pantheon takes a little time to refresh the filesystem | ||
terminus build:workflow:wait $TERMINUS_SITE.$TERMINUS_ENV | ||
terminus build:workflow:wait "$TERMINUS_SITE"."$TERMINUS_ENV" | ||
|
||
### | ||
# Set up WordPress, theme, and plugins for the test run | ||
### | ||
# Silence output so as not to show the password. | ||
{ | ||
terminus wp $SITE_ENV -- core install --title=$TERMINUS_ENV-$TERMINUS_SITE --url=$PANTHEON_SITE_URL --admin_user=$WORDPRESS_ADMIN_USERNAME [email protected] --admin_password=$WORDPRESS_ADMIN_PASSWORD | ||
terminus wp "$SITE_ENV" -- core install --title="$TERMINUS_ENV"-"$TERMINUS_SITE" --url="$PANTHEON_SITE_URL" --admin_user="$WORDPRESS_ADMIN_USERNAME" [email protected] --admin_password="$WORDPRESS_ADMIN_PASSWORD" | ||
} &> /dev/null | ||
terminus wp $SITE_ENV -- plugin activate wp-native-php-sessions | ||
terminus wp $SITE_ENV -- theme activate twentytwentythree | ||
terminus wp $SITE_ENV -- rewrite structure '/%year%/%monthnum%/%day%/%postname%/' | ||
terminus wp "$SITE_ENV" -- plugin activate wp-native-php-sessions | ||
terminus wp "$SITE_ENV" -- theme activate twentytwentythree | ||
terminus wp "$SITE_ENV" -- rewrite structure '/%year%/%monthnum%/%day%/%postname%/' |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.