Skip to content

Commit c43d7ea

Browse files
committed
Add editorconfig, gitattributes, CI workflow, update composer.json, README
1 parent f0f043e commit c43d7ea

25 files changed

Lines changed: 2122 additions & 353 deletions

‎.editorconfig‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 4
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[composer.json]
18+
indent_size = 4

‎.gitattributes‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
* text=auto eol=lf
2+
3+
# Files to exclude from the distributed Composer package.
4+
/.editorconfig export-ignore
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.github export-ignore
8+
/.php-cs-fixer.dist.php export-ignore
9+
/phpstan.neon.dist export-ignore
10+
/phpunit.xml.dist export-ignore
11+
/tests export-ignore
12+
/docs export-ignore
13+
/CONTRIBUTING.md export-ignore
14+
/CODE_OF_CONDUCT.md export-ignore

‎.github/workflows/ci.yml‎

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, "*.x", "feat/*", "fix/*"]
6+
pull_request:
7+
branches: [main, "*.x"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
validate:
14+
name: composer validate
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: "8.1"
21+
extensions: json, mbstring
22+
coverage: none
23+
tools: composer:v2
24+
- run: composer validate --strict
25+
26+
cs:
27+
name: Coding style (PHP-CS-Fixer)
28+
runs-on: ubuntu-latest
29+
needs: validate
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: "8.1"
35+
extensions: json, mbstring
36+
coverage: none
37+
tools: composer:v2
38+
- name: Install dependencies
39+
run: composer install --prefer-dist --no-progress --no-interaction
40+
- name: Check coding standards
41+
run: composer cs-check
42+
43+
stan:
44+
name: Static analysis (PHPStan)
45+
runs-on: ubuntu-latest
46+
needs: validate
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: shivammathur/setup-php@v2
50+
with:
51+
php-version: "8.3"
52+
extensions: json, mbstring
53+
coverage: none
54+
tools: composer:v2
55+
- name: Install dependencies
56+
run: composer install --prefer-dist --no-progress --no-interaction
57+
- name: Run PHPStan
58+
run: composer stan
59+
60+
tests:
61+
name: PHPUnit (PHP ${{ matrix.php }}, ${{ matrix.deps }})
62+
runs-on: ubuntu-latest
63+
needs: validate
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
php: ["8.1", "8.2", "8.3", "8.4"]
68+
deps: ["highest"]
69+
include:
70+
- php: "8.1"
71+
deps: "lowest"
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Set up PHP ${{ matrix.php }}
76+
uses: shivammathur/setup-php@v2
77+
with:
78+
php-version: ${{ matrix.php }}
79+
extensions: json, mbstring
80+
coverage: none
81+
tools: composer:v2
82+
83+
- name: Get composer cache directory
84+
id: composer-cache
85+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
86+
87+
- name: Cache composer dependencies
88+
uses: actions/cache@v4
89+
with:
90+
path: ${{ steps.composer-cache.outputs.dir }}
91+
key: composer-${{ matrix.php }}-${{ matrix.deps }}-${{ hashFiles('**/composer.json') }}
92+
restore-keys: composer-${{ matrix.php }}-${{ matrix.deps }}-
93+
94+
- name: Install highest dependencies
95+
if: matrix.deps == 'highest'
96+
run: composer update --prefer-dist --no-progress --no-interaction
97+
98+
- name: Install lowest dependencies
99+
if: matrix.deps == 'lowest'
100+
run: composer update --prefer-dist --no-progress --no-interaction --prefer-lowest --prefer-stable
101+
102+
- name: Run PHPUnit
103+
run: composer test
104+
105+
coverage:
106+
name: Coverage
107+
runs-on: ubuntu-latest
108+
needs: tests
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
- name: Set up PHP
113+
uses: shivammathur/setup-php@v2
114+
with:
115+
php-version: "8.3"
116+
extensions: json, mbstring
117+
coverage: pcov
118+
tools: composer:v2
119+
120+
- name: Install dependencies
121+
run: composer install --prefer-dist --no-progress --no-interaction
122+
123+
- name: Run PHPUnit with coverage
124+
run: vendor/bin/phpunit --coverage-clover=coverage.xml
125+
126+
- name: Upload coverage to Codecov
127+
uses: codecov/codecov-action@v5
128+
with:
129+
files: ./coverage.xml
130+
flags: phpunit
131+
fail_ci_if_error: false

‎.gitignore‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
/.vscode/
33
/.vs/
44
/vendor/
5-
/composer.lock
5+
/composer.lock
6+
/build/
7+
/.phpunit.cache/
8+
/.phpunit.result.cache
9+
/.php-cs-fixer.cache

‎.php-cs-fixer.dist.php‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->in([__DIR__ . '/src', __DIR__ . '/tests'])
7+
->name('*.php');
8+
9+
return (new PhpCsFixer\Config())
10+
->setRiskyAllowed(true)
11+
->setRules([
12+
'@PSR12' => true,
13+
'@PHP81Migration' => true,
14+
'declare_strict_types' => true,
15+
'array_syntax' => ['syntax' => 'short'],
16+
'no_unused_imports' => true,
17+
'ordered_imports' => [
18+
'sort_algorithm' => 'alpha',
19+
'imports_order' => ['class', 'function', 'const'],
20+
],
21+
'single_quote' => true,
22+
'trailing_comma_in_multiline' => true,
23+
'no_trailing_whitespace' => true,
24+
'no_whitespace_in_blank_line' => true,
25+
'blank_line_after_opening_tag' => true,
26+
'blank_line_before_statement' => ['statements' => ['return']],
27+
'method_chaining_indentation' => true,
28+
'native_function_invocation' => false,
29+
'phpdoc_align' => ['align' => 'vertical'],
30+
'phpdoc_separation' => true,
31+
'phpdoc_trim' => true,
32+
'no_superfluous_phpdoc_tags' => false,
33+
])
34+
->setFinder($finder)
35+
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache');

0 commit comments

Comments
 (0)