Skip to content

Commit

Permalink
Merge pull request #1 from php-etl/feature/github-actions
Browse files Browse the repository at this point in the history
Added GitHub actions + updated dependencies
  • Loading branch information
sebprt authored Apr 19, 2023
2 parents 4335fc5 + c27c57c commit abe134f
Show file tree
Hide file tree
Showing 14 changed files with 763 additions and 41 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/phpstan-5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: PHPStan level 5
on: push
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: '**/vendor'
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: php-actions/composer@v6
with:
args: --prefer-dist
php_version: '8.2'
- name: PHPStan
uses: php-actions/phpstan@v3
with:
path: src/
level: 5
php_version: '8.2'
23 changes: 23 additions & 0 deletions .github/workflows/phpstan-6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: PHPStan level 6
on: push
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: '**/vendor'
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: php-actions/composer@v6
with:
args: --prefer-dist
php_version: '8.2'

- name: PHPStan
uses: php-actions/phpstan@v3
with:
path: src/
level: 6
23 changes: 23 additions & 0 deletions .github/workflows/phpstan-7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: PHPStan level 7
on: push
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: '**/vendor'
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: php-actions/composer@v6
with:
args: --prefer-dist
php_version: '8.2'

- name: PHPStan
uses: php-actions/phpstan@v3
with:
path: src/
level: 7
23 changes: 23 additions & 0 deletions .github/workflows/phpstan-8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: PHPStan level 8
on: push
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: '**/vendor'
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: php-actions/composer@v6
with:
args: --prefer-dist
php_version: '8.2'

- name: PHPStan
uses: php-actions/phpstan@v3
with:
path: src/
level: 8
36 changes: 36 additions & 0 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Quality (PHPStan lvl 4)
on: push
jobs:
cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Cs-Fixer
run: |
wget -q https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer
chmod a+x php-cs-fixer
PHP_CS_FIXER_IGNORE_ENV=true ./php-cs-fixer fix src --dry-run
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: '**/vendor'
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: php-actions/composer@v6
with:
args: --prefer-dist
php_version: '8.2'

- name: PHPStan
uses: php-actions/phpstan@v3
with:
path: src/
level: 4
28 changes: 28 additions & 0 deletions .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# github action that checks code with Rector
name: Rector

on:
pull_request: null

jobs:
rector:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == 'php-etl/sftp-action-flow'
steps:
- uses: actions/checkout@v3

- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none

- uses: "ramsey/composer-install@v2"

- run: bin/rector --ansi

- # commit only to core contributors who have repository access
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[rector] Rector fixes'
commit_author: 'GitHub Action <[email protected]>'
commit_user_email: '[email protected]'
41 changes: 41 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in('src')
;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PHP82Migration' => true,
'@PHP81Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'@PSR1' => true,
'@PSR12' => true,
'@PhpCsFixer' => true,
'@Symfony' => true,
'ternary_to_elvis_operator' => true,
'set_type_to_cast' => true,
'self_accessor' => true,
'psr_autoloading' => true,
'php_unit_test_annotation' => ['style' => 'annotation'],
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_construct' => true,
'no_useless_sprintf' => true,
'no_homoglyph_names' => true,
'native_function_invocation' => true,
'native_constant_invocation' => true,
'modernize_types_casting' => true,
'logical_operators' => true,
'is_null' => true,
'function_to_constant' => true,
'fopen_flag_order' => true,
'error_suppression' => true,
'ereg_to_preg' => true,
'dir_constant' => true,
'method_chaining_indentation' => false,
])
->setFinder($finder)
->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line
;
120 changes: 120 additions & 0 deletions bin/phpstan
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env php
<?php

/**
* Proxy PHP file generated by Composer
*
* This file includes the referenced bin path (../vendor/phpstan/phpstan/phpstan)
* using a stream wrapper to prevent the shebang from being output on PHP<8
*
* @generated
*/

namespace Composer;

$GLOBALS['_composer_bin_dir'] = __DIR__;
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/vendor/autoload.php';

if (PHP_VERSION_ID < 80000) {
if (!class_exists('Composer\BinProxyWrapper')) {
/**
* @internal
*/
final class BinProxyWrapper
{
private $handle;
private $position;
private $realpath;

public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = substr($path, 17);
$this->realpath = realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = fopen($this->realpath, $mode);
$this->position = 0;

return (bool) $this->handle;
}

public function stream_read($count)
{
$data = fread($this->handle, $count);

if ($this->position === 0) {
$data = preg_replace('{^#!.*\r?\n}', '', $data);
}

$this->position += strlen($data);

return $data;
}

public function stream_cast($castAs)
{
return $this->handle;
}

public function stream_close()
{
fclose($this->handle);
}

public function stream_lock($operation)
{
return $operation ? flock($this->handle, $operation) : true;
}

public function stream_seek($offset, $whence)
{
if (0 === fseek($this->handle, $offset, $whence)) {
$this->position = ftell($this->handle);
return true;
}

return false;
}

public function stream_tell()
{
return $this->position;
}

public function stream_eof()
{
return feof($this->handle);
}

public function stream_stat()
{
return array();
}

public function stream_set_option($option, $arg1, $arg2)
{
return true;
}

public function url_stat($path, $flags)
{
$path = substr($path, 17);
if (file_exists($path)) {
return stat($path);
}

return false;
}
}
}

if (
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
) {
include("phpvfscomposer://" . __DIR__ . '/..'.'/vendor/phpstan/phpstan/phpstan');
exit(0);
}
}

include __DIR__ . '/..'.'/vendor/phpstan/phpstan/phpstan';
Loading

0 comments on commit abe134f

Please sign in to comment.