Commit 0448bfbb authored by Stefan Behnel's avatar Stefan Behnel

Add a coverage test job with a compiled Cython package to compare plain Python...

Add a coverage test job with a compiled Cython package to compare plain Python and compiled Cython both for completeness and speed.
parent c9cccfea
...@@ -71,17 +71,18 @@ jobs: ...@@ -71,17 +71,18 @@ jobs:
- os: ubuntu-18.04 - os: ubuntu-18.04
python-version: pypy-2.7 python-version: pypy-2.7
backend: c backend: c
env: {} env: { NO_CYTHON_COMPILE: 1 }
- os: ubuntu-18.04 - os: ubuntu-18.04
python-version: pypy-3.7 python-version: pypy-3.7
backend: c backend: c
env: {} env: { NO_CYTHON_COMPILE: 1 }
# Pypy [allowed-failures] - These specifically test known bugs # Pypy [allowed-failures] - These specifically test known bugs
- os: ubuntu-18.04 - os: ubuntu-18.04
python-version: pypy-2.7 python-version: pypy-2.7
backend: c backend: c
env: env:
{ {
NO_CYTHON_COMPILE: 1,
EXCLUDE: "--listfile=tests/pypy_bugs.txt --listfile=tests/pypy2_bugs.txt bugs", EXCLUDE: "--listfile=tests/pypy_bugs.txt --listfile=tests/pypy2_bugs.txt bugs",
} }
allowed_failure: true allowed_failure: true
...@@ -89,7 +90,7 @@ jobs: ...@@ -89,7 +90,7 @@ jobs:
- os: ubuntu-18.04 - os: ubuntu-18.04
python-version: pypy-3.7 python-version: pypy-3.7
backend: c backend: c
env: { EXCLUDE: "--listfile=tests/pypy_bugs.txt bugs" } env: { NO_CYTHON_COMPILE: 1, EXCLUDE: "--listfile=tests/pypy_bugs.txt bugs" }
allowed_failure: true allowed_failure: true
extra_hash: "-allowed_failures" extra_hash: "-allowed_failures"
# Coverage - Disabled due to taking too long to run # Coverage - Disabled due to taking too long to run
...@@ -149,10 +150,7 @@ jobs: ...@@ -149,10 +150,7 @@ jobs:
run: bash ./Tools/ci-run.sh run: bash ./Tools/ci-run.sh
code_quality: pycoverage:
strategy:
# Allows for matrix sub-jobs to fail without canceling the rest
fail-fast: false
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
env: env:
...@@ -172,11 +170,40 @@ jobs: ...@@ -172,11 +170,40 @@ jobs:
python-version: 3.9 python-version: 3.9
- name: Run Coverage - name: Run Coverage
env: { COVERAGE: 1 } env: { COVERAGE: 1, NO_CYTHON_COMPILE: 1 }
run: bash ./Tools/ci-run.sh run: bash ./Tools/ci-run.sh
- name: Upload Coverage Report - name: Upload Coverage Report
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
path: coverage-report-html name: pycoverage_html
path: coverage-report-html
cycoverage:
runs-on: ubuntu-18.04
env:
BACKEND: c,cpp
OS_NAME: ubuntu-18.04
PYTHON_VERSION: 3.9
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Run Coverage
env: { COVERAGE: 1 }
run: bash ./Tools/ci-run.sh
- name: Upload Coverage Report
uses: actions/upload-artifact@v2
with:
name: cycoverage_html
path: coverage-report-html
...@@ -84,9 +84,12 @@ fi ...@@ -84,9 +84,12 @@ fi
ccache -s 2>/dev/null || true ccache -s 2>/dev/null || true
export PATH="/usr/lib/ccache:$PATH" export PATH="/usr/lib/ccache:$PATH"
if [ "$COVERAGE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then if [ "$NO_CYTHON_COMPILE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then
CFLAGS="-O2 -ggdb -Wall -Wextra $(python -c 'import sys; print("-fno-strict-aliasing" if sys.version_info[0] == 2 else "")')" \ CFLAGS="-O2 -ggdb -Wall -Wextra $(python -c 'import sys; print("-fno-strict-aliasing" if sys.version_info[0] == 2 else "")')" \
python setup.py build_ext -i $(python -c 'import sys; print("-j5" if sys.version_info >= (3,5) else "")') || exit 1 python setup.py build_ext -i \
$(if [ "$COVERAGE" == "1" ]; then echo " --cython-coverage"; fi) \
$(python -c 'import sys; print("-j5" if sys.version_info >= (3,5) else "")') \
|| exit 1
fi fi
if [ "$TEST_CODE_STYLE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then if [ "$TEST_CODE_STYLE" != "1" -a -n "${PYTHON_VERSION##pypy*}" ]; then
......
...@@ -79,7 +79,7 @@ else: ...@@ -79,7 +79,7 @@ else:
scripts = ["cython.py", "cythonize.py", "cygdb.py"] scripts = ["cython.py", "cythonize.py", "cygdb.py"]
def compile_cython_modules(profile=False, compile_more=False, cython_with_refnanny=False): def compile_cython_modules(profile=False, coverage=False, compile_more=False, cython_with_refnanny=False):
source_root = os.path.abspath(os.path.dirname(__file__)) source_root = os.path.abspath(os.path.dirname(__file__))
compiled_modules = [ compiled_modules = [
"Cython.Plex.Scanners", "Cython.Plex.Scanners",
...@@ -135,6 +135,8 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan ...@@ -135,6 +135,8 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
defines = [] defines = []
if cython_with_refnanny: if cython_with_refnanny:
defines.append(('CYTHON_REFNANNY', '1')) defines.append(('CYTHON_REFNANNY', '1'))
if coverage:
defines.append(('CYTHON_TRACE', '1'))
extensions = [] extensions = []
for module in compiled_modules: for module in compiled_modules:
...@@ -168,6 +170,9 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan ...@@ -168,6 +170,9 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
if profile: if profile:
get_directive_defaults()['profile'] = True get_directive_defaults()['profile'] = True
sys.stderr.write("Enabled profiling for the Cython binary modules\n") sys.stderr.write("Enabled profiling for the Cython binary modules\n")
if coverage:
get_directive_defaults()['linetrace'] = True
sys.stderr.write("Enabled line tracing and profiling for the Cython binary modules\n")
# not using cythonize() directly to let distutils decide whether building extensions was requested # not using cythonize() directly to let distutils decide whether building extensions was requested
add_command_class("build_ext", new_build_ext) add_command_class("build_ext", new_build_ext)
...@@ -178,6 +183,10 @@ cython_profile = '--cython-profile' in sys.argv ...@@ -178,6 +183,10 @@ cython_profile = '--cython-profile' in sys.argv
if cython_profile: if cython_profile:
sys.argv.remove('--cython-profile') sys.argv.remove('--cython-profile')
cython_coverage = '--cython-coverage' in sys.argv
if cython_coverage:
sys.argv.remove('--cython-coverage')
try: try:
sys.argv.remove("--cython-compile-all") sys.argv.remove("--cython-compile-all")
cython_compile_more = True cython_compile_more = True
...@@ -230,7 +239,7 @@ packages = [ ...@@ -230,7 +239,7 @@ packages = [
def run_build(): def run_build():
if compile_cython_itself and (is_cpython or cython_compile_more): if compile_cython_itself and (is_cpython or cython_compile_more):
compile_cython_modules(cython_profile, cython_compile_more, cython_with_refnanny) compile_cython_modules(cython_profile, cython_coverage, cython_compile_more, cython_with_refnanny)
from Cython import __version__ as version from Cython import __version__ as version
setup( setup(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment