From 7d68bf21b51387d2d85660496dbd8a09bd54f534 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 5 Sep 2017 18:34:06 -0500 Subject: [PATCH 1/2] Reapply earlier, reverted appveyor changes --- .gitlab-ci.yml | 4 ++++ .travis.yml | 2 +- README.rst | 15 +++++++++------ run-coveralls.sh | 6 ------ run-tests-for-ci.sh | 5 ++++- 5 files changed, 18 insertions(+), 14 deletions(-) delete mode 100644 run-coveralls.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fb58f198..1d6346b1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,6 +6,8 @@ except: - tags coverage: '/TOTAL.+ ([0-9]{1,3}%)/' + variables: + CODECOV_TOKEN: "895e3bf2-cfd0-45f8-9a14-4b7bd148f76d" Python 3.5: script: @@ -15,6 +17,8 @@ Python 3.5: except: - tags coverage: '/TOTAL.+ ([0-9]{1,3}%)/' + variables: + CODECOV_TOKEN: "895e3bf2-cfd0-45f8-9a14-4b7bd148f76d" Documentation: script: diff --git a/.travis.yml b/.travis.yml index 63bcd6d8..d03d74ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: python cache: pip install: true script: - - bash ./run-coveralls.sh + - bash ./run-tests-for-ci.sh env: - PY_EXE=python2.7 - PY_EXE=python3.5 diff --git a/README.rst b/README.rst index 43eee408..72e7c465 100644 --- a/README.rst +++ b/README.rst @@ -1,14 +1,17 @@ -.. image:: https://travis-ci.org/inducer/relate.svg?branch=master - :target: https://travis-ci.org/inducer/relate - -.. image:: https://coveralls.io/repos/github/inducer/relate/badge.svg?branch=master - :target: https://coveralls.io/github/inducer/relate?branch=master - RELATE ====== Relate is an Environment for Learning And TEaching +.. image:: https://travis-ci.org/inducer/relate.svg?branch=master + :target: https://travis-ci.org/inducer/relate + +.. image:: https://ci.appveyor.com/api/projects/status/d5bigdw90bxnfdgy?svg=true + :target: https://ci.appveyor.com/project/inducer/relate + +.. image:: https://codecov.io/gh/inducer/relate/branch/master/graph/badge.svg + :target: https://codecov.io/gh/inducer/relate/commits + +----------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+ | .. image:: https://raw.githubusercontent.com/inducer/relate/master/doc/images/screenshot.png | .. image:: https://raw.githubusercontent.com/inducer/relate/master/doc/images/screenshot-2.png | +----------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+ diff --git a/run-coveralls.sh b/run-coveralls.sh deleted file mode 100644 index 8a8a08fd..00000000 --- a/run-coveralls.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/bash - -source $(dirname $0)/run-tests-for-ci.sh - -$PIP install coveralls -coveralls diff --git a/run-tests-for-ci.sh b/run-tests-for-ci.sh index f330de3a..be80ebd9 100644 --- a/run-tests-for-ci.sh +++ b/run-tests-for-ci.sh @@ -72,4 +72,7 @@ cp local_settings.example.py local_settings.py $PIP install coverage coverage run --source=. manage.py test test/ -coverage report -m \ No newline at end of file +coverage report -m + +$PIP install codecov +codecov -X gcov \ No newline at end of file -- GitLab From f9c83ed1ab202dd07877870bea4561ce3032c033 Mon Sep 17 00:00:00 2001 From: dzhuang Date: Sun, 10 Sep 2017 22:40:53 +0800 Subject: [PATCH 2/2] Added Flake8 and Mypy tests via Travis-CI. --- .travis.yml | 10 +++-- appveyor.yml | 72 ++++++++++++++++++++++++++++++++ appveyor/run_with_env.cmd | 88 +++++++++++++++++++++++++++++++++++++++ run-tests-for-ci.sh | 10 ++--- run-travis-ci.sh | 20 +++++++++ setup.cfg | 8 +++- 6 files changed, 197 insertions(+), 11 deletions(-) create mode 100644 appveyor.yml create mode 100644 appveyor/run_with_env.cmd create mode 100644 run-travis-ci.sh diff --git a/.travis.yml b/.travis.yml index 3f73e830..66dc043e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,12 @@ install: true matrix: include: - python: "2.7" - env: PY_EXE=python2.7 + env: PY=true PY_EXE=python2.7 - python: "3.5" - env: PY_EXE=python3.5 + env: PY=true PY_EXE=python3.5 + - python: "3.5" + env: Flake8=true PY_EXE=python3.5 + - python: "3.6" + env: Mypy=true PY_EXE=python3.6 script: - - bash ./run-tests-for-ci.sh + - bash ./run-travis-ci.sh diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..db90d589 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,72 @@ +# +# Most of these settings are taken from here: +# https://github.com/ogrisel/python-appveyor-demo/blob/master/appveyor.yml +# + +version: 1.0.{build} + +build: off + +cache: + - '%LOCALAPPDATA%\pip\Cache' + +environment: + global: + # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the + # /E:ON and /V:ON options are not enabled in the batch script intepreter + # See: http://stackoverflow.com/a/13751649/163740 + CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd" + + matrix: + # Pre-installed Python versions, which Appveyor may upgrade to + # a later point release. + # See: http://www.appveyor.com/docs/installed-software#python + + - PYTHON: "C:\\Python27-x64" + PYTHON_VERSION: "2.7.x" # currently 2.7.13 + PYTHON_ARCH: "64" + + - PYTHON: "C:\\Python35-x64" + PYTHON_VERSION: "3.5.x" # currently 3.5.3 + PYTHON_ARCH: "64" + +init: + - "ECHO %PYTHON%" + - ps: "ls C:/Python*" + +install: + # Prepend newly installed Python to the PATH of this build (this cannot be + # done from inside the powershell script as it would require to restart + # the parent CMD process). + - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" + + - ECHO "Filesystem root:" + - ps: "ls \"C:/\"" + + # Check that we have the expected version and architecture for Python + - "python --version" + - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" + + # Upgrade to the latest version of pip to avoid it displaying warnings + # about it being out of date. + - "pip install --disable-pip-version-check --user --upgrade pip" + + - "git submodule update --init --recursive" + + # Install requirements + - ps: "cat requirements.txt | ?{$_ -notmatch 'dnspython'} > req.txt" + - "%CMD_IN_ENV% pip install -r req.txt" + - ps: "if ($env:PYTHON -like '*Python2*') { pip install dnspython mock} else { pip install dnspython3 }" + + +before_test: + - "%CMD_IN_ENV% pip install coverage" + +test_script: + # Run the project tests + - "copy local_settings.example.py local_settings.py /Y" + - "%CMD_IN_ENV% coverage run manage.py test test/" + +after_test: + - "%CMD_IN_ENV% pip install codecov" + - "%CMD_IN_ENV% codecov -X gcov" diff --git a/appveyor/run_with_env.cmd b/appveyor/run_with_env.cmd new file mode 100644 index 00000000..5da547c4 --- /dev/null +++ b/appveyor/run_with_env.cmd @@ -0,0 +1,88 @@ +:: To build extensions for 64 bit Python 3, we need to configure environment +:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: +:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1) +:: +:: To build extensions for 64 bit Python 2, we need to configure environment +:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of: +:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0) +:: +:: 32 bit builds, and 64-bit builds for 3.5 and beyond, do not require specific +:: environment configurations. +:: +:: Note: this script needs to be run with the /E:ON and /V:ON flags for the +:: cmd interpreter, at least for (SDK v7.0) +:: +:: More details at: +:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows +:: http://stackoverflow.com/a/13751649/163740 +:: +:: Author: Olivier Grisel +:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ +:: +:: Notes about batch files for Python people: +:: +:: Quotes in values are literally part of the values: +:: SET FOO="bar" +:: FOO is now five characters long: " b a r " +:: If you don't want quotes, don't include them on the right-hand side. +:: +:: The CALL lines at the end of this file look redundant, but if you move them +:: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y +:: case, I don't know why. +@ECHO OFF + +SET COMMAND_TO_RUN=%* +SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows +SET WIN_WDK=c:\Program Files (x86)\Windows Kits\10\Include\wdf + +:: Extract the major and minor versions, and allow for the minor version to be +:: more than 9. This requires the version number to have two dots in it. +SET MAJOR_PYTHON_VERSION=%PYTHON_VERSION:~0,1% +IF "%PYTHON_VERSION:~3,1%" == "." ( + SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1% +) ELSE ( + SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,2% +) + +:: Based on the Python version, determine what SDK version to use, and whether +:: to set the SDK for 64-bit. +IF %MAJOR_PYTHON_VERSION% == 2 ( + SET WINDOWS_SDK_VERSION="v7.0" + SET SET_SDK_64=Y +) ELSE ( + IF %MAJOR_PYTHON_VERSION% == 3 ( + SET WINDOWS_SDK_VERSION="v7.1" + IF %MINOR_PYTHON_VERSION% LEQ 4 ( + SET SET_SDK_64=Y + ) ELSE ( + SET SET_SDK_64=N + IF EXIST "%WIN_WDK%" ( + :: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/ + REN "%WIN_WDK%" 0wdf + ) + ) + ) ELSE ( + ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%" + EXIT 1 + ) +) + +IF %PYTHON_ARCH% == 64 ( + IF %SET_SDK_64% == Y ( + ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture + SET DISTUTILS_USE_SDK=1 + SET MSSdk=1 + "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION% + "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release + ECHO Executing: %COMMAND_TO_RUN% + call %COMMAND_TO_RUN% || EXIT 1 + ) ELSE ( + ECHO Using default MSVC build environment for 64 bit architecture + ECHO Executing: %COMMAND_TO_RUN% + call %COMMAND_TO_RUN% || EXIT 1 + ) +) ELSE ( + ECHO Using default MSVC build environment for 32 bit architecture + ECHO Executing: %COMMAND_TO_RUN% + call %COMMAND_TO_RUN% || EXIT 1 +) diff --git a/run-tests-for-ci.sh b/run-tests-for-ci.sh index be80ebd9..848e5369 100644 --- a/run-tests-for-ci.sh +++ b/run-tests-for-ci.sh @@ -68,11 +68,7 @@ $PIP install -r req.txt cp local_settings.example.py local_settings.py -#python manage.py test test/ - -$PIP install coverage -coverage run --source=. manage.py test test/ -coverage report -m - $PIP install codecov -codecov -X gcov \ No newline at end of file +coverage run manage.py test test/ +coverage report -m +codecov diff --git a/run-travis-ci.sh b/run-travis-ci.sh new file mode 100644 index 00000000..b2a25525 --- /dev/null +++ b/run-travis-ci.sh @@ -0,0 +1,20 @@ +#! /bin/bash + +# before_script +if [[ $Flake8 == true ]]; then + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh +fi + +if [[ $Mypy == true ]]; then + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-mypy.sh + cp local_settings.example.py local_settings.py +fi + +# run ci according to env variables +if [[ $PY == true ]]; then + . ./run-tests-for-ci.sh +elif [[ $Mypy == true ]]; then + . ./prepare-and-run-mypy.sh python3.6 mypy==0.521 typed-ast==1.0.4 +elif [[ $Flake8 == true ]]; then + . ./prepare-and-run-flake8.sh relate course accounts test bin +fi \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 05106c25..b5bc2109 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,11 +4,11 @@ max-line-length=85 exclude=course/migrations,accounts/migrations,static,components,course/mdx_mathjax.py [coverage:run] +source = . branch=True cover_pylib=False omit = */.env/* - */__init__.py */virtualenv*/* */setuptools*/* */migrations/* @@ -33,6 +33,9 @@ exclude_lines = def __repr__ if self.debug if settings.Debug + if debug + debug_print + if show_log # Don't complain if tests don't hit defensive assertion code: raise AssertionError @@ -42,4 +45,7 @@ exclude_lines = if 0: if __name__ == .__main__.: + # mypy import + if False: + ignore_errors = True -- GitLab