Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'tox' to run tests #108

Merged
merged 5 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build/
dist/
.uptodate
/.env
/junit.xml
/junit-*.xml
/.cache
.ensure-*
/.tox
16 changes: 16 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://bazel.build>`_.
* 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)
==================

Expand Down
43 changes: 20 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment was marked as abuse.

This comment was marked as abuse.


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:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
==========
Expand Down
4 changes: 3 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ machine:

dependencies:
override:
- pip install tox flake8
- make deps

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:
Expand Down
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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