Skip to content

Commit b96eaca

Browse files
Make CONTRIBUTING.rst be up to date. (#3750)
1 parent 26214d2 commit b96eaca

File tree

1 file changed

+60
-169
lines changed

1 file changed

+60
-169
lines changed

CONTRIBUTING.rst

Lines changed: 60 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ In order to add a feature to ``google-cloud-python``:
2121
documentation (in ``docs/``).
2222

2323
- The feature must work fully on the following CPython versions: 2.7,
24-
3.4, and 3.5 on both UNIX and Windows.
24+
3.4, 3.5, and 3.6 on both UNIX and Windows.
2525

2626
- The feature must not add unnecessary dependencies (where
2727
"unnecessary" is of course subjective, but new dependencies should
@@ -57,7 +57,7 @@ You'll have to create a development environment to hack on
5757
Now your local repo is set up such that you will push changes to your GitHub
5858
repo, from which you can submit a pull request.
5959

60-
To work on the codebase and run the tests, we recommend using ``tox``,
60+
To work on the codebase and run the tests, we recommend using ``nox``,
6161
but you can also use a ``virtualenv`` of your own creation.
6262

6363
.. _repo: https://github.com/GoogleCloudPlatform/google-cloud-python
@@ -68,11 +68,15 @@ Using a custom ``virtualenv``
6868
- To create a virtualenv in which to install ``google-cloud-python``::
6969

7070
$ cd ${HOME}/hack-on-google-cloud-python
71-
$ virtualenv --python python2.7 ${ENV_NAME}
71+
$ virtualenv --python python3.6 ${ENV_NAME}
7272

7373
You can choose which Python version you want to use by passing a ``--python``
74-
flag to ``virtualenv``. For example, ``virtualenv --python python2.7``
75-
chooses the Python 2.7 interpreter to be installed.
74+
flag to ``virtualenv``. For example, ``virtualenv --python python3.6``
75+
chooses the Python 3.6 interpreter to be installed.
76+
77+
.. note::
78+
We recommend developing in Python 3, and using the test suite to
79+
ensure compatibility with Python 2.
7680

7781
- From here on in within these instructions, the
7882
``${HOME}/hack-on-google-cloud-python/${ENV_NAME}`` virtual environment you
@@ -91,43 +95,32 @@ Using a custom ``virtualenv``
9195
Unfortunately using ``setup.py develop`` is not possible with this
9296
project, because it uses `namespace packages`_.
9397

94-
Using ``tox``
98+
Using ``nox``
9599
=============
96100

97-
- To test your changes, run unit tests with ``tox``::
98-
99-
$ tox -e py27
100-
$ tox -e py34
101-
$ ...
102-
103-
- If you'd like to poke around your code in an interpreter, let
104-
``tox`` install the environment of your choice::
105-
106-
$ # Install only; without running tests
107-
$ tox -e ${ENV} --recreate --notest
101+
We use `nox`_ to instrument our tests.
108102

109-
After doing this, you can activate the virtual environment and
110-
use the interpreter from that environment::
103+
- To test your changes, run unit tests with ``nox``::
111104

112-
$ source .tox/${ENV}/bin/activate
113-
(ENV) $ .tox/${ENV}/bin/python
105+
$ nox -f datastore/nox.py -s "unit_tests(python_version='2.7')"
106+
$ nox -f datastore/nox.py -s "unit_tests(python_version='3.4')"
107+
$ ...
114108

115-
Unfortunately, your changes to the source tree won't be picked up
116-
by the ``tox`` environment, so if you make changes, you'll need
117-
to again ``--recreate`` the environment.
109+
.. note::
118110

119-
- To run unit tests on a restricted set of packages::
111+
The unit tests and system tests are contained in the individual
112+
``nox.py`` files in each directory; substitute ``datastore`` in the
113+
example above with the package of your choice.
120114

121-
$ tox -e py27 -- core datastore
122115

123116
Alternatively, you can just navigate directly to the package you are
124117
currently developing and run tests there::
125118

126119
$ export GIT_ROOT=$(pwd)
127-
$ cd ${GIT_ROOT}/core/
128-
$ tox -e py27
129120
$ cd ${GIT_ROOT}/datastore/
130-
$ tox -e py27
121+
$ nox -s "unit_tests(python_version='3.6')"
122+
123+
.. nox: https://pypi.org/project/nox-automation/
131124
132125
Note on Editable Installs / Develop Mode
133126
========================================
@@ -162,13 +155,13 @@ On Debian/Ubuntu::
162155
Coding Style
163156
************
164157

165-
- PEP8 compliance, with exceptions defined in ``tox.ini``.
166-
If you have ``tox`` installed, you can test that you have not introduced
158+
- PEP8 compliance, with exceptions defined in the linter configuration.
159+
If you have ``nox`` installed, you can test that you have not introduced
167160
any non-compliant code via::
168161

169-
$ tox -e lint
162+
$ nox -s lint
170163

171-
- In order to make ``tox -e lint`` run faster, you can set some environment
164+
- In order to make ``nox -s lint`` run faster, you can set some environment
172165
variables::
173166

174167
export GOOGLE_CLOUD_TESTING_REMOTE="upstream"
@@ -185,49 +178,20 @@ Exceptions to PEP8:
185178
"Function-Under-Test"), which is PEP8-incompliant, but more readable.
186179
Some also use a local variable, ``MUT`` (short for "Module-Under-Test").
187180

188-
*************
189-
Running Tests
190-
*************
191-
192-
- To run all tests for ``google-cloud-python`` on a single Python version, run
193-
``py.test`` from your development virtualenv (See
194-
`Using a Development Checkout`_ above).
195-
196-
.. _Using a Development Checkout: #using-a-development-checkout
197-
198-
- To run the full set of ``google-cloud-python`` tests on all platforms, install
199-
``tox`` (https://tox.readthedocs.io/en/latest/) into a system Python. The
200-
``tox`` console script will be installed into the scripts location for that
201-
Python. While ``cd``'-ed to the ``google-cloud-python`` checkout root
202-
directory (it contains ``tox.ini``), invoke the ``tox`` console script.
203-
This will read the ``tox.ini`` file and execute the tests on multiple
204-
Python versions and platforms; while it runs, it creates a ``virtualenv`` for
205-
each version/platform combination. For example::
206-
207-
$ sudo --set-home /usr/bin/pip install tox
208-
$ cd ${HOME}/hack-on-google-cloud-python/
209-
$ /usr/bin/tox
210-
211-
.. _Using a Development Checkout: #using-a-development-checkout
212-
213181
********************
214182
Running System Tests
215183
********************
216184

217-
- To run system tests you can execute::
218-
219-
$ tox -e system-tests
220-
$ tox -e system-tests3
221-
222-
or run only system tests for a particular package via::
185+
- To run system tests for a given package, you can execute::
223186

224-
$ python system_tests/run_system_test.py --package {package}
225-
$ python3 system_tests/run_system_test.py --package {package}
187+
$ nox -f datastore/nox.py -s "system_tests(python_version='3.6')"
188+
$ nox -f datastore/nox.py -s "system_tests(python_version='2.7')"
226189

227-
To run a subset of the system tests::
190+
.. note::
228191

229-
$ tox -e system-tests -- datastore storage
230-
$ python system_tests/attempt_system_tests.py datastore storage
192+
System tests are only configured to run under Python 2.7 and
193+
Python 3.6. For expediency, we do not run them in older versions
194+
of Python 3.
231195

232196
This alone will not run the tests. You'll need to change some local
233197
auth settings and change some configuration in your project to
@@ -270,90 +234,21 @@ Running System Tests
270234
- For datastore query tests, you'll need stored data in your dataset.
271235
To populate this data, run::
272236

273-
$ python system_tests/populate_datastore.py
237+
$ python datastore/tests/system/utils/populate_datastore.py
274238

275239
- If you make a mistake during development (i.e. a failing test that
276240
prevents clean-up) you can clear all system test data from your
277241
datastore instance via::
278242

279-
$ python system_tests/clear_datastore.py
280-
281-
System Test Emulators
282-
=====================
283-
284-
- System tests can also be run against local `emulators`_ that mock
285-
the production services. To run the system tests with the
286-
``datastore`` emulator::
287-
288-
$ tox -e datastore-emulator
289-
$ GOOGLE_CLOUD_DISABLE_GRPC=true tox -e datastore-emulator
290-
291-
This also requires that the ``gcloud`` command line tool is
292-
installed. If you'd like to run them directly (outside of a
293-
``tox`` environment), first start the emulator and
294-
take note of the process ID::
295-
296-
$ gcloud beta emulators datastore start --no-legacy 2>&1 > log.txt &
297-
[1] 33333
243+
$ python datastore/tests/system/utils/clear_datastore.py
298244

299-
then determine the environment variables needed to interact with
300-
the emulator::
301-
302-
$ gcloud beta emulators datastore env-init
303-
export DATASTORE_LOCAL_HOST=localhost:8417
304-
export DATASTORE_HOST=http://localhost:8417
305-
export DATASTORE_DATASET=google-cloud-settings-app-id
306-
export DATASTORE_PROJECT_ID=google-cloud-settings-app-id
307-
308-
using these environment variables run the emulator::
309-
310-
$ DATASTORE_HOST=http://localhost:8471 \
311-
> DATASTORE_DATASET=google-cloud-settings-app-id \
312-
> GOOGLE_CLOUD_NO_PRINT=true \
313-
> python system_tests/run_system_test.py \
314-
> --package=datastore --ignore-requirements
315-
316-
and after completion stop the emulator and any child
317-
processes it spawned::
318-
319-
$ kill -- -33333
320-
321-
.. _emulators: https://cloud.google.com/sdk/gcloud/reference/beta/emulators/
322-
323-
- To run the system tests with the ``pubsub`` emulator::
324-
325-
$ tox -e pubsub-emulator
326-
$ GOOGLE_CLOUD_DISABLE_GRPC=true tox -e pubsub-emulator
327-
328-
If you'd like to run them directly (outside of a ``tox`` environment), first
329-
start the emulator and take note of the process ID::
330-
331-
$ gcloud beta emulators pubsub start 2>&1 > log.txt &
332-
[1] 44444
333-
334-
then determine the environment variables needed to interact with
335-
the emulator::
336-
337-
$ gcloud beta emulators pubsub env-init
338-
export PUBSUB_EMULATOR_HOST=localhost:8897
339-
340-
using these environment variables run the emulator::
341-
342-
$ PUBSUB_EMULATOR_HOST=localhost:8897 \
343-
> python system_tests/run_system_test.py \
344-
> --package=pubsub
345-
346-
and after completion stop the emulator and any child
347-
processes it spawned::
348-
349-
$ kill -- -44444
350245

351246
*************
352247
Test Coverage
353248
*************
354249

355250
- The codebase *must* have 100% test statement coverage after each commit.
356-
You can test coverage via ``tox -e cover``.
251+
You can test coverage via ``nox -s cover``.
357252

358253
******************************************************
359254
Documentation Coverage and Building HTML Documentation
@@ -386,10 +281,10 @@ using to develop ``google-cloud-python``):
386281
#. Open the ``docs/_build/html/index.html`` file to see the resulting HTML
387282
rendering.
388283

389-
As an alternative to 1. and 2. above, if you have ``tox`` installed, you
284+
As an alternative to 1. and 2. above, if you have ``nox`` installed, you
390285
can build the docs via::
391286

392-
$ tox -e docs
287+
$ nox -s docs
393288

394289
********************************************
395290
Note About ``README`` as it pertains to PyPI
@@ -404,27 +299,15 @@ may cause problems creating links or rendering the description.
404299

405300
.. _description on PyPI: https://pypi.org/project/google-cloud/
406301

407-
********************************************
408-
Travis Configuration and Build Optimizations
409-
********************************************
302+
**********************
303+
CircleCI Configuration
304+
**********************
410305

411-
All build scripts in the ``.travis.yml`` configuration file which have
412-
Python dependencies are specified in the ``tox.ini`` configuration.
413-
They are executed in the Travis build via ``tox -e ${ENV}`` where
306+
All build scripts in the ``.circleci/config.yml`` configuration file which have
307+
Python dependencies are specified in the ``nox.py`` configuration.
308+
They are executed in the Travis build via ``nox -s ${ENV}`` where
414309
``${ENV}`` is the environment being tested.
415310

416-
If new ``tox`` environments are added to be run in a Travis build, they
417-
should be listed in ``[tox].envlist`` as a default environment.
418-
419-
We speed up builds by using the Travis `caching feature`_.
420-
421-
.. _caching feature: https://docs.travis-ci.com/user/caching/#pip-cache
422-
423-
We intentionally **do not** cache the ``.tox/`` directory. Instead, we
424-
allow the ``tox`` environments to be re-built for every build. This
425-
way, we'll always get the latest versions of our dependencies and any
426-
caching or wheel optimization to be done will be handled automatically
427-
by ``pip``.
428311

429312
*************************
430313
Supported Python Versions
@@ -435,14 +318,16 @@ We support:
435318
- `Python 2.7`_
436319
- `Python 3.4`_
437320
- `Python 3.5`_
321+
- `Python 3.6`_
438322

439323
.. _Python 2.7: https://docs.python.org/2.7/
440324
.. _Python 3.4: https://docs.python.org/3.4/
441325
.. _Python 3.5: https://docs.python.org/3.5/
326+
.. _Python 3.6: https://docs.python.org/3.6/
442327

443-
Supported versions can be found in our ``tox.ini`` `config`_.
328+
Supported versions can be found in our ``nox.py`` `config`_.
444329

445-
.. _config: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/tox.ini
330+
.. _config: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/nox.py
446331

447332
We explicitly decided not to support `Python 2.5`_ due to `decreased usage`_
448333
and lack of continuous integration `support`_.
@@ -475,17 +360,23 @@ This library follows `Semantic Versioning`_.
475360

476361
.. _Semantic Versioning: http://semver.org/
477362

478-
It is currently in major version zero (``0.y.z``), which means that anything
479-
may change at any time and the public API should not be considered
363+
Some packages are currently in major version zero (``0.y.z``), which means that
364+
anything may change at any time and the public API should not be considered
480365
stable.
481366

482367
******************************
483368
Contributor License Agreements
484369
******************************
485370

486-
Before we can accept your pull requests you'll need to sign a Contributor License Agreement (CLA):
371+
Before we can accept your pull requests you'll need to sign a Contributor
372+
License Agreement (CLA):
487373

488-
- **If you are an individual writing original source code** and **you own the intellectual property**, then you'll need to sign an `individual CLA <https://developers.google.com/open-source/cla/individual>`__.
489-
- **If you work for a company that wants to allow you to contribute your work**, then you'll need to sign a `corporate CLA <https://developers.google.com/open-source/cla/corporate>`__.
374+
- **If you are an individual writing original source code** and **you own the
375+
intellectual property**, then you'll need to sign an
376+
`individual CLA <https://developers.google.com/open-source/cla/individual>`__.
377+
- **If you work for a company that wants to allow you to contribute your work**,
378+
then you'll need to sign a
379+
`corporate CLA <https://developers.google.com/open-source/cla/corporate>`__.
490380

491-
You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.
381+
You can sign these electronically (just scroll to the bottom). After that,
382+
we'll be able to accept your pull requests.

0 commit comments

Comments
 (0)