Skip to content

Commit

Permalink
Merge branch 'main' into 97-set-jetpack-to-staging-on-non-production-…
Browse files Browse the repository at this point in the history
…sites
  • Loading branch information
srtfisher authored Sep 4, 2024
2 parents edcceec + 782ddcf commit e45b280
Show file tree
Hide file tree
Showing 39 changed files with 347 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{php,neon}]
[*.{php,neon,php.hbs}]
indent_size = 4
indent_style = tab

Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/all-pr-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "All Pull Request Tests"

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
# We use a single job to ensure that all steps run in the same environment and
# reduce the number of minutes used.
pr-tests:
# Don't run on draft PRs
if: github.event.pull_request.draft == false
# Timeout after 10 minutes
timeout-minutes: 10
# Define a matrix of PHP/WordPress versions to test against
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2, 8.3]
wordpress: ["latest"]
multisite: [false, true]
runs-on: ubuntu-latest
# Cancel any existing runs of this workflow
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-P${{ matrix.php }}-WP${{ matrix.wordpress }}-MS${{ matrix.multisite }}
cancel-in-progress: true
# Name the job in the matrix
name: "PR Tests PHP ${{ matrix.php }} WordPress ${{ matrix.wordpress }} Multisite ${{ matrix.multisite }}"
steps:
- uses: actions/checkout@v4

- name: Run General Tests
# See https://github.com/alleyinteractive/action-test-general for more options
uses: alleyinteractive/action-test-general@develop

- name: Run PHP Tests
# See https://github.com/alleyinteractive/action-test-php for more options
uses: alleyinteractive/action-test-php@develop
with:
php-version: '${{ matrix.php }}'
skip-audit: 'true'
skip-wordpress-install: 'true'
wordpress-version: '${{ matrix.wordpress }}'
wordpress-multisite: '${{ matrix.multisite }}'
35 changes: 0 additions & 35 deletions .github/workflows/cs.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/tests.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .scaffolder/feature/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: wp-alleyvate@feature

inputs:
- name: featureName
description: "Feature Name"
type: string
- name: tests
description: "Include Tests?"
type: boolean
default: true

files:
- source: feature.php.hbs
destination: src/alley/wp/alleyvate/features/{{ wpClassFilename inputs.featureName }}
- source: test.php.hbs
if: "{{ inputs.tests }}"
destination: tests/alley/wp/alleyvate/features/{{ wpClassFilename inputs.featureName prefix="test-" }}
27 changes: 27 additions & 0 deletions .scaffolder/feature/feature.php.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Class file for {{ wpClassName inputs.featureName }}
*
* (c) Alley <info@alley.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package wp-alleyvate
*/

namespace Alley\WP\Alleyvate\Features;

use Alley\WP\Types\Feature;

/**
* {{ wpClassName inputs.featureName }} feature.
*/
final class {{ wpClassName inputs.featureName }} implements Feature {
/**
* Boot the feature.
*/
public function boot(): void {
// ...
}
}
51 changes: 51 additions & 0 deletions .scaffolder/feature/test.php.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Class file for {{ wpClassName inputs.featureName prefix="Test_" }}
*
* (c) Alley <info@alley.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package wp-alleyvate
*/

declare( strict_types=1 );

namespace Alley\WP\Alleyvate\Features;

use Mantle\Testing\Concerns\Refresh_Database;
use Mantle\Testkit\Test_Case;

/**
* Tests for {{ wpClassName inputs.featureName }} feature.
*/
final class {{ wpClassName inputs.featureName prefix="Test_" }} extends Test_Case {
use Refresh_Database;

/**
* Feature instance.
*
* @var {{ wpClassName inputs.featureName }}
*/
private {{ wpClassName inputs.featureName }} $feature;

/**
* Set up.
*/
protected function setUp(): void {
parent::setUp();

$this->feature = new {{ wpClassName inputs.featureName }}();
}

/**
* Example Test.
*/
public function test_example(): void {
// Activate the feature.
$this->feature->boot();

$this->assertTrue( true );
}
}
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

This library adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/en/1.0.0/).

## Unreleased
## 3.3.0

### Added

* `disable_site_health_directories`: Added a feature to disable the site health check for information about the WordPress directories and their sizes.

## 3.2.0

### Added

* `disable_apple_news_non_prod_push`: Added a feature to disable pushing to Apple News when not on a production environment.

### Fixed

* `force_two_factor_authentication`: Fixed an infinite loop issue on VIP sites.

## 3.1.0

### Added
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ which have been shown to force those environments to use an insecure protocol at

This feature disables sending password change notification emails to site admins.

### `disable_site_health_directories`

This feature disables the site health check for information about the WordPress directories and their sizes.

### `disable_sticky_posts`

This feature disables WordPress sticky posts entirely, including the ability to set and query sticky posts.


### `disable_trackbacks`

This feature disables WordPress from sending or receiving trackbacks or pingbacks.
Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,36 @@
"require-dev": {
"alleyinteractive/alley-coding-standards": "^2.0",
"friendsofphp/php-cs-fixer": "^3.8",
"mantle-framework/testkit": "^0.12",
"mantle-framework/testkit": "^1.0",
"szepeviktor/phpstan-wordpress": "^1.3"
},
"scripts": {
"fixer": "php-cs-fixer -v fix --allow-risky=yes",
"fixer:test": "php-cs-fixer fix -v --dry-run --stop-on-violation --using-cache=no --allow-risky=yes",
"lint": [
"@phpcs",
"@fixer:test",
"@phpstan"
],
"phpcbf": "phpcbf",
"phpcs": "phpcs",
"phpstan": "phpstan --memory-limit=768M",
"phpunit": "phpunit",
"scaffold": "npx npx @alleyinteractive/scaffolder@latest wp-alleyvate@feature",
"test": [
"@lint",
"@phpunit"
]
},
"autoload-dev": {
"psr-4": {
"Alley\\WP\\Alleyvate\\": "tests/Alley/WP/Alleyvate"
}
},
"extra": {
"wordpress-autoloader": {
"autoload": {
"Alley\\": "src/alley/"
},
"autoload-dev": {
"Alley\\": "tests/alley/"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
<exclude-pattern>tests/</exclude-pattern>
</rule>

<!-- Allow PSR-4 in all test files -->
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>tests/</exclude-pattern>
</rule>

<!-- In effect, set the minimum supported version of WordPress to the latest version. -->
<config name="minimum_supported_wp_version" value="99.0"/>
</ruleset>
14 changes: 7 additions & 7 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
cacheDirectory=".phpunit.result.cache"
>
<testsuite name="unit">
<directory suffix=".php">tests/alley/wp/</directory>
</testsuite>
<testsuite name="unit">
<directory suffix="Test.php">tests/Alley/WP/</directory>
</testsuite>
</phpunit>
2 changes: 1 addition & 1 deletion src/alley/wp/alleyvate/class-feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function add_debug_information( $info ): array {

$info['wp-alleyvate']['fields'] ??= [];
$info['wp-alleyvate']['fields'][] = [
'label' => sprintf(
'label' => \sprintf(
/* translators: %s: Feature name. */
__( 'Feature: %s', 'alley' ),
$this->handle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function filter__posts_where( $where, $wp_query ) {
}

wp_die(
sprintf(
\sprintf(
/* translators: The maximum number of pages. */
esc_html__( 'Invalid Request: Pagination beyond page %d has been disabled for performance reasons.', 'alley' ),
esc_html( $max_pages ),
Expand Down
Loading

0 comments on commit e45b280

Please sign in to comment.