Skip to content

Commit

Permalink
Phpstan (lukewaite#43)
Browse files Browse the repository at this point in the history
* Add phpcs

* Fix phpcs

* Install composer deps

* Add php analysis

* Add phpstan

* no analysis

* Fix phpstan

* Update

* Update

* Fix

* Fix phpunit

* fix lint

* Fix queue sp

* Update?

* Push

* Updates

* Put back code

* phpstan

* Fix phpcs

* no lowest

* no fail fast

* no fail fast

* stable only
  • Loading branch information
lukewaite authored Dec 14, 2022
1 parent 39955f6 commit 838f08f
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 34 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ on:
- main
- '*.x'
pull_request:

schedule:
- cron: '0 0 * * *'

permissions:
contents: read
Expand All @@ -16,11 +17,13 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: true
fail-fast: false
matrix:
php: [ '7.3', '7.4', '8.0', '8.1', '8.2' ]
laravel: [^8]
dependency-version: [prefer-stable]

name: PHP ${{ matrix.php }}
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
Expand All @@ -34,13 +37,28 @@ jobs:
php-version: ${{ matrix.php }}
coverage: xdebug

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress
- name: Execute tests
run: vendor/bin/phpunit

- name: PHPStan Static Analysis
uses: php-actions/phpstan@v3
with:
path: src/

- name: Upload Scrutinizer coverage
uses: sudo-bot/action-scrutinizer@latest
with:
cli-args: "--format=php-clover tests/reports/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}"
phpcs:
name: phpcs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6
- name: Check PSR-12 Codestyle
run: composer check-style
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 3
runs: 3
19 changes: 12 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@
}
},
"require": {
"illuminate/support": ">8 <9",
"illuminate/support": "^8",
"aws/aws-sdk-php": "^3.20.6"
},
"require-dev": {
"mockery/mockery": "^1.5",
"laravel/framework": ">8 <9",
"phpunit/phpunit": "~9",
"squizlabs/php_codesniffer": "^2.8",
"scrutinizer/ocular": "^1.3"
"laravel/framework": "^8",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5",
"scrutinizer/ocular": "^1.3",
"phpstan/phpstan": "^1.9",
"nunomaduro/larastan": "^1|^2",
"orchestra/testbench": "^6|^7"
},
"scripts": {
"cs": "phpcs --standard=psr2 src/",
"test": "phpunit"
"test": "phpunit",
"check-style": "phpcs -p --standard=psr12 src/",
"fix-style": "phpcbf -p --standard=psr12 src/",
"phpstan": "phpstan analyse"
}
}
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon

parameters:
paths:
- src/
level: 2
14 changes: 2 additions & 12 deletions src/BatchQueueServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Laravel Queue for AWS Batch.
*
Expand All @@ -19,18 +20,7 @@ class BatchQueueServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton(
'command.queueawsbatch.work-batch',
function ($app) {
return new QueueWorkBatchCommand(
$app['queue'],
$app['queue.worker'],
$app['Illuminate\Foundation\Exceptions\Handler']
);
}
);

$this->commands('command.queueawsbatch.work-batch');
$this->commands(QueueWorkBatchCommand::class);
}

public function boot()
Expand Down
1 change: 1 addition & 0 deletions src/Connectors/BatchConnector.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Laravel Queue for AWS Batch.
*
Expand Down
16 changes: 8 additions & 8 deletions src/Console/QueueWorkBatchCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Laravel Queue for AWS Batch.
*
Expand All @@ -12,6 +13,7 @@
namespace LukeWaite\LaravelQueueAwsBatch\Console;

use Illuminate\Console\Command;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Queue\Console\WorkCommand;
use Illuminate\Queue\QueueManager;
Expand Down Expand Up @@ -39,9 +41,9 @@ class QueueWorkBatchCommand extends WorkCommand
protected $manager;
protected $exceptions;

public function __construct(QueueManager $manager, Worker $worker, Handler $exceptions)
public function __construct(QueueManager $manager, Worker $worker, Handler $exceptions, Cache $cache)
{
parent::__construct($worker);
parent::__construct($worker, $cache);
$this->manager = $manager;
$this->exceptions = $exceptions;
}
Expand All @@ -52,11 +54,8 @@ public function fire()

try {
$this->runJob();
} catch (\Exception $e) {
$this->exceptions->report($e);
throw $e;
} catch (\Throwable $e) {
$this->exceptions->report(new FatalThrowableError($e));
$this->exceptions->report($e);
throw $e;
}
}
Expand All @@ -74,16 +73,17 @@ protected function runJob()
throw new UnsupportedException('queue:work-batch can only be run on batch queues');
}

$job = $connection->getJobById($jobId, $connectionName);
$job = $connection->getJobById($jobId);

// If we're able to pull a job off of the stack, we will process it and
// then immediately return back out.
if (!is_null($job)) {
return $this->worker->process(
$this->worker->process(
$this->manager->getName($connectionName),
$job,
$this->gatherWorkerOptions()
);
return;
}

// If we hit this point, we haven't processed our job
Expand Down
1 change: 1 addition & 0 deletions src/Exceptions/JobNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Laravel Queue for AWS Batch.
*
Expand Down
1 change: 1 addition & 0 deletions src/Exceptions/LaravelAwsBatchQueueException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Laravel Queue for AWS Batch.
*
Expand Down
1 change: 1 addition & 0 deletions src/Exceptions/UnsupportedException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Laravel Queue for AWS Batch.
*
Expand Down
1 change: 1 addition & 0 deletions src/Jobs/BatchJob.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Laravel Queue for AWS Batch.
*
Expand Down
3 changes: 2 additions & 1 deletion src/Queues/BatchQueue.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Laravel Queue for AWS Batch.
*
Expand Down Expand Up @@ -111,7 +112,7 @@ public function getJobById($id)

$job = new DatabaseJobRecord($job);

return $this->marshalJob($job->queue, $job);
return $this->marshalJob($this->default, $job);
}

protected function marshalJob($queue, $job)
Expand Down

0 comments on commit 838f08f

Please sign in to comment.