Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop on Windows #108

Merged
merged 33 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1086c20
ci: trying on Windows
andreoliwa Oct 27, 2019
d65f7f6
ci: only the os key
andreoliwa Oct 27, 2019
6603fa6
ci: try the build matrix
andreoliwa Oct 27, 2019
3793e06
ci: try explicit stage test
andreoliwa Oct 27, 2019
2eaf6bb
ci: install Python 3.7 (default is Python 3.8 now)
andreoliwa Oct 27, 2019
2f7621a
ci: remove refreshenv
andreoliwa Oct 27, 2019
b08a581
ci: run cc-test-reporter only on Linux
andreoliwa Oct 27, 2019
0f6e146
ci: fix "Could not parse andreoliwa/nitpick/.travis.yml"
andreoliwa Oct 27, 2019
4c426e6
ci: use poetry run to work on Windows
andreoliwa Oct 27, 2019
c8c2b7d
ci: run all pre-commit hooks only on Python 3.7 Linux
andreoliwa Oct 27, 2019
b781e35
ci: run only pytest on Windows, without coverage
andreoliwa Oct 27, 2019
8f99189
fix: deal with the root dir on Windows
andreoliwa Oct 27, 2019
9f07baf
ci: try disabling --doctest-modules
andreoliwa Oct 27, 2019
647e81a
ci: debug pytest
andreoliwa Oct 27, 2019
968b8d9
ci: remove PATH
andreoliwa Oct 27, 2019
1744682
ci: restore PATH
andreoliwa Oct 27, 2019
3195956
ci: no capture
andreoliwa Oct 28, 2019
bff5b6b
ci: try running flake8
andreoliwa Oct 28, 2019
6c5efc4
ci: try running pytest again for the last time
andreoliwa Oct 28, 2019
6ffcc40
ci: try running coverage with debug
andreoliwa Oct 28, 2019
3963357
ci: spawn poetry shell
andreoliwa Oct 28, 2019
4a29684
ci: try PYTHONPATH
andreoliwa Oct 28, 2019
ffe37e2
ci: try another PYTHONPATH
andreoliwa Oct 28, 2019
cc2ccfd
ci: list files under PYTHONPATH
andreoliwa Oct 28, 2019
d9c325f
ci: fix PYTHONPATH
andreoliwa Oct 28, 2019
87e24ef
ci: run coverage again
andreoliwa Oct 28, 2019
32d507e
ci: try calling activate.bat
andreoliwa Oct 28, 2019
e91f570
ci: try Python 3.8 on Windows
andreoliwa Oct 28, 2019
336361c
ci: comment out Windows, run only Linux builds
andreoliwa Oct 28, 2019
1c27cf4
ci: remove Python 3.8 for now (maybe it needs pyproject.toml changes)
andreoliwa Oct 28, 2019
2a57db2
Merge branch 'develop' into windows-infinite-loop
andreoliwa Oct 29, 2019
3d82843
build: update hooks
andreoliwa Oct 29, 2019
dd5c015
refactor: restore previous logic to climb dirs (thanks @Skrierz)
andreoliwa Oct 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ root = true
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

# Whitespace at the end of lines
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8

# Whitespace at the end of lines
trim_trailing_whitespace = true

[*.{yml,yaml}]
indent_size = 2

[Makefile]
indent_style = tab
indent_size = 4
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
# Thanks to https://github.com/sloria/environs/blob/master/.pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v2.4.0
hooks:
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.0
rev: v1.25.1
hooks:
- id: pyupgrade
- repo: https://github.com/python/black
rev: 19.3b0
rev: 19.10b0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: v1.3.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]
additional_dependencies: [black==19.10b0]
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3
hooks:
Expand All @@ -48,7 +48,7 @@ repos:
types: [python]
always_run: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v2.4.0
hooks:
- id: flake8
additional_dependencies: [flake8-blind-except, flake8-bugbear, flake8-comprehensions,
Expand Down
45 changes: 33 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# https://docs.travis-ci.com/user/reference/xenial/
dist: xenial
env:
global:
- CC_TEST_REPORTER_ID=2da342a92e29aa78fcf1dc84b18af77f8eede63db675363fd1151673be3ce4f3
Expand All @@ -13,22 +11,20 @@ cache:
- $PRE_COMMIT_HOME
# https://docs.travis-ci.com/user/languages/python/
language: python
python:
- "3.5"
- "3.6"
- "3.7"
# https://docs.travis-ci.com/user/reference/xenial/
dist: xenial
install:
- pip3 install --upgrade pip poetry coveralls pre-commit
- poetry install --no-ansi --no-interaction
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then chmod +x ./cc-test-reporter; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then ./cc-test-reporter before-build; fi
script:
- "./.travis/script.sh"
- "./.travis/script.sh $TRAVIS_OS_NAME $TRAVIS_PYTHON_VERSION"
after_script:
- coverage xml
- if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
install:
- pip install -U poetry coveralls pre-commit
- poetry install --no-ansi --no-interaction
after_success:
- coverage combine
- coveralls
Expand All @@ -39,6 +35,7 @@ notifications:
stages:
- name: release
if: branch = master
- name: test
jobs:
include:
# Define the release stage that runs semantic-release
Expand All @@ -52,3 +49,27 @@ jobs:
provider: script
skip_cleanup: true
script: semantic-release
- stage: test
python: 3.7
- python: 3.6
- python: 3.5
# Thanks to https://github.com/cclauss/Travis-CI-Python-on-three-OSes/blob/master/.travis.yml
# TODO Build freezing on Windows, see comments on .travis/script.sh
# - name: "Python: 3.8"
# os: windows
# language: shell
# before_install:
# - choco install python
# - python -m pip install --upgrade pip
# env:
# - PATH=/c/Python38:/c/Python38/Scripts:$PATH
# - PYTHONPATH=/c/Users/travis/AppData/Local/pypoetry/Cache/virtualenvs/nitpick-py3.8/lib/site-packages
# - name: "Python: 3.7"
# os: windows
# language: shell
# before_install:
# - choco install python3 --version=3.7.4
# - python -m pip install --upgrade pip
# env:
# - PATH=/c/Python37:/c/Python37/Scripts:$PATH
# - PYTHONPATH=/c/Users/travis/AppData/Local/pypoetry/Cache/virtualenvs/nitpick-py3.7/lib/site-packages
62 changes: 48 additions & 14 deletions .travis/script.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,55 @@
#!/usr/bin/env bash
echo "Python version = $TRAVIS_PYTHON_VERSION"
export ARG_OS_NAME=$1
export ARG_PYTHON_VERSION=$2

fix=
test "$TRAVIS_PYTHON_VERSION" == '3.4' && fix=fix
test "$TRAVIS_PYTHON_VERSION" == '3.5' && fix=fix
echo "OS = $ARG_OS_NAME"
echo "Python version = $ARG_PYTHON_VERSION"

# Run all pre-commit hooks on Travis.
if [[ "$fix" == 'fix' ]]; then
python3 .travis/fix_pre_commit.py
pre-commit run --all-files --config .travis/.temp-without-black.yaml
else
if [[ "$ARG_OS_NAME" == 'linux' && "$ARG_PYTHON_VERSION" == '3.7' ]]; then
echo "Run all pre-commit hooks only on Python 3.7 Linux"
pre-commit run --all-files

echo "Running flake8 again for nitpick to check itself"
poetry install # This is needed to install nitpick itself, not only the dependencies
poetry run flake8
fi

echo "Running flake8 again for nitpick to check itself"
poetry install # This is needed to install nitpick itself, not only the dependencies
flake8
if [[ "$ARG_OS_NAME" == 'linux' ]]; then
echo "Running pytest with coverage report on Linux"
poetry run coverage run --branch --parallel-mode --source=nitpick -m pytest
else
# TODO Several commands don't work on the Windows build on Travis.
echo "Running pytest with coverage report on Windows"

# Build freezes with message:
# Spawning shell within C:\Users\travis\AppData\Local\pypoetry\Cache\virtualenvs\nitpick-py3.7
# poetry shell

export PYTEST_DEBUG=1
# Build shows debug messages and freezes on this line:
# early skip of rewriting module: text_unidecode [assertion]

echo "Running coverage report"
coverage run --branch --parallel-mode --source=nitpick -m pytest
# Build fails with message:
# No module named 'pytest'
# /c/Users/travis/AppData/Local/pypoetry/Cache/virtualenvs/nitpick-py3.7/activate.bat

# Build freezes with no message:
# poetry run flake8 --help
# poetry run flake8

coverage run --branch --parallel-mode --source=nitpick -m pytest
# Build freezes on test collection:
# ============================= test session starts =============================
# platform win32 -- Python 3.7.4, pytest-5.2.2, py-1.8.0, pluggy-0.13.0 -- c:\users\travis\appdata\local\pypoetry\cache\virtualenvs\nitpick-py3.7\scripts\python.exe
# cachedir: .pytest_cache
# rootdir: C:\Users\travis\build\andreoliwa\nitpick, inifile: setup.cfg
# plugins: repeat-0.8.0, runfailed-0.6
# collecting ...

# All builds fail after 10 minutes with this message:
# No output has been received in the last 10m0s, this potentially indicates
# a stalled build or something wrong with the build itself.
# Check the details on how to adjust your build configuration on:
# https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
# The build has been terminated
fi
10 changes: 5 additions & 5 deletions docs/defaults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ Content of `styles/black.toml <https://raw.githubusercontent.com/andreoliwa/nitp
[["pre-commit-config.yaml".repos]]
yaml = """
- repo: https://github.com/python/black
rev: 19.3b0
rev: 19.10b0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: v1.3.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]
additional_dependencies: [black==19.10b0]
"""
# TODO The toml library has issues loading arrays with multiline strings:
# https://github.com/uiri/toml/issues/123
Expand Down Expand Up @@ -86,7 +86,7 @@ Content of `styles/flake8.toml <https://raw.githubusercontent.com/andreoliwa/nit
[["pre-commit-config.yaml".repos]]
yaml = """
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v2.4.0
hooks:
- id: flake8
additional_dependencies: [flake8-blind-except, flake8-bugbear, flake8-comprehensions,
Expand Down Expand Up @@ -260,13 +260,13 @@ Content of `styles/pre-commit/general.toml <https://raw.githubusercontent.com/an
[["pre-commit-config.yaml".repos]]
yaml = """
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v2.4.0
hooks:
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.0
rev: v1.25.1
hooks:
- id: pyupgrade
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NOTE: generated by the Makefile
# This will be installed by Read the Docs, from the root folder
Pygments==2.4.2
Sphinx==2.2.0
Sphinx==2.2.1
sphinx-rtd-theme==0.4.3
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
Expand Down
10 changes: 5 additions & 5 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion src/nitpick/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def climb_directory_tree(starting_path: PathOrStr, file_patterns: Iterable[str])
if current_dir.is_file():
current_dir = current_dir.parent

while current_dir.root != str(current_dir):
while current_dir.anchor != str(current_dir):
for root_file in file_patterns:
found_files = list(current_dir.glob(root_file))
if found_files:
Expand Down
4 changes: 2 additions & 2 deletions styles/black.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ line-length = 120
[["pre-commit-config.yaml".repos]]
yaml = """
- repo: https://github.com/python/black
rev: 19.3b0
rev: 19.10b0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: v1.3.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]
additional_dependencies: [black==19.10b0]
"""
# TODO The toml library has issues loading arrays with multiline strings:
# https://github.com/uiri/toml/issues/123
Expand Down
2 changes: 1 addition & 1 deletion styles/flake8.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = ".tox,build"
[["pre-commit-config.yaml".repos]]
yaml = """
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v2.4.0
hooks:
- id: flake8
additional_dependencies: [flake8-blind-except, flake8-bugbear, flake8-comprehensions,
Expand Down
4 changes: 2 additions & 2 deletions styles/pre-commit/general.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[["pre-commit-config.yaml".repos]]
yaml = """
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v2.4.0
hooks:
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.0
rev: v1.25.1
hooks:
- id: pyupgrade
"""
4 changes: 2 additions & 2 deletions tests/test_pre_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def test_suggest_initial_contents(request):
hooks:
- id: isort
- repo: https://github.com/python/black
rev: 19.3b0
rev: 19.10b0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: v1.3.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]\x1b[0m
additional_dependencies: [black==19.10b0]\x1b[0m
"""
)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,15 @@ def test_merge_styles_into_single_file(request):
[["pre-commit-config.yaml".repos]]
yaml = """
- repo: https://github.com/python/black
rev: 19.3b0
rev: 19.10b0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: v1.3.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]
additional_dependencies: [black==19.10b0]
"""

[["pre-commit-config.yaml".repos]]
Expand Down