-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from alleyinteractive/performance/schedule
Improve garabge collector performance by using standalone interval
- Loading branch information
Showing
9 changed files
with
111 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: "All Pull Request Tests" | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
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: | ||
matrix: | ||
php: [8.1, 8.2, 8.3] | ||
wordpress: ["latest"] | ||
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 }} | ||
cancel-in-progress: true | ||
# Name the job in the matrix | ||
name: "PR Tests PHP ${{ matrix.php }} WordPress ${{ matrix.wordpress }}" | ||
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 }}' | ||
wordpress-version: '${{ matrix.wordpress }}' | ||
skip-wordpress-install: 'true' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
namespace AI_Logger\Tests; | ||
|
||
use AI_Logger\AI_Logger_Garbage_Collector; | ||
use Mantle\Testkit\Test_Case; | ||
|
||
/** | ||
* Test for the Garbage Collector. | ||
*/ | ||
class GarbageCollectorTest extends Test_Case { | ||
public function test_it_schedules_the_cron_event() { | ||
$this->assertInCronQueue( AI_Logger_Garbage_Collector::CRON_HOOK ); | ||
} | ||
|
||
public function test_it_runs_cleanup() { | ||
$this->expectApplied( 'ai_logger_garbage_collector_max_age' )->andReturnInteger(); | ||
|
||
$old_log_id = static::factory()->post->for( 'ai_log' )->create( [ | ||
'post_date' => date( 'Y-m-d H:i:s', strtotime( '-1 month' ) ), | ||
] ); | ||
|
||
$recent_log_id = static::factory()->post->for( 'ai_log' )->create(); | ||
|
||
AI_Logger_Garbage_Collector::run_cleanup( false ); | ||
|
||
$this->assertInstanceOf( \WP_Post::class, get_post( $recent_log_id ) ); | ||
$this->assertNull( get_post( $old_log_id ) ); | ||
} | ||
} |