Skip to content

Commit 1aca471

Browse files
committed
Add reusable linter workflow
1 parent da4604e commit 1aca471

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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+
eslinter-config:
12+
description: 'The location of the configuration file'
13+
type: string
14+
required: false
15+
default: './tools/linters/eslint.config.js'
16+
17+
enable_jsonlinter:
18+
description: 'Enable the JSON-Linter for this repository'
19+
type: boolean
20+
required: false
21+
default: false
22+
23+
enable_yamllinter:
24+
description: 'Enable the YAML-Linter for this repository'
25+
type: boolean
26+
required: false
27+
default: false
28+
yamllinter-config:
29+
description: 'The location of the linter-configuration'
30+
type: string
31+
required: false
32+
default: './tools/linters/.yaml-lint.yml'
33+
34+
enable_stylelinter:
35+
description: 'Enable the Style-Linter for this repository'
36+
type: boolean
37+
required: false
38+
default: false
39+
stylelinter-pattern:
40+
description: 'The file-pattern to match files that are being linted'
41+
type: string
42+
required: false
43+
default: '**/*.{css,scss,sass}'
44+
stylelinter-config:
45+
description: 'The location of the linter-configuration'
46+
type: string
47+
required: false
48+
default: 'tools/linters/.stylelintrc.json'
49+
50+
repository:
51+
description: 'The repository that needs linting'
52+
type: string
53+
default: ${{ github.repository }}
54+
required: false
55+
ref:
56+
description: 'The branch, tag or SHA that needs linting'
57+
type: string
58+
required: false
59+
default: ${{ github.ref }}
60+
61+
jobs:
62+
ecmascript-linter:
63+
if: inputs.enable_eslinter == true
64+
runs-on: ubuntu-latest
65+
66+
steps:
67+
- name: Install NodeJS
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: latest
71+
72+
- name: Checkout Code
73+
uses: actions/checkout@v4
74+
with:
75+
fetch-depth: 0
76+
repository: ${{ inputs.repository }}
77+
ref: ${{ inputs.ref }}
78+
79+
- name: Install ESLint
80+
run: |
81+
npm install eslint eslint-config
82+
83+
- name: Lint JavaScript
84+
run: ./node_modules/.bin/eslint --config=${{ inputs.eslinter-config }}
85+
env:
86+
DEBUG: eslint:languages:js
87+
88+
json-linter:
89+
if: inputs.enable_jsonlinter == true
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- name: Checkout Code
94+
uses: actions/checkout@v4
95+
with:
96+
fetch-depth: 0
97+
repository: ${{ inputs.repository }}
98+
ref: ${{ inputs.ref }}
99+
100+
- name: Lint JSON
101+
uses: limitusus/json-syntax-check@v2
102+
103+
style-linter:
104+
if: inputs.enable_stylelinter == true
105+
runs-on: ubuntu-latest
106+
107+
steps:
108+
- name: Install NodeJS
109+
uses: actions/setup-node@v4
110+
with:
111+
node-version: latest
112+
113+
- name: Checkout Code
114+
uses: actions/checkout@v4
115+
with:
116+
fetch-depth: 0
117+
repository: ${{ inputs.repository }}
118+
ref: ${{ inputs.ref }}
119+
120+
- name: Install StyleLint
121+
run: npm install stylelint stylelint-config-standard
122+
123+
- name: Lint stylesheets
124+
run: |
125+
./node_modules/.bin/stylelint \
126+
-f verbose \
127+
-c=${{ inputs.stylelinter-config }} ${{ inputs.stylelinter-pattern }}
128+
129+
yaml-linter:
130+
if: inputs.enable_yamllinter == true
131+
runs-on: ubuntu-latest
132+
133+
steps:
134+
- name: Checkout Code
135+
uses: actions/checkout@v4
136+
with:
137+
fetch-depth: 0
138+
repository: ${{ inputs.repository }}
139+
ref: ${{ inputs.ref }}
140+
141+
- name: Lint YAML
142+
uses: ibiqlik/action-yamllint@v3.1.1
143+
with:
144+
config_file: ${{ inputs.yamllinter-config }}

0 commit comments

Comments
 (0)