diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f5a2327c..9dd1121f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,10 +4,10 @@ on: push: branches: - master - - '*.x' + - "*.x" pull_request: schedule: - - cron: '0 0 * * *' + - cron: "0 0 * * *" jobs: mysql: @@ -68,12 +68,11 @@ jobs: - name: Require cachewerk/relay run: | - composer require cachewerk/relay --no-interaction --no-update - if: matrix.php != 8.5 - + composer require cachewerk/relay --no-interaction --no-update + - name: Install dependencies run: | - composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} + composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} - name: Execute tests run: vendor/bin/pest -vvv @@ -131,12 +130,11 @@ jobs: - name: Require cachewerk/relay run: | - composer require cachewerk/relay --no-interaction --no-update - if: matrix.php != 8.5 - + composer require cachewerk/relay --no-interaction --no-update + - name: Install dependencies run: | - composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} + composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} - name: Execute tests run: vendor/bin/pest -vvv @@ -192,12 +190,11 @@ jobs: - name: Require cachewerk/relay run: | - composer require cachewerk/relay --no-interaction --no-update - if: matrix.php != 8.5 + composer require cachewerk/relay --no-interaction --no-update - name: Install dependencies run: | - composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} + composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} - name: Execute tests run: vendor/bin/pest -vvv @@ -244,12 +241,11 @@ jobs: - name: Require cachewerk/relay run: | - composer require cachewerk/relay --no-interaction --no-update - if: matrix.php != 8.5 + composer require cachewerk/relay --no-interaction --no-update - name: Install dependencies run: | - composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} + composer update --prefer-dist --no-interaction --no-progress --${{ matrix.stability }} - name: Execute tests run: vendor/bin/pest -vvv diff --git a/composer.json b/composer.json index ba0aa9c0..3fd2df96 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,9 @@ { "name": "laravel/pulse", "description": "Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.", - "keywords": ["laravel"], + "keywords": [ + "laravel" + ], "homepage": "https://github.com/laravel/pulse", "license": "MIT", "support": { @@ -40,7 +42,7 @@ "mockery/mockery": "^1.0", "orchestra/testbench": "^8.36|^9.15|^10.8", "pestphp/pest": "^2.0|^3.0|^4.0", - "pestphp/pest-plugin-laravel": "^2.2", + "pestphp/pest-plugin-laravel": "^2.2|^3.0|^4.0", "phpstan/phpstan": "^1.12.21", "predis/predis": "^1.0|^2.0" }, @@ -96,4 +98,4 @@ "@php vendor/bin/pest" ] } -} +} \ No newline at end of file diff --git a/src/Recorders/Servers.php b/src/Recorders/Servers.php index d97da1ad..5dc0cca3 100644 --- a/src/Recorders/Servers.php +++ b/src/Recorders/Servers.php @@ -107,10 +107,10 @@ protected function cpu(): int } return match (PHP_OS_FAMILY) { - 'Darwin' => (int) `top -l 1 | grep -E "^CPU" | tail -1 | awk '{ print $3 + $5 }'`, - 'Linux' => (int) `top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'`, - 'Windows' => (int) trim(`wmic cpu get loadpercentage | more +1`), - 'BSD' => (int) `top -b -d 2| grep 'CPU: ' | tail -1 | awk '{print$10}' | grep -Eo '[0-9]+\.[0-9]+' | awk '{ print 100 - $1 }'`, + 'Darwin' => (int) shell_exec("top -l 1 | grep -E \"^CPU\" | tail -1 | awk '{ print $3 + $5 }'"), + 'Linux' => (int) shell_exec("top -bn1 | grep -E '^(%Cpu|CPU)' | awk '{ print $2 + $4 }'"), + 'Windows' => (int) trim((string) shell_exec('wmic cpu get loadpercentage | more +1')), + 'BSD' => (int) shell_exec("top -b -d 2| grep 'CPU: ' | tail -1 | awk '{print$10}' | grep -Eo '[0-9]+\.[0-9]+' | awk '{ print 100 - $1 }'"), default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; } @@ -127,18 +127,18 @@ protected function memory(): array } $memoryTotal = match (PHP_OS_FAMILY) { - 'Darwin' => intval(`sysctl hw.memsize | grep -Eo '[0-9]+'` / 1024 / 1024), - 'Linux' => intval(`cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'` / 1024), - 'Windows' => intval(((int) trim(`wmic ComputerSystem get TotalPhysicalMemory | more +1`)) / 1024 / 1024), - 'BSD' => intval(`sysctl hw.physmem | grep -Eo '[0-9]+'` / 1024 / 1024), + 'Darwin' => intval(intval(shell_exec("sysctl hw.memsize | grep -Eo '[0-9]+'")) / 1024 / 1024), + 'Linux' => intval(intval(shell_exec("cat /proc/meminfo | grep MemTotal | grep -E -o '[0-9]+'")) / 1024), + 'Windows' => intval(((int) trim((string) shell_exec('wmic ComputerSystem get TotalPhysicalMemory | more +1'))) / 1024 / 1024), + 'BSD' => intval(intval(shell_exec("sysctl hw.physmem | grep -Eo '[0-9]+'")) / 1024 / 1024), default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; $memoryUsed = match (PHP_OS_FAMILY) { - 'Darwin' => $memoryTotal - intval(intval(`vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'`) * intval(`pagesize`) / 1024 / 1024), // MB - 'Linux' => $memoryTotal - intval(`cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'` / 1024), // MB - 'Windows' => $memoryTotal - intval(((int) trim(`wmic OS get FreePhysicalMemory | more +1`)) / 1024), // MB - 'BSD' => intval(intval(`( sysctl vm.stats.vm.v_cache_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_inactive_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_active_count | grep -Eo '[0-9]+' ) | awk '{s+=$1} END {print s}'`) * intval(`pagesize`) / 1024 / 1024), // MB + 'Darwin' => $memoryTotal - intval(intval(shell_exec("vm_stat | grep 'Pages free' | grep -Eo '[0-9]+'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB + 'Linux' => $memoryTotal - intval(shell_exec("cat /proc/meminfo | grep MemAvailable | grep -E -o '[0-9]+'")) / 1024, // MB + 'Windows' => $memoryTotal - intval(((int) trim((string) shell_exec('wmic OS get FreePhysicalMemory | more +1'))) / 1024), // MB + 'BSD' => intval(intval(shell_exec("( sysctl vm.stats.vm.v_cache_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_inactive_count | grep -Eo '[0-9]+' ; sysctl vm.stats.vm.v_active_count | grep -Eo '[0-9]+' ) | awk '{s+=$1} END {print s}'")) * intval(shell_exec('pagesize')) / 1024 / 1024), // MB default => throw new RuntimeException('The pulse:check command does not currently support '.PHP_OS_FAMILY), }; diff --git a/src/Users.php b/src/Users.php index 7de0b343..e807bd3d 100644 --- a/src/Users.php +++ b/src/Users.php @@ -47,6 +47,7 @@ public function load(Collection $keys): self if ($provider instanceof EloquentUserProvider) { $model = $provider->getModel(); + // @phpstan-ignore staticMethod.notFound $this->resolvedUsers = $model::findMany($keys); } else { $this->resolvedUsers = $keys->map(fn ($key) => $provider->retrieveById($key));