Skip to content

Commit 6bc1315

Browse files
authored
[CI] Move lintcheck from Circle to GHA (#5035)
1 parent 87fb0ad commit 6bc1315

File tree

2 files changed

+79
-96
lines changed

2 files changed

+79
-96
lines changed

.circleci/config.yml

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -223,68 +223,6 @@ run_test_coverage: &run_test_coverage
223223
- store_artifacts:
224224
path: htmlcov
225225

226-
run_clang_format: &run_clang_format
227-
name: Run clang-format
228-
command: |
229-
sudo apt-get update
230-
sudo apt install -y clang-format-7
231-
git_status=$(git status --porcelain)
232-
if [[ $git_status ]]; then
233-
echo "Checkout code is not clean"
234-
echo "${git_status}"
235-
exit 1
236-
fi
237-
238-
find -name '*.cpp' -o -name '*.h' -o -name '*.cc' | xargs clang-format-7 -i -style=file
239-
git_status=$(git status --porcelain)
240-
if [[ $git_status ]]; then
241-
git diff
242-
echo "clang-format-7 recommends the changes above, please manually apply them OR automatically apply the changes "
243-
echo "by running \"clang-format-7 -i -style=file /PATH/TO/foo.cpp\" to the following files"
244-
echo "${git_status}"
245-
exit 1
246-
else
247-
echo "PASSED C++ format"
248-
fi
249-
250-
run_yapf: &run_yapf
251-
name: Run yapf
252-
command: |
253-
pyenv install 3.7.0
254-
pyenv global 3.7.0
255-
pip install --upgrade pip
256-
pip install yapf==0.30.0
257-
258-
git_status=$(git status --porcelain)
259-
if [[ $git_status ]]; then
260-
echo "Checkout code is not clean"
261-
echo "${git_status}"
262-
exit 1
263-
fi
264-
265-
yapf -i -r *.py test/ scripts/ torch_xla/
266-
git_status=$(git status --porcelain)
267-
if [[ $git_status ]]; then
268-
git diff
269-
echo "yapf recommends the changes above, please manually apply them OR automatically apply the changes "
270-
echo "by running `yapf -i /PATH/TO/foo.py` to the following files"
271-
echo "${git_status}"
272-
exit 1
273-
else
274-
echo "PASSED Python format"
275-
fi
276-
277-
assert_no_torch_pin: &assert_no_torch_pin
278-
name: Make sure torch_patches/.torch_pin is removed before merging
279-
command: |
280-
TORCH_PIN=./torch_patches/.torch_pin
281-
if [[ -f "${TORCH_PIN}" ]]; then
282-
echo "Please remove ${TORCH_PIN} before landing."
283-
exit 1
284-
else
285-
echo "No ${TORCH_PIN} found, safe to land..."
286-
fi
287-
288226
assert_continue_on_error_is_false: &assert_continue_on_error_is_false
289227
name: Make sure CONTINUE_ON_ERROR flags are set to false before merging
290228
command: |
@@ -314,28 +252,6 @@ ci_params: &ci_params
314252
resource_class: << parameters.resource_class >>
315253

316254
jobs:
317-
linter_check:
318-
machine:
319-
image: ubuntu-2004:202111-02
320-
steps:
321-
- checkout
322-
- run:
323-
<<: *run_clang_format
324-
- run:
325-
<<: *run_yapf
326-
327-
linter_check_no_torch_pin:
328-
machine:
329-
image: ubuntu-2004:202111-02
330-
steps:
331-
- checkout
332-
- run:
333-
<<: *assert_no_torch_pin
334-
- run:
335-
<<: *run_clang_format
336-
- run:
337-
<<: *run_yapf
338-
339255
continue_on_error_is_false:
340256
machine:
341257
image: ubuntu-2004:202111-02
@@ -362,18 +278,6 @@ jobs:
362278
workflows:
363279
build:
364280
jobs:
365-
- linter_check:
366-
filters:
367-
branches:
368-
ignore:
369-
- master
370-
- ^r\d*\.?\d*$
371-
- linter_check_no_torch_pin:
372-
filters:
373-
branches:
374-
only:
375-
- master
376-
- ^r\d*\.?\d*$
377281
- pytorch_xla_run_build
378282
- pytorch_xla_run_test:
379283
name: pytorch_xla_run_CPU_test

.github/workflows/lintercheck.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Linter check
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- r[0-9]+.[0-9]+
9+
10+
jobs:
11+
linter_check:
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v3
16+
- name: Setup Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.7'
20+
cache: 'pip'
21+
- run: pip install yapf==0.30.0
22+
23+
- name: Check no TORCH_PIN
24+
if: github.event_name == 'push' && github.event.ref == 'master'
25+
shell: bash
26+
run: |
27+
TORCH_PIN=./torch_patches/.torch_pin
28+
if [[ -f "${TORCH_PIN}" ]]; then
29+
echo "Please remove ${TORCH_PIN} before landing."
30+
exit 1
31+
else
32+
echo "No ${TORCH_PIN} found, safe to land..."
33+
fi
34+
- name: Run clang-format
35+
shell: bash
36+
env:
37+
CLANG_FORMAT: clang-format-7
38+
run: |
39+
sudo apt-get update
40+
sudo apt install -y "${CLANG_FORMAT}"
41+
git_status=$(git status --porcelain)
42+
if [[ $git_status ]]; then
43+
echo "Checkout code is not clean"
44+
echo "${git_status}"
45+
exit 1
46+
fi
47+
48+
find . -name '*.cpp' -o -name '*.h' -name '*.cc' | xargs "${CLANG_FORMAT}" -i -style=file
49+
git_status=$(git status --porcelain)
50+
if [[ $git_status ]]; then
51+
git diff
52+
echo "${CLANG_FORMAT} recommends the changes above, please manually apply them OR automatically apply the changes "
53+
echo "by running \"${CLANG_FORMAT} -i -style=file /PATH/TO/foo.cpp\" to the following files"
54+
echo "${git_status}"
55+
exit 1
56+
else
57+
echo "PASSED C++ format"
58+
fi
59+
- name: Run yapf
60+
shell: bash
61+
run: |
62+
git_status=$(git status --porcelain)
63+
if [[ $git_status ]]; then
64+
echo "Checkout code is not clean"
65+
echo "${git_status}"
66+
exit 1
67+
fi
68+
69+
yapf -i -r *.py test/ scripts/ torch_xla/
70+
git_status=$(git status --porcelain)
71+
if [[ $git_status ]]; then
72+
git diff
73+
echo "yapf recommends the changes above, please manually apply them OR automatically apply the changes "
74+
echo "by running `yapf -i /PATH/TO/foo.py` to the following files"
75+
echo "${git_status}"
76+
exit 1
77+
else
78+
echo "PASSED Python format"
79+
fi

0 commit comments

Comments
 (0)