Skip to content

Commit 5013c12

Browse files
feat(lint): add linelint
1 parent 61d1ced commit 5013c12

5 files changed

Lines changed: 65 additions & 0 deletions

File tree

.github/matchers/linelint.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "linelint",
5+
"severity": "error",
6+
"pattern": [
7+
{
8+
"regexp": "^(\\[EOF Rule\\]) (File \"([^\"]+)\" has lint errors)$",
9+
"code": 1,
10+
"message": 2,
11+
"file": 3
12+
}
13+
]
14+
}
15+
]
16+
}

.github/workflows/__call-common-lint.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ jobs:
2525
steps:
2626
- name: Checkout
2727
uses: actions/checkout@v5
28+
with:
29+
fetch-depth: 2 # need to fetch 2 to get list of changed files
30+
31+
- name: Get changed files
32+
id: changed_files
33+
shell: bash
34+
run: |
35+
firstCommit='${{ github.event.pull_request.base.sha }}'
36+
lastCommit='${{ github.event.pull_request.head.sha }}'
37+
changedFiles=$(git diff --name-only --diff-filter=d "${firstCommit}" "${lastCommit}" | tr '\n' ' ')
38+
39+
echo "Changed files: ${changedFiles}"
40+
echo "CHANGED_FILES=${changedFiles}" >> "${GITHUB_OUTPUT}"
2841
2942
- name: Download problem matchers
3043
shell: bash
@@ -48,6 +61,7 @@ jobs:
4861
[cmake-lint]="${gh_path}/cmake-lint.json"
4962
[gcc]="${gh_path}/gcc.json"
5063
[hadolint]="${gh_path}/hadolint.json"
64+
[linelint]="${gh_path}/linelint.json"
5165
[shellcheck-gcc]="${gh_path}/shellcheck-gcc.json"
5266
[yamllint]="${gh_path}/yamllint.json"
5367
)
@@ -73,6 +87,7 @@ jobs:
7387
python-version: '3.12'
7488

7589
- name: Install Python dependencies
90+
shell: bash
7691
run: |
7792
# shellcheck disable=SC2102 # this is triggered by the [toolchain] extra
7893
python -m pip install --upgrade \
@@ -101,7 +116,14 @@ jobs:
101116
"https://raw.githubusercontent.com/LizardByte/.github/master/.github/actionlint.yml"
102117
fi
103118
119+
- name: Install linelint
120+
shell: bash
121+
run: |
122+
go install github.com/fernandrone/linelint@latest
123+
echo "${HOME}/go/bin" >> "${GITHUB_PATH}"
124+
104125
- name: Replace shell
126+
# for actionlint
105127
shell: bash
106128
run: |
107129
# Replace in workflow files
@@ -130,6 +152,7 @@ jobs:
130152
- name: C++ - find files
131153
id: cpp_files
132154
if: always()
155+
shell: bash
133156
run: |
134157
# find files
135158
found_files=$(find . -type f \
@@ -176,6 +199,7 @@ jobs:
176199

177200
- name: C++ - Clang format (simple)
178201
if: always() && steps.clang_format_diff.outcome == 'failure'
202+
shell: bash
179203
run: |
180204
echo "::add-matcher::.github/matchers/clang-format.json"
181205
set +e
@@ -193,6 +217,7 @@ jobs:
193217
- name: CMake - find files
194218
id: cmake_files
195219
if: always()
220+
shell: bash
196221
run: |
197222
# find files
198223
found_files=$(find . -type f -iname "CMakeLists.txt" -o -iname "*.cmake")
@@ -221,6 +246,7 @@ jobs:
221246
222247
- name: CMake - cmake-lint
223248
if: always() && steps.cmake_files.outputs.found_files
249+
shell: bash
224250
run: |
225251
echo "::add-matcher::.github/matchers/cmake-lint.json"
226252
set +e
@@ -234,6 +260,7 @@ jobs:
234260
- name: Docker - find files
235261
id: docker_files
236262
if: always()
263+
shell: bash
237264
run: |
238265
found_files=$(find . -type f -iname "Dockerfile" -o -iname "*.dockerfile")
239266
@@ -244,6 +271,7 @@ jobs:
244271
245272
- name: Docker - hadolint
246273
if: always() && steps.docker_files.outputs.found_files
274+
shell: bash
247275
run: |
248276
docker pull hadolint/hadolint
249277
@@ -286,6 +314,14 @@ jobs:
286314
287315
exit ${error}
288316
317+
- name: linelint
318+
if: always()
319+
shell: bash
320+
run: |
321+
echo "::add-matcher::.github/matchers/linelint.json"
322+
linelint ${{ steps.changed_files.outputs.CHANGED_FILES }}
323+
echo "::remove-matcher owner=linelint::"
324+
289325
- name: PowerShell - PSScriptAnalyzer
290326
if: always()
291327
shell: pwsh
@@ -339,6 +375,7 @@ jobs:
339375
340376
- name: Python - flake8
341377
if: always()
378+
shell: bash
342379
run: |
343380
echo "::group::problem matcher"
344381
set +e
@@ -359,6 +396,7 @@ jobs:
359396
360397
- name: Python - nbqa flake8
361398
if: always()
399+
shell: bash
362400
run: |
363401
echo "::group::problem matcher"
364402
set +e
@@ -381,6 +419,7 @@ jobs:
381419
382420
- name: Python - nb-clean
383421
if: always()
422+
shell: bash
384423
run: |
385424
output=$(find . -name '*.ipynb' -exec nb-clean check {} \;)
386425
@@ -393,6 +432,7 @@ jobs:
393432
- name: Rust - find Cargo.toml
394433
id: run_cargo
395434
if: always()
435+
shell: bash
396436
run: |
397437
# check if Cargo.toml exists
398438
if [ -f "Cargo.toml" ]; then
@@ -412,6 +452,7 @@ jobs:
412452

413453
- name: Rust - cargo fmt
414454
if: always() && steps.run_cargo.outputs.found_cargo == 'true'
455+
shell: bash
415456
run: |
416457
set +e
417458
error=0
@@ -449,6 +490,7 @@ jobs:
449490
- name: shellcheck - find files
450491
id: shellcheck_files
451492
if: always()
493+
shell: bash
452494
run: |
453495
found_files=$(find . -type f -iname "*.bash" -o -iname "*.sh")
454496
@@ -459,6 +501,7 @@ jobs:
459501
460502
- name: shellcheck
461503
if: always() && steps.shellcheck_files.outputs.found_files
504+
shell: bash
462505
run: |
463506
echo "::add-matcher::.github/matchers/shellcheck-gcc.json"
464507
set +e
@@ -472,6 +515,7 @@ jobs:
472515
- name: YAML - find files
473516
id: yaml_files
474517
if: always()
518+
shell: bash
475519
run: |
476520
# space separated list of files
477521
FILES=.clang-format
@@ -491,6 +535,7 @@ jobs:
491535
- name: YAML - yamllint
492536
id: yamllint
493537
if: always()
538+
shell: bash
494539
run: |
495540
if [ ! -f .yamllint.yml ]; then
496541
curl -sSL https://raw.githubusercontent.com/LizardByte/.github/master/.yamllint.yml -o .yamllint.yml

test/sample.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

test/sample2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

test/sample3.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test
2+

0 commit comments

Comments
 (0)