Skip to content

Commit e21bcb5

Browse files
committed
Add reusable phplinter-workflow
1 parent d777583 commit e21bcb5

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

.github/workflows/phplinter.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
description: 'The PHP-version to use for linting'
8+
type: string
9+
required: true
10+
repository:
11+
description: 'The repository that needs linting'
12+
type: string
13+
required: true
14+
ref:
15+
description: 'The branch, tag or SHA that needs linting'
16+
type: string
17+
required: false
18+
default: 'master'
19+
20+
env:
21+
supported: '["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]'
22+
23+
jobs:
24+
linter:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Supported version check
29+
if: contains(fromJSON(env.supported), inputs.php-version) == false
30+
run: exit 1
31+
32+
- name: Checkout Code
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
repository: ${{ inputs.repository }}
37+
ref: ${{ inputs.ref }}
38+
39+
- name: Setup PHP runtime
40+
uses: shivammathur/setup-php@v2
41+
with:
42+
tools: phive
43+
php-version: ${{ inputs.php-version }}
44+
coverage: "none"
45+
46+
- name: Install overtrue/phplint (v3.4)
47+
if: inputs.php-version == '7.4'
48+
run: |
49+
phive install overtrue/phplint@~3.4.0 --force-accept-unsigned --target ./bin
50+
51+
- name: Install overtrue/phplint (v4.5)
52+
if: inputs.php-version == '8.0'
53+
run: |
54+
phive install overtrue/phplint@~4.5.0 --force-accept-unsigned --target ./bin
55+
56+
- name: Install overtrue/phplint (v9.4)
57+
if: inputs.php-version == '8.1'
58+
run: |
59+
phive install overtrue/phplint@~9.4.0 --force-accept-unsigned --target ./bin
60+
61+
- name: Install overtrue/phplint (v9.5)
62+
if: inputs.php-version != '7.4' && inputs.php-version != '8.0' && inputs.php-version != '8.1'
63+
run: |
64+
phive install overtrue/phplint@~9.5.0 --force-accept-unsigned --target ./bin
65+
66+
- name: Lint PHP files
67+
run: |
68+
./bin/phplint --no-cache --no-progress -v

0 commit comments

Comments
 (0)