Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a few improvements to linting (#8184)
Use our own script for the yamllint check. This allows us to only look at modified files and run it locally as part of lint.sh Made some misc cleanups to the other bash scripts along the way, like making check_tabs.sh not hang forever if there are no modified files (grep gets passed an empty list of files and then sits there waiting for input).
- Loading branch information
1 parent
3d97314
commit cf9ee44
Showing
5 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2021 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Runs yamllint on files modified vs the specified reference commit | ||
# (default "main") | ||
|
||
set -uo pipefail | ||
|
||
BASE_REF="${1:-main}" | ||
|
||
declare -a included_files_patterns=( | ||
"\.yaml$" | ||
"\.yml$" | ||
) | ||
|
||
declare -a excluded_files_patterns=( | ||
"/third_party/" | ||
"^third_party/" | ||
) | ||
|
||
# Join on | | ||
included_files_pattern="$(IFS="|" ; echo "${included_files_patterns[*]?}")" | ||
excluded_files_pattern="$(IFS="|" ; echo "${excluded_files_patterns[*]?}")" | ||
|
||
readarray -t files < <(\ | ||
(git diff --name-only --diff-filter=d "${BASE_REF}" || kill $$) \ | ||
| grep -E "${included_files_pattern?}" \ | ||
| grep -v -E "${excluded_files_pattern?}") | ||
|
||
if (( ${#files[@]} == 0 )); then | ||
echo "No Yaml files changed" | ||
exit 0 | ||
fi | ||
|
||
|
||
yamllint --strict "${files[@]}" |