From 0481aa94c5337d3f0e443e65931300e1bec7a06e Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Thu, 18 Jan 2018 18:11:01 +0000 Subject: [PATCH 1/5] Use 'tox' to run tests Allows for testing multiple Pythons. --- .gitignore | 3 ++- Makefile | 43 ++++++++++++++++++++----------------------- README.rst | 2 +- circle.yml | 3 ++- tox.ini | 12 ++++++++++++ 5 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 7c2b395e..7937eb07 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ build/ dist/ .uptodate /.env -/junit.xml +/junit-*.xml /.cache .ensure-* +/.tox diff --git a/Makefile b/Makefile index 5d04e1cd..697ba1f8 100644 --- a/Makefile +++ b/Makefile @@ -23,56 +23,53 @@ DOCKER_IMAGE_DIRS=$(patsubst %/Dockerfile,%,$(DOCKERFILES)) IMAGE_NAMES=$(foreach dir,$(DOCKER_IMAGE_DIRS),$(patsubst %,$(IMAGE_PREFIX)/%,$(shell basename $(dir)))) # Python-specific stuff -VIRTUALENV_DIR ?= .env -VIRTUALENV_BIN = $(VIRTUALENV_DIR)/bin -DEPS_UPTODATE = $(VIRTUALENV_DIR)/.deps-uptodate - -VIRTUALENV := $(shell command -v virtualenv 2> /dev/null) +TOX := $(shell command -v tox 2> /dev/null) PIP := $(shell command -v pip 2> /dev/null) +FLAKE8 := $(shell command -v flake8 2> /dev/null) -JUNIT_XML := "junit.xml" - -.ensure-virtualenv: .ensure-pip -ifndef VIRTUALENV - $(error "virtualenv is not installed. Install with `pip install [--user] virtualenv`.") +.ensure-tox: .ensure-pip +ifndef TOX + rm -f .ensure-tox + $(error "tox is not installed. Install with `pip install [--user] tox`.") endif - touch .ensure-virtualenv + touch .ensure-tox .ensure-pip: ifndef PIP + rm -f .ensure-pip $(error "pip is not installed. Install with `python -m [--user] ensurepip`.") endif touch .ensure-pip -$(VIRTUALENV_BIN)/pip: .ensure-virtualenv - virtualenv $(VIRTUALENV_DIR) +.ensure-flake8: .ensure-pip +ifndef FLAKE8 + rm -f .ensure-flake8 + $(error "flake8 is not installed. Install with `pip install [--user] flake8`.") +endif + touch .ensure-pip images: $(info $(IMAGE_NAMES)) all: $(UPTODATE_FILES) test lint -$(DEPS_UPTODATE): setup.py $(VIRTUALENV_BIN)/pip - $(VIRTUALENV_BIN)/pip install -e .[dev] - touch $(DEPS_UPTODATE) - -deps: $(DEPS_UPTODATE) +deps: setup.py .ensure-tox tox.ini $(VIRTUALENV_BIN)/flake8 $(VIRTUALENV_BIN)/py.test: $(DEPS_UPTODATE) gfdatasource/$(UPTODATE): gfdatasource/* -lint: $(VIRTUALENV_BIN)/flake8 - $(VIRTUALENV_BIN)/flake8 gfdatasource/gfdatasource grafanalib +lint: .ensure-flake8 + $(FLAKE8) gfdatasource/gfdatasource grafanalib -test: $(VIRTUALENV_BIN)/py.test - $(VIRTUALENV_BIN)/py.test --junitxml=$(JUNIT_XML) +test: .ensure-tox + $(TOX) --skip-missing-interpreters clean: $(SUDO) docker rmi $(IMAGE_NAMES) >/dev/null 2>&1 || true rm -rf $(UPTODATE_FILES) rm -rf grafanalib.egg-info - rm $(DEPS_UPTODATE) + rm -f .ensure-pip .ensure-tox .ensure-flake8 find . -name '*.pyc' | xargs rm clean-deps: diff --git a/README.rst b/README.rst index 64d9fd04..848f1012 100644 --- a/README.rst +++ b/README.rst @@ -129,7 +129,7 @@ Support This library is in its very early stages. We'll probably make changes that break backwards compatibility, although we'll try hard not to. -grafanalib works with Python 3.4 and 3.5. +grafanalib works with Python 2.7, 3.4, 3.5, and 3.6. Developing ========== diff --git a/circle.yml b/circle.yml index 8b5f2f17..abc96d94 100644 --- a/circle.yml +++ b/circle.yml @@ -15,7 +15,8 @@ test: override: - "mkdir -p $(dirname $SRCDIR) && cp -r $(pwd)/ $SRCDIR" - "mkdir -p $CIRCLE_TEST_REPORTS/py.test/" - - cd $SRCDIR; make JUNIT_XML=$CIRCLE_TEST_REPORTS/py.test/junit.xml all + - cd $SRCDIR; make all + - mv $SRCDIR/junit-*.xml $CIRCLE_TEST_REPORTS/py.test/ deployment: push: diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..50e8e0b7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,12 @@ +# Tox (https://tox.readthedocs.io/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py27, py34, py35, py36 + +[testenv] +commands = pytest --junitxml=junit-{envname}.xml +deps = + pytest From 1e83beba7af7935d594dae12fdda6ee01fadec78 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Mon, 19 Feb 2018 14:41:51 +0000 Subject: [PATCH 2/5] Install tox before calling tox --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index abc96d94..cf50da01 100644 --- a/circle.yml +++ b/circle.yml @@ -9,6 +9,7 @@ machine: dependencies: override: + - pip install --user tox - make deps test: From 32c43b77e7c01ba66ca2f39a3c9ddebd34a1c3e0 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Mon, 19 Feb 2018 14:46:06 +0000 Subject: [PATCH 3/5] Install tox globally --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index cf50da01..929b86bc 100644 --- a/circle.yml +++ b/circle.yml @@ -9,7 +9,7 @@ machine: dependencies: override: - - pip install --user tox + - pip install tox - make deps test: From a2457e82b961d2986556916913690a61bcf3d7b7 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Mon, 19 Feb 2018 14:49:14 +0000 Subject: [PATCH 4/5] Also install flake8 --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 929b86bc..6051b017 100644 --- a/circle.yml +++ b/circle.yml @@ -9,7 +9,7 @@ machine: dependencies: override: - - pip install tox + - pip install tox flake8 - make deps test: From e507c86fed62b60a010be863fb242c26f8b67fac Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Mon, 19 Feb 2018 14:55:37 +0000 Subject: [PATCH 5/5] Update CHANGELOG.rst --- CHANGELOG.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5ce277cc..b435b368 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,22 @@ Changelog ========= +0.5.0 (2018-??-??) +================== + +New features +------------ + +* grafanalib now supports Python 2.7. This enables it to be used within `Bazel `_. +* Partial support for graphs against Elasticsearch datasources (https://github.com/weaveworks/grafanalib/pull/99) + +Extensions +---------- + +* Constants for days, hours, and minutes (https://github.com/weaveworks/grafanalib/pull/98) +* Groups and tags can now be used with templates (https://github.com/weaveworks/grafanalib/pull/97) + + 0.4.0 (2017-11-23) ==================