Skip to content

Commit c2861c6

Browse files
author
Takashi Matsuo
committed
changed the filename
also simplified the config stop runnint `gcloud update` add a warning about editing noxfile.py
1 parent e23b853 commit c2861c6

File tree

3 files changed

+34
-57
lines changed

3 files changed

+34
-57
lines changed

test_config.py renamed to monitoring/api/v3/alerts-client/noxfile_config.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# the noxfile.py.
1919

2020
# The source of truth:
21-
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/test_config.py
21+
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py
2222

2323
TEST_CONFIG_OVERRIDE = {
2424
# You can opt out from the test for specific Python versions.
@@ -33,17 +33,11 @@
3333
# names for your e2e test.
3434
'cloud_run_e2e_test_files': ['e2e_test.py'],
3535

36-
# If set to True, the test will install the library from the root
37-
# of the repository.
38-
'install_library_from_source': False,
39-
40-
# Set to True if you want to use the Cloud Project configured for each
41-
# build.
42-
'use_build_specific_project': False,
43-
44-
# An envvar key for determining the build specific project. Normally you
45-
# don't have to modify this.
46-
'build_specific_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT_ENV',
36+
# An envvar key for determining the project id to use. Change it
37+
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using
38+
# a build specific Cloud project.
39+
# 'gcloud_project_env': 'GCLOUD_PROJECT',
40+
'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
4741

4842
# A dictionary you want to inject into your test. Don't put any
4943
# secrets here. These values will override predefined values.

noxfile-template.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@
1919

2020
import nox
2121

22+
# WARNING - WARNING - WARNING - WARNING - WARNING
23+
# WARNING - WARNING - WARNING - WARNING - WARNING
24+
# DO NOT EDIT THIS FILE EVER!
25+
# WARNING - WARNING - WARNING - WARNING - WARNING
26+
# WARNING - WARNING - WARNING - WARNING - WARNING
27+
28+
# Copy `noxfile_config.py` to your directory and modify it instead.
29+
2230

2331
# `TEST_CONFIG` dict is a configuration hook that allows users to
2432
# modify the test configurations. The values here should be in sync
25-
# with `test_config.py`. Users will copy `test_config.py` into their
26-
# directory and modify it.
33+
# with `noxfile_config.py`. Users will copy `noxfile_config.py` into
34+
# their directory and modify it.
2735

2836
TEST_CONFIG = {
2937
# You can opt out from the test for specific Python versions.
@@ -38,42 +46,35 @@
3846
# names for your e2e test.
3947
'cloud_run_e2e_test_files': ['e2e_test.py'],
4048

41-
# If set to True, the test will install the library from the root
42-
# of the repository.
43-
'install_library_from_source': False,
44-
45-
# Set to True if you want to use the Cloud Project configured for each
46-
# build.
47-
'use_build_specific_project': False,
48-
49-
# An envvar key for determining the build specific project. Normally you
50-
# don't have to modify this.
51-
'build_specific_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
49+
# An envvar key for determining the project id to use. Change it
50+
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using
51+
# a build specific Cloud project.
52+
'gcloud_project_env': 'GCLOUD_PROJECT',
53+
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
5254

5355
# A dictionary you want to inject into your test. Don't put any
5456
# secrets here. These values will override predefined values.
5557
'envs': {},
5658
}
5759

5860
try:
59-
from test_config import TEST_CONFIG_OVERRIDE
61+
from noxfile_config import TEST_CONFIG_OVERRIDE
6062
except ImportError:
6163
TEST_CONFIG_OVERRIDE = {}
6264

63-
# Update the TEST_CONFIG with user supplied values.
65+
# Update the TEST_CONFIG with the user supplied values.
6466
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
6567

6668

6769
def get_pytest_env_vars():
6870
"""Returns a dict for pytest invocation."""
6971
ret = {}
7072

71-
# Override the GCLOUD_PROJECT
72-
if TEST_CONFIG['use_build_specific_project']:
73-
env_key = TEST_CONFIG['build_specific_project_env']
74-
# This should error out if not set.
75-
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
76-
ret['GCLOUD_PROJECT'] = os.environ[env_key]
73+
# Override the GCLOUD_PROJECT and the alias.
74+
env_key = TEST_CONFIG['gcloud_project_env']
75+
# This should error out if not set.
76+
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
77+
ret['GCLOUD_PROJECT'] = os.environ[env_key]
7778

7879
# Apply user supplied envs.
7980
ret.update(TEST_CONFIG['envs'])
@@ -204,9 +205,6 @@ def cloud_run(session):
204205

205206
# Only update gcloud on Kokoro.
206207
if os.environ.get("KOKORO_JOB_NAME"):
207-
# Update gcloud
208-
session.run("gcloud", "components", "update", "--quiet")
209-
210208
# Activate service account
211209
key_file = os.environ['GOOGLE_APPLICATION_CREDENTIALS']
212210
session.run(

monitoring/api/v3/alerts-client/test_config.py renamed to noxfile_config.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
16-
17-
# Temporary set BUILD_SPECIFIC_GCLOUD_PROJECT in this file.
18-
kokoro_job_name = os.environ.get('KOKORO_JOB_NAME')
19-
if kokoro_job_name and 'python3.7' in kokoro_job_name:
20-
os.environ['BUILD_SPECIFIC_GCLOUD_PROJECT'] = 'tmatsuo-test'
21-
else:
22-
os.environ['BUILD_SPECIFIC_GCLOUD_PROJECT'] = os.environ['GCLOUD_PROJECT']
23-
2415
# Default TEST_CONFIG_OVERRIDE for python repos.
2516

2617
# You can copy this file into your directory, then it will be inported from
2718
# the noxfile.py.
2819

2920
# The source of truth:
30-
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/test_config.py
21+
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py
3122

3223
TEST_CONFIG_OVERRIDE = {
3324
# You can opt out from the test for specific Python versions.
@@ -42,17 +33,11 @@
4233
# names for your e2e test.
4334
'cloud_run_e2e_test_files': ['e2e_test.py'],
4435

45-
# If set to True, the test will install the library from the root
46-
# of the repository.
47-
'install_library_from_source': False,
48-
49-
# Set to True if you want to use the Cloud Project configured for each
50-
# build.
51-
'use_build_specific_project': True,
52-
53-
# An envvar key for determining the build specific project. Normally you
54-
# don't have to modify this.
55-
'build_specific_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
36+
# An envvar key for determining the project id to use. Change it
37+
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using
38+
# a build specific Cloud project.
39+
'gcloud_project_env': 'GCLOUD_PROJECT',
40+
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
5641

5742
# A dictionary you want to inject into your test. Don't put any
5843
# secrets here. These values will override predefined values.

0 commit comments

Comments
 (0)