diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 22d961dbea41e95f17ac2935fa7f684376865b1d..cc1bc36c19aacdb9cc6251e18db060520dd6147f 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 d3d9998fbe8b1658c8cb1fe2a641d838ffe73e34..66dc043ef5c650218fffa68532ca098ffdd89332 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-coveralls.sh + - bash ./run-travis-ci.sh diff --git a/README.rst b/README.rst index 43eee408ea1a2f67e0036f6ca7fc4fecdc1eeea9..72e7c4654dc9f939864e8032c3e29bd495fab8af 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/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000000000000000000000000000000000..db90d58940938f34bcafd2ff5fa0427326859fff --- /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 0000000000000000000000000000000000000000..5da547c499eea5b8b91ab7f29d6752a376148a8a --- /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-coveralls.sh b/run-coveralls.sh deleted file mode 100644 index 8a8a08fd441edee8610557e398838a9d00ff4cb8..0000000000000000000000000000000000000000 --- 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 f330de3ac8f8eba562290dddf300b500a06504ff..848e5369d400a37bc1e47459f2ac18fa2210e9a4 100644 --- a/run-tests-for-ci.sh +++ b/run-tests-for-ci.sh @@ -68,8 +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 \ No newline at end of file +$PIP install codecov +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 0000000000000000000000000000000000000000..b2a25525bbfc78c524740a7c67e2a16aea9705e4 --- /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 05106c2592c1a0da356fdf3ad699038020cc0301..b5bc21092b5802c1a35a5a76a79ccb965b6c85a4 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