Skip to content

Commit e99dfb7

Browse files
authored
Add github actions ci/cd (#21)
* Add github actions * Remove 7.4 on check * Pint * Stan level 5 * Stan level 6 * Stan level 7 - ignore error >.< * Stan level 8 * WIP max stan * json encode if value is array * Check text format first * Allow timestamps to be parsed as date * Add force handler for numeric cells * Prioritize wanted user format * Fix model support * Always get string value for text * strval * Add basic test * Add basic test with batch job id response * Fix cs * Process only on ajax request
1 parent bf73743 commit e99dfb7

18 files changed

+509
-126
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
phpunit:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
fail-fast: true
16+
matrix:
17+
php: [8.0, 8.1]
18+
stability: [prefer-stable]
19+
20+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php }}
30+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, memcached
31+
tools: composer:v2
32+
coverage: none
33+
34+
- name: Setup Memcached
35+
uses: niden/actions-memcached@v7
36+
37+
- name: Install dependencies
38+
uses: nick-invision/retry@v1
39+
with:
40+
timeout_minutes: 5
41+
max_attempts: 5
42+
command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
43+
44+
- name: Execute tests
45+
run: vendor/bin/phpunit --verbose

.github/workflows/static-analysis.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
push:
5+
paths:
6+
- .github/workflows/static-analysis.yml
7+
- composer.*
8+
- phpstan.neon.dist
9+
- src/**
10+
- tests/**
11+
12+
pull_request:
13+
paths:
14+
- .github/workflows/static-analysis.yml
15+
- composer.*
16+
- phpstan.neon.dist
17+
- src/**
18+
- tests/**
19+
20+
schedule:
21+
- cron: '0 0 * * *'
22+
23+
jobs:
24+
static-analysis-phpstan:
25+
26+
name: "Static Analysis with PHPStan"
27+
runs-on: ubuntu-latest
28+
29+
strategy:
30+
fail-fast: true
31+
matrix:
32+
php: [8.1]
33+
stability: [prefer-stable]
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v2
38+
39+
- name: Setup PHP
40+
uses: shivammathur/setup-php@v2
41+
with:
42+
php-version: ${{ matrix.php }}
43+
tools: composer:v2
44+
coverage: none
45+
46+
- name: Install dependencies
47+
uses: nick-invision/retry@v1
48+
with:
49+
timeout_minutes: 5
50+
max_attempts: 5
51+
command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
52+
53+
- name: "Run a static analysis with phpstan/phpstan"
54+
run: "vendor/bin/phpstan --error-format=checkstyle"

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

composer.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
"require": {
2020
"php": ">=7.4|8.*",
2121
"yajra/laravel-datatables-buttons": "4.*|9.*",
22-
"yajra/laravel-datatables-html": "^4.40|9.*",
2322
"livewire/livewire": "2.*|3.*",
24-
"openspout/openspout": "^3"
23+
"openspout/openspout": "^3",
24+
"ext-json": "*"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^9.5.9"
27+
"maatwebsite/excel": "^3.1.40",
28+
"nunomaduro/larastan": "^2.1",
29+
"orchestra/testbench": "^7.3"
2830
},
2931
"autoload": {
3032
"psr-4": {
@@ -33,7 +35,15 @@
3335
},
3436
"autoload-dev": {
3537
"psr-4": {
36-
"Yajra\\DataTables\\Tests\\": "tests/"
38+
"Yajra\\DataTables\\Exports\\Tests\\": "tests/"
39+
}
40+
},
41+
"config": {
42+
"preferred-install": "dist",
43+
"sort-packages": true,
44+
"optimize-autoloader": true,
45+
"platform": {
46+
"php": "8.0.2"
3747
}
3848
},
3949
"extra": {

phpstan.neon.dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
includes:
2+
- ./vendor/nunomaduro/larastan/extension.neon
3+
4+
parameters:
5+
6+
paths:
7+
- src
8+
9+
level: max
10+
11+
ignoreErrors:
12+
- '#Parameter \#1 \$callback of method Illuminate\\Container\\Container::call\(\) expects \(callable\(\): mixed\)\|string*#'
13+
14+
excludePaths:
15+
- tests
16+
17+
checkMissingIterableValueType: false

phpunit.xml renamed to phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<testsuites>
1313
<testsuite name="Package Test Suite">
1414
<directory suffix=".php">./tests/</directory>
15+
<exclude>./tests/views/</exclude>
1516
</testsuite>
1617
</testsuites>
1718
</phpunit>

src/Commands/DataTablesPurgeExportCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Support\Facades\File;
7-
use Illuminate\Support\Facades\Log;
87
use Illuminate\Support\Facades\Storage;
98
use Illuminate\Support\Str;
109

@@ -31,8 +30,13 @@ class DataTablesPurgeExportCommand extends Command
3130
*/
3231
public function handle()
3332
{
33+
/** @var string $disk */
3434
$disk = config('datatables-export.disk', 'local');
35-
$timestamp = now()->subDay(config('datatables-export.purge.days'))->getTimestamp();
35+
36+
/** @var int $daysOld */
37+
$daysOld = config('datatables-export.purge.days', 1);
38+
39+
$timestamp = now()->subDays($daysOld)->getTimestamp();
3640

3741
collect(Storage::disk($disk)->files())
3842
->each(function ($file) use ($timestamp, $disk) {

src/ExportServiceProvider.php

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,38 @@
44

55
use Illuminate\Support\ServiceProvider;
66
use Livewire\Livewire;
7-
use Maatwebsite\Excel\ExcelServiceProvider;
7+
use Livewire\LivewireServiceProvider;
88
use Yajra\DataTables\Commands\DataTablesPurgeExportCommand;
9-
use Yajra\DataTables\Generators\DataTablesHtmlCommand;
10-
use Yajra\DataTables\Generators\DataTablesMakeCommand;
11-
use Yajra\DataTables\Generators\DataTablesScopeCommand;
129
use Yajra\DataTables\Livewire\ExportButtonComponent;
1310

1411
class ExportServiceProvider extends ServiceProvider
1512
{
16-
/**
17-
* Bootstrap the application events.
18-
*
19-
* @return void
20-
*/
21-
public function boot()
13+
public function boot(): void
2214
{
23-
$this->loadViewsFrom(__DIR__ . '/resources/views', 'datatables-export');
15+
$this->loadViewsFrom(__DIR__.'/resources/views', 'datatables-export');
2416

2517
$this->publishAssets();
2618

2719
Livewire::component('export-button', ExportButtonComponent::class);
2820
}
2921

30-
/**
31-
* Publish datatables assets.
32-
*/
33-
protected function publishAssets()
22+
protected function publishAssets(): void
3423
{
3524
$this->publishes([
36-
__DIR__ . '/config/datatables-export.php' => config_path('datatables-export.php'),
25+
__DIR__.'/config/datatables-export.php' => config_path('datatables-export.php'),
3726
], 'datatables-export');
3827

3928
$this->publishes([
40-
__DIR__ . '/resources/views' => base_path('/resources/views/vendor/datatables-export'),
29+
__DIR__.'/resources/views' => base_path('/resources/views/vendor/datatables-export'),
4130
], 'datatables-export');
4231
}
4332

44-
/**
45-
* Register the service provider.
46-
*
47-
* @return void
48-
*/
49-
public function register()
33+
public function register(): void
5034
{
51-
$this->mergeConfigFrom(__DIR__ . '/config/datatables-export.php', 'datatables-export');
35+
$this->mergeConfigFrom(__DIR__.'/config/datatables-export.php', 'datatables-export');
5236

5337
$this->commands([DataTablesPurgeExportCommand::class]);
38+
39+
$this->app->register(LivewireServiceProvider::class);
5440
}
5541
}

0 commit comments

Comments
 (0)