-
Notifications
You must be signed in to change notification settings - Fork 608
175 lines (161 loc) · 7.06 KB
/
lint.yml
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
# Copyright 2019 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
# Keep this in sync with build_tools/scripts/lint.sh
name: Lint
on: [pull_request]
jobs:
bazel_to_cmake:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Running bazel_to_cmake for IREE core
run: ./build_tools/bazel_to_cmake/bazel_to_cmake.py --verbosity=2
- name: Running bazel_to_cmake for IREE TF Integration Tests
run: ./build_tools/bazel_to_cmake/bazel_to_cmake.py --root_dir=integrations/tensorflow/e2e --verbosity=2
- name: Checking Diff
run: |
# Make sure to pick up new files that have been added.
git add -A
git diff HEAD --exit-code
buildifier:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Fetching Base Branch
# We have to explicitly fetch the base branch as well
run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}"
- name: Downloading Buildifier
run: |
mkdir -p "${HOME?}/bin"
wget https://github.com/bazelbuild/buildtools/releases/download/4.0.1/buildifier -O "${HOME?}/bin/buildifier"
chmod +x "${HOME?}/bin/buildifier"
echo "${HOME?}/bin" >> $GITHUB_PATH
- name: Running buildifier on changed files
run: |
# Fail if the script fails (unfixable lint warnings) or it creates a
# diff (fixable lint warnings or formatting).
EXIT_CODE=0
./build_tools/scripts/run_buildifier.sh "${GITHUB_BASE_REF?}" || EXIT_CODE=1
git diff --exit-code
exit "${EXIT_CODE?}"
black:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Setting up python
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
- name: Fetching Base Branch
# We have to explicitly fetch the base branch as well
run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}"
- name: Install black
run: |
python3 -m pip install black==23.3
- name: Check if modified files are formatted
run: |
# The filter lowercase `d` means to exclude deleted files.
git diff "${GITHUB_BASE_REF?}" --name-only --diff-filter=d \
-- '*.py' ':!third_party' \
| xargs --no-run-if-empty black --check --diff --verbose
- name: Instructions for fixing the above linting errors
if: failure()
run: |
printf "You can fix formatting by running 'black' on the modified python files:\n"
printf " git diff ${GITHUB_BASE_REF?} --name-only -- '*.py' ':!third_party' | xargs black\n"
pytype:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Setting up python
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
- name: Fetching Base Branch
# We have to explicitly fetch the base branch as well
run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}"
- name: Install pytype
run: python3 -m pip install pytype
- name: Run pytype on changed files
run: ./build_tools/pytype/check_diff.sh "${GITHUB_BASE_REF?}"
clang-format:
runs-on: ubuntu-20.04
steps:
- name: Installing dependencies
run: |
wget https://raw.githubusercontent.com/llvm-mirror/clang/master/tools/clang-format/git-clang-format -O /tmp/git-clang-format
chmod +x /tmp/git-clang-format
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Fetching Base Branch
# We have to explicitly fetch the base branch as well
run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}"
- name: Running clang-format on changed source files
run: |
/tmp/git-clang-format "${GITHUB_BASE_REF?}" --binary=clang-format-12 --style=file
git diff --exit-code
tabs:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Fetching Base Branch
# We have to explicitly fetch the base branch as well
run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}"
- name: Checking tabs
run: ./build_tools/scripts/check_tabs.sh "${GITHUB_BASE_REF?}"
yamllint:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Fetching Base Branch
# We have to explicitly fetch the base branch as well
run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}"
- name: yamllint
run: ./build_tools/scripts/run_yamllint.sh "${GITHUB_BASE_REF?}"
markdownlint:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Downloading markdownlint
run: npm install -g markdownlint-cli
- name: Running markdownlint
run: ./build_tools/scripts/run_markdownlint.sh
path_lengths:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Running check_path_lengths
run: ./build_tools/scripts/check_path_lengths.py
generated_cmake_files:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Generating CMake files
run: |
./build_tools/scripts/generate_cmake_files.sh
- name: Checking Diff
run: |
# Make sure to run build_tools/scripts/generate_cmake_files.sh and
# pick up new files that have been added.
git add -A
git diff HEAD --exit-code
build_file_names:
runs-on: ubuntu-20.04
steps:
- name: Checking out repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Check BUILD files are not named BUILD (prefer BUILD.bazel)
run: exit $(git ls-files '**/BUILD' | wc -l)
- name: Instructions for fixing the above linting error
if: failure()
run: |
echo "failure: found files named BUILD. Please rename the following files to BUILD.bazel:"
git ls-files '**/BUILD'