Skip to content

Commit 92efc4e

Browse files
committed
Refactor: merge reusable workflows
1 parent 2f8980a commit 92efc4e

File tree

1 file changed

+209
-0
lines changed

1 file changed

+209
-0
lines changed
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
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: ${{ matrix.php_version }} != '7.4' && ${{ matrix.php_version }} != '8.0' && ${{ matrix.php_version }} != '8.1'
120+
run: |
121+
phive install overtrue/phplint@~9.5.0 --force-accept-unsigned --target ./bin
122+
123+
- name: Lint PHP files
124+
run: |
125+
./bin/phplint --no-cache --no-progress -v
126+
127+
ecmascript-linter:
128+
if: inputs.enable_eslinter == true
129+
runs-on: ubuntu-latest
130+
131+
steps:
132+
- name: Install NodeJS
133+
uses: actions/setup-node@v4
134+
with:
135+
node-version: latest
136+
137+
- name: Checkout Code
138+
uses: actions/checkout@v4
139+
with:
140+
fetch-depth: 0
141+
repository: ${{ inputs.repository }}
142+
ref: ${{ inputs.ref }}
143+
144+
- name: Install ESLint
145+
run: |
146+
npm install eslint eslint-config
147+
148+
- name: Lint JavaScript
149+
run: ./node_modules/.bin/eslint --config=${{ inputs.eslinter-config }}
150+
env:
151+
DEBUG: eslint:languages:js
152+
153+
json-linter:
154+
if: inputs.enable_jsonlinter == true
155+
runs-on: ubuntu-latest
156+
157+
steps:
158+
- name: Checkout Code
159+
uses: actions/checkout@v4
160+
with:
161+
fetch-depth: 0
162+
repository: ${{ inputs.repository }}
163+
ref: ${{ inputs.ref }}
164+
165+
- name: Lint JSON
166+
uses: limitusus/json-syntax-check@v2
167+
168+
style-linter:
169+
if: inputs.enable_stylelinter == true
170+
runs-on: ubuntu-latest
171+
172+
steps:
173+
- name: Install NodeJS
174+
uses: actions/setup-node@v4
175+
with:
176+
node-version: latest
177+
178+
- name: Checkout Code
179+
uses: actions/checkout@v4
180+
with:
181+
fetch-depth: 0
182+
repository: ${{ inputs.repository }}
183+
ref: ${{ inputs.ref }}
184+
185+
- name: Install StyleLint
186+
run: npm install stylelint stylelint-config-standard
187+
188+
- name: Lint stylesheets
189+
run: |
190+
./node_modules/.bin/stylelint \
191+
-f verbose \
192+
-c=${{ inputs.stylelinter-config }} ${{ inputs.stylelinter-pattern }}
193+
194+
yaml-linter:
195+
if: inputs.enable_yamllinter == true
196+
runs-on: ubuntu-latest
197+
198+
steps:
199+
- name: Checkout Code
200+
uses: actions/checkout@v4
201+
with:
202+
fetch-depth: 0
203+
repository: ${{ inputs.repository }}
204+
ref: ${{ inputs.ref }}
205+
206+
- name: Lint YAML
207+
uses: ibiqlik/action-yamllint@v3.1.1
208+
with:
209+
config_file: ${{ inputs.yamllinter-config }}

0 commit comments

Comments
 (0)