From abdb23a914e00a3b1cededcb737fb5f9a0b8f753 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 17 Jul 2018 15:23:12 +0700 Subject: [PATCH] .moban.yaml: Add CI check scripts Related to https://gitlab.com/coala/mobans/issues/65 --- .ci/check_setuptools.py | 48 ++++++++++++++++++++++++++++++++++++++++ .ci/check_unsupported.sh | 2 +- .moban.yaml | 4 +++- .travis.yml | 1 + 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 .ci/check_setuptools.py diff --git a/.ci/check_setuptools.py b/.ci/check_setuptools.py new file mode 100644 index 0000000000..f6857db1fe --- /dev/null +++ b/.ci/check_setuptools.py @@ -0,0 +1,48 @@ +from __future__ import print_function + +import subprocess +import sys + +import setuptools + + +def get_setuptools_version(): + with open('requirements.txt') as f: + for line in f: + if line.startswith('setuptools'): + line = line.rstrip() + if '>=' not in line: + raise ValueError('%s doesnt use ">="' % line) + _, version = line.split('>=') + return version + + +def check_setuptools_version(version): + print('Checking setuptools==%s' % version, file=sys.stderr) + if setuptools.__version__ != version: + print('Failed! setuptools==%s' % setuptools.__version__, + file=sys.stderr) + return 2 + + pip_list = subprocess.check_output(['pip', 'list', '--format=legacy']) + pip_list = pip_list.decode('utf8') + if 'setuptools (%s)' % version not in pip_list: + print('Failed! pip list reports wrong setuptools:\n%s' % pip_list, + file=sys.stderr) + return 3 + +if __name__ == '__main__': + version = None + try: + version = get_setuptools_version() + except Exception as e: + print('Exception extracting setuptools version from requirements.txt: ' + '%s' % e, + file=sys.stderr) + sys.exit(1) + + if not version: + print('Unable to find setuptools in requirements.txt', + file=sys.stderr) + sys.exit(1) + sys.exit(check_setuptools_version(version)) diff --git a/.ci/check_unsupported.sh b/.ci/check_unsupported.sh index ee0a75d8e5..cd075cfc8f 100755 --- a/.ci/check_unsupported.sh +++ b/.ci/check_unsupported.sh @@ -33,7 +33,7 @@ fi set -e # The following is emitted on stdout -grep -q 'coala supports only python 3.4.4 or later' setup.log +grep -q 'coala supports only Python 3.4.2 or later' setup.log # The following is emitted on stderr grep -q 'error: Setup script exited with 4' setup.log diff --git a/.moban.yaml b/.moban.yaml index ab2a6b1e46..6ac3d2a1b3 100644 --- a/.moban.yaml +++ b/.moban.yaml @@ -38,7 +38,9 @@ targets: - .ci/appveyor.yml: ci/appveyor.yml.jj2 - .ci/run_with_env.cmd: run_with_env.cmd - .ci/check_unsupported.sh: ci/check_unsupported.sh.jj2 - - .ci/check_moban.sh: ci/check_moban.sh - runtime.txt: runtime.txt - netlify.toml: docs/netlify.toml - coala-bears.cabal: coala-bears.cabal.jj2 +copy: + - .ci/check_moban.sh: ci/check_moban.sh + - .ci/check_setuptools.py: ci/check_setuptools.py diff --git a/.travis.yml b/.travis.yml index 9544d7517b..2bc2fb3188 100644 --- a/.travis.yml +++ b/.travis.yml @@ -185,6 +185,7 @@ before_script: - .ci/deps.coala-bears.sh script: + - .ci/check_setuptools.py - python setup.py bdist_wheel - pip install $(ls ./dist/*.whl)"[alldeps]" # Ensure bear requirements are in sync with the bear PipRequirement