Skip to content

Commit 53ab14d

Browse files
authored
Add YAML file check (#858)
This adds a job to run `yamllint` on `*.{yaml,yml}` files in the repository. YAML files are currently found not only in the GitHub workflows directory; they're also in `docs/`, and we can imagine more YAML-based config files being added in the future.
2 parents 7a83907 + 394e588 commit 53ab14d

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "yamllint",
5+
"pattern": [
6+
{
7+
"regexp": "^(.*\\.ya?ml)$",
8+
"file": 1
9+
},
10+
{
11+
"regexp": "^\\s{2}(\\d+):(\\d+)\\s+(error|warning)\\s+(.*?)\\s+\\((.*)\\)$",
12+
"line": 1,
13+
"column": 2,
14+
"severity": 3,
15+
"message": 4,
16+
"code": 5,
17+
"loop": true
18+
}
19+
]
20+
}
21+
]
22+
}

.github/workflows/ci-file-checks.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ jobs:
7979
python_files: ${{steps.filter.outputs.python_files}}
8080
cc: ${{steps.filter.outputs.cc}}
8181
cc_files: ${{steps.filter.outputs.cc_files}}
82+
yaml: ${{steps.filter.outputs.yaml}}
83+
yaml_files: ${{steps.filter.outputs.yaml_files}}
8284
steps:
8385
# When invoked manually, use the given SHA to figure out the change list.
8486
- if: github.event_name == 'workflow_dispatch'
@@ -125,6 +127,10 @@ jobs:
125127
- '**/*.cc'
126128
- '**/*.h'
127129
- '**/*.proto'
130+
yaml:
131+
- added|modified:
132+
- '**/*.yaml'
133+
- '**/*.yml'
128134
129135
Setup:
130136
if: needs.Changes.outputs.python == 'true'
@@ -336,3 +342,27 @@ jobs:
336342
} >> "$GITHUB_STEP_SUMMARY"
337343
fi
338344
exit $exit_code
345+
346+
Yaml-lint:
347+
if: needs.Changes.outputs.yaml == 'true'
348+
name: YAML lint
349+
needs: Changes
350+
runs-on: ubuntu-24.04
351+
steps:
352+
- name: Check out a copy of the TFQ git repository
353+
uses: actions/checkout@v4
354+
355+
- name: Set up yamllint output problem matcher
356+
run: echo '::add-matcher::.github/problem-matchers/yamllint.json'
357+
358+
- name: Find out the yamllint version
359+
id: yamllint
360+
run: |
361+
version=$(yamllint --version)
362+
echo "version=${version#yamllint }" >> "$GITHUB_OUTPUT"
363+
364+
- name: Run yamllint ${{steps.yamllint.outputs.version}}
365+
run: |
366+
set -x
367+
# shellcheck disable=SC2086
368+
yamllint --format github ${{needs.Changes.outputs.yaml_files}}

0 commit comments

Comments
 (0)