Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-kulhanek committed Jan 21, 2025
1 parent 90cddd6 commit f847de2
Show file tree
Hide file tree
Showing 15 changed files with 634 additions and 689 deletions.
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
reviewers:
- tomas-kulhanek
schedule:
interval: "daily"
day: monday
commit-message:
prefix: "chore"
open-pull-requests-limit: 10
groups:
symfony:
patterns:
- "symfony/*"
- "twig/*"
- "doctrine/*"
scheb:
patterns:
- "scheb/*"

- package-ecosystem: github-actions
directory: "/"
assignees:
- tomas-kulhanek
reviewers:
- tomas-kulhanek
schedule:
interval: weekly
day: monday
117 changes: 117 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Code Quality Assurance ✅
run-name: ${{ github.actor }} running Code Quality Assurance ✅

on:
push:
paths:
- '.github/workflows/ci.yml'
- '**/*.php'
- 'composer.json'
- 'composer.lock'
- 'phpcs.xml'
- 'phpstan.neon'
- 'rector.php'

branches:
- master
pull_request:
types: [opened, reopened, synchronize]
paths:
- '.github/workflows/ci.yml'
- '**/*.php'
- 'composer.json'
- 'composer.lock'
- 'phpcs.xml'
- 'phpstan.neon'
- 'rector.php'

workflow_dispatch: ~

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
composer-install-args: "--no-progress --no-interaction --prefer-dist --no-scripts --ignore-platform-reqs"

jobs:
composer:
name: "📦 Composer"
runs-on: ubuntu-24.04
strategy:
matrix:
php-versions: ['8.2', '8.3', '8.4']

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

- name: 🔍 Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@v3
with:
files: composer.json

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-versions }}
restore-keys: |
${{ runner.os }}-${{ matrix.php-versions }}-composer-
- uses: php-actions/composer@v6
name: 🏗 PHP ${{ matrix.php-versions }} and Composer install
with:
args: ${{ env.composer-install-args }}
php_version: ${{ matrix.php-versions }}
- name: Validate Composer
run: composer validate --strict
- name: Security Check
run: composer audit

check:
needs: composer
name: "🛡️ Check"
runs-on: ubuntu-24.04
strategy:
matrix:
php-versions: ['8.2', '8.3', '8.4']

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

- name: 🔍 Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@v3
with:
files: composer.json

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-versions }}
restore-keys: |
${{ runner.os }}-${{ matrix.php-versions }}-composer-
- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer

- name: "🎪 PhpStan"
id: phpstan
run: composer phpstan

- name: "📝 Code style"
id: phpcs
if: success() || steps.phpstan.outcome == 'failure'
run: composer phpcs

- name: "🧹Rector"
id: rector
if: success() || steps.phpstan.outcome == 'failure' || steps.phpcs.outcome == 'failure'
run: composer rector
96 changes: 96 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Nightly checks
run-name: ${{ github.actor }} running nightly checks

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: ~

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
composer-install-args: "--no-progress --no-interaction --prefer-dist --no-scripts --ignore-platform-reqs"

jobs:
composer:
name: "📦 Composer"
runs-on: ubuntu-24.04
strategy:
matrix:
php-versions: ['8.2', '8.3', '8.4']

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

- name: 🔍 Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@v3
with:
files: composer.json

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-versions }}
restore-keys: |
${{ runner.os }}-${{ matrix.php-versions }}-composer-
- uses: php-actions/composer@v6
name: 🏗 PHP ${{ matrix.php-versions }} and Composer install
with:
args: ${{ env.composer-install-args }}
php_version: ${{ matrix.php-versions }}
- name: Validate Composer
run: composer validate --strict
- name: Security Check
run: composer audit

check:
needs: composer
name: "🛡️ Check"
runs-on: ubuntu-24.04
strategy:
matrix:
php-versions: ['8.2', '8.3', '8.4']

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

- name: 🔍 Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@v3
with:
files: composer.json

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-versions }}
restore-keys: |
${{ runner.os }}-${{ matrix.php-versions }}-composer-
- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer

- name: "🎪 PhpStan"
id: phpstan
run: composer phpstan

- name: "📝 Code style"
id: phpcs
if: success() || steps.phpstan.outcome == 'failure'
run: composer phpcs

- name: "🧹Rector"
id: rector
if: success() || steps.phpstan.outcome == 'failure' || steps.phpcs.outcome == 'failure'
run: composer rector
19 changes: 19 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Assign PR Author

on:
workflow_dispatch: {}
workflow_call: {}
pull_request:
types: [ opened ]

concurrency:
group: "${{ github.workflow }}-${{github.head_ref || github.ref_name}}-assign-pr-author"
cancel-in-progress: false

jobs:
assignAuthor:
name: Assign Author
runs-on: ubuntu-24.04
steps:
- name: Assign Author
uses: technote-space/assign-author@v1
39 changes: 32 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,60 @@
"homepage": "http://helppc.cz",
"type": "library",
"support": {
"email": "info@tirus.cz",
"email": "jsem@tomaskulhanek.cz",
"issues": "https://github.com/helppc/chrome-pdf/issues",
"source": "https://github.com/helppc/chrome-pdf"
},
"license": [
"MIT"
],
"description": "Client for browserless.io Chrome",
"authors": [
{
"name": "Tomas Kulhanek",
"homepage": "http://tirus.cz"
"homepage": "https://tomaskulhanek.cz"
}
],
"require": {
"php": ">=7.4"
"php": ">=8.2",
"symfony/http-client": "^7.2"
},
"autoload": {
"psr-4": {
"HelpPC\\ChromePdf\\": "src/"
}
},

"scripts": {
"check": [
"@phpstan",
"@phpcs",
"@rector"
],
"phpcs": "phpcs --standard=./phpcs.xml",
"phpcbf": "phpcbf --standard=./phpcs.xml",
"phpstan": "php -d xdebug.mode=off vendor/phpstan/phpstan/phpstan analyze -c phpstan.neon --no-progress --memory-limit=-1",
"phpstan-pro": "php -d xdebug.mode=off vendor/phpstan/phpstan/phpstan analyze -c phpstan.neon --no-progress --memory-limit=-1 --pro",
"rector": "php vendor/bin/rector process --dry-run"
},
"require-dev": {
"phpstan/phpstan": "^0.12.0",
"phpstan/phpstan-nette": "^0.12",
"symfony/console": "^5.1"
"symfony/console": "^5.1",
"phpstan/phpstan": "^2.0.0",
"phpstan/phpstan-strict-rules": "^2.0.0",
"phpunit/phpunit": "^11.3",
"rector/rector": "^2.0",
"shipmonk/phpstan-rules": "^4.0",
"slevomat/coding-standard": "^8.15",
"squizlabs/php_codesniffer": "^3.10"
},
"archive": {
"exclude": [
"/tests"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
}
23 changes: 23 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>

<rule ref="PSR12"/>

<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="linesCountBeforeDeclare" value="1"/>
<property name="linesCountAfterDeclare" value="1"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
</properties>
</rule>

<file>src/</file>

</ruleset>
Loading

0 comments on commit f847de2

Please sign in to comment.