Skip to content

Commit 53699f4

Browse files
committed
Initial commit
0 parents  commit 53699f4

File tree

83 files changed

+5537
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+5537
-0
lines changed

.github/workflows/tests.yml

+275
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
name: "Tests"
2+
3+
on: ['push', 'pull_request']
4+
5+
env:
6+
MIN_COVERED_MSI: 88
7+
MIN_MSI: 86
8+
REQUIRED_PHP_EXTENSIONS: "json"
9+
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
10+
11+
jobs:
12+
coding-standards:
13+
name: "Coding Standards"
14+
15+
runs-on: "ubuntu-latest"
16+
17+
strategy:
18+
matrix:
19+
php: [7.4]
20+
dependencies: [locked]
21+
22+
steps:
23+
- name: "Checkout"
24+
uses: "actions/checkout@v2"
25+
26+
- name: "Install PHP with extensions"
27+
uses: "shivammathur/setup-php@v2"
28+
with:
29+
coverage: "none"
30+
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
31+
php-version: "${{ matrix.php }}"
32+
33+
# - name: "Validate composer.json and composer.lock"
34+
# run: "composer validate --strict"
35+
36+
- name: "Determine composer cache directory"
37+
id: "determine-composer-cache-directory"
38+
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""
39+
40+
- name: "Cache dependencies installed with composer"
41+
uses: "actions/cache@v2"
42+
with:
43+
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
44+
key: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
45+
restore-keys: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-"
46+
47+
- name: "Install lowest dependencies from composer.json"
48+
if: "matrix.dependencies == 'lowest'"
49+
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"
50+
51+
- name: "Install locked dependencies from composer.lock"
52+
if: "matrix.dependencies == 'locked'"
53+
run: "composer install --no-interaction --no-progress --no-suggest"
54+
55+
- name: "Install highest dependencies from composer.json"
56+
if: "matrix.dependencies == 'highest'"
57+
run: "composer update --no-interaction --no-progress --no-suggest"
58+
59+
- name: "Run ergebnis/composer-normalize"
60+
run: "composer normalize --dry-run"
61+
62+
- name: "Run phpcs"
63+
run: "composer codestyle"
64+
65+
static-code-analysis:
66+
name: "Static Code Analysis"
67+
68+
runs-on: "ubuntu-latest"
69+
70+
strategy:
71+
matrix:
72+
php: [7.4]
73+
74+
dependencies: [locked]
75+
76+
steps:
77+
- name: "Checkout"
78+
uses: "actions/checkout@v2"
79+
80+
- name: "Install PHP with extensions"
81+
uses: "shivammathur/setup-php@v2"
82+
with:
83+
coverage: "none"
84+
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
85+
php-version: "${{ matrix.php }}"
86+
87+
- name: "Determine composer cache directory"
88+
id: "determine-composer-cache-directory"
89+
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""
90+
91+
- name: "Cache dependencies installed with composer"
92+
uses: "actions/cache@v2"
93+
with:
94+
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
95+
key: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
96+
restore-keys: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-"
97+
98+
- name: "Install lowest dependencies from composer.json"
99+
if: "matrix.dependencies == 'lowest'"
100+
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"
101+
102+
- name: "Install locked dependencies from composer.lock"
103+
if: "matrix.dependencies == 'locked'"
104+
run: "composer install --no-interaction --no-progress --no-suggest"
105+
106+
- name: "Install highest dependencies from composer.json"
107+
if: "matrix.dependencies == 'highest'"
108+
run: "composer update --no-interaction --no-progress --no-suggest"
109+
110+
- name: "Create cache directory for phpstan/phpstan"
111+
run: "mkdir -p .build/phpstan"
112+
113+
- name: "Cache cache directory for phpstan/phpstan"
114+
uses: "actions/cache@v2"
115+
with:
116+
path: ".build/phpstan"
117+
key: "php-${{ matrix.php }}-phpstan-${{ github.sha }}"
118+
restore-keys: "php-${{ matrix.php }}-phpstan-"
119+
120+
- name: "Run phpstan/phpstan"
121+
run: "composer phpstan"
122+
123+
tests:
124+
name: "Tests"
125+
126+
runs-on: "ubuntu-latest"
127+
128+
strategy:
129+
matrix:
130+
php: [7.4]
131+
132+
dependencies:
133+
- "lowest"
134+
- "locked"
135+
- "highest"
136+
137+
steps:
138+
- name: "Checkout"
139+
uses: "actions/checkout@v2"
140+
141+
- name: "Install PHP with extensions"
142+
uses: "shivammathur/setup-php@v2"
143+
with:
144+
coverage: "none"
145+
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
146+
php-version: "${{ matrix.php }}"
147+
148+
- name: "Determine composer cache directory"
149+
id: "determine-composer-cache-directory"
150+
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""
151+
152+
- name: "Cache dependencies installed with composer"
153+
uses: "actions/cache@v2"
154+
with:
155+
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
156+
key: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
157+
restore-keys: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-"
158+
159+
- name: "Install lowest dependencies from composer.json"
160+
if: "matrix.dependencies == 'lowest'"
161+
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"
162+
163+
- name: "Install locked dependencies from composer.lock"
164+
if: "matrix.dependencies == 'locked'"
165+
run: "composer install --no-interaction --no-progress --no-suggest"
166+
167+
- name: "Install highest dependencies from composer.json"
168+
if: "matrix.dependencies == 'highest'"
169+
run: "composer update --no-interaction --no-progress --no-suggest"
170+
171+
- name: "Run all tests"
172+
run: "composer test"
173+
174+
code-coverage:
175+
name: "Code Coverage"
176+
177+
runs-on: "ubuntu-latest"
178+
179+
strategy:
180+
matrix:
181+
php: [7.4]
182+
183+
dependencies:
184+
- "locked"
185+
186+
steps:
187+
- name: "Checkout"
188+
uses: "actions/checkout@v2"
189+
190+
- name: "Install PHP with extensions"
191+
uses: "shivammathur/setup-php@v2"
192+
with:
193+
coverage: "pcov"
194+
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
195+
php-version: "${{ matrix.php }}"
196+
197+
- name: "Determine composer cache directory"
198+
id: "determine-composer-cache-directory"
199+
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""
200+
201+
- name: "Cache dependencies installed with composer"
202+
uses: "actions/cache@v2"
203+
with:
204+
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
205+
key: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
206+
restore-keys: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-"
207+
208+
- name: "Install lowest dependencies from composer.json"
209+
if: "matrix.dependencies == 'lowest'"
210+
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"
211+
212+
- name: "Install locked dependencies from composer.lock"
213+
if: "matrix.dependencies == 'locked'"
214+
run: "composer install --no-interaction --no-progress --no-suggest"
215+
216+
- name: "Install highest dependencies from composer.json"
217+
if: "matrix.dependencies == 'highest'"
218+
run: "composer update --no-interaction --no-progress --no-suggest"
219+
220+
- name: "Collect code coverage with pcov and phpunit/phpunit"
221+
run: "composer test-coverage"
222+
223+
- name: "Send code coverage report to Codecov.io"
224+
env:
225+
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
226+
run: "bash <(curl -s https://codecov.io/bash)"
227+
228+
mutation-tests:
229+
name: "Mutation Tests"
230+
231+
runs-on: "ubuntu-latest"
232+
233+
strategy:
234+
matrix:
235+
php: [7.4]
236+
237+
dependencies:
238+
- "locked"
239+
240+
steps:
241+
- name: "Checkout"
242+
uses: "actions/checkout@v2"
243+
244+
- name: "Install PHP with extensions"
245+
uses: "shivammathur/setup-php@v2"
246+
with:
247+
coverage: "pcov"
248+
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
249+
php-version: "${{ matrix.php }}"
250+
251+
- name: "Determine composer cache directory"
252+
id: "determine-composer-cache-directory"
253+
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""
254+
255+
- name: "Cache dependencies installed with composer"
256+
uses: "actions/cache@v2"
257+
with:
258+
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
259+
key: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
260+
restore-keys: "php-${{ matrix.php }}-composer-${{ matrix.dependencies }}-"
261+
262+
- name: "Install lowest dependencies from composer.json"
263+
if: "matrix.dependencies == 'lowest'"
264+
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"
265+
266+
- name: "Install locked dependencies from composer.lock"
267+
if: "matrix.dependencies == 'locked'"
268+
run: "composer install --no-interaction --no-progress --no-suggest"
269+
270+
- name: "Install highest dependencies from composer.json"
271+
if: "matrix.dependencies == 'highest'"
272+
run: "composer update --no-interaction --no-progress --no-suggest"
273+
274+
- name: "Run mutation tests with pcov and infection/infection"
275+
run: "vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=${{ env.MIN_COVERED_MSI }} --min-msi=${{ env.MIN_MSI }}"

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.build
2+
.phpcs-cache
3+
composer.lock
4+
vendor
5+
coverage
6+
.phpunit.result.cache
7+
.idea

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## Unreleased
8+

CONTRIBUTING.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
### Coding Standards
44+
45+
We are using [`squizlabs/PHP_CodeSniffer`](https://github.com/squizlabs/PHP_CodeSniffer) to enforce coding standards in PHP files.
46+
47+
Run
48+
49+
```
50+
$ composer codestyle
51+
```
52+
53+
to automatically fix coding standard violations.
54+
55+
### Static Code Analysis
56+
57+
We are using [`phpstan/phpstan`](https://github.com/phpstan/phpstan) to statically analyze the code.
58+
59+
Run
60+
61+
```
62+
$ composer phpstan
63+
```
64+
65+
to run a static code analysis.
66+
67+
### Tests
68+
69+
We are using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to drive the development.
70+
71+
Run
72+
73+
```
74+
$ composer test
75+
```
76+
77+
to run all the tests.
78+
79+
Alternatively, you can run
80+
81+
```
82+
$ composer test-fast
83+
```
84+
85+
to get feedback quickly. This command will only run unit tests. Which should take around 100-200ms to run.
86+
87+
:exclamation: Make sure to run the whole test suite before opening a PR with the suggested changes.
88+
89+
### Mutation Tests
90+
91+
We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.
92+
93+
Enable `pcov` or `Xdebug` and run
94+
95+
```
96+
$ composer test-mutation
97+
```
98+
99+
to run mutation tests.
100+
101+
**Happy coding**!

0 commit comments

Comments
 (0)