Skip to content

Commit a17c8d4

Browse files
NicolasHugfacebook-github-bot
authored andcommitted
[fbsync] port lint workflows from CircleCI to GHA (#7401)
Reviewed By: vmoens Differential Revision: D44416612 fbshipit-source-id: 0c5e199258248c776dcec6606016abfeb50f78aa
1 parent e0144f9 commit a17c8d4

File tree

3 files changed

+95
-116
lines changed

3 files changed

+95
-116
lines changed

.circleci/config.yml

Lines changed: 0 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.circleci/config.yml.in

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -269,61 +269,6 @@ jobs:
269269
python .circleci/regenerate.py
270270
git diff --exit-code || (echo ".circleci/config.yml not in sync with config.yml.in! Run .circleci/regenerate.py to update config"; exit 1)
271271

272-
lint_python_and_config:
273-
docker:
274-
- image: cimg/python:3.8
275-
steps:
276-
- checkout
277-
- pip_install:
278-
args: pre-commit
279-
descr: Install lint utilities
280-
- run:
281-
name: Install pre-commit hooks
282-
command: pre-commit install-hooks
283-
- run:
284-
name: Lint Python code and config files
285-
command: pre-commit run --all-files
286-
- run:
287-
name: Required lint modifications
288-
when: on_fail
289-
command: git --no-pager diff
290-
291-
lint_c:
292-
docker:
293-
- image: cimg/python:3.8
294-
steps:
295-
- apt_install:
296-
args: libtinfo5
297-
descr: Install additional system libraries
298-
- checkout
299-
- run:
300-
name: Install lint utilities
301-
command: |
302-
curl https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/clang-format-linux64 -o clang-format
303-
chmod +x clang-format
304-
sudo mv clang-format /opt/clang-format
305-
- run:
306-
name: Lint C code
307-
command: ./.circleci/unittest/linux/scripts/run-clang-format.py -r torchvision/csrc --clang-format-executable /opt/clang-format
308-
- run:
309-
name: Required lint modifications
310-
when: on_fail
311-
command: git --no-pager diff
312-
313-
type_check_python:
314-
docker:
315-
- image: cimg/python:3.8
316-
steps:
317-
- checkout
318-
- install_torchvision:
319-
editable: true
320-
- pip_install:
321-
args: mypy
322-
descr: Install Python type check utilities
323-
- run:
324-
name: Check Python types statically
325-
command: mypy --install-types --non-interactive --config-file mypy.ini
326-
327272
unittest_onnx:
328273
docker:
329274
- image: cimg/python:3.8
@@ -996,9 +941,6 @@ workflows:
996941
lint:
997942
jobs:
998943
- circleci_consistency
999-
- lint_python_and_config
1000-
- lint_c
1001-
- type_check_python
1002944

1003945
build:
1004946
jobs:

.github/workflows/lint.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
workflow_dispatch:
11+
12+
jobs:
13+
python-source-and-configs:
14+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
15+
with:
16+
repository: pytorch/vision
17+
script: |
18+
set -euo pipefail
19+
20+
echo '::group::Setup environment'
21+
CONDA_PATH=$(which conda)
22+
eval "$(${CONDA_PATH} shell.bash hook)"
23+
conda create --name ci --quiet --yes python=3.8 pip
24+
conda activate ci
25+
echo '::endgroup::'
26+
27+
echo '::group::Install lint tools'
28+
pip install --progress-bar=off pre-commit
29+
echo '::endgroup::'
30+
31+
echo '::group::Lint Python source and configs'
32+
set +e
33+
pre-commit run --all-files
34+
35+
if [ $? -ne 0 ]; then
36+
git --no-pager diff
37+
exit 1
38+
fi
39+
echo '::endgroup::'
40+
41+
c-source:
42+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
43+
with:
44+
repository: pytorch/vision
45+
script: |
46+
set -euo pipefail
47+
48+
echo '::group::Setup environment'
49+
CONDA_PATH=$(which conda)
50+
eval "$(${CONDA_PATH} shell.bash hook)"
51+
# clang-format needs some shared libraries that conflict with the system ones. Thus, we install them from conda
52+
# and prepend the libraries to linker path to prioritize them
53+
conda create --name ci --quiet --yes python=3.8 ncurses=5 libgcc
54+
conda activate ci
55+
export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}"
56+
echo '::endgroup::'
57+
58+
echo '::group::Install lint tools'
59+
curl https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/clang-format-linux64 -o ./clang-format
60+
chmod +x ./clang-format
61+
echo '::endgroup::'
62+
63+
echo '::group::Lint C source'
64+
set +e
65+
./.circleci/unittest/linux/scripts/run-clang-format.py -r torchvision/csrc --clang-format-executable ./clang-format
66+
67+
if [ $? -ne 0 ]; then
68+
git --no-pager diff
69+
exit 1
70+
fi
71+
echo '::endgroup::'
72+
73+
74+
python-types:
75+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
76+
with:
77+
repository: pytorch/vision
78+
script: |
79+
set -euo pipefail
80+
81+
export PYTHON_VERSION=3.8
82+
export GPU_ARCH_TYPE=cpu
83+
./.github/scripts/setup-env.sh
84+
85+
CONDA_PATH=$(which conda)
86+
eval "$(${CONDA_PATH} shell.bash hook)"
87+
conda activate ci
88+
89+
echo '::group::Install lint tools'
90+
pip install --progress-bar=off mypy
91+
echo '::endgroup::'
92+
93+
echo '::group::Lint Python types'
94+
mypy --install-types --non-interactive --config-file mypy.ini
95+
echo '::endgroup::'

0 commit comments

Comments
 (0)