Skip to content

Commit 3d53377

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

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

.github/workflows/phplinter.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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:
22+
- 7.4
23+
- 8.0
24+
- 8.1
25+
- 8.2
26+
- 8.3
27+
- 8.4
28+
29+
jobs:
30+
linter:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- name: Supported version check
35+
if: contains(fromJson(env.supported), inputs.php-version) == false
36+
run: exit 1
37+
38+
- name: Checkout Code
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
repository: ${{ inputs.repository }}
43+
ref: ${{ inputs.ref }}
44+
45+
- name: Setup PHP runtime
46+
uses: shivammathur/setup-php@v2
47+
with:
48+
tools: phive
49+
php-version: ${{ inputs.php-version }}
50+
coverage: "none"
51+
52+
- name: Install overtrue/phplint (v3.4)
53+
if: inputs.php-version == '7.4'
54+
run: |
55+
phive install overtrue/phplint@~3.4.0 --force-accept-unsigned --target ./bin
56+
57+
- name: Install overtrue/phplint (v4.5)
58+
if: inputs.php-version == '8.0'
59+
run: |
60+
phive install overtrue/phplint@~4.5.0 --force-accept-unsigned --target ./bin
61+
62+
- name: Install overtrue/phplint (v9.4)
63+
if: inputs.php-version == '8.1'
64+
run: |
65+
phive install overtrue/phplint@~9.4.0 --force-accept-unsigned --target ./bin
66+
67+
- name: Install overtrue/phplint (v9.5)
68+
if: inputs.php-version != '7.4' && inputs.php-version != '8.0' && inputs.php-version != '8.1'
69+
run: |
70+
phive install overtrue/phplint@~9.5.0 --force-accept-unsigned --target ./bin
71+
72+
- name: Lint PHP files
73+
run: |
74+
./bin/phplint --no-cache --no-progress -v

0 commit comments

Comments
 (0)