Skip to content

Commit f729a44

Browse files
authored
TST: Use nox docker image for PIP CircleCI tests (#251)
* 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.
1 parent c3dda4a commit f729a44

15 files changed

+97
-92
lines changed

.circleci/config.yml

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
version: 2
22
jobs:
33
# Pip
4-
"pip-2.7-0.19.2":
4+
"pip-2.7":
55
docker:
6-
- image: python:2.7
7-
environment:
8-
PYTHON: "2.7"
9-
PANDAS: "0.19.2"
6+
- image: thekevjames/nox
107
steps:
118
- checkout
129
- run: ci/config_auth.sh
13-
- run: ci/run_pip.sh
14-
"pip-3.5-0.18.1":
10+
- run: nox -s unit-2.7 system-2.7
11+
12+
"pip-3.5":
1513
docker:
16-
- image: python:3.5
17-
environment:
18-
PYTHON: "3.5"
19-
PANDAS: "0.18.1"
14+
- image: thekevjames/nox
2015
steps:
2116
- checkout
2217
- run: ci/config_auth.sh
23-
- run: ci/run_pip.sh
24-
"pip-3.6-MASTER":
18+
- run: nox -s unit-3.5 system-3.5
19+
20+
"pip-3.6":
2521
docker:
26-
- image: python:3.6
27-
environment:
28-
PYTHON: "3.6"
29-
PANDAS: "MASTER"
22+
- image: thekevjames/nox
3023
steps:
3124
- checkout
3225
- run: ci/config_auth.sh
33-
- run: ci/run_pip.sh
34-
# Coverage
35-
- run: codecov
36-
"pip-3.7-0.23.4":
26+
- run: nox -s unit-3.6 system-3.6
27+
28+
"pip-3.7":
3729
docker:
38-
- image: python:3.7
39-
environment:
40-
PYTHON: "3.7"
41-
PANDAS: "0.23.4"
30+
- image: thekevjames/nox
4231
steps:
4332
- checkout
4433
- run: ci/config_auth.sh
45-
- run: ci/run_pip.sh
34+
- run: nox -s unit-3.7 system-3.7 cover
35+
36+
"lint":
37+
docker:
38+
- image: thekevjames/nox
39+
environment:
40+
# Resolve "Python 3 was configured to use ASCII as encoding for the environment"
41+
LC_ALL: C.UTF-8
42+
LANG: C.UTF-8
43+
steps:
44+
- checkout
45+
- run: nox -s lint
4646

4747
# Conda
4848
"conda-3.6-0.20.1":
@@ -56,20 +56,13 @@ jobs:
5656
- run: ci/config_auth.sh
5757
- run: ci/run_conda.sh
5858

59-
lint:
60-
docker:
61-
- image: python:3.6
62-
steps:
63-
- checkout
64-
- run: pip install nox
65-
- run: nox -s lint
6659
workflows:
6760
version: 2
6861
build:
6962
jobs:
70-
- "pip-2.7-0.19.2"
71-
- "pip-3.5-0.18.1"
72-
- "pip-3.6-MASTER"
73-
- "pip-3.7-0.23.4"
74-
- "conda-3.6-0.20.1"
75-
- lint
63+
- "pip-2.7"
64+
- "pip-3.5"
65+
- "pip-3.6"
66+
- "pip-3.7"
67+
- lint
68+
- "conda-3.6-0.20.1"

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
ignore = E203, E266, E501, W503
3+
exclude =
4+
# Standard linting exemptions.
5+
__pycache__,
6+
.git,
7+
*.pyc,
8+
conf.py

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ dist
6868
# wheel files
6969
*.whl
7070
**/wheelhouse/*
71+
pip-wheel-metadata
72+
7173
# coverage
7274
.coverage
7375
.testmondata

ci/requirements-2.7-0.19.2.pip

Lines changed: 0 additions & 1 deletion
This file was deleted.

ci/requirements-2.7.pip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mock
2+
pandas==0.17.1
3+
google-auth==1.4.1
4+
google-auth-oauthlib==0.0.1
5+
google-cloud-bigquery==0.32.0
6+
pydata-google-auth==0.1.2

ci/requirements-3.5-0.18.1.pip

Lines changed: 0 additions & 3 deletions
This file was deleted.

ci/requirements-3.5.pip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pandas==0.19.0
2+
google-auth==1.4.1
3+
google-auth-oauthlib==0.0.1
4+
google-cloud-bigquery==0.32.0
5+
pydata-google-auth==0.1.2

ci/requirements-3.6-MASTER.pip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
--pre -f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com/ pandas
12
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core
23
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=core
34
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery
5+
pydata-google-auth==0.1.2

ci/requirements-3.6.pip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pandas
2+
pydata-google-auth
3+
google-cloud-bigquery

ci/requirements-3.7-0.23.4.pip

Whitespace-only changes.

ci/requirements-3.7.pip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pandas==0.24.0
2+
google-cloud-bigquery==1.9.0
3+
pydata-google-auth==0.1.2

noxfile.py

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,34 @@
88

99
import nox
1010

11-
PANDAS_PRE_WHEELS = (
12-
"https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83"
13-
".ssl.cf2.rackcdn.com"
14-
)
15-
1611

12+
supported_pythons = ["2.7", "3.5", "3.6", "3.7"]
1713
latest_python = "3.6"
1814

1915

2016
@nox.session
21-
def test(session):
22-
session.install("mock", "pytest", "pytest-cov")
17+
def lint(session, python=latest_python):
18+
session.install("black", "flake8")
2319
session.install("-e", ".")
20+
session.run("flake8", "pandas_gbq")
21+
session.run("flake8", "tests")
22+
session.run("black", "--check", ".")
2423

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

30-
session.run(
31-
"pytest",
32-
os.path.join(".", "tests"),
33-
"--quiet",
34-
"--cov=pandas_gbq",
35-
"--cov=tests.unit",
36-
"--cov-report",
37-
"xml:/tmp/pytest-cov.xml",
38-
*additional_args
39-
)
25+
@nox.session(python=latest_python)
26+
def blacken(session):
27+
session.install("black")
28+
session.run("black", ".")
4029

4130

42-
@nox.session
31+
@nox.session(python=supported_pythons)
4332
def unit(session):
4433
session.install("mock", "pytest", "pytest-cov")
4534
session.install("-e", ".")
4635
session.run(
4736
"pytest",
4837
os.path.join(".", "tests", "unit"),
49-
"--quiet",
38+
"-v",
5039
"--cov=pandas_gbq",
5140
"--cov=tests.unit",
5241
"--cov-report",
@@ -56,32 +45,32 @@ def unit(session):
5645

5746

5847
@nox.session
59-
def test_earliest_deps(session, python="3.5"):
60-
session.install(
61-
"-r", os.path.join(".", "ci", "requirements-3.5-0.18.1.pip")
62-
)
63-
test(session)
48+
def cover(session, python=latest_python):
49+
session.install("coverage", "pytest-cov")
50+
session.run("coverage", "report", "--show-missing", "--fail-under=40")
51+
session.run("coverage", "erase")
6452

6553

66-
@nox.session
67-
def test_latest_deps(session, python=latest_python):
54+
@nox.session(python=supported_pythons)
55+
def system(session):
56+
session.install("pytest", "pytest-cov")
6857
session.install(
69-
"--pre", "--upgrade", "--timeout=60", "-f", PANDAS_PRE_WHEELS, "pandas"
58+
"-r",
59+
os.path.join(".", "ci", "requirements-{}.pip".format(session.python)),
7060
)
7161
session.install(
72-
"-r", os.path.join(".", "ci", "requirements-3.6-MASTER.pip")
62+
"-e",
63+
".",
64+
# Use dependencies from requirements file instead.
65+
# This enables testing with specific versions of the dependencies.
66+
"--no-dependencies",
7367
)
74-
test(session)
75-
76-
77-
@nox.session
78-
def lint(session, python=latest_python):
79-
session.install("black")
80-
session.run("black", "--check", ".")
8168

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

83-
@nox.session
84-
def cover(session, python=latest_python):
85-
session.install("coverage", "pytest-cov")
86-
session.run("coverage", "report", "--show-missing", "--fail-under=40")
87-
session.run("coverage", "erase")
74+
session.run(
75+
"pytest", os.path.join(".", "tests", "system"), "-v", *additional_args
76+
)

pandas_gbq/gbq.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
import os
32
import time
43
import warnings
54
from collections import OrderedDict
@@ -69,7 +68,7 @@ def _check_google_client_version():
6968
def _test_google_api_imports():
7069

7170
try:
72-
import pydata_google_auth
71+
import pydata_google_auth # noqa
7372
except ImportError as ex:
7473
raise ImportError(
7574
"pandas-gbq requires pydata-google-auth: {0}".format(ex)

tests/unit/test_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def test_read_gbq_should_use_dialect(mock_bigquery_client):
4646
pandas_gbq.read_gbq("SELECT 1")
4747

4848
_, kwargs = mock_bigquery_client.query.call_args
49-
assert kwargs["job_config"].use_legacy_sql == True
49+
assert kwargs["job_config"].use_legacy_sql
5050

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

5454
_, kwargs = mock_bigquery_client.query.call_args
55-
assert kwargs["job_config"].use_legacy_sql == False
55+
assert not kwargs["job_config"].use_legacy_sql
5656
pandas_gbq.context.dialect = None # Reset the global state.

tests/unit/test_gbq.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def mock_get_user_credentials(*args, **kwargs):
5858

5959
@pytest.fixture(autouse=True)
6060
def no_auth(monkeypatch):
61-
from pandas_gbq import auth
6261
import pydata_google_auth
6362

6463
monkeypatch.setattr(pydata_google_auth, "default", mock_get_credentials)

0 commit comments

Comments
 (0)