From 9c6edab726b1b98cd01b7fa2da0d76c125f33909 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 28 Apr 2019 17:36:54 -0700 Subject: [PATCH] azure pipelines [skip travis] [skip appveyor] --- .travis.yml | 34 ----------------------- README.md | 5 ++-- appveyor.yml | 29 -------------------- azure-pipelines.yml | 50 ++++++++++++++++++++++++++++++++++ pre_commit/languages/node.py | 10 ++++--- pre_commit/languages/python.py | 8 +++--- testing/util.py | 4 +-- tests/xargs_test.py | 2 +- tox.ini | 15 +++++----- 9 files changed, 72 insertions(+), 85 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 azure-pipelines.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 32376b27..00000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: python -dist: xenial -services: - - docker -matrix: - include: - - env: TOXENV=py27 - - env: TOXENV=py27 LATEST_GIT=1 - - env: TOXENV=py36 - python: 3.6 - - env: TOXENV=pypy - python: pypy2.7-5.10.0 - - env: TOXENV=py37 - python: 3.7 -install: pip install coveralls tox -script: tox -before_install: - - git --version - - | - if [ "$LATEST_GIT" = "1" ]; then - testing/latest-git.sh - export PATH="/tmp/git/bin:$PATH" - fi - - git --version - - 'testing/get-swift.sh && export PATH="/tmp/swift/usr/bin:$PATH"' - - 'curl -sSf https://sh.rustup.rs | bash -s -- -y' - - export PATH="$HOME/.cargo/bin:$PATH" -after_success: coveralls -cache: - directories: - - $HOME/.cache/pip - - $HOME/.cache/pre-commit - - $HOME/.rustup - - $HOME/.swift diff --git a/README.md b/README.md index 12b222d3..c91a69ac 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -[![Build Status](https://travis-ci.org/pre-commit/pre-commit.svg?branch=master)](https://travis-ci.org/pre-commit/pre-commit) -[![Coverage Status](https://coveralls.io/repos/github/pre-commit/pre-commit/badge.svg?branch=master)](https://coveralls.io/github/pre-commit/pre-commit?branch=master) -[![Build status](https://ci.appveyor.com/api/projects/status/mmcwdlfgba4esaii/branch/master?svg=true)](https://ci.appveyor.com/project/asottile/pre-commit/branch/master) +[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/asottile.pyupgrade?branchName=master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=21&branchName=master) +[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/asottile/asottile/21/master.svg)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=21&branchName=master) ## pre-commit diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 23d3931c..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,29 +0,0 @@ -environment: - global: - COVERAGE_IGNORE_WINDOWS: '# pragma: windows no cover' - TOX_TESTENV_PASSENV: COVERAGE_IGNORE_WINDOWS - matrix: - - TOXENV: py27 - - TOXENV: py37 - -install: - - "SET PATH=C:\\Python37;C:\\Python37\\Scripts;%PATH%" - - pip install tox virtualenv --upgrade - - "mkdir -p C:\\Temp" - - "SET TMPDIR=C:\\Temp" - - "curl -sSf https://sh.rustup.rs | bash -s -- -y" - - "SET PATH=%USERPROFILE%\\.cargo\\bin;%PATH%" - -# Not a C# project -build: false - -before_test: - # Shut up CRLF messages - - git config --global core.autocrlf false - - git config --global core.safecrlf false - -test_script: tox - -cache: - - '%LOCALAPPDATA%\pip\cache' - - '%USERPROFILE%\.cache\pre-commit' diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..ce09d9c4 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,50 @@ +trigger: + branches: + include: [master, test-me-*] + tags: + include: ['*'] + +resources: + repositories: + - repository: asottile + type: github + endpoint: github + name: asottile/azure-pipeline-templates + ref: refs/tags/v0.0.13 + +jobs: +- template: job--pre-commit.yml@asottile +- template: job--python-tox.yml@asottile + parameters: + toxenvs: [py27, py37] + os: windows + additional_variables: + COVERAGE_IGNORE_WINDOWS: '# pragma: windows no cover' + TOX_TESTENV_PASSENV: COVERAGE_IGNORE_WINDOWS + TEMP: C:\Temp # remove when dropping python2 + pre_test: + - template: step--rust-install.yml +- template: job--python-tox.yml@asottile + parameters: + toxenvs: [py37] + os: linux + name_postfix: _latest_git + pre_test: + - task: UseRubyVersion@0 + - template: step--git-install.yml + - template: step--rust-install.yml + - bash: | + testing/get-swift.sh + echo '##vso[task.prependpath]/tmp/swift/usr/bin' + displayName: install swift +- template: job--python-tox.yml@asottile + parameters: + toxenvs: [pypy, pypy3, py27, py36, py37] + os: linux + pre_test: + - task: UseRubyVersion@0 + - template: step--rust-install.yml + - bash: | + testing/get-swift.sh + echo '##vso[task.prependpath]/tmp/swift/usr/bin' + displayName: install swift diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py index aac1c591..cd3b7b54 100644 --- a/pre_commit/languages/node.py +++ b/pre_commit/languages/node.py @@ -23,7 +23,7 @@ def _envdir(prefix, version): return prefix.path(directory) -def get_env_patch(venv): +def get_env_patch(venv): # pragma: windows no cover if sys.platform == 'cygwin': # pragma: no cover _, win_venv, _ = cmd_output('cygpath', '-w', venv) install_prefix = r'{}\bin'.format(win_venv.strip()) @@ -41,12 +41,14 @@ def get_env_patch(venv): @contextlib.contextmanager -def in_env(prefix, language_version): +def in_env(prefix, language_version): # pragma: windows no cover with envcontext(get_env_patch(_envdir(prefix, language_version))): yield -def install_environment(prefix, version, additional_dependencies): +def install_environment( + prefix, version, additional_dependencies, +): # pragma: windows no cover additional_dependencies = tuple(additional_dependencies) assert prefix.exists('package.json') envdir = _envdir(prefix, version) @@ -72,6 +74,6 @@ def install_environment(prefix, version, additional_dependencies): ) -def run_hook(hook, file_args): +def run_hook(hook, file_args): # pragma: windows no cover with in_env(hook.prefix, hook.language_version): return helpers.run_xargs(hook, helpers.to_cmd(hook), file_args) diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py index 86f5368c..2897d0ea 100644 --- a/pre_commit/languages/python.py +++ b/pre_commit/languages/python.py @@ -109,15 +109,15 @@ def norm_version(version): if _sys_executable_matches(version): return sys.executable + version_exec = _find_by_py_launcher(version) + if version_exec: + return version_exec + # Try looking up by name version_exec = find_executable(version) if version_exec and version_exec != version: return version_exec - version_exec = _find_by_py_launcher(version) - if version_exec: - return version_exec - # If it is in the form pythonx.x search in the default # place on windows if version.startswith('python'): diff --git a/testing/util.py b/testing/util.py index 15696730..b3b12868 100644 --- a/testing/util.py +++ b/testing/util.py @@ -30,8 +30,8 @@ def cmd_output_mocked_pre_commit_home(*args, **kwargs): skipif_cant_run_docker = pytest.mark.skipif( - docker_is_running() is False, - reason='Docker isn\'t running or can\'t be accessed', + os.name == 'nt' or not docker_is_running(), + reason="Docker isn't running or can't be accessed", ) skipif_cant_run_swift = pytest.mark.skipif( diff --git a/tests/xargs_test.py b/tests/xargs_test.py index 71f5454c..d2d7d7b3 100644 --- a/tests/xargs_test.py +++ b/tests/xargs_test.py @@ -145,7 +145,7 @@ def test_argument_too_long(): def test_xargs_smoke(): ret, out, err = xargs.xargs(('echo',), ('hello', 'world')) assert ret == 0 - assert out == b'hello world\n' + assert out.replace(b'\r\n', b'\n') == b'hello world\n' assert err == b'' diff --git a/tox.ini b/tox.ini index d9bcb6b1..0ee1611f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,19 @@ [tox] -project = pre_commit -# These should match the travis env list -envlist = py27,py36,py37,pypy +envlist = py27,py36,py37,pypy,pypy3,pre-commit [testenv] deps = -rrequirements-dev.txt -passenv = LOCALAPPDATA +passenv = HOME LOCALAPPDATA commands = coverage erase coverage run -m pytest {posargs:tests} coverage report --fail-under 100 - pre-commit run --all-files + pre-commit install -[testenv:venv] -envdir = venv-{[tox]project} -commands = +[testenv:pre-commit] +skip_install = true +deps = pre-commit +commands = pre-commit run --all-files --show-diff-on-failure [pep8] ignore = E265,E501,W504