Skip to content

Commit

Permalink
[CMSP-695] Filter WP font_dir (#29)
Browse files Browse the repository at this point in the history
* use the downloaded tmp directory to source the wp-latest.json

* add fonts namespace and font dir mods

* load our font dir mods
we're loading after pantheon-updates because that's where the get_current_wordpress_version helper is defined

* initial hello world tests

* test the pantheon_font_dir function works as expected

* allow a nightly version of WP to be installed

* handle installed nightly releases for testing

* create wp-config for nightly wp if one doesn't exist

* install latest gutenberg if we're running tests on latest wp
this allows us to test things that are in gutenberg but haven't been merged into core yet

* fix spacing

* Add font library retrieval function from Gutenberg

* change how we identify whether to skip the test
check wp version and then maybe pull font library out of gutenberg

* Add test for our font directory filtering

* use a function to get the modify fonts dir value

* use the new function rather than a constant

* don't add our own filter
we don't need a filter if users can just filter it themselves.

* lower the priority of our font_dir filter
this means that if a customer adds the filter with the default priority, it will override our modification.

* test that lowering the priority and filtering font_dir overrides our modification

* test disabling our font dir modification

* linting fixes

* fix download function for shellcheck

* check if the file exists first

* install wp-cli for tests

* move multisite tests to run before nightly tests

* setup nightly tests

* use latest checkout

* remove reference to non-existant filter

* return after marking test skipped

* maybe we need to check against latest 6.4.x

* explicitly skip tests if wp_get_font_dir does not exist after trying to load gberg

* don't remove non-existant file

* better prompt for local install

* turn on debugging for phpunit test

* remove the rm's which apparently aren't doing anything

* don't define a path
because I guess we're installing in the current directory

* try /tmp/wordpress

* remove debug mode

* add labels and dividers between each run

* add composer-diff workflow

* fix prerelease check logic

* capital W and P, i guess, dangit

* test on all PHPs

* break wp_get_upload_dir out to a global

* use our global for the wp_upload_dir

* switch the wp_ prefix for pantheon_
so we don't ever end up with accidental naming clashes

* ignore unused variable
it's not actually unused

* Mock our pantheon_upload_dir global so we can test against it

* don't prefix property with an underscore

* linting fixes

* simplify font dir

Co-authored-by: Phil Tyler <[email protected]>

* remove function and just use the filter

* remove wp version checks and rely on wp_get_font_dir check

* remove function call
because function no longer exists

* use wpunit-helpers instead of our own files

* remove shellcheck action
we don't need it since these are shellchecked at the source

* allow the wpunit-helpers plugin

* gitignore the scripts sourced by wpunit-helpers

* after copying the files, we need to chmod them, so hook to post-install and post-update

* update syntax and add a nightly script

* bump actions/cache

* use the new release

---------

Co-authored-by: Phil Tyler <[email protected]>
  • Loading branch information
jazzsequence and pwtyler authored Feb 13, 2024
1 parent 133425b commit 7d1d919
Show file tree
Hide file tree
Showing 13 changed files with 362 additions and 270 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/composer-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Composer Diff
on:
pull_request:
paths:
- 'composer.lock'
permissions:
contents: write
pull-requests: write
jobs:
composer-diff:
name: Composer Diff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate composer diff
id: composer_diff
uses: IonBazan/composer-diff-action@v1
- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }}
with:
header: composer-diff
message: |
<summary>Composer Changes</summary>
${{ steps.composer_diff.outputs.composer_diff }}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Lint
run: |
composer install
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/shellcheck.yml

This file was deleted.

24 changes: 18 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: PHP Compatibility
uses: pantheon-systems/phpcompatibility-action@dev
with:
Expand All @@ -26,23 +26,35 @@ jobs:
services:
mariadb:
image: mariadb:10.6
strategy:
matrix:
php_version: [7.4, 8.1, 8.3] # Versions represent newest 7.x, WP supported with exclusions, and beta support.
steps:
- uses: actions/checkout@v3
- name: Setup PHP 8.3
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
php-version: ${{ matrix.php_version }}
extensions: mysqli, zip, imagick
- name: Start MySQL
run: sudo systemctl start mysql
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/vendor
key: test-phpunit-dependencies-${{ hashFiles('composer.json') }}
restore-keys: test-phpunit-dependencies-${{ hashFiles('composer.json') }}
- name: Install Composer dependencies
run: composer install
run: |
if [ ${{ matrix.php_version }} = "7.4" ]; then
composer update
fi
composer install
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
- name: Run PHPUnit
run: bash ./bin/phpunit-test.sh

8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Ignore composer files.
/vendor
composer.lock
composer.lock

# Ignore bin files copied from wpunit-helpers
/bin/install-local-tests.sh
/bin/install-wp-tests.sh
/bin/phpunit-test.sh
/bin/helpers.sh
61 changes: 0 additions & 61 deletions bin/install-local-tests.sh

This file was deleted.

151 changes: 0 additions & 151 deletions bin/install-wp-tests.sh

This file was deleted.

29 changes: 0 additions & 29 deletions bin/phpunit-test.sh

This file was deleted.

18 changes: 15 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@
},
"require-dev": {
"pantheon-systems/pantheon-wp-coding-standards": "^2.0",
"pantheon-systems/wpunit-helpers": "^2.0",
"phpunit/phpunit": "^9",
"yoast/phpunit-polyfills": "^2.0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"pantheon-systems/wpunit-helpers": true
}
},
"scripts": {
"chmod-scripts": [
"chmod +x bin/*.sh"
],
"post-install-cmd": [
"@chmod-scripts"
],
"post-update-cmd": [
"@chmod-scripts"
],
"lint": [
"@phplint",
"@phpcs"
Expand All @@ -30,7 +41,8 @@
"@test:multisite"
],
"test:multisite": "WP_MULTISITE=1 vendor/bin/phpunit --colors=always",
"test:install": "bin/install-local-tests.sh --no-db",
"test:install:withdb": "bin/install-local-tests.sh"
"test:install": "bin/install-local-tests.sh --skip-db=true",
"test:install:withdb": "bin/install-local-tests.sh",
"test:install:nightly": "bin/install-local-tests.sh --version=nightly --skip-db=true"
}
}
Loading

0 comments on commit 7d1d919

Please sign in to comment.