-
Notifications
You must be signed in to change notification settings - Fork 53
96 lines (81 loc) · 3.15 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
name: Lint
on:
pull_request:
push:
branches:
- main
# the most recent commit in the PR would cancel older commit's in-progress workflows
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id}}
cancel-in-progress: true
env:
working_directory: .
jobs:
check-license:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Look for missing license headers
working-directory: ${{ env.working_directory }}
run: |
find . -regextype posix-extended -regex '.*\.(cpp|h|py|md|svg)' | egrep -v '^./(\.|third_party|bin|build|nvfuser/include|nvfuser/version.py|tools/linter/adapters|csrc/serde/fusion_cache_generated.h)' | xargs grep -L SPDX-FileCopyrightText | tee missing-header-files.txt
# test that file is empty
test ! -s missing-header-files.txt
clang-tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Run lintrunner
working-directory: ${{ env.working_directory }}
run: |
tools/apt-install-things.sh &
tools/pip-install-things.sh &
source tools/setup-env.sh
# clang-tidy does not work well with gcc-13 headers, remove them
sudo rm -rf /usr/lib/gcc/x86_64-linux-gnu/13
# Install lintrunner
pip install lintrunner
# Initialize lintrunner
lintrunner init 2> /dev/null
wait
# Run cmake build
python setup.py --cmake-only
# Generate csrc/serde/fusion_cache_generated.h
# NOTE: this might cause a compile of flatbuffers if it is missing
ninja -C build build_flatbuffer_config
# Run lintrunner on all csrc files exclude benchmark and test folders
this_commit=$(git rev-parse HEAD)
git fetch origin main
git checkout origin/main
head_commit=$(git rev-parse HEAD)
git checkout $this_commit
# diff-filter for lower case letter:
# https://github.com/git/git/commit/7f2ea5f0f2fb056314092cce23202096ca70f076
git --no-pager diff --diff-filter=d --name-only $head_commit | grep -e "csrc/.*\.cpp" -e "csrc/.*\.h" | xargs lintrunner --take CLANGTIDY --force-color
lintrunner:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Run lintrunner
working-directory: ${{ env.working_directory }}
run: |
# Install lintrunner
pip install lintrunner
# Initialize lintrunner
lintrunner init 2> /dev/null
# Install dependencies
sudo apt install -y libtinfo5
# Run lintrunner except clang-tidy
lintrunner --force-color --take FLAKE8,MYPY,CLANGFORMAT,NOQA,TYPEIGNORE,NEWLINE,MYPYSTRICT,TABS,SPACES,EXEC,BLACK,TORCH_INTERNAL_ASSERT,TORCH_CHECK,C10_ERROR,TORCH_CUDA_CU_API --all-files