Skip to content

Commit 0ed7328

Browse files
committed
Added Github actions and strict types
1 parent a2ff71f commit 0ed7328

File tree

19 files changed

+187
-55
lines changed

19 files changed

+187
-55
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/lint.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lint
2+
3+
on: [ push ]
4+
5+
jobs:
6+
lint_with_php_cs_fixer:
7+
name: Lint code with PHP-CS-Fixer
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Install dependencies
13+
uses: php-actions/composer@v6
14+
with:
15+
command: install
16+
only_args: -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
17+
php_version: 8.1
18+
19+
- name: Run PHP-CS-Fixer
20+
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --dry-run
21+
22+
lint_with_phpcs:
23+
name: Lint code with PHP CodeSniffer
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- name: Install dependencies
29+
uses: php-actions/composer@v6
30+
with:
31+
command: install
32+
only_args: -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
33+
php_version: 8.1
34+
35+
- name: Run PHP CodeSniffer
36+
run: vendor/bin/phpcs --extensions=php

.github/workflows/unittests.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Unit Test
2+
3+
on: [ push ]
4+
5+
jobs:
6+
PHPUnit:
7+
strategy:
8+
matrix:
9+
include:
10+
# Laravel 6.*
11+
- php: 7.4
12+
laravel: 6.*
13+
testbench: 4.*
14+
composer-flag: '--prefer-stable'
15+
- php: 8.0
16+
laravel: 6.*
17+
testbench: 4.*
18+
composer-flag: '--prefer-stable'
19+
# Laravel 7.*
20+
- php: 7.4
21+
laravel: 7.*
22+
testbench: 5.*
23+
composer-flag: '--prefer-stable'
24+
- php: 8.0
25+
laravel: 7.*
26+
testbench: 5.*
27+
composer-flag: '--prefer-stable'
28+
# Laravel 8.*
29+
- php: 7.4
30+
laravel: 8.*
31+
testbench: 6.*
32+
composer-flag: '--prefer-stable'
33+
- php: 8.0
34+
laravel: 8.*
35+
testbench: 6.*
36+
composer-flag: '--prefer-stable'
37+
- php: 8.1
38+
laravel: 8.*
39+
testbench: 6.*
40+
composer-flag: '--prefer-stable'
41+
# Laravel 9.*
42+
- php: 8.0
43+
laravel: 9.*
44+
testbench: 7.*
45+
composer-flag: '--prefer-stable'
46+
- php: 8.1
47+
laravel: 9.*
48+
testbench: 7.*
49+
composer-flag: '--prefer-stable'
50+
# Laravel 10.*
51+
- php: 8.1
52+
laravel: 10.*
53+
testbench: 8.*
54+
composer-flag: '--prefer-stable'
55+
- php: 8.2
56+
laravel: 10.*
57+
testbench: 8.*
58+
composer-flag: '--prefer-stable'
59+
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- uses: actions/checkout@v3
64+
65+
- name: Setup PHP
66+
uses: shivammathur/setup-php@v2
67+
with:
68+
php-version: ${{ matrix.php }}
69+
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
70+
coverage: xdebug
71+
72+
- name: Install dependencies
73+
run: composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
74+
75+
- name: Update dependencies
76+
run: composer update ${{ matrix.composer-flag }} --prefer-dist --no-interaction
77+
78+
- name: Run PHPUnit
79+
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
80+
81+
- name: Upload coverage reports to Codecov
82+
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.phpunit.result.cache
55
.php-cs-fixer.cache
66
composer.lock
7+
.phpunit.cache

.php-cs-fixer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22

33
return (new PhpCsFixer\Config())
4-
->setRiskyAllowed(false)
4+
->setRiskyAllowed(true)
55
->setRules([
6-
'@PSR2' => true,
6+
'@PSR12' => true,
7+
'declare_strict_types' => true,
8+
'modernize_types_casting' => true,
9+
'void_return' => true,
710
])
811
->setUsingCache(true)
912
->setFinder(
1013
PhpCsFixer\Finder::create()
1114
->in(__DIR__.'/src')
1215
->in(__DIR__.'/tests')
13-
)
14-
;
16+
);

.styleci.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
],
1212
"license": "MIT",
1313
"require": {
14-
"php": "^7.1|^8.0",
15-
"illuminate/support": "^5.8|^6|^7|^8|^9",
16-
"illuminate/database": "^5.8|^6|^7|^8|^9"
14+
"php": "^7.4|^8.0",
15+
"illuminate/support": "^6|^7|^8|^9|^10",
16+
"illuminate/database": "^6|^7|^8|^9|^10"
1717
},
1818
"require-dev": {
19-
"orchestra/testbench": "^3.8|^4.0|^5.0|^6.0|^7.0",
20-
"phpunit/phpunit": "^7.0|^8.0|^9.0",
21-
"friendsofphp/php-cs-fixer": "2.*|^3.6",
19+
"orchestra/testbench": "^3.8|^4.0|^5.0|^6.0|^7.0|^8.0",
20+
"phpunit/phpunit": "^7|^8|^9|^10",
21+
"friendsofphp/php-cs-fixer": "^3.6",
2222
"squizlabs/php_codesniffer": "^3.5"
2323
},
2424
"autoload": {
@@ -35,7 +35,7 @@
3535
"test": "vendor/bin/phpunit",
3636
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
3737
"fix": "./vendor/bin/php-cs-fixer fix",
38-
"lint": "./vendor/bin/phpcs --error-severity=1 --warning-severity=8 --extensions=php"
38+
"lint": "./vendor/bin/phpcs --extensions=php"
3939
},
4040
"extra": {
4141
"laravel": {

docker/Dockerfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
FROM php:8.0-cli
1+
FROM php:8.1-cli
22

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

7-
RUN docker-php-ext-install zip
8-
9-
RUN pecl install xdebug-3.0.4 \
10-
&& docker-php-ext-enable xdebug
5+
RUN chmod +x /usr/local/bin/install-php-extensions && \
6+
install-php-extensions zip xdebug
117

128
# Install composer and add its bin to the PATH.
139
RUN curl -s http://getcomposer.org/installer | php && \

phpcs.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?xml version="1.0"?>
22
<ruleset name="ASH2">
33
<description>The ASH2 coding standard.</description>
4-
<rule ref="PSR2">
4+
<rule ref="PSR12">
5+
<properties>
6+
<property name="lineLimit" value="150"/>
7+
</properties>
58
</rule>
69

710
<file>src/</file>

phpunit.xml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false">
12-
<testsuites>
13-
<testsuite name="Feature">
14-
<directory>tests/Feature</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
22-
<php>
23-
<env name="DB_CONNECTION" value="testing"/>
24-
</php>
2+
<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">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="Feature">
10+
<directory>tests/Feature</directory>
11+
</testsuite>
12+
</testsuites>
13+
<php>
14+
<env name="DB_CONNECTION" value="testing"/>
15+
</php>
2516
</phpunit>

0 commit comments

Comments
 (0)