Skip to content

Commit 11565e2

Browse files
committed
Add JSON lint check to ci.yml
1 parent d53967d commit 11565e2

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "json-lint",
5+
"pattern": [
6+
{
7+
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(.+)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"message": 4
12+
}
13+
]
14+
}
15+
]
16+
}

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ jobs:
8787
cff_files: ${{steps.filter.outputs.cff_files}}
8888
gha: ${{steps.filter.outputs.gha}}
8989
gha_files: ${{steps.filter.outputs.gha_files}}
90+
json: ${{steps.filter.outputs.json}}
91+
json_files: ${{steps.filter.outputs.json_files}}
9092
steps:
9193
# When invoked manually, use the given SHA to figure out the change list.
9294
- if: github.event_name == 'workflow_dispatch'
@@ -136,6 +138,9 @@ jobs:
136138
- added|modified:
137139
- '**/*.yaml'
138140
- '**/*.yml'
141+
json:
142+
- added|modified:
143+
- '**/*.json'
139144
140145
setup:
141146
if: needs.changes.outputs.python == 'true'
@@ -410,6 +415,26 @@ jobs:
410415
# shellcheck disable=SC2086
411416
yamllint $changed_files
412417
418+
json-lint:
419+
if: needs.changes.outputs.json == 'true'
420+
name: Validate JSON files
421+
needs: changes
422+
runs-on: ubuntu-24.04
423+
timeout-minutes: 5
424+
env:
425+
changed_files: ${{needs.changes.outputs.json_files}}
426+
steps:
427+
- name: Check out a copy of the git repository
428+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
429+
430+
- name: Install jsonlint
431+
run: |
432+
npm install -g @prantlf/jsonlint
433+
434+
- name: Run jsonlint on JSON files
435+
run: |
436+
jsonlint --continue ${{env.changed_files}}
437+
413438
cff-validation:
414439
if: needs.changes.outputs.cff == 'true'
415440
name: Validate CITATION.cff file(s)

.jsonlintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"comments": false,
3+
"compact": true,
4+
"endOfLine": "lf",
5+
"indent": 2,
6+
"no-duplicate-keys": true,
7+
"patterns": ["**/*.json"],
8+
"singleQuote": false,
9+
"trailing-commas": false
10+
}

0 commit comments

Comments
 (0)