Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8035d67

Browse files
authored
Merge pull request #345 from vmuriart/ci2
Coverage & CI Setup Improvement
2 parents ef133a3 + 1145a44 commit 8035d67

File tree

8 files changed

+132
-28
lines changed

8 files changed

+132
-28
lines changed

.travis.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
1-
sudo: required
2-
language: python
1+
sudo: false
32

3+
language: python
44
python:
55
- 2.7
66
- 3.3
77
- 3.4
88
- 3.5
99
- 3.6
1010

11-
before_install:
12-
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe"
13-
- sudo apt-get install software-properties-common
14-
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
15-
- echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/4.2.4.4 main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
16-
- echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
17-
- sudo apt-get update
18-
- sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install mono-devel mono-complete referenceassemblies-pcl ca-certificates-mono nunit-console
11+
env:
12+
global:
13+
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
14+
- SEGFAULT_SIGNALS=all
15+
- PYTHONUNBUFFERED=True
16+
17+
addons:
18+
apt:
19+
sources:
20+
- mono
21+
- mono-libtiff-compat
22+
packages:
23+
- mono-devel
24+
- ca-certificates-mono
25+
- nunit-console
1926

2027
install:
21-
- pip install six
22-
- pip install pycparser
23-
- python setup.py build_ext --inplace
28+
- pip install pycparser coverage codecov six
29+
- coverage run setup.py build_ext --inplace
2430

2531
script:
2632
- export PYTHONPATH=`pwd`:$PYTHONPATH
2733
- python src/tests/runtests.py
2834
# - nunit-console src/embed_tests/bin/x64/ReleaseMono/Python.EmbeddingTest.dll
2935

36+
after_success:
37+
# Uncomment if need to geninterop, ie. py37 final
38+
# - python tools/geninterop/geninterop.py
39+
40+
# Waiting on mono-cov support or SharpCover
41+
- codecov
42+
3043
notifications:
3144
email: false

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![appveyor shield][]](https://ci.appveyor.com/project/pythonnet/pythonnet/branch/master)
44
[![travis shield][]](https://travis-ci.org/pythonnet/pythonnet)
5+
[![codecov shield][]](https://codecov.io/github/pythonnet/pythonnet)
56
[![license shield][]](./LICENSE)
67
[![pypi package version][]](https://pypi.python.org/pypi/pythonnet)
78
[![python supported shield][]](https://pypi.python.org/pypi/pythonnet)
@@ -80,6 +81,8 @@ int32
8081

8182
[appveyor shield]: https://img.shields.io/appveyor/ci/pythonnet/pythonnet/master.svg?label=AppVeyor
8283

84+
[codecov shield]: https://img.shields.io/codecov/c/github/pythonnet/pythonnet/pytest.svg?label=codecov
85+
8386
[license shield]: https://img.shields.io/badge/license-MIT-blue.svg
8487

8588
[pypi package version]: https://img.shields.io/pypi/v/pythonnet.svg

appveyor.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ environment:
1010
PYTHONUNBUFFERED: True
1111
PYTHONWARNINGS: 'ignore:::wheel.pep425tags:'
1212
PYTHONPATH: C:\testdir
13-
NUNIT: nunit-console
1413
CONDA_BLD: C:\conda
1514
CONDA_BLD_VERSION: 3.5
1615

@@ -35,7 +34,6 @@ init:
3534
- set CONDA_BLD_ARCH=%PLATFORM:x=%
3635
- set PYTHON=C:\PYTHON%PYTHON_VERSION:.=%
3736
- if %PLATFORM%==x86 (set CONDA_BLD_ARCH=32)
38-
- if %PLATFORM%==x86 (set NUNIT=%NUNIT%-x86)
3937
- if %PLATFORM%==x64 (set PYTHON=%PYTHON%-x64)
4038

4139
# Prepend newly installed Python to the PATH of this build
@@ -47,26 +45,29 @@ init:
4745
- python -c "import ctypes; print(ctypes.sizeof(ctypes.c_wchar))"
4846

4947
install:
50-
# install conda and deps
51-
- ps: .\ci\install_miniconda.ps1
48+
# install for wheels & coverage
49+
- pip install --upgrade pip wheel coverage codecov six
5250

53-
# install for wheels
54-
- pip install --upgrade pip wheel six
51+
# Install OpenCover. Can't put on packages.config; not Linux/Mono compatible
52+
- .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages
5553

5654
build_script:
57-
# build clean sdist & wheel
58-
- python setup.py sdist bdist_wheel
59-
60-
# build and dist conda package
61-
- '%CMD_IN_ENV% %CONDA_BLD%\Scripts\conda build conda.recipe'
62-
- ps: $CONDA_PKG=(&"$env:CONDA_BLD\Scripts\conda" build conda.recipe --output -q)
63-
- ps: Copy-Item $CONDA_PKG "$env:APPVEYOR_BUILD_FOLDER\dist\"
55+
# build clean sdist & wheel with coverage of setup.py, install local wheel
56+
- coverage run setup.py sdist bdist_wheel
6457

6558
test_script:
6659
- pip install --no-index --find-links=.\dist\ pythonnet
6760
- ps: Copy-Item (Resolve-Path .\build\*\Python.Test.dll) C:\testdir
68-
- python src\tests\runtests.py
69-
# - "%NUNIT% src/embed_tests/bin/%PLATFORM%/ReleaseWin/Python.EmbeddingTest.dll"
61+
62+
# Test runner
63+
- ps: .\ci\appveyor_run_tests.ps1
64+
65+
# Build conda-recipe on Pull Requests
66+
- ps: .\ci\appveyor_build_recipe.ps1
67+
68+
on_finish:
69+
# Upload coverage
70+
- codecov
7071

7172
artifacts:
7273
- path: dist\*

ci/appveyor_build_recipe.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
2+
Invoke-Expression .\ci\install_miniconda.ps1
3+
&"$env:CONDA_BLD\Scripts\conda" build conda.recipe --dirty -q
4+
$CONDA_PKG=(&"$env:CONDA_BLD\Scripts\conda" build conda.recipe --output -q)
5+
Copy-Item $CONDA_PKG "$env:APPVEYOR_BUILD_FOLDER\dist\"
6+
}

ci/appveyor_run_tests.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Script to simplify appveyor configuration and resolve path to tools
2+
3+
# Executable paths for OpenCover
4+
# Note if OpenCover fails, it won't affect the exit codes.
5+
$OPENCOVER = Resolve-Path .\packages\OpenCover.*\tools\OpenCover.Console.exe
6+
$NUNIT = Resolve-Path .\packages\NUnit.ConsoleRunner*\tools\nunit3-console.exe
7+
$PY = Get-Command python
8+
9+
# Can't use ".\build\*\Python.EmbeddingTest.dll". Missing framework files.
10+
$CS_TESTS = Resolve-Path .\src\embed_tests\bin\*\*\Python.EmbeddingTest.dll
11+
$RUNTIME_DIR = Resolve-Path .\src\runtime\bin\*\ReleaseWin\
12+
13+
# Run python tests with C# coverage
14+
# why `2>&1 | %{ "$_" }`? see: http://stackoverflow.com/a/20950421/5208670
15+
.$OPENCOVER -register:user -searchdirs:"$RUNTIME_DIR" -output:py.coverage -target:"$PY" -targetargs:src\tests\runtests.py -returntargetcode 2>&1 | %{ "$_" }
16+
$PYTHON_STATUS = $LastExitCode
17+
if ($PYTHON_STATUS -ne 0) {
18+
Write-Host "Python tests failed, continuing to embedded tests" -ForegroundColor "Red"
19+
}
20+
21+
# Run Embedded tests with C# coverage
22+
# .$OPENCOVER -register:user -searchdirs:"$RUNTIME_DIR" -output:cs.coverage -target:"$NUNIT" -targetargs:"$CS_TESTS" -returntargetcode
23+
# $NUNIT_STATUS = $LastExitCode
24+
# if ($NUNIT_STATUS -ne 0) {
25+
# Write-Host "Embedded tests failed" -ForegroundColor "Red"
26+
# }
27+
28+
# Embedded tests failing due to open issues, pass/fail only on Python exit code
29+
# if ($PYTHON_STATUS -ne 0 -or $NUNIT_STATUS -ne 0) {
30+
if ($PYTHON_STATUS -ne 0) {
31+
Write-Host "Tests failed" -ForegroundColor "Red"
32+
$host.SetShouldExit(1)
33+
}

conda.recipe/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Conda Recipe
2+
3+
The files here are needed to build Python.Net with conda
4+
5+
http://conda.pydata.org/docs/building/recipe.html

src/embed_tests/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="NUnit" version="3.5.0" targetFramework="net40" />
4+
<package id="NUnit.ConsoleRunner" version="3.5.0" targetFramework="net40" />
45
</packages>

tox.ini

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[tox]
2+
skipsdist=True
3+
skip_missing_interpreters=True
4+
envlist =
5+
py27
6+
py33
7+
py34
8+
py35
9+
py36
10+
check
11+
12+
[testenv]
13+
recreate=True
14+
basepython =
15+
py27: {env:TOXPYTHON:python2.7}
16+
py33: {env:TOXPYTHON:python3.3}
17+
py34: {env:TOXPYTHON:python3.4}
18+
py35: {env:TOXPYTHON:python3.5}
19+
py36: {env:TOXPYTHON:python3.6}
20+
check: python3.5
21+
setenv =
22+
PYTHONUNBUFFERED=True
23+
DISTUTILS_DEBUG=
24+
passenv =
25+
*
26+
commands =
27+
python --version
28+
python -c "import struct; print('ARCH: %d' % (struct.calcsize('P') * 8))"
29+
python -c "import ctypes; print('UCS%d' % ctypes.sizeof(ctypes.c_wchar))"
30+
python setup.py bdist_wheel
31+
pip install --no-index --find-links=dist/ pythonnet
32+
{posargs:python src\tests\runtests.py}
33+
34+
[testenv:check]
35+
ignore_errors=True
36+
deps =
37+
check-manifest
38+
flake8
39+
commands =
40+
check-manifest {toxinidir}
41+
flake8 src setup.py
42+
python setup.py check --strict --metadata

0 commit comments

Comments
 (0)