-
Notifications
You must be signed in to change notification settings - Fork 487
79 lines (75 loc) · 2.43 KB
/
lintercheck.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
name: Linter check
on:
pull_request:
push:
branches:
- master
tags:
- r[0-9]+.[0-9]+
jobs:
linter_check:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
cache: 'pip'
- run: pip install yapf==0.30.0
- name: Check no TORCH_PIN
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
shell: bash
run: |
TORCH_PIN=./.torch_pin
if [[ -f "${TORCH_PIN}" ]]; then
echo "Please remove ${TORCH_PIN} before landing."
exit 1
else
echo "No ${TORCH_PIN} found, safe to land..."
fi
- name: Run clang-format
shell: bash
env:
CLANG_FORMAT: clang-format-11
run: |
sudo apt-get update
sudo apt install -y "${CLANG_FORMAT}"
git_status=$(git status --porcelain)
if [[ $git_status ]]; then
echo "Checkout code is not clean"
echo "${git_status}"
exit 1
fi
find . -name '*.cpp' -o -name '*.h' -o -name '*.cc' | xargs "${CLANG_FORMAT}" -i -style=file
git_status=$(git status --porcelain)
if [[ $git_status ]]; then
git diff
echo "${CLANG_FORMAT} recommends the changes above, please manually apply them OR automatically apply the changes "
echo "by running \"${CLANG_FORMAT} -i -style=file /PATH/TO/foo.cpp\" to the following files"
echo "${git_status}"
exit 1
else
echo "PASSED C++ format"
fi
- name: Run yapf
shell: bash
run: |
git_status=$(git status --porcelain)
if [[ $git_status ]]; then
echo "Checkout code is not clean"
echo "${git_status}"
exit 1
fi
yapf -i -r *.py test/ scripts/ torch_xla/ benchmarks/
git_status=$(git status --porcelain)
if [[ $git_status ]]; then
git diff
echo "yapf recommends the changes above, please manually apply them OR automatically apply the changes "
echo "by running `yapf -i /PATH/TO/foo.py` to the following files"
echo "${git_status}"
exit 1
else
echo "PASSED Python format"
fi