From bf5dc52c714b6057a008eac9eb27a3ccc737cf3f Mon Sep 17 00:00:00 2001 From: Kamil Páral Date: Feb 07 2017 08:19:28 +0000 Subject: improve install and testing process Recommend --system-site-packages by default, because it's the simplest approach. Tell how to install RPM deps if preffered. Print coverage when running the test suite. Make Makefile targets phony, because they are not files. Differential Revision: https://phab.qa.fedoraproject.org/D1114 --- diff --git a/Makefile b/Makefile index 3504a4b..7498803 100644 --- a/Makefile +++ b/Makefile @@ -33,23 +33,32 @@ GITBRANCH:=$(shell git rev-parse --abbrev-ref HEAD) TARGETDIST:=fc25 BUILDTARGET=fedora-25-x86_64 +.PHONY: test test: $(VENV) - sh -c "set -e; . $(VENV)/bin/activate; python setup.py develop; TEST='true' py.test --cov $(SRC); deactivate" + sh -c "set -e; . $(VENV)/bin/activate; python setup.py develop; \ + TEST='true' py.test --cov-report=term-missing --cov $(SRC); deactivate" +.PHONY: test-ci test-ci: $(VENV) - sh -c "set -e; . $(VENV)/bin/activate; python setup.py develop; TEST='true' py.test --cov-report xml --cov $(SRC); deactivate" + sh -c "set -e; . $(VENV)/bin/activate; python setup.py develop; \ + TEST='true' py.test --cov-report=xml --cov $(SRC); deactivate" +.PHONY: pylint pylint: pylint -f parseable $(SRC) | tee pylint.out +.PHONY: pep8 pep8: pep8 $(SRC)/*.py $(SRC)/*/*.py | tee pep8.out +.PHONY: ci ci: test-ci pylint pep8 +.PHONY: docs docs: sphinx-build -b html -d docs/_build/doctrees docs/source docs/_build/html +.PHONY: clean clean: rm -rf dist rm -rf resultsdb.egg-info @@ -57,30 +66,39 @@ clean: rm -f pep8.out rm -f pylint.out +.PHONY: archive archive: $(SRC)-$(VERSION).tar.gz +.PHONY: $(SRC)-$(VERSION).tar.gz $(SRC)-$(VERSION).tar.gz: git archive $(GITBRANCH) --prefix=$(SRC)-$(VERSION)/ | gzip -c9 > $@ +.PHONY: mocksrpm mocksrpm: archive mock -r $(BUILDTARGET) --buildsrpm --spec $(SPECFILE) --sources . cp /var/lib/mock/$(BUILDTARGET)/result/$(NVR).$(TARGETDIST).src.rpm . +.PHONY: mockbuild mockbuild: mocksrpm mock -r $(BUILDTARGET) --no-clean --rebuild $(NVR).$(TARGETDIST).src.rpm cp /var/lib/mock/$(BUILDTARGET)/result/$(NVR).$(TARGETDIST).noarch.rpm . +#.PHONY: kojibuild #kojibuild: mocksrpm # koji build --scratch dist-6E-epel-testing-candidate $(NVR).$(TARGETDIST).src.rpm +.PHONY: nvr nvr: @echo $(NVR) +.PHONY: cleanvenv cleanvenv: rm -rf $(VENV) +.PHONY: virtualenv virtualenv: $(VENV) +.PHONY: $(VENV) $(VENV): - virtualenv --distribute --system-site-packages $(VENV) - sh -c "set -e; . $(VENV)/bin/activate; pip install --force-reinstall -r requirements.txt; deactivate" + virtualenv --system-site-packages $(VENV) + sh -c "set -e; . $(VENV)/bin/activate; pip install -r requirements.txt; deactivate" diff --git a/README.md b/README.md index 7c6b81a..bb44e85 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,21 @@ First, clone the repository. Then, setup a virtual environment for development: $ sudo dnf install python-virtualenv - $ virtualenv env_resultsdb + $ virtualenv --system-site-packages env_resultsdb $ source env_resultsdb/bin/activate $ pip install -r requirements.txt +If you encounter any installation issues, it's possible that you don't have +`gcc` and necessary C development headers installed to compile C extensions +from PyPI. Either install those based on the error messages, or install +the necessary packages directly to your system: + + $ sudo dnf builddep resultsdb.spec + +Install the project: + + $ python setup.py develop + Initialize your database: $ DEV=true ./init_db.sh @@ -50,11 +61,7 @@ depending on your local settings. ## Running test suite -You can run this test suite with the following command (with virtualenv active):: +You can run the test suite with the following command (with virtualenv +active):: $ pytest - -or with this command (without virtualenv active):: - - $ make test - diff --git a/requirements.txt b/requirements.txt index 6886215..3fde127 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # This is a list of pypi packages to be installed into virtualenv. Alternatively, # you can install these as RPMs instead of pypi packages. Use -# `rpmspec -q --requires resultsdb.spec` +# `sudo dnf builddep resultsdb.spec` # A note for maintainers: Please keep this list in sync with resultsdb.spec. # You should require exact versions here (in order to define an exact working @@ -11,7 +11,6 @@ # This list is in the same order as the requirements in the specfile. - fedmsg == 0.17.2 alembic == 0.8.3 Flask == 0.10.1 @@ -22,5 +21,7 @@ six == 1.10.0 SQLAlchemy >= 0.9.8 WTForms == 2.0 +# Test suite requirements + pytest >= 2.4.2 pytest-cov >= 1.6 diff --git a/tox.ini b/tox.ini index 41bd383..a52903d 100644 --- a/tox.ini +++ b/tox.ini @@ -11,4 +11,4 @@ max-line-length=99 minversion=2.0 python_functions=test should python_files=test_* functest_* -addopts=--functional testing/ +addopts=--functional testing/ --cov resultsdb --cov-report=term-missing