Skip to content

Commit 0bf4187

Browse files
committed
Refactor: merge reusable workflows
1 parent 2f8980a commit 0bf4187

File tree

1 file changed

+198
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)