Skip to content

Commit

Permalink
Added laravel 10, PHP 8.2 support and GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
korridor committed Feb 16, 2023
1 parent 995952f commit edcb471
Show file tree
Hide file tree
Showing 30 changed files with 256 additions and 216 deletions.
10 changes: 4 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
/phpunit.xml export-ignore
/phpunit.xml.old export-ignore
/phpcs.xml export-ignore
/phpcs.xml export-ignore
/docker export-ignore
/.travis.yml export-ignore
/.styleci.yml export-ignore
/.php_cs export-ignore
/.editorconfig export-ignore
/.php-cs-fixer.php export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/vendor export-ignore
/.github export-ignore
/coverage export-ignore
/.phpunit.cache export-ignore
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint

on: [ push ]

jobs:
lint_with_php_cs_fixer:
name: Lint code with PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install dependencies
uses: php-actions/composer@v6
with:
command: install
only_args: -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
php_version: 8.1

- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --dry-run

lint_with_phpcs:
name: Lint code with PHP CodeSniffer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install dependencies
uses: php-actions/composer@v6
with:
command: install
only_args: -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
php_version: 8.1

- name: Run PHP CodeSniffer
run: vendor/bin/phpcs --extensions=php
50 changes: 50 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Unit Test

on: [ push ]

jobs:
PHPUnit:
strategy:
matrix:
include:
# Laravel 10.*
- php: 8.1
laravel: 10.*
testbench: 8.*
composer-flag: '--prefer-stable'
- php: 8.2
laravel: 10.*
testbench: 8.*
composer-flag: '--prefer-stable'
- php: 8.1
laravel: 10.*
testbench: 8.*
composer-flag: '--prefer-lowest'
- php: 8.2
laravel: 10.*
testbench: 8.*
composer-flag: '--prefer-lowest'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: xdebug

- name: Install dependencies
run: composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update

- name: Update dependencies
run: composer update ${{ matrix.composer-flag }} --prefer-dist --no-interaction

- name: Run PHPUnit
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ composer.lock
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
.phpunit.cache
10 changes: 8 additions & 2 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?php

return (new PhpCsFixer\Config())
->setRiskyAllowed(false)
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@PSR12' => true,
'@PSR12:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'modernize_types_casting' => true,
'void_return' => true,
])
->setUsingCache(true)
->setFinder(
Expand Down
1 change: 0 additions & 1 deletion .styleci.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .travis.yml

This file was deleted.

16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
}
],
"require": {
"php": "^7.2|^8",
"php": ">=8.1",
"composer/composer": "^2",
"illuminate/console": "^5.8|^6|^7|^8|^9",
"illuminate/database": "^5.8|^6|^7|^8|^9",
"illuminate/support": "^5.8|^6|^7|^8|^9"
"illuminate/console": "^10",
"illuminate/database": "^10",
"illuminate/support": "^10"
},
"require-dev": {
"orchestra/testbench": "^3.6|^4.0|^5.0|^6.0|^7.0",
"phpunit/phpunit": "^7.0|^8.0|^9.0",
"friendsofphp/php-cs-fixer": "2.*|^3",
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^10.0",
"friendsofphp/php-cs-fixer": "^3",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
Expand All @@ -35,7 +35,7 @@
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
"test-coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-html coverage",
"fix": "./vendor/bin/php-cs-fixer fix",
"lint": "./vendor/bin/phpcs --error-severity=1 --warning-severity=8 --extensions=php"
},
Expand Down
12 changes: 4 additions & 8 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
FROM php:8.0-cli
FROM php:8.1-cli

RUN apt-get update && apt-get install -y \
zlib1g-dev \
libzip-dev
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN docker-php-ext-install zip

RUN pecl install xdebug-3.0.4 \
&& docker-php-ext-enable xdebug
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions zip xdebug

# Install composer and add its bin to the PATH.
RUN curl -s http://getcomposer.org/installer | php && \
Expand Down
5 changes: 4 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0"?>
<ruleset name="ASH2">
<description>The ASH2 coding standard.</description>
<rule ref="PSR2">
<rule ref="PSR12">
<properties>
<property name="lineLimit" value="150"/>
</properties>
</rule>

<file>src/</file>
Expand Down
61 changes: 25 additions & 36 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<server name="APP_ENV" value="testing"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="QUEUE_DRIVER" value="sync"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<server name="APP_ENV" value="testing"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="QUEUE_DRIVER" value="sync"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
37 changes: 0 additions & 37 deletions phpunit.xml.old

This file was deleted.

Loading

0 comments on commit edcb471

Please sign in to comment.