Skip to content

Commit 32c6115

Browse files
authored
Merge pull request #4 from tattersoftware/tools
PHP 8, Toolkit
2 parents 08637a1 + 2e06621 commit 32c6115

File tree

13 files changed

+320
-19
lines changed

13 files changed

+320
-19
lines changed

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/.github export-ignore
2+
/docs export-ignore
3+
/examples export-ignore
4+
/tests export-ignore
5+
/.editorconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/phpstan.neon.dist export-ignore
10+
11+
# Configure diff output for .php and .phar files.
12+
*.php diff=php
13+
*.phar -diff

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: composer
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: daily

.github/workflows/analyze.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# When a PR is opened or a push is made, perform
2+
# a static analysis check on the code using PHPStan.
3+
name: PHPStan
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- 'develop'
9+
paths:
10+
- 'src/**'
11+
- 'tests/**'
12+
- 'composer.**'
13+
- 'phpstan*'
14+
- '.github/workflows/analyze.yml'
15+
push:
16+
branches:
17+
- 'develop'
18+
paths:
19+
- 'src/**'
20+
- 'tests/**'
21+
- 'composer.**'
22+
- 'phpstan*'
23+
- '.github/workflows/analyze.yml'
24+
25+
jobs:
26+
build:
27+
name: PHP ${{ matrix.php-versions }} Static Analysis
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
php-versions: ['7.3', '7.4', '8.0']
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
37+
- name: Setup PHP
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
php-version: ${{ matrix.php-versions }}
41+
tools: composer, pecl, phpunit
42+
extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3
43+
44+
- name: Get composer cache directory
45+
id: composer-cache
46+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
47+
48+
- name: Create composer cache directory
49+
run: mkdir -p ${{ steps.composer-cache.outputs.dir }}
50+
51+
- name: Cache composer dependencies
52+
uses: actions/cache@v2
53+
with:
54+
path: ${{ steps.composer-cache.outputs.dir }}
55+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
56+
restore-keys: ${{ runner.os }}-composer-
57+
58+
- name: Create PHPStan cache directory
59+
run: mkdir -p build/phpstan
60+
61+
- name: Cache PHPStan results
62+
uses: actions/cache@v2
63+
with:
64+
path: build/phpstan
65+
key: ${{ runner.os }}-phpstan-${{ github.sha }}
66+
restore-keys: ${{ runner.os }}-phpstan-
67+
68+
- name: Install dependencies
69+
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
70+
env:
71+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
72+
73+
- name: Run static analysis
74+
run: vendor/bin/phpstan analyze

.github/workflows/test.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: PHPUnit
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
push:
8+
branches:
9+
- develop
10+
11+
jobs:
12+
main:
13+
name: PHP ${{ matrix.php-versions }} Unit Tests
14+
15+
strategy:
16+
matrix:
17+
php-versions: ['7.3', '7.4', '8.0']
18+
19+
runs-on: ubuntu-latest
20+
21+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
27+
- name: Setup PHP, with composer and extensions
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: ${{ matrix.php-versions }}
31+
tools: composer, pecl, phpunit
32+
extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3
33+
coverage: xdebug
34+
35+
- name: Get composer cache directory
36+
id: composer-cache
37+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
38+
39+
- name: Cache composer dependencies
40+
uses: actions/cache@v2
41+
with:
42+
path: ${{ steps.composer-cache.outputs.dir }}
43+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
44+
restore-keys: ${{ runner.os }}-composer-
45+
46+
- name: Install dependencies
47+
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
48+
env:
49+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
50+
51+
- name: Test with PHPUnit
52+
run: vendor/bin/phpunit --verbose --coverage-text
53+
54+
- if: matrix.php-versions == '7.4'
55+
name: Run Coveralls
56+
run: |
57+
composer global require php-coveralls/php-coveralls:^2.4
58+
php-coveralls --coverage_clover=build/logs/clover.xml -v
59+
env:
60+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
COVERALLS_PARALLEL: true
62+
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} - ${{ matrix.db-platforms }}
63+
64+
coveralls:
65+
needs: [main]
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Coveralls Finished
69+
uses: coverallsapp/github-action@master
70+
with:
71+
github-token: ${{ secrets.GITHUB_TOKEN }}
72+
parallel-finished: true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
vendor/
2+
build/
3+
phpunit*.xml
4+
phpunit
5+
*.cache
6+
composer.lock
7+
.DS_Store

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ easily changed.
3131
## Configuration (optional)
3232

3333
The library's default behavior can be changed using its config file. Copy
34-
bin/Alerts.php to app/Config/Alerts.php and follow the instructions in the
34+
**examples/Alerts.php** to **app/Config/Alerts.php** and follow the instructions in the
3535
comments. If no config file is found the library will use its defaults.
3636

3737
## Usage

composer.json

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "tatter/alerts",
3+
"type": "library",
34
"description": "Lightweight user alerts for CodeIgniter 4",
45
"keywords": [
56
"codeigniter",
@@ -19,19 +20,37 @@
1920
}
2021
],
2122
"require": {
22-
"php" : "^7.0"
23+
"php": "^7.3 || ^8.0"
2324
},
2425
"require-dev": {
25-
"codeigniter4/framework": "dev-master"
26+
"codeigniter4/codeigniter4": "dev-develop",
27+
"tatter/tools": "^1.4"
2628
},
2729
"autoload": {
2830
"psr-4": {
2931
"Tatter\\Alerts\\": "src"
32+
},
33+
"exclude-from-classmap": [
34+
"**/Database/Migrations/**"
35+
]
36+
},
37+
"autoload-dev": {
38+
"psr-4": {
39+
"Tests\\Support\\": "tests/_support"
3040
}
3141
},
42+
"repositories": [
43+
{
44+
"type": "vcs",
45+
"url": "https://github.com/codeigniter4/CodeIgniter4",
46+
"no-api": true
47+
}
48+
],
49+
"minimum-stability": "dev",
50+
"prefer-stable": true,
3251
"scripts": {
33-
"post-update-cmd": [
34-
"composer dump-autoload"
35-
]
52+
"analyze": "phpstan analyze",
53+
"style": "phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 tests/ src/",
54+
"test": "phpunit"
3655
}
3756
}
File renamed without changes.

phpstan.neon.dist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
parameters:
2+
tmpDir: build/phpstan
3+
level: 5
4+
paths:
5+
- src
6+
- tests
7+
bootstrapFiles:
8+
- vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php
9+
excludes_analyse:
10+
- src/Config/Routes.php
11+
- src/Views/*
12+
ignoreErrors:
13+
- '#Unsafe usage of new static\(\)*#'
14+
universalObjectCratesClasses:
15+
- CodeIgniter\Entity
16+
- Faker\Generator
17+
scanDirectories:
18+
- vendor/codeigniter4/codeigniter4/system/Helpers
19+
dynamicConstantNames:
20+
- APP_NAMESPACE
21+
- CI_DEBUG
22+
- ENVIRONMENT

phpunit.xml.dist

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php"
4+
backupGlobals="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
stopOnError="false"
10+
stopOnFailure="false"
11+
stopOnIncomplete="false"
12+
stopOnSkipped="false"
13+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
14+
15+
<coverage includeUncoveredFiles="true" processUncoveredFiles="true">
16+
<include>
17+
<directory suffix=".php">./src</directory>
18+
</include>
19+
<exclude>
20+
<directory suffix=".php">./src/Views</directory>
21+
<file>./src/Config/Routes.php</file>
22+
</exclude>
23+
<report>
24+
<clover outputFile="build/logs/clover.xml"/>
25+
<html outputDirectory="build/logs/html"/>
26+
<php outputFile="build/logs/coverage.serialized"/>
27+
<text outputFile="php://stdout" showUncoveredFiles="false"/>
28+
</report>
29+
</coverage>
30+
31+
<testsuites>
32+
<testsuite name="app">
33+
<directory>./tests</directory>
34+
</testsuite>
35+
</testsuites>
36+
37+
<logging>
38+
<testdoxHtml outputFile="build/logs/testdox.html"/>
39+
<testdoxText outputFile="build/logs/testdox.txt"/>
40+
<junit outputFile="build/logs/logfile.xml"/>
41+
</logging>
42+
43+
<php>
44+
<env name="XDEBUG_MODE" value="coverage"/>
45+
<server name="app.baseURL" value="http://example.com"/>
46+
47+
<!-- Directory containing phpunit.xml -->
48+
<const name="HOMEPATH" value="./"/>
49+
50+
<!-- Directory containing the Paths config file -->
51+
<const name="CONFIGPATH" value="./vendor/codeigniter4/codeigniter4/app/Config/"/>
52+
53+
<!-- Directory containing the front controller (index.php) -->
54+
<const name="PUBLICPATH" value="./vendor/codeigniter4/codeigniter4/public/"/>
55+
56+
<!-- https://getcomposer.org/xdebug -->
57+
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
58+
59+
<!-- Database configuration -->
60+
<!-- Uncomment to use alternate testing database configuration
61+
<env name="database.tests.hostname" value="localhost"/>
62+
<env name="database.tests.database" value="tests"/>
63+
<env name="database.tests.username" value="tests_user"/>
64+
<env name="database.tests.password" value=""/>
65+
<env name="database.tests.DBDriver" value="MySQLi"/>
66+
<env name="database.tests.DBPrefix" value="tests_"/>
67+
-->
68+
</php>
69+
</phpunit>

0 commit comments

Comments
 (0)