Skip to content

Commit 3b865c6

Browse files
authored
TST: configure CircleCI (#232)
Use CircleCI for testing pandas-gbq. This configuration uses the canonical Python and miniconda3 Docker images to reduce problems caused by a unique configuration. Also: * Re-enables conda tests. * Adds Python 3.7 tests.
1 parent b8c9051 commit 3b865c6

12 files changed

+181
-40
lines changed

.circleci/config.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
version: 2
2+
jobs:
3+
# Pip
4+
"pip-2.7-0.19.2":
5+
docker:
6+
- image: python:2.7
7+
environment:
8+
PYTHON: "2.7"
9+
PANDAS: "0.19.2"
10+
steps:
11+
- checkout
12+
- run: ci/config_auth.sh
13+
- run: ci/run_pip.sh
14+
"pip-3.5-0.18.1":
15+
docker:
16+
- image: python:3.5
17+
environment:
18+
PYTHON: "3.5"
19+
PANDAS: "0.18.1"
20+
steps:
21+
- checkout
22+
- run: ci/config_auth.sh
23+
- run: ci/run_pip.sh
24+
"pip-3.6-MASTER":
25+
docker:
26+
- image: python:3.6
27+
environment:
28+
PYTHON: "3.6"
29+
PANDAS: "MASTER"
30+
steps:
31+
- checkout
32+
- run: ci/config_auth.sh
33+
- run: ci/run_pip.sh
34+
# Coverage
35+
- run: codecov
36+
"pip-3.7-0.23.4":
37+
docker:
38+
- image: python:3.7
39+
environment:
40+
PYTHON: "3.7"
41+
PANDAS: "0.23.4"
42+
steps:
43+
- checkout
44+
- run: ci/config_auth.sh
45+
- run: ci/run_pip.sh
46+
47+
# Conda
48+
"conda-3.6-0.20.1":
49+
docker:
50+
- image: continuumio/miniconda3
51+
environment:
52+
PYTHON: "3.6"
53+
PANDAS: "0.20.1"
54+
steps:
55+
- checkout
56+
- run: ci/config_auth.sh
57+
- run: ci/run_conda.sh
58+
59+
lint:
60+
docker:
61+
- image: python:3.6
62+
steps:
63+
- checkout
64+
- run: pip install nox
65+
- run: nox -s lint
66+
workflows:
67+
version: 2
68+
build:
69+
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

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,4 @@ Thumbs.db
8989
# Credentials #
9090
###############
9191
bigquery_credentials.dat
92+
ci/service_account.json

ci/config_auth.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
# Don't set -x, because we don't want to leak keys.
4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
5+
6+
# Write key to file if present.
7+
if [ ! -z "$SERVICE_ACCOUNT_KEY" ] ; then
8+
echo "$SERVICE_ACCOUNT_KEY" | base64 --decode > "$DIR"/service_account.json
9+
fi

ci/requirements-2.7-0.19.2.pip

-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
google-auth
2-
google-auth-oauthlib
3-
PyCrypto
41
mock
5-
google-cloud-bigquery

ci/requirements-3.5-0.18.1.pip

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
google-auth==1.4.1
22
google-auth-oauthlib==0.0.1
3-
google-cloud-bigquery==0.32.0
4-
pandas==0.18.1
3+
google-cloud-bigquery==0.32.0

ci/requirements-3.6-MASTER.pip

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
google-auth
2-
google-auth-oauthlib
3-
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core
4-
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=core
5-
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery
1+
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core
2+
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=core
3+
git+https://github.com/googleapis/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery

ci/requirements-3.7-0.23.4.pip

Whitespace-only changes.

ci/run_conda.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -e -x
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
4+
5+
# Install dependencies using Conda
6+
7+
conda config --set always_yes yes --set changeps1 no
8+
conda config --add channels pandas
9+
conda config --add channels conda-forge
10+
conda update -q conda
11+
conda info -a
12+
conda create -q -n test-environment python=$PYTHON
13+
source activate test-environment
14+
if [[ "$PANDAS" == "MASTER" ]]; then
15+
conda install -q numpy pytz python-dateutil;
16+
PRE_WHEELS="https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com";
17+
pip install --pre --upgrade --timeout=60 -f $PRE_WHEELS pandas;
18+
else
19+
conda install -q pandas=$PANDAS;
20+
fi
21+
22+
REQ="ci/requirements-${PYTHON}-${PANDAS}"
23+
conda install -q --file "$REQ.conda";
24+
python setup.py develop
25+
26+
# Run the tests
27+
$DIR/run_tests.sh

ci/run_pip.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e -x
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
4+
5+
# Install dependencies using Pip
6+
7+
if [[ "$PANDAS" == "MASTER" ]]; then
8+
PRE_WHEELS="https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com";
9+
pip install --pre --upgrade --timeout=60 -f $PRE_WHEELS pandas;
10+
else
11+
pip install pandas==$PANDAS
12+
fi
13+
14+
# Install test requirements
15+
pip install coverage pytest pytest-cov flake8 codecov
16+
17+
REQ="ci/requirements-${PYTHON}-${PANDAS}"
18+
pip install -r "$REQ.pip"
19+
pip install -e .
20+
21+
$DIR/run_tests.sh

ci/run_tests.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e -x
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
4+
5+
if [ -f "$DIR/service_account.json" ]; then
6+
export GOOGLE_APPLICATION_CREDENTIALS="$DIR/service_account.json"
7+
fi
8+
9+
# Install test requirements
10+
pip install coverage pytest pytest-cov flake8 codecov
11+
pytest -v -m "not local_auth" --cov=pandas_gbq --cov-report xml:/tmp/pytest-cov.xml tests

docs/source/contributing.rst

+32-28
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ want to clone your fork to your machine::
105105
This creates the directory `pandas-gbq-yourname` and connects your repository to
106106
the upstream (main project) *pandas-gbq* repository.
107107

108-
The testing suite will run automatically on Travis-CI once your pull request is submitted.
108+
The testing suite will run automatically on CircleCI once your pull request is submitted.
109109
However, if you wish to run the test suite on a branch prior to submitting the pull request,
110-
then Travis-CI needs to be hooked up to your GitHub repository. Instructions for doing so
111-
are `here <http://about.travis-ci.org/docs/user/getting-started/>`__.
110+
then CircleCI needs to be hooked up to your GitHub repository. Instructions for doing so
111+
are `here <https://circleci.com/docs/2.0/getting-started/>`__.
112112

113113
Creating a branch
114114
-----------------
@@ -214,11 +214,13 @@ the more common ``PEP8`` issues:
214214
- we restrict line-length to 79 characters to promote readability
215215
- passing arguments should have spaces after commas, e.g. ``foo(arg1, arg2, kw1='bar')``
216216

217-
Travis-CI will run the `flake8 <http://pypi.python.org/pypi/flake8>`_ tool
218-
and report any stylistic errors in your code. Therefore, it is helpful before
219-
submitting code to run the check yourself on the diff::
217+
CircleCI will run the `'black' code formatting tool
218+
<https://black.readthedocs.io/>`_ and report any stylistic errors in your
219+
code. Therefore, it is helpful before submitting code to run the formatter
220+
yourself::
220221

221-
git diff master | flake8 --diff
222+
pip install black
223+
black .
222224

223225
Backwards Compatibility
224226
~~~~~~~~~~~~~~~~~~~~~~~
@@ -287,10 +289,12 @@ directory.
287289
Running Google BigQuery Integration Tests
288290
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289291

290-
You will need to create a Google BigQuery private key in JSON format in
291-
order to run Google BigQuery integration tests on your local machine and
292-
on Travis-CI. The first step is to create a `service account
293-
<https://console.cloud.google.com/iam-admin/serviceaccounts/>`__.
292+
You will need to create a Google BigQuery private key in JSON format in order
293+
to run Google BigQuery integration tests on your local machine and on
294+
CircleCI. The first step is to create a `service account
295+
<https://console.cloud.google.com/iam-admin/serviceaccounts/>`__. Grant the
296+
service account permissions to run BigQuery queries and to create datasets
297+
and tables.
294298

295299
To run the integration tests locally, set the following environment variables
296300
before running ``pytest``:
@@ -301,30 +305,30 @@ before running ``pytest``:
301305

302306
Integration tests are skipped in pull requests because the credentials that
303307
are required for running Google BigQuery integration tests are
304-
`encrypted <https://docs.travis-ci.com/user/encrypting-files/>`__
305-
on Travis-CI and are only accessible from the pydata/pandas-gbq repository. The
306-
credentials won't be available on forks of pandas-gbq. Here are the steps to run
307-
gbq integration tests on a forked repository:
308-
309-
#. Go to `Travis CI <https://travis-ci.org/>`__ and sign in with your GitHub
310-
account.
311-
#. Click on the ``+`` icon next to the ``My Repositories`` list and enable
312-
Travis builds for your fork.
313-
#. Click on the gear icon to edit your travis build, and add two environment
308+
`configured in the CircleCI web interface
309+
<https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project>`_
310+
and are only accessible from the pydata/pandas-gbq repository. The
311+
credentials won't be available on forks of pandas-gbq. Here are the steps to
312+
run gbq integration tests on a forked repository:
313+
314+
#. Go to `CircleCI <https://circleci.com/dashboard>`__ and sign in with your
315+
GitHub account.
316+
#. Switch to your personal account in the top-left organization switcher.
317+
#. Use the "Add projects" tab to enable CircleCI for your fork.
318+
#. Click on the gear icon to edit your CircleCI build, and add two environment
314319
variables:
315320

316321
- ``GBQ_PROJECT_ID`` with the value being the ID of your BigQuery project.
317322

318-
- ``SERVICE_ACCOUNT_KEY`` with the value being the *contents* of the JSON
319-
key that you downloaded for your service account. Use single quotes around
320-
your JSON key to ensure that it is treated as a string.
323+
- ``SERVICE_ACCOUNT_KEY`` with the value being the base64-encoded
324+
*contents* of the JSON key that you downloaded for your service account.
321325

322-
For both environment variables, keep the "Display value in build log" option
323-
DISABLED. These variables contain sensitive data and you do not want their
324-
contents being exposed in build logs.
326+
Keep the contents of these variables confidential. These variables contain
327+
sensitive data and you do not want their contents being exposed in build
328+
logs.
325329
#. Your branch should be tested automatically once it is pushed. You can check
326330
the status by visiting your Travis branches page which exists at the
327-
following location: https://travis-ci.org/your-user-name/pandas-gbq/branches .
331+
following location: https://circleci.com/gh/your-username/pandas-gbq .
328332
Click on a build job for your branch.
329333

330334
Documenting your code

tests/system/test_auth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_get_application_default_credentials_returns_credentials():
9090

9191

9292
@pytest.mark.local_auth
93-
def test_get_user_account_credentials_bad_file_returns_credentials():
93+
def test_get_user_account_credentials_bad_file_returns_user_credentials():
9494
from google.auth.credentials import Credentials
9595

9696
with mock.patch("__main__.open", side_effect=IOError()):

0 commit comments

Comments
 (0)