-
Notifications
You must be signed in to change notification settings - Fork 2
232 lines (230 loc) · 7.94 KB
/
Copy pathlinting.yml
File metadata and controls
232 lines (230 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Linting and code quality check
on:
workflow_call:
inputs:
black-version:
required: false
type: string
default: '26.1.0'
flake8-version:
required: false
type: string
default: '7.3.0'
pylint-version:
required: false
type: string
default: '4.0.4'
ruff-version:
required: false
type: string
default: '0.15.0'
BASH_SEVERITY:
required: false
type: string
default: 'style'
VALIDATE_BASH:
required: false
type: boolean
default: true
VALIDATE_BASH_EXEC:
required: false
type: boolean
default: true
VALIDATE_CSS:
required: false
type: boolean
default: true
VALIDATE_DOCKERFILE_HADOLINT:
required: false
type: boolean
default: true
VALIDATE_GITHUB_ACTIONS:
required: false
type: boolean
default: true
VALIDATE_HTML:
required: false
type: boolean
default: true
VALIDATE_JAVASCRIPT_ES:
required: false
type: boolean
default: true
VALIDATE_JAVASCRIPT_STANDARD:
required: false
type: boolean
default: true
VALIDATE_JSON:
required: false
type: boolean
default: true
VALIDATE_MARKDOWN:
required: false
type: boolean
default: true
VALIDATE_POWERSHELL:
required: false
type: boolean
default: true
VALIDATE_RENOVATE:
required: false
type: boolean
default: true
VALIDATE_XML:
required: false
type: boolean
default: true
VALIDATE_YAML:
required: false
type: boolean
default: true
SUPER_LINTER_FILTER_REGEX_EXCLUDE:
required: false
type: string
jobs:
flake8:
name: flake8
if: ${{ inputs.flake8-version != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install apt dependencies
run: |
sudo apt-get install -y -qq python3 python3-pip
- name: Install pip dependencies
run: |
python -m pip install --upgrade pip
pip3 install flake8==${{ inputs.flake8-version }}
flake8 --version
- name: Lint with Flake8
run: |
flake8 --config=.flake8 --count --statistics --show-source .
pylint:
name: pylint
if: ${{ inputs.pylint-version != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install apt dependencies
run: |
sudo apt-get install -y -qq python3 python3-pip
- name: Install pip dependencies
run: |
python -m pip install --upgrade pip
pip3 install pylint==${{ inputs.pylint-version }}
pylint --version
- name: Configure Pylint
if: ${{ hashFiles('.pylintrc') == '' }}
run: |
echo ".pylintrc does not exists. Will be downloaded."
wget https://raw.githubusercontent.com/mundialis/github-workflows/main/linting-config-examples/.pylintrc
- name: Configure Pylint - allowed to fail
if: ${{ hashFiles('.pylintrc_allowed_to_fail') == '' }}
run: |
echo ".pylintrc_allowed_to_fail does not exists. Will be downloaded."
wget https://raw.githubusercontent.com/mundialis/github-workflows/main/linting-config-examples/.pylintrc_allowed_to_fail
- name: Lint with Pylint
run: |
pylint .
- name: Lint with Pylint - More strict, allowed to fail
run: |
pylint --rc-file=.pylintrc_allowed_to_fail .
black:
name: black
if: ${{ inputs.black-version != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install apt dependencies
run: |
sudo apt-get install -y -qq python3 python3-pip
- name: Install pip dependencies
run: |
python -m pip install --upgrade pip
pip3 install black==${{ inputs.black-version }}
black --version
- name: Check code style with Black
run: |
black --check --diff --line-length 79 .
- name: Create and upload code suggestions to apply for black
id: diff-black
uses: OSGeo/grass/.github/actions/create-upload-suggestions@main
with:
tool-name: black
# extra-upload-changes: .clang-format
ruff:
name: ruff
if: ${{ inputs.ruff-version != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install apt dependencies
run: |
sudo apt-get install -y -qq python3 python3-pip
- name: Install pip dependencies
run: |
python -m pip install --upgrade pip
pip3 install ruff==${{ inputs.ruff-version }} toml-union
ruff --version
- name: Configure ruff
run: |
echo "Download ruff.toml..."
wget https://raw.githubusercontent.com/mundialis/github-workflows/main/linting-config-examples/ruff.toml -O ruff-github-workflows.toml
- name: Merge ruff config
run: |
# Merge shared config with local one. Also works if no ruff.toml exists.
toml-union ruff.toml ruff-github-workflows.toml -o ruff-merged.toml
- name: Run ruff (output annotations on fixable errors)
run: |
ruff check --config ruff-merged.toml --output-format=github . --preview --unsafe-fixes
continue-on-error: true
- name: Run ruff (apply fixes for suggestions)
run: |
ruff check --config ruff-merged.toml . --preview --fix --unsafe-fixes
- name: No diff for merged ruff.toml
if: ${{ hashFiles('ruff-github-workflows.toml') != '' }}
run: |
rm ruff-github-workflows.toml && rm ruff-merged.toml
- name: Create and upload code suggestions to apply for ruff
id: diff-ruff
if: ${{ !cancelled() }}
uses: OSGeo/grass/.github/actions/create-upload-suggestions@main
with:
tool-name: ruff
# extra-upload-changes: ruff.toml
super-linter:
name: super-linter
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
# To report GitHub Actions status checks
statuses: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0
- name: Lint code base
uses: super-linter/super-linter/slim@4ce20838b8ab83717e78138c5b3a1407148e0918 # v8.7.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: main
# (https://github.com/super-linter/super-linter/blob/main/README.md)
BASH_SEVERITY: ${{ inputs.BASH_SEVERITY }}
VALIDATE_BASH: "${{ inputs.VALIDATE_BASH == true && true || '' }}"
VALIDATE_BASH_EXEC: "${{ inputs.VALIDATE_BASH_EXEC == true && true || '' }}"
VALIDATE_CSS: "${{ inputs.VALIDATE_CSS == true && true || '' }}"
VALIDATE_DOCKERFILE_HADOLINT: "${{ inputs.VALIDATE_DOCKERFILE_HADOLINT == true && true || '' }}"
VALIDATE_GITHUB_ACTIONS: "${{ inputs.VALIDATE_GITHUB_ACTIONS == true && true || '' }}"
VALIDATE_HTML: "${{ inputs.VALIDATE_HTML == true && true || '' }}"
VALIDATE_JAVASCRIPT_ES: "${{ inputs.VALIDATE_JAVASCRIPT_ES == true && true || '' }}"
VALIDATE_JAVASCRIPT_STANDARD: "${{ inputs.VALIDATE_JAVASCRIPT_STANDARD == true && true || '' }}"
VALIDATE_JSON: "${{ inputs.VALIDATE_JSON == true && true || '' }}"
VALIDATE_MARKDOWN: "${{ inputs.VALIDATE_MARKDOWN == true && true || '' }}"
VALIDATE_POWERSHELL: "${{ inputs.VALIDATE_POWERSHELL == true && true || '' }}"
VALIDATE_RENOVATE: "${{ inputs.VALIDATE_RENOVATE == true && true || '' }}"
VALIDATE_XML: "${{ inputs.VALIDATE_XML == true && true || '' }}"
VALIDATE_YAML: "${{ inputs.VALIDATE_YAML == true && true || '' }}"
FILTER_REGEX_EXCLUDE: ${{ inputs.SUPER_LINTER_FILTER_REGEX_EXCLUDE }}