Skip to content

Commit d25d2cb

Browse files
build(python): exit with success status if no samples found (#225)
Source-Link: googleapis/synthtool@53ea389 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:e1793a23ae0ee9aafb2e3a53b564a351f74790dbe3c2d75f8fc3b8c43e5c036c
1 parent 07a8ce3 commit d25d2cb

9 files changed

+85
-19
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
docker:
22
image: gcr.io/repo-automation-bots/owlbot-python:latest
3-
digest: sha256:58c7342b0bccf85028100adaa3d856cb4a871c22ca9c01960d996e66c40548ce
3+
digest: sha256:e1793a23ae0ee9aafb2e3a53b564a351f74790dbe3c2d75f8fc3b8c43e5c036c

.kokoro/samples/python3.9/common.cfg

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Build logs will be here
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Specify which tests to run
11+
env_vars: {
12+
key: "RUN_TESTS_SESSION"
13+
value: "py-3.9"
14+
}
15+
16+
# Declare build specific Cloud project.
17+
env_vars: {
18+
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
19+
value: "python-docs-samples-tests-py39"
20+
}
21+
22+
env_vars: {
23+
key: "TRAMPOLINE_BUILD_FILE"
24+
value: "github/python-api-core/.kokoro/test-samples.sh"
25+
}
26+
27+
# Configure the docker image for kokoro-trampoline.
28+
env_vars: {
29+
key: "TRAMPOLINE_IMAGE"
30+
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
31+
}
32+
33+
# Download secrets for samples
34+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
35+
36+
# Download trampoline resources.
37+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
38+
39+
# Use the trampoline script to run in docker.
40+
build_file: "python-api-core/.kokoro/trampoline.sh"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}
7+
8+
env_vars: {
9+
key: "TRAMPOLINE_BUILD_FILE"
10+
value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "False"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}

.kokoro/test-samples-impl.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ set -eo pipefail
2020
# Enables `**` to include files nested inside sub-folders
2121
shopt -s globstar
2222

23-
# Exit early if samples directory doesn't exist
24-
if [ ! -d "./samples" ]; then
25-
echo "No tests run. `./samples` not found"
23+
# Exit early if samples don't exist
24+
if ! find samples -name 'requirements.txt' | grep -q .; then
25+
echo "No tests run. './samples/**/requirements.txt' not found"
2626
exit 0
2727
fi
2828

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# See https://pre-commit.com/hooks.html for more hooks
1717
repos:
1818
- repo: https://github.com/pre-commit/pre-commit-hooks
19-
rev: v3.4.0
19+
rev: v4.0.1
2020
hooks:
2121
- id: trailing-whitespace
2222
- id: end-of-file-fixer

CONTRIBUTING.rst

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In order to add a feature:
2222
documentation.
2323

2424
- The feature must work fully on the following CPython versions:
25-
3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows.
25+
2.7, 3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows.
2626

2727
- The feature must not add unnecessary dependencies (where
2828
"unnecessary" is of course subjective, but new dependencies should
@@ -68,15 +68,12 @@ Using ``nox``
6868
We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
6969

7070
- To test your changes, run unit tests with ``nox``::
71+
$ nox -s unit
7172

72-
$ nox -s unit-2.7
73-
$ nox -s unit-3.8
74-
$ ...
73+
- To run a single unit test::
7574

76-
- Args to pytest can be passed through the nox command separated by a `--`. For
77-
example, to run a single test::
75+
$ nox -s unit-3.9 -- -k <name of test>
7876

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

8178
.. note::
8279

@@ -143,18 +140,16 @@ Running System Tests
143140
- To run system tests, you can execute::
144141

145142
# Run all system tests
146-
$ nox -s system-3.8
147-
$ nox -s system-2.7
143+
$ nox -s system
148144

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

152148

153149
.. note::
154150

155-
System tests are only configured to run under Python 2.7 and
156-
Python 3.8. For expediency, we do not run them in older versions
157-
of Python 3.
151+
System tests are only configured to run under Python 2.7 and 3.8.
152+
For expediency, we do not run them in older versions of Python 3.
158153

159154
This alone will not run the tests. You'll need to change some local
160155
auth settings and change some configuration in your project to
@@ -202,11 +197,13 @@ Supported Python Versions
202197

203198
We support:
204199

200+
- `Python 2.7`_
205201
- `Python 3.6`_
206202
- `Python 3.7`_
207203
- `Python 3.8`_
208204
- `Python 3.9`_
209205

206+
.. _Python 2.7: https://docs.python.org/2.7/
210207
.. _Python 3.6: https://docs.python.org/3.6/
211208
.. _Python 3.7: https://docs.python.org/3.7/
212209
.. _Python 3.8: https://docs.python.org/3.8/
@@ -218,8 +215,8 @@ Supported versions can be found in our ``noxfile.py`` `config`_.
218215
.. _config: https://github.com/googleapis/python-api-core/blob/master/noxfile.py
219216

220217

221-
We also explicitly decided to support Python 3 beginning with version
222-
3.6. Reasons for this include:
218+
We also explicitly decided to support Python 3 beginning with version 2.7.
219+
Reasons for this include:
223220

224221
- Encouraging use of newest versions of Python 3
225222
- Taking the lead of `prominent`_ open-source `projects`_

0 commit comments

Comments
 (0)