From 8bb94f0bd4211dc1eb5da7b13865f122256b52ac Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 10 Mar 2019 13:42:05 -0700 Subject: [PATCH] azure pipelines [skip travis] [skip appveyor] --- .coveragerc | 1 - .travis.yml | 22 -------------- README.md | 7 ++--- appveyor.yml | 17 ----------- azure-pipelines.yml | 25 ++++++++++++++++ get-git-lfs.py | 42 --------------------------- pre_commit_hooks/util.py | 2 -- tests/check_added_large_files_test.py | 5 ++-- tests/check_merge_conflict_test.py | 6 ++-- tox.ini | 1 - 10 files changed, 33 insertions(+), 95 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 azure-pipelines.yml delete mode 100755 get-git-lfs.py diff --git a/.coveragerc b/.coveragerc index 0a55c5f..7c592a9 100644 --- a/.coveragerc +++ b/.coveragerc @@ -6,7 +6,6 @@ omit = .tox/* /usr/* setup.py - get-git-lfs.py [report] show_missing = True diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fa16cce..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -dist: xenial -language: python -matrix: - include: # These should match the tox env list - - env: TOXENV=py27 - - env: TOXENV=py36 - python: 3.6 - - env: TOXENV=py37 - python: 3.7 - - env: TOXENV=pypy - python: pypy2.7-5.10.0 -install: pip install coveralls tox -script: tox -before_install: - # Install git-lfs for a test - - './get-git-lfs.py && export PATH="/tmp/git-lfs:$PATH"' -after_success: coveralls -cache: - directories: - - $HOME/.cache/pip - - $HOME/.cache/pre-commit - - /tmp/git-lfs diff --git a/README.md b/README.md index 177c4be..a937771 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ -[![Build Status](https://travis-ci.org/pre-commit/pre-commit-hooks.svg?branch=master)](https://travis-ci.org/pre-commit/pre-commit-hooks) -[![Coverage Status](https://coveralls.io/repos/github/pre-commit/pre-commit-hooks/badge.svg?branch=master)](https://coveralls.io/github/pre-commit/pre-commit-hooks?branch=master) -[![Build status](https://ci.appveyor.com/api/projects/status/dfcpng35u4g0r0t1/branch/master?svg=true)](https://ci.appveyor.com/project/asottile/pre-commit-hooks/branch/master) +[![Build Status](https://asottile.visualstudio.com/asottile/_apis/build/status/pre-commit.pre-commit-hooks?branchName=master)](https://asottile.visualstudio.com/asottile/_build/latest?definitionId=17&branchName=master) +[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/asottile/asottile/17/master.svg)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=17&branchName=master) pre-commit-hooks -========== +================ Some out-of-the-box hooks for pre-commit. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 395320b..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -environment: - matrix: - - TOXENV: py27 - - TOXENV: py37 - -install: - - "SET PATH=C:\\Python37;C:\\Python37\\Scripts;%PATH%" - - pip install tox - -# Not a C# project -build: 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 0000000..ab4c896 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,25 @@ +trigger: + branches: + include: [master, test-me-*] + +resources: + repositories: + - repository: asottile + type: github + endpoint: asottile-github + name: asottile/azure-pipeline-templates + ref: refs/tags/v0.0.8 + +jobs: +- template: job--python-tox.yml@asottile + parameters: + toxenvs: [py27, py37] + os: windows + pre_test: + - script: git lfs +- template: job--python-tox.yml@asottile + parameters: + toxenvs: [pypy, py27, py36, py37] + os: linux + pre_test: + - script: git lfs diff --git a/get-git-lfs.py b/get-git-lfs.py deleted file mode 100755 index 4b09cac..0000000 --- a/get-git-lfs.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -"""This is a script to install git-lfs to a tempdir for use in tests""" -import io -import os.path -import shutil -import tarfile -import urllib.request -from typing import cast -from typing import IO - -DOWNLOAD_PATH = ( - 'https://github.com/github/git-lfs/releases/download/' - 'v2.2.1/git-lfs-linux-amd64-2.2.1.tar.gz' -) -PATH_IN_TAR = 'git-lfs-2.2.1/git-lfs' -DEST_PATH = '/tmp/git-lfs/git-lfs' -DEST_DIR = os.path.dirname(DEST_PATH) - - -def main(): # type: () -> int - if ( - os.path.exists(DEST_PATH) and - os.path.isfile(DEST_PATH) and - os.access(DEST_PATH, os.X_OK) - ): - print('Already installed!') - return 0 - - shutil.rmtree(DEST_DIR, ignore_errors=True) - os.makedirs(DEST_DIR, exist_ok=True) - - contents = io.BytesIO(urllib.request.urlopen(DOWNLOAD_PATH).read()) - with tarfile.open(fileobj=contents) as tar: - with cast(IO[bytes], tar.extractfile(PATH_IN_TAR)) as src_file: - with open(DEST_PATH, 'wb') as dest_file: - shutil.copyfileobj(src_file, dest_file) - os.chmod(DEST_PATH, 0o755) - return 0 - - -if __name__ == '__main__': - exit(main()) diff --git a/pre_commit_hooks/util.py b/pre_commit_hooks/util.py index 5d1d11b..d68e769 100644 --- a/pre_commit_hooks/util.py +++ b/pre_commit_hooks/util.py @@ -24,8 +24,6 @@ def cmd_output(*cmd, **kwargs): # type: (*str, **Any) -> str proc = subprocess.Popen(cmd, **kwargs) stdout, stderr = proc.communicate() stdout = stdout.decode('UTF-8') - if stderr is not None: - stderr = stderr.decode('UTF-8') if retcode is not None and proc.returncode != retcode: raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr) return stdout diff --git a/tests/check_added_large_files_test.py b/tests/check_added_large_files_test.py index 06671d7..7f5e418 100644 --- a/tests/check_added_large_files_test.py +++ b/tests/check_added_large_files_test.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from __future__ import unicode_literals -import subprocess +import distutils.spawn import pytest @@ -67,8 +67,7 @@ def test_integration(temp_git_dir): def has_gitlfs(): - output = cmd_output('git', 'lfs', retcode=None, stderr=subprocess.STDOUT) - return 'git lfs status' in output + return distutils.spawn.find_executable('git-lfs') is not None xfailif_no_gitlfs = pytest.mark.xfail( diff --git a/tests/check_merge_conflict_test.py b/tests/check_merge_conflict_test.py index 50e389c..af7cc43 100644 --- a/tests/check_merge_conflict_test.py +++ b/tests/check_merge_conflict_test.py @@ -22,7 +22,7 @@ def f1_is_a_conflict_file(tmpdir): cmd_output('git', 'init', '--', repo1.strpath) with repo1.as_cwd(): repo1_f1.ensure() - cmd_output('git', 'add', '--', repo1_f1.strpath) + cmd_output('git', 'add', '.') cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'commit1') cmd_output('git', 'clone', repo1.strpath, repo2.strpath) @@ -77,7 +77,7 @@ def repository_pending_merge(tmpdir): cmd_output('git', 'init', repo1.strpath) with repo1.as_cwd(): repo1_f1.ensure() - cmd_output('git', 'add', '--', repo1_f1.strpath) + cmd_output('git', 'add', '.') cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'commit1') cmd_output('git', 'clone', repo1.strpath, repo2.strpath) @@ -90,7 +90,7 @@ def repository_pending_merge(tmpdir): # Commit in clone and pull without committing with repo2.as_cwd(): repo2_f2.write('child\n') - cmd_output('git', 'add', '--', repo2_f2.strpath) + cmd_output('git', 'add', '.') cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'clone commit2') cmd_output('git', 'pull', '--no-commit', '--no-rebase') # We should end up in a pending merge diff --git a/tox.ini b/tox.ini index 3020bc0..590783a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,4 @@ [tox] -# These should match the travis env list envlist = py27,py36,py37,pypy3 [testenv]