Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
docs: update python contributing guide (#9)
Browse files Browse the repository at this point in the history
* docs: update python contributing guide

Adds details about blacken, updates version for system tests,
and shows how to pass through pytest arguments.

Source-Author: Chris Cotter <cjcotter@google.com>
Source-Date: Mon Feb 8 17:13:36 2021 -0500
Source-Repo: googleapis/synthtool
Source-Sha: 4679e7e415221f03ff2a71e3ffad75b9ec41d87e
Source-Link: googleapis/synthtool@4679e7e

* build(python): enable flakybot on library unit and system tests

Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
Source-Date: Wed Feb 17 14:10:46 2021 -0700
Source-Repo: googleapis/synthtool
Source-Sha: d17674372e27fb8f23013935e794aa37502071aa
Source-Link: googleapis/synthtool@d176743
  • Loading branch information
yoshi-automation committed Feb 25, 2021
1 parent ace8341 commit b6e095f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -50,8 +50,10 @@ docs.metadata

# Virtual environment
env/

# Test logs
coverage.xml
sponge_log.xml
*sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
Expand Down
10 changes: 10 additions & 0 deletions .kokoro/build.sh
Expand Up @@ -40,6 +40,16 @@ python3 -m pip uninstall --yes --quiet nox-automation
python3 -m pip install --upgrade --quiet nox
python3 -m nox --version

# If this is a continuous build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap cleanup EXIT HUP
fi

# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
if [[ -n "${NOX_SESSION:-}" ]]; then
Expand Down
22 changes: 18 additions & 4 deletions CONTRIBUTING.rst
Expand Up @@ -70,9 +70,14 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
- To test your changes, run unit tests with ``nox``::

$ nox -s unit-2.7
$ nox -s unit-3.7
$ nox -s unit-3.8
$ ...

- Args to pytest can be passed through the nox command separated by a `--`. For
example, to run a single test::

$ nox -s unit-3.8 -- -k <name of test>

.. note::

The unit tests and system tests are described in the
Expand All @@ -93,8 +98,12 @@ On Debian/Ubuntu::
************
Coding Style
************
- We use the automatic code formatter ``black``. You can run it using
the nox session ``blacken``. This will eliminate many lint errors. Run via::

$ nox -s blacken

- PEP8 compliance, with exceptions defined in the linter configuration.
- PEP8 compliance is required, with exceptions defined in the linter configuration.
If you have ``nox`` installed, you can test that you have not introduced
any non-compliant code via::

Expand Down Expand Up @@ -133,13 +142,18 @@ Running System Tests

- To run system tests, you can execute::

$ nox -s system-3.7
# Run all system tests
$ nox -s system-3.8
$ nox -s system-2.7

# Run a single system test
$ nox -s system-3.8 -- -k <name of test>


.. note::

System tests are only configured to run under Python 2.7 and
Python 3.7. For expediency, we do not run them in older versions
Python 3.8. For expediency, we do not run them in older versions
of Python 3.

This alone will not run the tests. You'll need to change some local
Expand Down
17 changes: 15 additions & 2 deletions noxfile.py
Expand Up @@ -93,6 +93,7 @@ def default(session):
session.run(
"py.test",
"--quiet",
f"--junitxml=unit_{session.python}_sponge_log.xml",
"--cov=google/cloud",
"--cov=tests/unit",
"--cov-append",
Expand Down Expand Up @@ -141,9 +142,21 @@ def system(session):

# Run py.test against the system tests.
if system_test_exists:
session.run("py.test", "--quiet", system_test_path, *session.posargs)
session.run(
"py.test",
"--quiet",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_path,
*session.posargs,
)
if system_test_folder_exists:
session.run("py.test", "--quiet", system_test_folder_path, *session.posargs)
session.run(
"py.test",
"--quiet",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_folder_path,
*session.posargs,
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
Expand Down
6 changes: 3 additions & 3 deletions synth.metadata
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/python-binary-authorization.git",
"sha": "79588df8099840dd4d5ba562e8d7e704a564e2bf"
"sha": "ace8341e008546e0eb38638bf55699a92f6c81d4"
}
},
{
Expand All @@ -19,14 +19,14 @@
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "33366574ffb9e11737b3547eb6f020ecae0536e8"
"sha": "d17674372e27fb8f23013935e794aa37502071aa"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "33366574ffb9e11737b3547eb6f020ecae0536e8"
"sha": "d17674372e27fb8f23013935e794aa37502071aa"
}
}
],
Expand Down

0 comments on commit b6e095f

Please sign in to comment.