Navigation Menu

Skip to content

Commit

Permalink
TST: Use nox docker image for PIP CircleCI tests (#251)
Browse files Browse the repository at this point in the history
* TST: Use nox docker image for PIP CircleCI tests

Fixes the CircleCI build.
Clean up the noxfile to use the same requirements files as CI.

Temporarily disables installing pandas nightlies and
google-cloud-bigquery from master since they were taking several minutes
to install in my local test environment.
  • Loading branch information
tswast committed Feb 15, 2019
1 parent c3dda4a commit f729a44
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 92 deletions.
71 changes: 32 additions & 39 deletions .circleci/config.yml
@@ -1,48 +1,48 @@
version: 2
jobs:
# Pip
"pip-2.7-0.19.2":
"pip-2.7":
docker:
- image: python:2.7
environment:
PYTHON: "2.7"
PANDAS: "0.19.2"
- image: thekevjames/nox
steps:
- checkout
- run: ci/config_auth.sh
- run: ci/run_pip.sh
"pip-3.5-0.18.1":
- run: nox -s unit-2.7 system-2.7

"pip-3.5":
docker:
- image: python:3.5
environment:
PYTHON: "3.5"
PANDAS: "0.18.1"
- image: thekevjames/nox
steps:
- checkout
- run: ci/config_auth.sh
- run: ci/run_pip.sh
"pip-3.6-MASTER":
- run: nox -s unit-3.5 system-3.5

"pip-3.6":
docker:
- image: python:3.6
environment:
PYTHON: "3.6"
PANDAS: "MASTER"
- image: thekevjames/nox
steps:
- checkout
- run: ci/config_auth.sh
- run: ci/run_pip.sh
# Coverage
- run: codecov
"pip-3.7-0.23.4":
- run: nox -s unit-3.6 system-3.6

"pip-3.7":
docker:
- image: python:3.7
environment:
PYTHON: "3.7"
PANDAS: "0.23.4"
- image: thekevjames/nox
steps:
- checkout
- run: ci/config_auth.sh
- run: ci/run_pip.sh
- run: nox -s unit-3.7 system-3.7 cover

"lint":
docker:
- image: thekevjames/nox
environment:
# Resolve "Python 3 was configured to use ASCII as encoding for the environment"
LC_ALL: C.UTF-8
LANG: C.UTF-8
steps:
- checkout
- run: nox -s lint

# Conda
"conda-3.6-0.20.1":
Expand All @@ -56,20 +56,13 @@ jobs:
- run: ci/config_auth.sh
- run: ci/run_conda.sh

lint:
docker:
- image: python:3.6
steps:
- checkout
- run: pip install nox
- run: nox -s lint
workflows:
version: 2
build:
jobs:
- "pip-2.7-0.19.2"
- "pip-3.5-0.18.1"
- "pip-3.6-MASTER"
- "pip-3.7-0.23.4"
- "conda-3.6-0.20.1"
- lint
- "pip-2.7"
- "pip-3.5"
- "pip-3.6"
- "pip-3.7"
- lint
- "conda-3.6-0.20.1"
8 changes: 8 additions & 0 deletions .flake8
@@ -0,0 +1,8 @@
[flake8]
ignore = E203, E266, E501, W503
exclude =
# Standard linting exemptions.
__pycache__,
.git,
*.pyc,
conf.py
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -68,6 +68,8 @@ dist
# wheel files
*.whl
**/wheelhouse/*
pip-wheel-metadata

# coverage
.coverage
.testmondata
Expand Down
1 change: 0 additions & 1 deletion ci/requirements-2.7-0.19.2.pip

This file was deleted.

6 changes: 6 additions & 0 deletions ci/requirements-2.7.pip
@@ -0,0 +1,6 @@
mock
pandas==0.17.1
google-auth==1.4.1
google-auth-oauthlib==0.0.1
google-cloud-bigquery==0.32.0
pydata-google-auth==0.1.2
3 changes: 0 additions & 3 deletions ci/requirements-3.5-0.18.1.pip

This file was deleted.

5 changes: 5 additions & 0 deletions ci/requirements-3.5.pip
@@ -0,0 +1,5 @@
pandas==0.19.0
google-auth==1.4.1
google-auth-oauthlib==0.0.1
google-cloud-bigquery==0.32.0
pydata-google-auth==0.1.2
2 changes: 2 additions & 0 deletions ci/requirements-3.6-MASTER.pip
@@ -1,3 +1,5 @@
--pre -f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com/ pandas
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=core
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery
pydata-google-auth==0.1.2
3 changes: 3 additions & 0 deletions ci/requirements-3.6.pip
@@ -0,0 +1,3 @@
pandas
pydata-google-auth
google-cloud-bigquery
Empty file removed ci/requirements-3.7-0.23.4.pip
Empty file.
3 changes: 3 additions & 0 deletions ci/requirements-3.7.pip
@@ -0,0 +1,3 @@
pandas==0.24.0
google-cloud-bigquery==1.9.0
pydata-google-auth==0.1.2
77 changes: 33 additions & 44 deletions noxfile.py
Expand Up @@ -8,45 +8,34 @@

import nox

PANDAS_PRE_WHEELS = (
"https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83"
".ssl.cf2.rackcdn.com"
)


supported_pythons = ["2.7", "3.5", "3.6", "3.7"]
latest_python = "3.6"


@nox.session
def test(session):
session.install("mock", "pytest", "pytest-cov")
def lint(session, python=latest_python):
session.install("black", "flake8")
session.install("-e", ".")
session.run("flake8", "pandas_gbq")
session.run("flake8", "tests")
session.run("black", "--check", ".")

# Skip local auth tests on Travis.
additional_args = list(session.posargs)
if "TRAVIS_BUILD_DIR" in os.environ:
additional_args = additional_args + ["-m", "not local_auth"]

session.run(
"pytest",
os.path.join(".", "tests"),
"--quiet",
"--cov=pandas_gbq",
"--cov=tests.unit",
"--cov-report",
"xml:/tmp/pytest-cov.xml",
*additional_args
)
@nox.session(python=latest_python)
def blacken(session):
session.install("black")
session.run("black", ".")


@nox.session
@nox.session(python=supported_pythons)
def unit(session):
session.install("mock", "pytest", "pytest-cov")
session.install("-e", ".")
session.run(
"pytest",
os.path.join(".", "tests", "unit"),
"--quiet",
"-v",
"--cov=pandas_gbq",
"--cov=tests.unit",
"--cov-report",
Expand All @@ -56,32 +45,32 @@ def unit(session):


@nox.session
def test_earliest_deps(session, python="3.5"):
session.install(
"-r", os.path.join(".", "ci", "requirements-3.5-0.18.1.pip")
)
test(session)
def cover(session, python=latest_python):
session.install("coverage", "pytest-cov")
session.run("coverage", "report", "--show-missing", "--fail-under=40")
session.run("coverage", "erase")


@nox.session
def test_latest_deps(session, python=latest_python):
@nox.session(python=supported_pythons)
def system(session):
session.install("pytest", "pytest-cov")
session.install(
"--pre", "--upgrade", "--timeout=60", "-f", PANDAS_PRE_WHEELS, "pandas"
"-r",
os.path.join(".", "ci", "requirements-{}.pip".format(session.python)),
)
session.install(
"-r", os.path.join(".", "ci", "requirements-3.6-MASTER.pip")
"-e",
".",
# Use dependencies from requirements file instead.
# This enables testing with specific versions of the dependencies.
"--no-dependencies",
)
test(session)


@nox.session
def lint(session, python=latest_python):
session.install("black")
session.run("black", "--check", ".")

# Skip local auth tests on CI.
additional_args = list(session.posargs)
if "CIRCLECI" in os.environ:
additional_args = additional_args + ["-m", "not local_auth"]

@nox.session
def cover(session, python=latest_python):
session.install("coverage", "pytest-cov")
session.run("coverage", "report", "--show-missing", "--fail-under=40")
session.run("coverage", "erase")
session.run(
"pytest", os.path.join(".", "tests", "system"), "-v", *additional_args
)
3 changes: 1 addition & 2 deletions pandas_gbq/gbq.py
@@ -1,5 +1,4 @@
import logging
import os
import time
import warnings
from collections import OrderedDict
Expand Down Expand Up @@ -69,7 +68,7 @@ def _check_google_client_version():
def _test_google_api_imports():

try:
import pydata_google_auth
import pydata_google_auth # noqa
except ImportError as ex:
raise ImportError(
"pandas-gbq requires pydata-google-auth: {0}".format(ex)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_context.py
Expand Up @@ -46,11 +46,11 @@ def test_read_gbq_should_use_dialect(mock_bigquery_client):
pandas_gbq.read_gbq("SELECT 1")

_, kwargs = mock_bigquery_client.query.call_args
assert kwargs["job_config"].use_legacy_sql == True
assert kwargs["job_config"].use_legacy_sql

pandas_gbq.context.dialect = "standard"
pandas_gbq.read_gbq("SELECT 1")

_, kwargs = mock_bigquery_client.query.call_args
assert kwargs["job_config"].use_legacy_sql == False
assert not kwargs["job_config"].use_legacy_sql
pandas_gbq.context.dialect = None # Reset the global state.
1 change: 0 additions & 1 deletion tests/unit/test_gbq.py
Expand Up @@ -58,7 +58,6 @@ def mock_get_user_credentials(*args, **kwargs):

@pytest.fixture(autouse=True)
def no_auth(monkeypatch):
from pandas_gbq import auth
import pydata_google_auth

monkeypatch.setattr(pydata_google_auth, "default", mock_get_credentials)
Expand Down

0 comments on commit f729a44

Please sign in to comment.