Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI #16

Merged
merged 52 commits into from
Jun 26, 2024
Merged

CI #16

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
84a0877
wip
timacdonald May 25, 2024
19da7a9
wip
timacdonald May 26, 2024
c9822f5
wip
timacdonald May 26, 2024
cc4ef52
wip
timacdonald May 26, 2024
b0f6f25
wip
timacdonald May 26, 2024
3c82b4d
wip
timacdonald May 28, 2024
93495fa
wip
timacdonald May 28, 2024
c37aeb0
wip
timacdonald May 28, 2024
ef31d7f
wip
timacdonald May 28, 2024
58df481
wip
timacdonald May 28, 2024
cae09bf
wip
timacdonald May 28, 2024
e18a419
wip
timacdonald May 28, 2024
1a57271
wip
timacdonald May 28, 2024
8e051e6
wip
timacdonald May 28, 2024
81915e3
wip
timacdonald May 28, 2024
e6db53b
wip
timacdonald Jun 21, 2024
f170b0a
wip
timacdonald Jun 21, 2024
b9bc05e
wip
timacdonald Jun 21, 2024
d679fd6
wip
timacdonald Jun 21, 2024
336aa82
wip
timacdonald Jun 21, 2024
aba1f56
wip
timacdonald Jun 21, 2024
524a30d
wip
timacdonald Jun 21, 2024
3f80ce0
wip
timacdonald Jun 21, 2024
5230278
wip
timacdonald Jun 21, 2024
42371a4
wip
timacdonald Jun 21, 2024
e65c3ae
wip
timacdonald Jun 21, 2024
2ec3ed7
wip
timacdonald Jun 21, 2024
657a94a
wip
timacdonald Jun 21, 2024
5758fcb
wip
timacdonald Jun 22, 2024
bd9b2ff
wip
timacdonald Jun 22, 2024
590db55
wip
timacdonald Jun 22, 2024
74dac3e
wip
timacdonald Jun 22, 2024
bd207ef
wip
timacdonald Jun 22, 2024
ebec2fe
wip
timacdonald Jun 22, 2024
313e361
wip
timacdonald Jun 22, 2024
48828db
wip
timacdonald Jun 22, 2024
0f0fe84
Update main.yml
timacdonald Jun 23, 2024
a4757f4
wip
timacdonald Jun 23, 2024
3874ad0
Improve tests
timacdonald Jun 25, 2024
47a004f
wip
timacdonald Jun 25, 2024
0f338d1
wip
timacdonald Jun 25, 2024
384065d
wip
timacdonald Jun 25, 2024
619d6e3
wip
timacdonald Jun 25, 2024
0b3ef35
wip
timacdonald Jun 25, 2024
197a7e7
wip
timacdonald Jun 26, 2024
6de8536
wip
timacdonald Jun 26, 2024
bc21008
wip
timacdonald Jun 26, 2024
bbc092e
wip
timacdonald Jun 26, 2024
045c870
wip
timacdonald Jun 26, 2024
8b50e71
Compile Assets
timacdonald Jun 26, 2024
6a6613d
wip
timacdonald Jun 26, 2024
bb01fcf
wip
timacdonald Jun 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: latest

- name: Install NPM dependencies
run: npm ci

- name: Compile assets
run: npm run build

- name: Commit compiled files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Compile Assets
file_pattern: dist/
99 changes: 99 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
checks:
runs-on: ubuntu-latest
name: 'Check'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: pcov
tools: infection, pint, phpstan

- name: Install dependencies
run: composer install

- name: Check platform requirements
run: composer check-platform-reqs

- name: Pint
run: pint --test

# Pest does not support Infection. Might need to migrate to PHPUnit.
- name: Infection
run: infection --show-mutations

- name: PHPStan
run: phpstan -v

tests:
runs-on: ubuntu-latest
name: 'PHP ${{ matrix.php }} Testbench ${{ matrix.testbench }} PHPUnit ${{ matrix.phpunit }}'
strategy:
matrix:
php: ['8.1', '8.2', '8.3']
include:
- php: '8.1'
testbench: '8.0'
phpunit: '10'
- php: '8.2'
testbench: '9.0'
phpunit: '11'
- php: '8.3'
testbench: '9.0'
phpunit: '11'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-testbench-${{ matrix.testbench }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-testbench-${{ matrix.testbench }}-composer-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Install dependencies
run: |
composer require --no-update --dev \
orchestra/testbench:^${{ matrix.testbench }}
composer update

- name: Configure PHPUnit
run: "if [ -f './phpunit.${{ matrix.phpunit }}.xml' ]; then cp ./phpunit.${{ matrix.phpunit }}.xml ./phpunit.xml; fi"

- name: PHPUnit
run: ./vendor/bin/phpunit --do-not-cache-result

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/composer.lock
/node_modules
/vendor
/.phpunit.cache
27 changes: 9 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,12 @@
},
"require-dev": {
"inertiajs/inertia-laravel": "^1.0",
"orchestra/pest-plugin-testbench": "^2.0",
"orchestra/testbench": "^9.0",
"pestphp/pest": "^2.0"
},
"extra": {
"laravel": {
"providers": [
"TiMacDonald\\Pulse\\ValidationErrorsServiceProvider"
]
}
"phpunit/phpunit": "^10.0 || ^11.0"
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
"sort-packages": true
},
"autoload": {
"psr-4": {
Expand All @@ -54,6 +43,13 @@
},
"minimum-stability": "stable",
"prefer-stable": true,
"extra": {
"laravel": {
"providers": [
"TiMacDonald\\Pulse\\ValidationErrorsServiceProvider"
]
}
},
"scripts": {
"post-autoload-dump": [
"@php vendor/bin/testbench package:purge-skeleton --ansi",
Expand All @@ -64,10 +60,5 @@
"@php vendor/bin/testbench workbench:build --ansi",
"@php vendor/bin/testbench serve"
]
},
"support": {
"issues": "https://github.com/timacdonald/pulse-validation-errors/issues",
"source": "https://github.com/timacdonald/pulse-validation-errors/releases/latest",
"docs": "https://github.com/timacdonald/pulse-validation-errors/blob/master/readme.md"
}
}
1 change: 1 addition & 0 deletions dist/validation.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions infection.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"source": {
"directories": [
"src"
]
},
"mutators": {
"@default": true,
"@function_signature": false
},
"minMsi": 100
}
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: max
paths:
- src
26 changes: 26 additions & 0 deletions phpunit.10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
failOnNotice="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
<php>
<env name="APP_KEY" value="base64:vFI2dJxJeGFdbe7JXMJkE6iIv0dKBCNBw/9hZJVF/UM="/>
<env name="DB_CONNECTION" value="testing"/>
<env name="PULSE_CACHE_DRIVER" value="array"/>
</php>
</phpunit>
20 changes: 16 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
failOnNotice="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="testsuite">
<directory suffix="Test.php">./tests/</directory>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
<php>
<env name="APP_KEY" value="base64:vFI2dJxJeGFdbe7JXMJkE6iIv0dKBCNBw/9hZJVF/UM="/>
<env name="DB_CONNECTION" value="testing"/>
<env name="PULSE_CACHE_DRIVER" value="array"/>
</php>
</phpunit>

2 changes: 1 addition & 1 deletion resources/views/validation-errors.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</p>
</x-pulse::td>
<x-pulse::td numeric class="text-gray-700 dark:text-gray-300 font-bold w-32">
@if ($config['sample_rate'] < 1)
@if ($config['sample_rate'] !== 1)
<span title="Sample rate: {{ $config['sample_rate'] }}, Raw value: {{ number_format($error->count) }}">~{{ number_format($error->count * (1 / $config['sample_rate'])) }}</span>
@else
{{ number_format($error->count) }}
Expand Down
11 changes: 4 additions & 7 deletions src/Cards/ValidationErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function render(): Renderable
'validation_error',
['count'],
$this->periodAsInterval(),
)->map(function ($row) {
)->map(function (object $row) { // @phpstan-ignore argument.type
/** @var object{ key: string, count: int } $row */
[$method, $uri, $action, $bag, $name, $message] = json_decode($row->key, flags: JSON_THROW_ON_ERROR) + [5 => null];

return (object) [
Expand All @@ -46,19 +47,15 @@ public function render(): Renderable
'count' => $row->count,
'key_hash' => md5($row->key),
];
}),
);
}));

return View::make('timacdonald::validation-errors', [
'time' => $time,
'runAt' => $runAt,
'errors' => $errors,
'config' => [
'enabled' => true,
'sample_rate' => 1,
'capture_messages' => true,
'ignore' => [],
...Config::get('pulse.recorders.'.ValidationErrorsRecorder::class, []),
...Config::get('pulse.recorders.'.ValidationErrorsRecorder::class, []), // @phpstan-ignore arrayUnpacking.nonIterable
],
]);
}
Expand Down
Loading