Skip to content

Commit 756882f

Browse files
authored
[NovaX] Lint Job on GHA (#2151)
* [NovaX] Lint Job on GHA * fix lint errors * pre-commit run all files * conda env to path * install older node * no need to remove prev libs * no source bashrc * default sys node * specific node version * fixing lint errors raised by whitespace detector * Remove CCI job
1 parent 0dc07eb commit 756882f

File tree

4 files changed

+77
-98
lines changed

4 files changed

+77
-98
lines changed

.circleci/config.yml

Lines changed: 0 additions & 49 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 & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -81,53 +81,6 @@ jobs:
8181
name: .circleci/config.yml not in sync with config.yml.in! Run '$ python .circleci/regenerate.py' to fix this.
8282
command: exit 1
8383

84-
lint_python_and_config:
85-
docker:
86-
- image: circleci/python:3.8
87-
steps:
88-
- checkout
89-
- run:
90-
name: Install lint utilities
91-
command: pip install --user --progress-bar=off pre-commit
92-
- run:
93-
name: Install pre-commit hooks
94-
command: pre-commit install-hooks
95-
- run:
96-
name: Lint Python code and config files
97-
command: pre-commit run --all-files
98-
- run:
99-
when: on_fail
100-
name: Code format not compliant with the rules! Run '$ pre-commit run --all-files' to fix this.
101-
command: exit 1
102-
103-
lint_c:
104-
docker:
105-
- image: circleci/python:3.8
106-
steps:
107-
- run:
108-
name: Install additional system libraries
109-
command: |
110-
sudo apt update -qy
111-
sudo apt install libtinfo5
112-
- checkout
113-
- run:
114-
name: Install lint utilities
115-
command: |
116-
curl https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/clang-format-linux64 -o clang-format
117-
chmod +x clang-format
118-
./clang-format --version
119-
- run:
120-
name: Lint C code
121-
command: >
122-
python run-clang-format.py
123-
--recursive
124-
--clang-format-executable=./clang-format
125-
torchtext/csrc
126-
- run:
127-
when: on_fail
128-
name: Code format not compliant with the rules! Run '$ python run-clang-format.py' to fix this.
129-
command: exit 1
130-
13184
smoke_test_docker_image_build:
13285
machine:
13386
image: ubuntu-1604:201903-01
@@ -167,8 +120,6 @@ workflows:
167120
lint:
168121
jobs:
169122
- circleci_consistency
170-
- lint_python_and_config
171-
- lint_c
172123
docker_build:
173124
triggers:
174125
- schedule:

.github/workflows/lint.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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/text
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+
echo $LD_LIBRARY_PATH
34+
export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}"
35+
pre-commit run --all-files
36+
37+
if [ $? -ne 0 ]; then
38+
git --no-pager diff
39+
exit 1
40+
fi
41+
echo '::endgroup::'
42+
43+
c-source:
44+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
45+
with:
46+
repository: pytorch/text
47+
script: |
48+
set -euo pipefail
49+
50+
echo '::group::Setup environment'
51+
CONDA_PATH=$(which conda)
52+
eval "$(${CONDA_PATH} shell.bash hook)"
53+
conda create --name ci --quiet --yes -c conda-forge 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+
python run-clang-format.py \
66+
--recursive \
67+
--clang-format-executable=./clang-format \
68+
torchtext/csrc
69+
70+
if [ $? -ne 0 ]; then
71+
git --no-pager diff
72+
exit 1
73+
fi
74+
echo '::endgroup::'

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
default_language_version:
2+
node: 16.14.2
3+
14
repos:
25
- repo: https://github.com/pre-commit/pre-commit-hooks
36
rev: v4.0.1

0 commit comments

Comments
 (0)