azure pipelines [skip travis] [skip appveyor]

This commit is contained in:
Anthony Sottile
2019-04-28 17:36:54 -07:00
parent 09e64e8ff6
commit 9c6edab726
9 changed files with 72 additions and 85 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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'

50
azure-pipelines.yml Normal file
View File

@@ -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

View File

@@ -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)

View File

@@ -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'):

View File

@@ -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(

View File

@@ -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''

15
tox.ini
View File

@@ -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