Skip to content

Commit

Permalink
[NovaX] Lint Job on GHA (#2151)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
osalpekar authored May 30, 2023
1 parent 0dc07eb commit 756882f
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 98 deletions.
49 changes: 0 additions & 49 deletions .circleci/config.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 0 additions & 49 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,53 +81,6 @@ jobs:
name: .circleci/config.yml not in sync with config.yml.in! Run '$ python .circleci/regenerate.py' to fix this.
command: exit 1

lint_python_and_config:
docker:
- image: circleci/python:3.8
steps:
- checkout
- run:
name: Install lint utilities
command: pip install --user --progress-bar=off pre-commit
- run:
name: Install pre-commit hooks
command: pre-commit install-hooks
- run:
name: Lint Python code and config files
command: pre-commit run --all-files
- run:
when: on_fail
name: Code format not compliant with the rules! Run '$ pre-commit run --all-files' to fix this.
command: exit 1

lint_c:
docker:
- image: circleci/python:3.8
steps:
- run:
name: Install additional system libraries
command: |
sudo apt update -qy
sudo apt install libtinfo5
- checkout
- run:
name: Install lint utilities
command: |
curl https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/clang-format-linux64 -o clang-format
chmod +x clang-format
./clang-format --version
- run:
name: Lint C code
command: >
python run-clang-format.py
--recursive
--clang-format-executable=./clang-format
torchtext/csrc
- run:
when: on_fail
name: Code format not compliant with the rules! Run '$ python run-clang-format.py' to fix this.
command: exit 1

smoke_test_docker_image_build:
machine:
image: ubuntu-1604:201903-01
Expand Down Expand Up @@ -167,8 +120,6 @@ workflows:
lint:
jobs:
- circleci_consistency
- lint_python_and_config
- lint_c
docker_build:
triggers:
- schedule:
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Lint

on:
pull_request:
push:
branches:
- nightly
- main
- release/*
workflow_dispatch:

jobs:
python-source-and-configs:
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
repository: pytorch/text
script: |
set -euo pipefail
echo '::group::Setup environment'
CONDA_PATH=$(which conda)
eval "$(${CONDA_PATH} shell.bash hook)"
conda create --name ci --quiet --yes python=3.8 pip
conda activate ci
echo '::endgroup::'
echo '::group::Install lint tools'
pip install --progress-bar=off pre-commit
echo '::endgroup::'
echo '::group::Lint Python source and configs'
set +e
echo $LD_LIBRARY_PATH
export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}"
pre-commit run --all-files
if [ $? -ne 0 ]; then
git --no-pager diff
exit 1
fi
echo '::endgroup::'
c-source:
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
repository: pytorch/text
script: |
set -euo pipefail
echo '::group::Setup environment'
CONDA_PATH=$(which conda)
eval "$(${CONDA_PATH} shell.bash hook)"
conda create --name ci --quiet --yes -c conda-forge python=3.8 ncurses=5 libgcc
conda activate ci
export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}"
echo '::endgroup::'
echo '::group::Install lint tools'
curl https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/clang-format-linux64 -o ./clang-format
chmod +x ./clang-format
echo '::endgroup::'
echo '::group::Lint C source'
set +e
python run-clang-format.py \
--recursive \
--clang-format-executable=./clang-format \
torchtext/csrc
if [ $? -ne 0 ]; then
git --no-pager diff
exit 1
fi
echo '::endgroup::'
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
default_language_version:
node: 16.14.2

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
Expand Down

0 comments on commit 756882f

Please sign in to comment.