Skip to content

Commit b2bccea

Browse files
committed
Github actions: Composer & Code-Style
1 parent 90e5bf7 commit b2bccea

File tree

5 files changed

+89
-3
lines changed

5 files changed

+89
-3
lines changed

.github/workflows/codestyle.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Codestyle
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ $default-branch ]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Cache Composer packages
19+
id: composer-cache
20+
uses: actions/cache@v3
21+
with:
22+
path: vendor
23+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }}
24+
restore-keys: |
25+
${{ runner.os }}-php-
26+
27+
- name: Install dependencies
28+
run: composer install --prefer-dist --no-progress
29+
30+
- name: Check code style
31+
run: composer run-script codestyle:lint

.github/workflows/composer.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PHP Composer
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ $default-branch ]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Validate composer.json and composer.lock
19+
run: composer validate --strict
20+
21+
- name: Cache Composer packages
22+
id: composer-cache
23+
uses: actions/cache@v3
24+
with:
25+
path: vendor
26+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-php-
29+
30+
- name: Install dependencies
31+
run: composer install --prefer-dist --no-progress
32+
33+
- name: Run test suite
34+
run: composer run-script test

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ codeCoverage/
33
vendor/
44
composer.lock
55
.php_cs.cache
6+
.php-cs-fixer.php
7+
.php-cs-fixer.cache
68
_ide_helper.php
79
.phpstorm.meta.php
810
coverage
911
coverage.xml
1012
phpunit.local.xml
1113
.phpunit.result.cache
1214
composer.lock
13-
/tests/_output
15+
/tests/_output

.php-cs-fixer.dist.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in('src')
5+
->append([__FILE__])
6+
;
7+
8+
$config = new PhpCsFixer\Config();
9+
10+
return $config
11+
->setRules([
12+
'@PSR12' => true,
13+
'array_syntax' => ['syntax' => 'short'],
14+
])
15+
->setFinder($finder)
16+
;

composer.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
"EDI\\Generator\\": "src/Generator/"
1010
}
1111
},
12-
"require": {
12+
"scripts": {
13+
"test": "vendor/bin/phpunit",
14+
"codestyle:fix": "vendor/bin/php-cs-fixer fix",
15+
"codestyle:lint": "vendor/bin/php-cs-fixer fix --dry-run"
1316
},
1417
"require-dev": {
1518
"sabas/edifact": "^0.4.1",
1619
"phpunit/phpunit": "~8.0",
17-
"friendsofphp/php-cs-fixer": "^2.14"
20+
"friendsofphp/php-cs-fixer": "^3.9.5"
1821
}
1922
}

0 commit comments

Comments
 (0)