Skip to content

Commit a820d34

Browse files
author
Oleksii Bulba
committed
Feature: Workflows
- Added reusable workflows: - coding-standards.yml - phpcs, phpmd, php-cs-fixer; - composer-lint.yml - composer validate, normalize; - continuous-integration.yaml - phpunit; - static-analysis.yml - phpstan, psalm; Signed-off-by: Oleksii Bulba <obulba@trading-point.com>
1 parent ee7e487 commit a820d34

File tree

4 files changed

+321
-0
lines changed

4 files changed

+321
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: 'Coding Standards'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
description: 'The PHP version to use when running the job'
8+
default: '8.2'
9+
required: false
10+
type: 'string'
11+
composer-root-version:
12+
description: 'The version of the package being tested, in case of circular dependencies.'
13+
required: false
14+
type: 'string'
15+
composer-options:
16+
description: 'Additional flags for the composer install command.'
17+
default: '--prefer-dist'
18+
required: false
19+
type: 'string'
20+
21+
jobs:
22+
coding-standards:
23+
name: 'Coding Standards'
24+
runs-on: 'ubuntu-22.04'
25+
26+
strategy:
27+
matrix:
28+
php-version:
29+
- '${{ inputs.php-version }}'
30+
31+
steps:
32+
- name: 'Checkout'
33+
uses: 'actions/checkout@v3'
34+
35+
- name: 'Install PHP'
36+
uses: 'shivammathur/setup-php@v2'
37+
with:
38+
coverage: 'none'
39+
php-version: '${{ matrix.php-version }}'
40+
tools: 'cs2pr'
41+
42+
- name: 'Set COMPOSER_ROOT_VERSION'
43+
run: |
44+
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
45+
if: '${{ inputs.composer-root-version }}'
46+
47+
- name: 'Install Php_Codesniffer with Composer'
48+
uses: 'ramsey/composer-install@v2'
49+
with:
50+
dependency-versions: 'highest'
51+
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/phpcs'
52+
53+
- name: 'Run PHP_CodeSniffer'
54+
run: 'vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr'
55+
56+
mess-detector:
57+
name: 'Mess detector'
58+
runs-on: 'ubuntu-22.04'
59+
60+
strategy:
61+
matrix:
62+
php-version:
63+
- '${{ inputs.php-version }}'
64+
65+
steps:
66+
- name: 'Checkout'
67+
uses: 'actions/checkout@v3'
68+
69+
- name: 'Install PHP'
70+
uses: 'shivammathur/setup-php@v2'
71+
with:
72+
coverage: 'none'
73+
php-version: '${{ matrix.php-version }}'
74+
75+
- name: 'Set COMPOSER_ROOT_VERSION'
76+
run: |
77+
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
78+
if: '${{ inputs.composer-root-version }}'
79+
80+
- name: 'Install MessDetector with Composer'
81+
uses: 'ramsey/composer-install@v2'
82+
with:
83+
dependency-versions: 'highest'
84+
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/phpmd'
85+
86+
- name: 'PHP Mess Detector'
87+
uses: 'php-actions/phpmd@v1'
88+
with:
89+
php_version: '${{ matrix.php-version }}'
90+
path: 'src/'
91+
output: 'github'
92+
vendored_phpmd_path: 'vendor/micro/dev-tools/phpmd/vendor/bin/phpmd'
93+
# ruleset: test/phpmd/ruleset.xml
94+
95+
phpcsfixer:
96+
name: 'PHP Code Style fixer'
97+
runs-on: 'ubuntu-22.04'
98+
99+
strategy:
100+
matrix:
101+
php-version:
102+
- '${{ inputs.php-version }}'
103+
104+
steps:
105+
- name: 'Checkout'
106+
uses: 'actions/checkout@v3'
107+
108+
- name: 'Install PHP'
109+
uses: 'shivammathur/setup-php@v2'
110+
with:
111+
coverage: 'none'
112+
php-version: '${{ matrix.php-version }}'
113+
114+
- name: 'Set COMPOSER_ROOT_VERSION'
115+
run: |
116+
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
117+
if: '${{ inputs.composer-root-version }}'
118+
119+
- name: 'Install PHP Code Style fixer with Composer'
120+
uses: 'ramsey/composer-install@v2'
121+
with:
122+
dependency-versions: 'highest'
123+
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/php-cs-fixer'
124+
125+
- name: 'PHP Code Style fixer'
126+
run: 'vendor/micro/dev-tools/phpmd/vendor/bin/php-cs-fixer fix --verbose --dry-run --using-cache=no'
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 'Composer Lint'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
description: 'The PHP version to use when running the job'
8+
default: '8.2'
9+
required: false
10+
type: 'string'
11+
12+
jobs:
13+
composer-lint:
14+
name: 'Composer Lint'
15+
runs-on: 'ubuntu-22.04'
16+
17+
strategy:
18+
matrix:
19+
php-version:
20+
- '${{ inputs.php-version }}'
21+
22+
steps:
23+
- name: 'Checkout'
24+
uses: 'actions/checkout@v3'
25+
26+
- name: 'Install PHP'
27+
uses: 'shivammathur/setup-php@v2'
28+
with:
29+
coverage: 'none'
30+
php-version: '${{ matrix.php-version }}'
31+
tools: composer:v2, composer-normalize:2
32+
env:
33+
COMPOSER_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
34+
35+
- name: 'Composer normalize'
36+
run: 'composer-normalize --dry-run'
37+
38+
- name: 'Composer validate'
39+
run: 'composer validate --strict'
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: 'Continuous Integration'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-versions:
7+
description: 'The PHP versions to use when running the job'
8+
default: '8.2'
9+
required: false
10+
type: 'string'
11+
composer-root-version:
12+
description: 'The version of the package being tested, in case of circular dependencies.'
13+
required: false
14+
type: 'string'
15+
composer-options:
16+
description: 'Additional flags for the composer install command.'
17+
default: '--prefer-dist'
18+
required: false
19+
type: 'string'
20+
21+
env:
22+
fail-fast: true
23+
24+
jobs:
25+
phpunit:
26+
name: 'PHPUnit'
27+
runs-on: 'ubuntu-22.04'
28+
29+
strategy:
30+
matrix:
31+
php-version: '${{ fromJson(inputs.php-versions) }}'
32+
dependencies:
33+
- 'highest'
34+
include:
35+
- php-version: '${{ fromJson(inputs.php-versions)[0] }}'
36+
dependencies: 'lowest'
37+
38+
steps:
39+
- name: 'Checkout'
40+
uses: 'actions/checkout@v3'
41+
with:
42+
fetch-depth: 2
43+
44+
- name: 'Install PHP with PCOV'
45+
uses: 'shivammathur/setup-php@v2'
46+
with:
47+
php-version: '${{ matrix.php-version }}'
48+
coverage: 'pcov'
49+
ini-values: 'zend.assertions=1'
50+
51+
- name: 'Set COMPOSER_ROOT_VERSION'
52+
run: |
53+
echo "COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}" >> $GITHUB_ENV
54+
if: '${{ inputs.composer-root-version }}'
55+
56+
- name: 'Install dependencies with Composer'
57+
uses: 'ramsey/composer-install@v2'
58+
with:
59+
dependency-versions: '${{ matrix.dependencies }}'
60+
composer-options: '${{ inputs.composer-options }}'
61+
62+
- name: 'Run PHPUnit'
63+
run: 'vendor/bin/phpunit --coverage-clover=coverage.xml'
64+
65+
- name: 'Upload coverage reports to Codecov'
66+
run: |
67+
# Replace `linux` below with the appropriate OS
68+
curl -Os https://uploader.codecov.io/latest/linux/codecov
69+
chmod +x codecov
70+
./codecov -t ${CODECOV_TOKEN}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: 'Static Analysis'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
description: 'The PHP version to use when running the job'
8+
default: '8.2'
9+
required: false
10+
type: 'string'
11+
composer-root-version:
12+
description: 'The version of the package being tested, in case of circular dependencies.'
13+
required: false
14+
type: 'string'
15+
composer-options:
16+
description: 'Additional flags for the composer install command.'
17+
default: '--prefer-dist'
18+
required: false
19+
type: 'string'
20+
21+
jobs:
22+
phpstan:
23+
name: 'PHPStan'
24+
runs-on: 'ubuntu-22.04'
25+
26+
strategy:
27+
matrix:
28+
php-version:
29+
- '${{ inputs.php-version }}'
30+
31+
steps:
32+
- name: 'Checkout code'
33+
uses: 'actions/checkout@v3'
34+
35+
- name: 'Install PHP'
36+
uses: 'shivammathur/setup-php@v2'
37+
with:
38+
coverage: 'none'
39+
php-version: '${{ matrix.php-version }}'
40+
41+
- name: 'Set COMPOSER_ROOT_VERSION'
42+
run: |
43+
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
44+
if: '${{ inputs.composer-root-version }}'
45+
46+
- name: 'Install PHPStan with Composer'
47+
uses: 'ramsey/composer-install@v2'
48+
with:
49+
dependency-versions: 'highest'
50+
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/phpstan'
51+
52+
- name: 'Run a static analysis with phpstan/phpstan'
53+
run: 'vendor/bin/phpstan analyse'
54+
55+
psalm:
56+
name: 'Psalm'
57+
runs-on: 'ubuntu-22.04'
58+
59+
strategy:
60+
matrix:
61+
php-version:
62+
- '${{ inputs.php-version }}'
63+
64+
steps:
65+
- name: 'Checkout code'
66+
uses: 'actions/checkout@v3'
67+
68+
- name: 'Install PHP'
69+
uses: 'shivammathur/setup-php@v2'
70+
with:
71+
coverage: 'none'
72+
php-version: '${{ matrix.php-version }}'
73+
74+
- name: 'Set COMPOSER_ROOT_VERSION'
75+
run: |
76+
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
77+
if: '${{ inputs.composer-root-version }}'
78+
79+
- name: 'Install Psalm with Composer'
80+
uses: 'ramsey/composer-install@v2'
81+
with:
82+
dependency-versions: 'highest'
83+
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/psalm'
84+
85+
- name: 'Run a static analysis with vimeo/psalm'
86+
run: 'vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)'

0 commit comments

Comments
 (0)