Skip to content

Commit 52b13e3

Browse files
committed
Refactor: merge reusable workflows
1 parent 2f8980a commit 52b13e3

File tree

1 file changed

+212
-0
lines changed

1 file changed

+212
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
workflow_call:
5+
inputs:
6+
enable_phplinter:
7+
description: 'Enable the PHP-Linter for this repository'
8+
type: boolean
9+
required: false
10+
default: false
11+
phplinter-versions:
12+
description: 'The PHP-version to use for linting'
13+
type: string
14+
required: false
15+
default: '["8.1", "8.2", "8.3", "8.4"]'
16+
17+
enable_eslinter:
18+
description: 'Enable the ES-Linter for this repository'
19+
type: boolean
20+
required: false
21+
default: false
22+
eslinter-config:
23+
description: 'The location of the configuration file'
24+
type: string
25+
required: false
26+
default: './tools/linters/eslint.config.js'
27+
28+
enable_jsonlinter:
29+
description: 'Enable the JSON-Linter for this repository'
30+
type: boolean
31+
required: false
32+
default: false
33+
34+
enable_yamllinter:
35+
description: 'Enable the YAML-Linter for this repository'
36+
type: boolean
37+
required: false
38+
default: false
39+
yamllinter-config:
40+
description: 'The location of the linter-configuration'
41+
type: string
42+
required: false
43+
default: ''
44+
45+
enable_stylelinter:
46+
description: 'Enable the Style-Linter for this repository'
47+
type: boolean
48+
required: false
49+
default: false
50+
stylelinter-pattern:
51+
description: 'The file-pattern to match files that are being linted'
52+
type: string
53+
required: false
54+
default: '**/*.{css,scss,sass}'
55+
stylelinter-config:
56+
description: 'The location of the linter-configuration'
57+
type: string
58+
required: false
59+
default: 'tools/linters/.stylelintrc.json'
60+
61+
repository:
62+
description: 'The repository that needs linting'
63+
type: string
64+
default: ${{ github.repository }}
65+
required: false
66+
ref:
67+
description: 'The branch, tag or SHA that needs linting'
68+
type: string
69+
required: false
70+
default: ${{ github.ref }}
71+
72+
env:
73+
php_supported_versions: '["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]'
74+
75+
jobs:
76+
phplinter:
77+
if: inputs.enable_phplinter == true
78+
runs-on: ubuntu-latest
79+
80+
strategy:
81+
matrix:
82+
php_version: fromJSON(inputs.phplinter-versions)
83+
84+
steps:
85+
- name: Supported version check
86+
if: contains(fromJSON(env.php_supported_versions), inputs.phplinter-versions) == false
87+
run: exit 1
88+
89+
- name: Checkout Code
90+
uses: actions/checkout@v4
91+
with:
92+
fetch-depth: 0
93+
repository: ${{ inputs.repository }}
94+
ref: ${{ inputs.ref }}
95+
96+
- name: Setup PHP runtime
97+
uses: shivammathur/setup-php@v2
98+
with:
99+
tools: phive
100+
php-version: ${{ matrix.php_version }}
101+
coverage: "none"
102+
103+
- name: Install overtrue/phplint (v3.4)
104+
if: matrix.php_version == '7.4'
105+
run: |
106+
phive install overtrue/phplint@~3.4.0 --force-accept-unsigned --target ./bin
107+
108+
- name: Install overtrue/phplint (v4.5)
109+
if: matrix.php_version == '8.0'
110+
run: |
111+
phive install overtrue/phplint@~4.5.0 --force-accept-unsigned --target ./bin
112+
113+
- name: Install overtrue/phplint (v9.4)
114+
if: matrix.php_version == '8.1'
115+
run: |
116+
phive install overtrue/phplint@~9.4.0 --force-accept-unsigned --target ./bin
117+
118+
- name: Install overtrue/phplint (v9.5)
119+
if: |
120+
matrix.php_version != '7.4'
121+
&& matrix.php_version != '8.0'
122+
&& matrix.php_version != '8.1'
123+
run: |
124+
phive install overtrue/phplint@~9.5.0 --force-accept-unsigned --target ./bin
125+
126+
- name: Lint PHP files
127+
run: |
128+
./bin/phplint --no-cache --no-progress -v
129+
130+
ecmascript-linter:
131+
if: inputs.enable_eslinter == true
132+
runs-on: ubuntu-latest
133+
134+
steps:
135+
- name: Install NodeJS
136+
uses: actions/setup-node@v4
137+
with:
138+
node-version: latest
139+
140+
- name: Checkout Code
141+
uses: actions/checkout@v4
142+
with:
143+
fetch-depth: 0
144+
repository: ${{ inputs.repository }}
145+
ref: ${{ inputs.ref }}
146+
147+
- name: Install ESLint
148+
run: |
149+
npm install eslint eslint-config
150+
151+
- name: Lint JavaScript
152+
run: ./node_modules/.bin/eslint --config=${{ inputs.eslinter-config }}
153+
env:
154+
DEBUG: eslint:languages:js
155+
156+
json-linter:
157+
if: inputs.enable_jsonlinter == true
158+
runs-on: ubuntu-latest
159+
160+
steps:
161+
- name: Checkout Code
162+
uses: actions/checkout@v4
163+
with:
164+
fetch-depth: 0
165+
repository: ${{ inputs.repository }}
166+
ref: ${{ inputs.ref }}
167+
168+
- name: Lint JSON
169+
uses: limitusus/json-syntax-check@v2
170+
171+
style-linter:
172+
if: inputs.enable_stylelinter == true
173+
runs-on: ubuntu-latest
174+
175+
steps:
176+
- name: Install NodeJS
177+
uses: actions/setup-node@v4
178+
with:
179+
node-version: latest
180+
181+
- name: Checkout Code
182+
uses: actions/checkout@v4
183+
with:
184+
fetch-depth: 0
185+
repository: ${{ inputs.repository }}
186+
ref: ${{ inputs.ref }}
187+
188+
- name: Install StyleLint
189+
run: npm install stylelint stylelint-config-standard
190+
191+
- name: Lint stylesheets
192+
run: |
193+
./node_modules/.bin/stylelint \
194+
-f verbose \
195+
-c=${{ inputs.stylelinter-config }} ${{ inputs.stylelinter-pattern }}
196+
197+
yaml-linter:
198+
if: inputs.enable_yamllinter == true
199+
runs-on: ubuntu-latest
200+
201+
steps:
202+
- name: Checkout Code
203+
uses: actions/checkout@v4
204+
with:
205+
fetch-depth: 0
206+
repository: ${{ inputs.repository }}
207+
ref: ${{ inputs.ref }}
208+
209+
- name: Lint YAML
210+
uses: ibiqlik/action-yamllint@v3.1.1
211+
with:
212+
config_file: ${{ inputs.yamllinter-config }}

0 commit comments

Comments
 (0)