Skip to content

Commit

Permalink
Move style check to CCI
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok committed May 13, 2020
1 parent 32bc374 commit 033d79a
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 134 deletions.
32 changes: 32 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,35 @@ jobs:
- store_test_results:
path: test-results

stylecheck:
<<: *binary_common
docker:
- image: "pytorch/manylinux-cuda100"
resource_class: medium
steps:
- checkout
- run:
name: Generate cache key
# This will refresh cache on Sundays, nightly build should generate new cache.
command: echo "$(date +"%Y-%U")" > .circleci-weekly
- restore_cache:

keys:
- env-v1-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}

- run:
name: Setup
command: .circleci/unittest/scripts/setup_env.sh
- save_cache:

key: env-v1-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}

paths:
- conda
- env
- run:
name: Run style check
command: .circleci/unittest/scripts/run_style_checks.sh

workflows:
# build:
Expand All @@ -299,6 +328,9 @@ workflows:
- unittest_linux:
name: unittest_linux_py3.6
python_version: '3.6'
- stylecheck:
name: stylecheck_py3.6
python_version: '3.6'
- unittest_linux:
name: unittest_linux_py3.7
python_version: '3.7'
Expand Down
29 changes: 29 additions & 0 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,35 @@ jobs:
- store_test_results:
path: test-results

stylecheck:
<<: *binary_common
docker:
- image: "pytorch/manylinux-cuda100"
resource_class: medium
steps:
- checkout
- run:
name: Generate cache key
# This will refresh cache on Sundays, nightly build should generate new cache.
command: echo "$(date +"%Y-%U")" > .circleci-weekly
- restore_cache:
{% raw %}
keys:
- env-v1-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
{% endraw %}
- run:
name: Setup
command: .circleci/unittest/scripts/setup_env.sh
- save_cache:
{% raw %}
key: env-v1-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
{% endraw %}
paths:
- conda
- env
- run:
name: Run style check
command: .circleci/unittest/scripts/run_style_checks.sh

workflows:
# build:
Expand Down
10 changes: 9 additions & 1 deletion .circleci/regenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,21 @@ def indent(indentation, data_list):
def unittest_workflows(indentation=6):
w = []
for os_type in ["linux"]:
for python_version in PYTHON_VERSIONS:
for i, python_version in enumerate(PYTHON_VERSIONS):
w.append({
f"unittest_{os_type}": {
"name": f"unittest_{os_type}_py{python_version}",
"python_version": python_version,
}
})

if i == 0:
w.append({
f"stylecheck": {
"name": f"stylecheck_py{python_version}",
"python_version": python_version,
}
})
return indent(indentation, w)


Expand Down
32 changes: 32 additions & 0 deletions .circleci/unittest/scripts/run_style_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -u

eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env

# We want to run all the style checks even if one of them fail.

exit_status=0

printf "\x1b[34mRunning flake8: "
flake8 --version
printf "\x1b[0m\n"
flake8 torchtext test build_tools/setup_helpers
status=$?
exit_status="$((exit_status+status))"
if [ "${status}" -ne 0 ]; then
printf "\x1b[31mflake8 failed. Check the format of Python files.\x1b[0m\n"
fi

printf "\x1b[34mRunning clang-format: "
clang-format --version
printf "\x1b[0m\n"
git-clang-format origin/master
git diff --exit-code
status=$?
exit_status="$((exit_status+status))"
if [ "${status}" -ne 0 ]; then
printf "\x1b[31mC++ files are not formatted. Please use git-clang-format to format CPP files.\x1b[0m\n"
fi
exit $exit_status
3 changes: 0 additions & 3 deletions .circleci/unittest/scripts/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ conda activate ./env

python -m torch.utils.collect_env
pytest --cov=torchtext --junitxml=test-results/junit.xml -v --durations 20 test
flake8 torchaudio test build_tools/setup_helpers
git-clang-format origin/master
git diff --exit-code || (echo "C++ files are not formatted. Use clang-format on CPP files."; exit 1)
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

13 changes: 0 additions & 13 deletions build_tools/travis/after_success.sh

This file was deleted.

68 changes: 0 additions & 68 deletions build_tools/travis/install.sh

This file was deleted.

26 changes: 0 additions & 26 deletions build_tools/travis/test_script.sh

This file was deleted.

0 comments on commit 033d79a

Please sign in to comment.