Commit a82a8025 authored by Godefroid Chapelle's avatar Godefroid Chapelle

Problem: coverage not run on CI

Solution: run coverage in containers on GH and Travis
parent 49ea5ae6
FROM centos as centos-python FROM centos as centos-python
RUN yum install -y make gcc openssl-devel libffi-devel RUN yum install -y make gcc openssl-devel libffi-devel sqlite-devel
ARG PYTHON_VER ARG PYTHON_VER
ENV LC_CTYPE="en_US.UTF-8" ENV LC_CTYPE="en_US.UTF-8"
RUN mkdir buildout RUN mkdir buildout
...@@ -12,5 +12,5 @@ ARG PYTHON_VER ...@@ -12,5 +12,5 @@ ARG PYTHON_VER
COPY doc /buildout/doc COPY doc /buildout/doc
COPY src /buildout/src COPY src /buildout/src
COPY zc.recipe.egg_ /buildout/zc.recipe.egg_ COPY zc.recipe.egg_ /buildout/zc.recipe.egg_
COPY setup.* dev.py *.rst *.txt buildout.cfg /buildout/ COPY setup.* dev.py *.rst *.txt buildout.cfg .coveragerc /buildout/
RUN make PYTHON_VER=${PYTHON_VER} build RUN make PYTHON_VER=${PYTHON_VER} build
FROM debian:stable-slim as debian-python FROM debian:stable-slim as debian-python
RUN apt-get update RUN apt-get update
RUN apt-get install -y make gcc openssl libffi-dev curl zlib1g-dev libssl-dev RUN apt-get install -y make gcc openssl libffi-dev curl zlib1g-dev libssl-dev libsqlite3-dev
ARG PYTHON_VER ARG PYTHON_VER
ENV LANG C.UTF-8 ENV LANG C.UTF-8
RUN mkdir buildout RUN mkdir buildout
...@@ -13,5 +13,5 @@ ARG PYTHON_VER ...@@ -13,5 +13,5 @@ ARG PYTHON_VER
COPY doc /buildout/doc COPY doc /buildout/doc
COPY src /buildout/src COPY src /buildout/src
COPY zc.recipe.egg_ /buildout/zc.recipe.egg_ COPY zc.recipe.egg_ /buildout/zc.recipe.egg_
COPY setup.* dev.py *.rst *.txt buildout.cfg /buildout/ COPY setup.* dev.py *.rst *.txt buildout.cfg .coveragerc /buildout/
RUN make PYTHON_VER=${PYTHON_VER} build RUN make PYTHON_VER=${PYTHON_VER} build
...@@ -22,4 +22,4 @@ jobs: ...@@ -22,4 +22,4 @@ jobs:
env: env:
PYTHON_VER: ${{matrix.python-version}} PYTHON_VER: ${{matrix.python-version}}
run: | run: |
docker run centos_buildout:python${PYTHON_VER} /buildout/bin/test -c -vvv docker run centos_buildout:python${PYTHON_VER} /bin/bash -c 'RUN_COVERAGE= COVERAGE_REPORT= /buildout/bin/test -c -vvv'
...@@ -22,4 +22,4 @@ jobs: ...@@ -22,4 +22,4 @@ jobs:
env: env:
PYTHON_VER: ${{matrix.python-version}} PYTHON_VER: ${{matrix.python-version}}
run: | run: |
docker run debian_buildout:python${PYTHON_VER} /buildout/bin/test -c -vvv docker run debian_buildout:python${PYTHON_VER} /bin/bash -c 'RUN_COVERAGE= COVERAGE_REPORT= /buildout/bin/test -c -vvv'
...@@ -17,4 +17,4 @@ install: ...@@ -17,4 +17,4 @@ install:
- docker build -f .github/workflows/Dockerfile --tag centos_buildout:python${PYTHON_VER} --build-arg PYTHON_VER=${PYTHON_VER} . - docker build -f .github/workflows/Dockerfile --tag centos_buildout:python${PYTHON_VER} --build-arg PYTHON_VER=${PYTHON_VER} .
script: script:
- docker run centos_buildout:python${PYTHON_VER} /buildout/bin/test -c -vvv - docker run centos_buildout:python${PYTHON_VER} /bin/bash -c 'RUN_COVERAGE= COVERAGE_REPORT= /buildout/bin/test -c -vvv'
...@@ -45,7 +45,7 @@ PYTHON_DOWNLOAD = $(PYTHON_BUILD_DIR)/$(PYTHON_ARCHIVE).tgz ...@@ -45,7 +45,7 @@ PYTHON_DOWNLOAD = $(PYTHON_BUILD_DIR)/$(PYTHON_ARCHIVE).tgz
BUILD_DIRS = $(PYTHON_PATH) bin build develop-eggs eggs parts BUILD_DIRS = $(PYTHON_PATH) bin build develop-eggs eggs parts
all: all_test all: all_test
.PHONY: all download_python python build test docker clean all_pythons all_test .PHONY: all download_python python build test coverage docker docker_deb all_pythons all_test all_coverage
# setup python from source # setup python from source
$(PYTHON_DOWNLOAD): $(PYTHON_DOWNLOAD):
...@@ -75,7 +75,7 @@ build: python ...@@ -75,7 +75,7 @@ build: python
$(PYTHON_PATH)/bin/$(PYTHON_EXE) dev.py $(PYTHON_PATH)/bin/$(PYTHON_EXE) dev.py
# copy to virtualenvs # copy to virtualenvs
ROOT_FILES := $(HERE)/setup.py $(HERE)/setup.cfg $(HERE)/dev.py $(HERE)/README.rst $(HERE)/CHANGES.rst $(HERE)/buildout.cfg ROOT_FILES := $(HERE)/setup.py $(HERE)/setup.cfg $(HERE)/dev.py $(HERE)/README.rst $(HERE)/CHANGES.rst $(HERE)/buildout.cfg $(HERE)/.coveragerc
SRC_FILES := $(shell find $(HERE)/src ! -path '*egg-info*' \( -name '*.py' -o -name '*.txt' -o -name '*.test' \) ) SRC_FILES := $(shell find $(HERE)/src ! -path '*egg-info*' \( -name '*.py' -o -name '*.txt' -o -name '*.test' \) )
RCP_FILES := $(shell find $(HERE)/zc.recipe.egg_ ! -path '*egg-info*' \( -name '*.py' -o -name '*.txt' -o -name '*.rst' -o -name '*.cfg' -o -name '*.in' \) ) RCP_FILES := $(shell find $(HERE)/zc.recipe.egg_ ! -path '*egg-info*' \( -name '*.py' -o -name '*.txt' -o -name '*.rst' -o -name '*.cfg' -o -name '*.in' \) )
DOC_FILES := $(shell find $(HERE)/doc -name '*.rst' -o -name '*.txt') DOC_FILES := $(shell find $(HERE)/doc -name '*.rst' -o -name '*.txt')
...@@ -96,6 +96,12 @@ $(VENV)/bin/$(PYTHON_EXE): $(PYTHON_PATH)/bin/$(PYTHON_EXE) ...@@ -96,6 +96,12 @@ $(VENV)/bin/$(PYTHON_EXE): $(PYTHON_PATH)/bin/$(PYTHON_EXE)
$(VENV)/bin/test: $(VENV)/bin/$(PYTHON_EXE) $(ALL_COPY) $(VENV)/bin/test: $(VENV)/bin/$(PYTHON_EXE) $(ALL_COPY)
cd $(VENV) && bin/$(PYTHON_EXE) dev.py --no-clean cd $(VENV) && bin/$(PYTHON_EXE) dev.py --no-clean
$(VENV)/bin/coverage: $(VENV)/bin/$(PYTHON_EXE)
$(VENV)/bin/pip install coverage
coverage: $(VENV)/bin/coverage $(VENV)/bin/test
COVERAGE_REPORT= RUN_COVERAGE= $(VENV)/bin/test $(testargs)
test: $(VENV)/bin/test test: $(VENV)/bin/test
$(VENV)/bin/test -c -vvv $(testargs) $(VENV)/bin/test -c -vvv $(testargs)
...@@ -106,6 +112,13 @@ all_pythons: ...@@ -106,6 +112,13 @@ all_pythons:
$(MAKE) PYTHON_VER=3.7 python $(MAKE) PYTHON_VER=3.7 python
$(MAKE) PYTHON_VER=3.8 python $(MAKE) PYTHON_VER=3.8 python
all_coverage:
$(MAKE) PYTHON_VER=2.7 coverage
$(MAKE) PYTHON_VER=3.5 coverage
$(MAKE) PYTHON_VER=3.6 coverage
$(MAKE) PYTHON_VER=3.7 coverage
$(MAKE) PYTHON_VER=3.8 coverage
all_test: all_test:
$(MAKE) PYTHON_VER=2.7 test $(MAKE) PYTHON_VER=2.7 test
$(MAKE) PYTHON_VER=3.5 test $(MAKE) PYTHON_VER=3.5 test
...@@ -115,7 +128,11 @@ all_test: ...@@ -115,7 +128,11 @@ all_test:
docker: docker:
docker build -f .github/workflows/Dockerfile --tag centos_buildout:python${PYTHON_VER} --build-arg PYTHON_VER=${PYTHON_VER} . docker build -f .github/workflows/Dockerfile --tag centos_buildout:python${PYTHON_VER} --build-arg PYTHON_VER=${PYTHON_VER} .
docker run centos_buildout:python${PYTHON_VER} /buildout/bin/test -c -vvv -t abi docker run centos_buildout:python${PYTHON_VER} /bin/bash -c 'RUN_COVERAGE= COVERAGE_REPORT= /buildout/bin/test -c -vvv -t abi'
docker_deb:
docker build -f .github/workflows/Dockerfile-debian --tag debian_buildout:python${PYTHON_VER} --build-arg PYTHON_VER=${PYTHON_VER} .
docker run debian_buildout:python${PYTHON_VER} /bin/bash -c 'RUN_COVERAGE= COVERAGE_REPORT= /buildout/bin/test -c -vvv -t abi'
clean: clean:
rm -rf $(VENVS) $(PYTHON_BUILD_DIR) $(HERE)/pythons rm -rf $(VENVS) $(PYTHON_BUILD_DIR) $(HERE)/pythons
...@@ -8,7 +8,7 @@ zope.interface = 4.1.3 ...@@ -8,7 +8,7 @@ zope.interface = 4.1.3
zope.exceptions = 4.0.8 zope.exceptions = 4.0.8
zc.recipe.testrunner = 2.0.0 zc.recipe.testrunner = 2.0.0
zope.testing = 4.5.0 zope.testing = 4.5.0
coverage = 4.4.1 coverage = 5.1
[py] [py]
recipe = zc.recipe.egg recipe = zc.recipe.egg
...@@ -23,6 +23,7 @@ eggs = ...@@ -23,6 +23,7 @@ eggs =
zc.buildout[test] zc.buildout[test]
zc.recipe.egg zc.recipe.egg
coverage coverage
defaults = ['-s', 'zc.buildout']
initialization = initialization =
import os.path import os.path
from zc.buildout.testing import setup_coverage from zc.buildout.testing import setup_coverage
......
...@@ -120,6 +120,23 @@ import zc.buildout.easy_install ...@@ -120,6 +120,23 @@ import zc.buildout.easy_install
zc.buildout.easy_install.scripts( zc.buildout.easy_install.scripts(
['zc.buildout'], pkg_resources.working_set, sys.executable, 'bin') ['zc.buildout'], pkg_resources.working_set, sys.executable, 'bin')
######################################################################
def install_coverage():
print('')
print('Install coverage')
print('')
bin_pip = os.path.join('bin', 'pip')
if subprocess.call(
[sys.executable] +
['-m', 'pip', 'install', 'coverage'],
):
raise RuntimeError("coverage install failed.")
try:
import coverage
except ImportError:
install_coverage()
###################################################################### ######################################################################
print('') print('')
print('Run buildout') print('Run buildout')
......
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