Skip to content

Commit 1b06f0f

Browse files
Create code-quality.yml
1 parent 114eb84 commit 1b06f0f

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

.github/workflows/code-quality.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Code Quality Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
10+
# Cancels all previous workflow runs for the same branch that have not yet completed.
11+
concurrency:
12+
# The concurrency group contains the workflow name and the branch name.
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
18+
lint: #-----------------------------------------------------------------------
19+
name: Lint PHP files
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check out source code
23+
uses: actions/checkout@v2
24+
25+
- name: Check existence of composer.json file
26+
id: check_composer_file
27+
uses: andstor/file-existence-action@v1
28+
with:
29+
files: "composer.json"
30+
31+
- name: Set up PHP environment
32+
if: steps.check_composer_file.outputs.files_exists == 'true'
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: '7.4'
36+
tools: cs2pr
37+
env:
38+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Install Composer dependencies & cache dependencies
41+
if: steps.check_composer_file.outputs.files_exists == 'true'
42+
uses: "ramsey/composer-install@v2"
43+
env:
44+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
45+
46+
- name: Check existence of vendor/bin/parallel-lint file
47+
id: check_linter_file
48+
uses: andstor/file-existence-action@v1
49+
with:
50+
files: "vendor/bin/parallel-lint"
51+
52+
- name: Run Linter
53+
if: steps.check_linter_file.outputs.files_exists == 'true'
54+
run: vendor/bin/parallel-lint -j 10 . --exclude vendor --checkstyle | cs2pr
55+
56+
phpcs: #----------------------------------------------------------------------
57+
name: PHPCS
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Check out source code
62+
uses: actions/checkout@v2
63+
64+
- name: Check existence of composer.json & phpcs.xml.dist files
65+
id: check_files
66+
uses: andstor/file-existence-action@v1
67+
with:
68+
files: "composer.json, phpcs.xml.dist"
69+
70+
- name: Set up PHP environment
71+
if: steps.check_files.outputs.files_exists == 'true'
72+
uses: shivammathur/setup-php@v2
73+
with:
74+
php-version: '7.4'
75+
tools: cs2pr
76+
env:
77+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Install Composer dependencies & cache dependencies
80+
if: steps.check_files.outputs.files_exists == 'true'
81+
uses: "ramsey/composer-install@v2"
82+
env:
83+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
84+
85+
- name: Check existence of vendor/bin/phpcs file
86+
id: check_phpcs_binary_file
87+
uses: andstor/file-existence-action@v1
88+
with:
89+
files: "vendor/bin/phpcs"
90+
91+
- name: Run PHPCS
92+
if: steps.check_phpcs_binary_file.outputs.files_exists == 'true'
93+
run: vendor/bin/phpcs -q --report=checkstyle | cs2pr

0 commit comments

Comments
 (0)