From c833de1b1e2b1b85858fb1a600e2eaa6c9eef950 Mon Sep 17 00:00:00 2001 From: Jeremy Postlethwaite Date: Sat, 6 Jul 2024 09:27:20 -0700 Subject: [PATCH] v73.0.0 --- .github/workflows/ci.yml | 126 ++++++++++++++--------- composer.json | 2 +- database/factories/UserFactory.php | 2 + phpstan.neon.dist | 3 +- phpunit-ci.xml | 77 ++++++++++++++ phpunit.xml.dist | 6 +- src/Models/Contracts/Revision.php | 3 + src/Models/Contracts/WithChildren.php | 3 + src/Models/Contracts/WithCreator.php | 3 + src/Models/Contracts/WithModifier.php | 3 + src/Models/Contracts/WithOwner.php | 3 + src/Models/Contracts/WithParent.php | 3 + src/Models/Scopes/ScopeFilterColumns.php | 6 +- src/Models/Scopes/ScopeFilterDates.php | 3 + src/Models/Scopes/ScopeFilterFlags.php | 3 + src/Models/Scopes/ScopeFilterIds.php | 3 + src/Models/Scopes/ScopeFilterTrash.php | 5 + src/Models/Scopes/ScopeSort.php | 5 + 18 files changed, 202 insertions(+), 57 deletions(-) create mode 100644 phpunit-ci.xml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eadd82e..5cd1999 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: 'CI' +name: "CI" on: push: @@ -30,9 +30,9 @@ jobs: echo "TIMESTAMP_START=$(date +'%s')" >> $GITHUB_OUTPUT - name: "Slack notification: IN PROGRESS" id: slack - uses: slackapi/slack-github-action@v1.25.0 + uses: slackapi/slack-github-action@v1.26.0 with: - channel-id: 'C068A06PV43' + channel-id: "C068A06PV43" payload: | { "text": "CI Build Status for playground: IN PROGRESS\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", @@ -49,11 +49,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Start:*\n${{ steps.timer_start.outputs.DATE_START }}" + "text": "*Start:* " }, { "type": "mrkdwn", - "text": "*End:*\n--" + "text": "*End:* --" } ] }, @@ -71,18 +71,25 @@ jobs: ] }, { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR:* ${{ github.event.pull_request.html_url || github.event.head_commit.url }}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Build:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Merge/Pull Request" + }, + "url": "${{ github.event.pull_request.html_url || github.event.head_commit.url }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Build: ${{ github.run_id }}" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] } ] } @@ -102,6 +109,7 @@ jobs: version: "11.0" php_version: "8.2" php_extensions: intl xdebug + configuration: phpunit-ci.xml coverage_clover: clover.xml coverage_text: true - name: Make code coverage badge @@ -110,7 +118,7 @@ jobs: coverage_badge_path: output/coverage.svg push_badge: false - name: Git push to testing/develop branch - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: publish_dir: ./output publish_branch: testing/develop @@ -122,6 +130,7 @@ jobs: level: 9 php_version: "8.2" path: config/ database/ src/ tests/Feature/ tests/Unit/ + args: --verbose --debug - name: Stopping timer if: ${{ !cancelled() }} id: timer_end @@ -130,10 +139,11 @@ jobs: run: | echo "DATE_END=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT echo "DURATION_PHRASE=$(($(date +'%s')-$TIMESTAMP_START)) seconds" >> $GITHUB_OUTPUT + echo "TIMESTAMP_END=$(date +'%s')" >> $GITHUB_OUTPUT - name: "Slack notification: Done" - uses: slackapi/slack-github-action@v1.25.0 + uses: slackapi/slack-github-action@v1.26.0 with: - channel-id: 'C068A06PV43' + channel-id: "C068A06PV43" update-ts: ${{ steps.slack.outputs.ts }} payload: | { @@ -151,11 +161,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Start:*\n${{ steps.timer_start.outputs.DATE_START }}" + "text": "*Start:* " }, { "type": "mrkdwn", - "text": "*End:*\n${{ steps.timer_end.outputs.DATE_END }}" + "text": "*End:* " } ] }, @@ -173,18 +183,26 @@ jobs: ] }, { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR:* ${{ github.event.pull_request.html_url || github.event.head_commit.url }}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Build:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Merge/Pull Request" + }, + "url": "${{ github.event.pull_request.html_url || github.event.head_commit.url }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Build: ${{ github.run_id }}" + }, + "style": "primary", + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] } ] } @@ -192,9 +210,9 @@ jobs: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} - name: "Send a notification for failures" if: ${{ failure() }} - uses: slackapi/slack-github-action@v1.25.0 + uses: slackapi/slack-github-action@v1.26.0 with: - channel-id: 'C068A06PV43' + channel-id: "C068A06PV43" update-ts: ${{ steps.slack.outputs.ts }} payload: | { @@ -212,11 +230,11 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Start:*\n${{ steps.timer_start.outputs.DATE_START }}" + "text": "*Start:* " }, { "type": "mrkdwn", - "text": "*End:*\n${{ steps.timer_end.outputs.DATE_END }}" + "text": "*End:* " } ] }, @@ -234,18 +252,26 @@ jobs: ] }, { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PR:* ${{ github.event.pull_request.html_url || github.event.head_commit.url }}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Build:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Merge/Pull Request" + }, + "url": "${{ github.event.pull_request.html_url || github.event.head_commit.url }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Build: ${{ github.run_id }}" + }, + "style": "danger", + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] } ] } diff --git a/composer.json b/composer.json index 33a6e0a..e08891d 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ } }, "scripts": { - "test": "vendor/bin/phpunit", + "test": "vendor/bin/testbench package:test", "format": "vendor/bin/php-cs-fixer fix", "analyse": "vendor/bin/phpstan analyse --verbose --debug --level max" } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 931948f..44046f2 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -11,6 +11,8 @@ /** * \Database\Factories\Playground\Models\UserFactory + * + * @extends Factory */ class UserFactory extends Factory { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9306fea..b249ebb 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,4 +17,5 @@ parameters: treatPhpDocTypesAsCertain: false - checkGenericClassInNonGenericObjectType: false + # editorUrl: 'vscode://file/%%file%%:%%line%%' + # editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%' \ No newline at end of file diff --git a/phpunit-ci.xml b/phpunit-ci.xml new file mode 100644 index 0000000..e863b8a --- /dev/null +++ b/phpunit-ci.xml @@ -0,0 +1,77 @@ + + + + + tests/Unit + + + tests/Feature + + + + + + + + + + + + + + + + + + + + + + src + + + + + + + + + + + + + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e863b8a..331ad4f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -27,9 +27,9 @@ tests/Unit - + - + diff --git a/src/Models/Contracts/Revision.php b/src/Models/Contracts/Revision.php index 01ca3e9..afa8563 100644 --- a/src/Models/Contracts/Revision.php +++ b/src/Models/Contracts/Revision.php @@ -6,6 +6,7 @@ */ namespace Playground\Models\Contracts; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; /** @@ -15,6 +16,8 @@ interface Revision { /** * Get the revisions of the model. + * + * @return HasMany */ public function revisions(): HasMany; } diff --git a/src/Models/Contracts/WithChildren.php b/src/Models/Contracts/WithChildren.php index 1a9dff6..175a96e 100644 --- a/src/Models/Contracts/WithChildren.php +++ b/src/Models/Contracts/WithChildren.php @@ -6,6 +6,7 @@ */ namespace Playground\Models\Contracts; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; /** @@ -15,6 +16,8 @@ interface WithChildren { /** * Get the children under the model. + * + * @return HasMany */ public function children(): HasMany; } diff --git a/src/Models/Contracts/WithCreator.php b/src/Models/Contracts/WithCreator.php index 0672af5..c48d0ca 100644 --- a/src/Models/Contracts/WithCreator.php +++ b/src/Models/Contracts/WithCreator.php @@ -6,6 +6,7 @@ */ namespace Playground\Models\Contracts; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; /** @@ -15,6 +16,8 @@ interface WithCreator { /** * Get the creator of the model. + * + * @return HasOne */ public function creator(): HasOne; } diff --git a/src/Models/Contracts/WithModifier.php b/src/Models/Contracts/WithModifier.php index 1febd36..b70491f 100644 --- a/src/Models/Contracts/WithModifier.php +++ b/src/Models/Contracts/WithModifier.php @@ -6,6 +6,7 @@ */ namespace Playground\Models\Contracts; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; /** @@ -15,6 +16,8 @@ interface WithModifier { /** * Get the modifier of the model. + * + * @return HasOne */ public function modifier(): HasOne; } diff --git a/src/Models/Contracts/WithOwner.php b/src/Models/Contracts/WithOwner.php index 553d077..1d25527 100644 --- a/src/Models/Contracts/WithOwner.php +++ b/src/Models/Contracts/WithOwner.php @@ -6,6 +6,7 @@ */ namespace Playground\Models\Contracts; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; /** @@ -15,6 +16,8 @@ interface WithOwner { /** * Get the owner of the model. + * + * @return HasOne */ public function owner(): HasOne; } diff --git a/src/Models/Contracts/WithParent.php b/src/Models/Contracts/WithParent.php index 148a99c..5099aa9 100644 --- a/src/Models/Contracts/WithParent.php +++ b/src/Models/Contracts/WithParent.php @@ -6,6 +6,7 @@ */ namespace Playground\Models\Contracts; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; /** @@ -15,6 +16,8 @@ interface WithParent { /** * Get the parent of the model. + * + * @return HasOne */ public function parent(): HasOne; } diff --git a/src/Models/Scopes/ScopeFilterColumns.php b/src/Models/Scopes/ScopeFilterColumns.php index 28ad2e5..dcd08a9 100644 --- a/src/Models/Scopes/ScopeFilterColumns.php +++ b/src/Models/Scopes/ScopeFilterColumns.php @@ -7,8 +7,8 @@ namespace Playground\Models\Scopes; use Illuminate\Database\Eloquent\Builder; - -// use Illuminate\Support\Facades\Log; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Log; /** * \Playground\Models\Scopes\ScopeFilterColumns @@ -16,8 +16,10 @@ trait ScopeFilterColumns { /** + * @param Builder $query * @param array $columns * @param array $validated + * @return Builder */ public static function scopeFilterColumns( Builder $query, diff --git a/src/Models/Scopes/ScopeFilterDates.php b/src/Models/Scopes/ScopeFilterDates.php index 90ad804..4db9d07 100644 --- a/src/Models/Scopes/ScopeFilterDates.php +++ b/src/Models/Scopes/ScopeFilterDates.php @@ -8,6 +8,7 @@ use Carbon\Exceptions\InvalidFormatException; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Log; @@ -17,8 +18,10 @@ trait ScopeFilterDates { /** + * @param Builder $query * @param array $dates * @param array $validated + * @return Builder */ public static function scopeFilterDates( Builder $query, diff --git a/src/Models/Scopes/ScopeFilterFlags.php b/src/Models/Scopes/ScopeFilterFlags.php index e8ac193..3101cd9 100644 --- a/src/Models/Scopes/ScopeFilterFlags.php +++ b/src/Models/Scopes/ScopeFilterFlags.php @@ -7,6 +7,7 @@ namespace Playground\Models\Scopes; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; /** * \Playground\Models\Scopes\ScopeFilterFlags @@ -14,8 +15,10 @@ trait ScopeFilterFlags { /** + * @param Builder $query * @param array $flags * @param array $validated + * @return Builder */ public static function scopeFilterFlags( Builder $query, diff --git a/src/Models/Scopes/ScopeFilterIds.php b/src/Models/Scopes/ScopeFilterIds.php index 48e1de5..6a430be 100644 --- a/src/Models/Scopes/ScopeFilterIds.php +++ b/src/Models/Scopes/ScopeFilterIds.php @@ -7,6 +7,7 @@ namespace Playground\Models\Scopes; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; use Ramsey\Uuid\Uuid; /** @@ -15,8 +16,10 @@ trait ScopeFilterIds { /** + * @param Builder $query * @param array $ids * @param array $validated + * @return Builder */ public static function scopeFilterIds( Builder $query, diff --git a/src/Models/Scopes/ScopeFilterTrash.php b/src/Models/Scopes/ScopeFilterTrash.php index 7a7de5b..c4f9baa 100644 --- a/src/Models/Scopes/ScopeFilterTrash.php +++ b/src/Models/Scopes/ScopeFilterTrash.php @@ -7,12 +7,17 @@ namespace Playground\Models\Scopes; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; /** * \Playground\Models\Scopes\ScopeFilterTrash */ trait ScopeFilterTrash { + /** + * @param Builder $query + * @return Builder + */ public static function scopeFilterTrash( Builder $query, string $visibility = null diff --git a/src/Models/Scopes/ScopeSort.php b/src/Models/Scopes/ScopeSort.php index 6cccee4..f4d755a 100644 --- a/src/Models/Scopes/ScopeSort.php +++ b/src/Models/Scopes/ScopeSort.php @@ -7,12 +7,17 @@ namespace Playground\Models\Scopes; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; /** * \Playground\Models\Scopes\ScopeSort */ trait ScopeSort { + /** + * @param Builder $query + * @return Builder + */ public static function scopeSort( Builder $query, mixed $sort = null