Skip to content

Commit d2289b9

Browse files
authored
Merge pull request #1 from lacatoire/test-workflow
test-workflow
2 parents 98cac35 + 51de94c commit d2289b9

28 files changed

Lines changed: 4956 additions & 436 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\Finder;
7+
8+
$finder = Finder::create()
9+
->in([__DIR__ . '/../../src', __DIR__ . '/../../tests']);
10+
11+
$config = new Config();
12+
$config->setRules(['@Symfony' => true]);
13+
$config->setFinder($finder);
14+
$config->setUsingCache(false);
15+
16+
return $config;

.github/workflows/php-cs-fixer.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: PHP Lint & CS Fixer
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: '8.3'
19+
coverage: none
20+
21+
- name: Install dependencies
22+
run: composer install --no-progress --no-interaction --prefer-dist
23+
24+
- name: Run PHP-CS-Fixer
25+
run: |
26+
composer codesniffer-fix

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.idea
1+
.idea
2+
vendor

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,19 @@ use Acriss\AcrissCodeParser;
4646
$parser = new AcrissCodeParser();
4747
$code = $parser->parse('CDMR');
4848

49-
// $code is an instance of Acriss\Model\AcrissCode
50-
51-
echo $code->category->value; // COMPACT
49+
echo $code->category->value;
5250
```
5351

5452
### Translate a code
5553

5654
```php
5755
use Acriss\AcrissTranslator;
5856

59-
$translator = new AcrissTranslator($translatorService); // Symfony's TranslatorInterface
57+
$translator = new AcrissTranslator($translatorService);
6058
$labels = $translator->translate($code, 'fr');
6159

62-
// $labels is an instance of Acriss\Model\TranslatedAcrissCode
63-
64-
echo $labels->category; // "Compacte"
65-
echo $labels->fuelAirCon; // "Essence, avec climatisation"
60+
echo $labels->category;
61+
echo $labels->fuelAirCon;
6662
```
6763

6864
### Get full details
@@ -125,7 +121,7 @@ composer install
125121
```php
126122
use Acriss\AcrissTranslator;
127123

128-
$translator = new AcrissTranslator($this->translator); // Symfony\Contracts\Translation\TranslatorInterface
124+
$translator = new AcrissTranslator($this->translator);
129125

130126
```
131127
* Compatible with Symfony translation (TranslatorInterface)
@@ -185,4 +181,10 @@ Want to add more? PRs welcome 👌
185181

186182
## 📄 License
187183

188-
This library is open-sourced under the MIT license.
184+
This library is open-sourced under the MIT license.
185+
186+
## Launch phpunit, phpstan, composer without anything
187+
188+
```bash
189+
docker run --rm -v "${PWD}:/app" -w /app php:8.3-cli bash -c "apt update && apt install -y git unzip curl > /dev/null && curl -sS https://getcomposer.org/installer | php && php composer.phar install && php vendor/bin/phpunit"
190+
```

composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit": "^10.0",
29-
"symfony/yaml": "*"
29+
"symfony/yaml": "*",
30+
"friendsofphp/php-cs-fixer": "*"
3031
},
3132
"extra": {
3233
"branch-alias": {
@@ -36,6 +37,13 @@
3637
"bundle": "Acriss\\Bridge\\Symfony\\AcrissCodeBundle"
3738
}
3839
},
40+
"scripts": {
41+
"codesniffer": "PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer fix src tests --dry-run --verbose --show-progress=dots --config=.github/php-cs-fixer/.php-cs-fixer.php",
42+
"codesniffer-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer fix src tests --verbose --show-progress=dots --config=.github/php-cs-fixer/.php-cs-fixer.php",
43+
"phpstan": "php ./vendor/bin/phpstan analyse --configuration .github/phpstan/phpstan.neon",
44+
"phpunit": "php ./vendor/bin/phpunit --configuration ./phpunit.xml.dist ./tests"
45+
},
46+
3947
"minimum-stability": "stable",
4048
"prefer-stable": true
4149
}

0 commit comments

Comments
 (0)