Skip to content

Commit d033806

Browse files
authored
Merge pull request #13 from tattersoftware/tools
Update Toolkit
2 parents 8f0bf49 + f915b0f commit d033806

File tree

8 files changed

+203
-53
lines changed

8 files changed

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

.github/workflows/test.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ name: PHPUnit
22

33
on:
44
pull_request:
5-
branches:
5+
branches:
6+
- develop
7+
push:
8+
branches:
69
- develop
710

811
jobs:
912
main:
10-
name: Build and test
13+
name: PHP ${{ matrix.php-versions }} Unit Tests
1114

1215
strategy:
1316
matrix:
14-
php-versions: ['7.2', '7.3', '7.4']
17+
php-versions: ['7.2', '7.3', '7.4', '8.0']
1518

1619
runs-on: ubuntu-latest
1720

@@ -34,16 +37,36 @@ jobs:
3437
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
3538

3639
- name: Cache composer dependencies
37-
uses: actions/cache@v1
40+
uses: actions/cache@v2
3841
with:
3942
path: ${{ steps.composer-cache.outputs.dir }}
4043
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
4144
restore-keys: ${{ runner.os }}-composer-
4245

4346
- name: Install dependencies
44-
run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader
47+
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
4548
env:
4649
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
4750

48-
- name: Test with phpunit
49-
run: vendor/bin/phpunit --coverage-text
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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Tatter\Relations
2-
32
Entity relationships for CodeIgniter 4
43

5-
[![](https://github.com/tattersoftware/codeigniter4-relations/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-relations/actions?query=workflow%3APHPUnit)
6-
4+
[![](https://github.com/tattersoftware/codeigniter4-relations/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-relations/actions?query=workflow%3A%22PHPUnit)
5+
[![](https://github.com/tattersoftware/codeigniter4-relations/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-relations/actions?query=workflow%3A%22PHPStan)
6+
[![Coverage Status](https://coveralls.io/repos/github/tattersoftware/codeigniter4-relations/badge.svg?branch=develop)](https://coveralls.io/github/tattersoftware/codeigniter4-relations?branch=develop)
77

88
## Quick Start
99

composer.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "tatter/relations",
3+
"type": "library",
34
"description": "Entity relationships for CodeIgniter 4",
45
"keywords": [
56
"codeigniter",
@@ -20,37 +21,38 @@
2021
"role": "Developer"
2122
}
2223
],
23-
"repositories": [
24-
{
25-
"type": "vcs",
26-
"url": "https://github.com/codeigniter4/CodeIgniter4"
27-
}
28-
],
29-
"minimum-stability": "dev",
30-
"prefer-stable": true,
3124
"require": {
32-
"php" : ">=7.2",
25+
"php": "^7.2|^8.0",
3326
"tatter/schemas": "^2.0"
3427
},
3528
"require-dev": {
3629
"codeigniter4/codeigniter4": "dev-develop",
37-
"mikey179/vfsstream": "1.6.*",
38-
"phpunit/phpunit" : "^8.5"
30+
"tatter/tools": "^1.3"
3931
},
4032
"autoload": {
4133
"psr-4": {
4234
"Tatter\\Relations\\": "src"
43-
}
35+
},
36+
"exclude-from-classmap": [
37+
"**/Database/Migrations/**"
38+
]
4439
},
4540
"autoload-dev": {
4641
"psr-4": {
4742
"Tests\\Support\\": "tests/_support"
4843
}
4944
},
45+
"repositories": [
46+
{
47+
"type": "vcs",
48+
"url": "https://github.com/codeigniter4/CodeIgniter4"
49+
}
50+
],
51+
"minimum-stability": "dev",
52+
"prefer-stable": true,
5053
"scripts": {
51-
"test": "phpunit",
52-
"post-update-cmd": [
53-
"composer dump-autoload"
54-
]
54+
"analyze": "phpstan analyze",
55+
"style": "phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 tests/ src/",
56+
"test": "phpunit"
5557
}
5658
}

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: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php"
34
backupGlobals="false"
45
colors="true"
56
convertErrorsToExceptions="true"
@@ -8,34 +9,39 @@
89
stopOnError="false"
910
stopOnFailure="false"
1011
stopOnIncomplete="false"
11-
stopOnSkipped="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+
1231
<testsuites>
1332
<testsuite name="app">
1433
<directory>./tests</directory>
1534
</testsuite>
1635
</testsuites>
1736

18-
<filter>
19-
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
20-
<directory suffix=".php">./src</directory>
21-
<exclude>
22-
<directory suffix=".php">./src/Views</directory>
23-
<file>./src/Config/Routes.php</file>
24-
</exclude>
25-
</whitelist>
26-
</filter>
27-
2837
<logging>
29-
<log type="coverage-html" target="build/logs/html"/>
30-
<log type="coverage-clover" target="build/logs/clover.xml"/>
31-
<log type="coverage-php" target="build/logs/coverage.serialized"/>
32-
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
33-
<log type="testdox-html" target="build/logs/testdox.html"/>
34-
<log type="testdox-text" target="build/logs/testdox.txt"/>
35-
<log type="junit" target="build/logs/logfile.xml"/>
38+
<testdoxHtml outputFile="build/logs/testdox.html"/>
39+
<testdoxText outputFile="build/logs/testdox.txt"/>
40+
<junit outputFile="build/logs/logfile.xml"/>
3641
</logging>
3742

3843
<php>
44+
<env name="XDEBUG_MODE" value="coverage"/>
3945
<server name="app.baseURL" value="http://example.com"/>
4046

4147
<!-- Directory containing phpunit.xml -->
@@ -51,13 +57,13 @@
5157
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
5258

5359
<!-- Database configuration -->
54-
<!-- <env name="database.tests.hostname" value="localhost"/> -->
55-
<!-- <env name="database.tests.database" value="tests"/> -->
56-
<!-- <env name="database.tests.username" value="tests_user"/> -->
57-
<!-- <env name="database.tests.password" value=""/> -->
58-
<!-- <env name="database.tests.DBDriver" value="MySQLi"/> -->
59-
<!-- <env name="database.tests.DBPrefix" value="tests_"/> -->
60-
<env name="database.tests.database" value=":memory:"/>
61-
<env name="database.tests.DBDriver" value="SQLite3"/>
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+
-->
6268
</php>
6369
</phpunit>

0 commit comments

Comments
 (0)