diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a91bb2e..223058a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,9 +2,13 @@ name: Tests on: push: - branches: [main] + branches: [ master ] pull_request: - branches: [main] + branches: [ master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: test: @@ -14,14 +18,48 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.2", "8.3"] - laravel: ["9.*", "10.*", "11.*", "12.*"] - exclude: - # Laravel 11+ requires PHP 8.2+, already satisfied here. - # Laravel 9 and 10 are compatible with PHP 8.2 and 8.3. - # No exclusions needed, but keep this block for clarity. + include: + # Laravel 8 — testbench ^6.0 supports PHP 7.3–8.1 + - php: "8.1" + laravel: "8.*" + testbench: "^6.0" + allow_insecure: true + # Laravel 9 — testbench ^7.0 supports PHP 8.0–8.1 + - php: "8.1" + laravel: "9.*" + testbench: "^7.0" + allow_insecure: true + # Laravel 10 — testbench ^8.0 supports PHP 8.1–8.3 + - php: "8.1" + laravel: "10.*" + testbench: "^8.0" + allow_insecure: false + - php: "8.2" + laravel: "10.*" + testbench: "^8.0" + allow_insecure: false + - php: "8.3" + laravel: "10.*" + testbench: "^8.0" + allow_insecure: false + # Laravel 11 — testbench ^9.0 supports PHP 8.2–8.3 - php: "8.2" - laravel: "9.*" # Laravel 9 supports PHP 8.0+, valid combo + laravel: "11.*" + testbench: "^9.0" + allow_insecure: false + - php: "8.3" + laravel: "11.*" + testbench: "^9.0" + allow_insecure: false + # Laravel 12 — testbench ^10.0 supports PHP 8.2–8.3 + - php: "8.2" + laravel: "12.*" + testbench: "^10.0" + allow_insecure: false + - php: "8.3" + laravel: "12.*" + testbench: "^10.0" + allow_insecure: false steps: - name: Checkout @@ -34,11 +72,16 @@ jobs: extensions: mbstring, pdo, pdo_sqlite, sqlite3 coverage: none + - name: Allow insecure packages + if: ${{ matrix.allow_insecure == true }} + run: composer config audit.block-insecure false + - name: Install dependencies run: | composer require "illuminate/support:${{ matrix.laravel }}" \ "illuminate/database:${{ matrix.laravel }}" \ "illuminate/console:${{ matrix.laravel }}" \ + "orchestra/testbench:${{ matrix.testbench }}" \ --no-update composer update --prefer-stable --prefer-dist --no-interaction diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..89ac437 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026-present Yoeri Walstra & collaborators + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/composer.json b/composer.json index 20a346e..63b8198 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,13 @@ } ], "require": { - "php": "^8.2", - "illuminate/console": "^9.0|^10.0|^11.0|^12.0", - "illuminate/database": "^9.0|^10.0|^11.0|^12.0", - "illuminate/support": "^9.0|^10.0|^11.0|^12.0" + "php": "^8.1", + "illuminate/console": "^8.0|^9.0|^10.0|^11.0|^12.0", + "illuminate/database": "^8.0|^9.0|^10.0|^11.0|^12.0", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0" }, "require-dev": { - "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", + "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0", "phpunit/phpunit": "^9.0|^10.0|^11.0" }, "autoload": { diff --git a/src/Console/Commands/ResourceCleanupCommand.php b/src/Console/Commands/ResourceCleanupCommand.php index 9fd2ec9..31da1ce 100644 --- a/src/Console/Commands/ResourceCleanupCommand.php +++ b/src/Console/Commands/ResourceCleanupCommand.php @@ -47,7 +47,7 @@ public function handle(): int if ($this->option('dry-run')) { $count = $query->count(); - $this->line(sprintf(' [dry-run] %s: %d record(s) would be deleted.', $modelClass, $count)); + $this->line(sprintf('[dry-run] %s: %d record(s) would be deleted.', $modelClass, $count)); $totalDeleted += $count; @@ -62,7 +62,7 @@ public function handle(): int } }); - $this->line(sprintf(' %s: %d record(s) deleted.', $modelClass, $deleted)); + $this->line(sprintf('%s: %d record(s) deleted.', $modelClass, $deleted)); $totalDeleted += $deleted; } diff --git a/tests/Feature/ResourceCleanupCommandTest.php b/tests/Feature/ResourceCleanupCommandTest.php index 3280496..cce5ee7 100644 --- a/tests/Feature/ResourceCleanupCommandTest.php +++ b/tests/Feature/ResourceCleanupCommandTest.php @@ -28,6 +28,7 @@ public function test_dry_run_without_soft_deletes(): void TestResource::create(['name' => 'recent']); $this->artisan('resource-cleanup:run --dry-run') + ->expectsOutput('[dry-run] ' . TestResource::class . ': 3 record(s) would be deleted.') ->expectsOutput('Done. Total: 3 record(s) would be deleted.') ->assertSuccessful(); @@ -62,10 +63,12 @@ public function test_resource_cleanup_deletes_old_records_without_soft_deletes() $old = Carbon::now()->subDays(91); TestResource::create(['name' => 'old-1', 'created_at' => $old]); TestResource::create(['name' => 'old-2', 'created_at' => $old]); + TestResource::create(['name' => 'old-3', 'created_at' => $old]); TestResource::create(['name' => 'recent']); $this->artisan('resource-cleanup:run') - ->expectsOutput('Done. Total: 2 record(s) deleted.') + ->expectsOutput(TestResource::class . ': 3 record(s) deleted.') + ->expectsOutput('Done. Total: 3 record(s) deleted.') ->assertSuccessful(); $this->assertSame(0, TestResource::where('name', 'like', 'old-%')->count()); @@ -118,7 +121,7 @@ public function test_resource_cleanup_valid_model_options(): void TestSoftDeletableResource::create(['name' => 'old', 'created_at' => $old])->delete(); $this->artisan('resource-cleanup:run', ['--model' => [TestSoftDeletableResource::class]]) - ->expectsOutput(' ' . TestSoftDeletableResource::class . ': 1 record(s) deleted.') + ->expectsOutput(TestSoftDeletableResource::class . ': 1 record(s) deleted.') ->assertSuccessful(); }