Skip to content

Commit 307f861

Browse files
committed
Merge branch 'release-v0-10-1'
2 parents 16d2686 + 3dd7dd7 commit 307f861

File tree

15 files changed

+406
-62
lines changed

15 files changed

+406
-62
lines changed

.dockerignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# composer
2+
vendor/
3+
4+
# docker
5+
Dockerfile
6+
.dockerignore
7+
8+
# documentation
9+
*.md
10+
11+
# friendsofphp/php-cs-fixer
12+
.php-cs-fixer.php
13+
.php-cs-fixer.cache
14+
15+
# git
16+
.git
17+
.gitignore
18+
.gitattributes
19+
20+
# IDEs
21+
.vscode/
22+
.idea/
23+
*.swp
24+
*.swo
25+
*~
26+
27+
# OS
28+
.DS_Store
29+
.DS_Store?
30+
._*
31+
.Spotlight-V100
32+
.Trashes
33+
ehthumbs.db
34+
Thumbs.db
35+
36+
# phpstan
37+
phpstan.neon
38+
39+
# phpunit
40+
phpunit.xml
41+
.phpunit.cache
42+

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
qa:
11+
name: QA (PHP ${{ matrix.php }})
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
php: ['8.0']
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php }}
26+
extensions: mbstring
27+
coverage: none
28+
29+
- name: Get Composer cache directory
30+
id: composer-cache
31+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
32+
33+
- name: Cache Composer dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: ${{ steps.composer-cache.outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: ${{ runner.os }}-composer-
39+
40+
- name: Install dependencies
41+
run: composer install --prefer-dist --no-progress --optimize-autoloader
42+
43+
- name: Check coding standards
44+
run: vendor/bin/php-cs-fixer fix --dry-run --verbose
45+
46+
- name: Run PHPStan
47+
run: vendor/bin/phpstan analyze --memory-limit=256M
48+
49+
- name: Run Rector
50+
run: vendor/bin/rector process --dry-run
51+
52+
- name: Run phpspec
53+
run: vendor/bin/phpspec --no-interaction run
54+
55+
- name: Run PHPUnit
56+
run: vendor/bin/phpunit

.gitignore

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
# Third party
2-
/composer.lock
3-
/vendor
4-
/phpunit.xml
5-
/.couscous
6-
/.php_cs.cache
7-
/.phpunit.result.cache
1+
# composer
2+
composer.lock
3+
vendor/
4+
5+
# couscous
6+
.couscous
7+
8+
# friendsofphp/php-cs-fixer
9+
.php_cs.cache
10+
.php-cs-fixer.php
11+
.php-cs-fixer.cache
12+
13+
# phpstan
14+
phpstan.neon
15+
16+
# phpunit
17+
phpunit.xml
18+
.phpunit.result.cache
819

920
# Temporary files
10-
/.php_cs.cache
1121
/fixtures/actual
1222
!/fixtures/actual/Generated*Test/.gitkeep

.php-cs-fixer.dist.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
/**
4+
* PHP CS Fixer documentation:
5+
* - Homepage: https://cs.symfony.com/
6+
* - List of all available rules: https://cs.symfony.com/doc/rules/index.html
7+
* - List of all available rule sets: https://cs.symfony.com/doc/ruleSets/index.html
8+
* - Find / Compare / See History rules: https://mlocati.github.io/php-cs-fixer-configurator
9+
*
10+
* To inspect a specific rule (e.g. `blank_line_before_statement`), run:
11+
*
12+
* ```console
13+
* > php-cs-fixer describe blank_line_before_statement
14+
* ```
15+
*
16+
* ------------------------------------------------------------------------------
17+
*
18+
* `new \PhpCsFixer\Finder()` is equivalent to:
19+
*
20+
* ```php
21+
* \Symfony\Component\Finder\Finder::create()
22+
* ->files()
23+
* ->name('/\.php$/')
24+
* ->exclude('vendor')
25+
* ->ignoreVCSIgnored(true) // Follow rules establish in .gitignore
26+
* ->ignoreDotFiles(false) // Do not ignore files starting with `.`, like `.php-cs-fixer-dist.php`
27+
* ;
28+
* ```
29+
*/
30+
31+
$finder = (new PhpCsFixer\Finder())
32+
->in(__DIR__)
33+
;
34+
35+
return (new PhpCsFixer\Config())
36+
->setRules([
37+
'@Symfony' => true,
38+
39+
// [Symfony] defaults to `camelCase`, we set it to `snake_case` (phpspec style)
40+
'php_unit_method_casing' => ['case' => 'snake_case'],
41+
42+
// [Symfony] defaults to `true`, we set it to `false` for phpspec
43+
'visibility_required' => false,
44+
])
45+
->setUsingCache(true)
46+
->setFinder($finder)
47+
;

.php_cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,34 @@ changes, improvements or alternatives may be given).
1212

1313
Here's some tips to make you the best contributor ever:
1414

15+
* [Getting started](#getting-started)
1516
* [Standard code](#standard-code)
1617
* [Specifications](#specifications)
1718
* [Keeping your fork up-to-date](#keeping-your-fork-up-to-date)
1819

20+
## Getting started
21+
22+
Initialize the Docker development environment:
23+
24+
```console
25+
make lib-init
26+
```
27+
28+
Run the full QA pipeline:
29+
30+
```console
31+
make lib-qa
32+
```
33+
34+
Run `make` to see all available targets.
35+
1936
## Standard code
2037

2138
Use [PHP CS fixer](http://cs.sensiolabs.org/) to make your code compliant with
2239
Memio's coding standards:
2340

2441
```console
25-
$ ./vendor/bin/php-cs-fixer fix .
42+
make cs-fix
2643
```
2744

2845
## Specifications
@@ -32,31 +49,31 @@ Memio drives its development using [phpspec](http://www.phpspec.net/).
3249
First bootstrap the code for the Specification:
3350

3451
```console
35-
$ phpspec describe 'Memio\Memio\MyNewUseCase'
52+
make phpspec arg="describe 'Memio\SpecGen\MyNewUseCase'"
3653
```
3754

3855
Next, write the actual code of the Specification:
3956

4057
```console
41-
$ $EDITOR spec/Memio/SpecGen/MyNewUseCase.php
58+
$EDITOR spec/Memio/SpecGen/MyNewUseCase.php
4259
```
4360

4461
Then bootstrap the code for the corresponding Use Case:
4562

4663
```console
47-
$ phpspec run
64+
make phpspec
4865
```
4966

5067
Follow that by writing the actual code of the Use Case:
5168

5269
```console
53-
$ $EDITOR src/Memio/SpecGen/MyNewUseCase.php
70+
$EDITOR src/Memio/SpecGen/MyNewUseCase.php
5471
```
5572

5673
Finally run the specification:
5774

5875
```console
59-
$ phpspec run
76+
make phpspec
6077
```
6178

6279
Results should be green!

Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# syntax=docker/dockerfile:1
2+
3+
###
4+
# PHP Dev Container
5+
# Utility Tools: PHP, bash, Composer
6+
###
7+
FROM php:7.2-cli AS php_dev_container
8+
9+
# Composer environment variables:
10+
# * default user is superuser (root), so allow them
11+
# * put cache directory in a readable/writable location
12+
# _Note_: When running `composer` in container, use `--no-cache` option
13+
ENV COMPOSER_ALLOW_SUPERUSER=1 \
14+
COMPOSER_CACHE_DIR=/tmp/.composer/cache
15+
16+
# Update apt sources to use archived Debian repositories
17+
RUN sed -i 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list \
18+
&& sed -i 's/security.debian.org/archive.debian.org/g' /etc/apt/sources.list \
19+
&& sed -i '/stretch-updates/d' /etc/apt/sources.list
20+
21+
# Install dependencies:
22+
# * git: for composer to download packages from source
23+
# * libzip-dev: for composer packages that use ZIP archives
24+
# * unzip: for composer to extract packages
25+
# _Note (Hadolint)_: No version locking for dev container
26+
# hadolint ignore=DL3008
27+
RUN apt-get update && apt-get install -y --no-install-recommends \
28+
git \
29+
libzip-dev \
30+
unzip \
31+
&& rm -rf /var/lib/apt/lists/*
32+
33+
# Copy Composer binary from composer image
34+
# _Note (Hadolint)_: False positive as `COPY` works with images too
35+
# See: https://github.com/hadolint/hadolint/issues/197#issuecomment-1016595425
36+
# hadolint ignore=DL3022
37+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
38+
39+
WORKDIR /app
40+
41+
# Caching `composer install`, as long as composer.json doesn't change.
42+
COPY composer.json ./
43+
RUN composer install \
44+
--no-cache \
45+
--no-interaction \
46+
--no-plugins \
47+
--no-scripts \
48+
--optimize-autoloader
49+
50+
# Copy the remaining application files (excluding those listed in .dockerignore)
51+
COPY . .

0 commit comments

Comments
 (0)