From 15e30db3ab93255e3c4f44db71108cabdf311b2c Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Wed, 18 Mar 2020 22:32:09 +0000 Subject: [PATCH] chore: only run 2.7 tests for GAE --- .kokoro/python2.7/common.cfg | 2 +- noxfile-template.py | 36 +++++------------------------------- noxfile.py | 34 ++++------------------------------ 3 files changed, 10 insertions(+), 62 deletions(-) diff --git a/.kokoro/python2.7/common.cfg b/.kokoro/python2.7/common.cfg index c97724e1b24..c80e7bf7617 100644 --- a/.kokoro/python2.7/common.cfg +++ b/.kokoro/python2.7/common.cfg @@ -41,5 +41,5 @@ action { # Specify which tests to run env_vars: { key: "RUN_TESTS_SESSION" - value: "py2" + value: "gae" } diff --git a/noxfile-template.py b/noxfile-template.py index 31ad795f04a..055988df534 100644 --- a/noxfile-template.py +++ b/noxfile-template.py @@ -139,28 +139,9 @@ def _setup_appengine_sdk(session): "appengine/standard/" ) ] -PY3_ONLY_SAMPLES = [ - sample - for sample in ALL_TESTED_SAMPLES - if ( - str(Path(sample).absolute().relative_to(REPO_ROOT)).startswith( - "appengine/standard_python37" - ) - or str(Path(sample).absolute().relative_to(REPO_ROOT)).startswith( - "appengine/flexible/django_cloudsql" - ) - or str(Path(sample).absolute().relative_to(REPO_ROOT)).startswith("functions/") - or str(Path(sample).absolute().relative_to(REPO_ROOT)).startswith( - "bigquery/pandas-gbq-migration" - ) - or str(Path(sample).absolute().relative_to(REPO_ROOT)).startswith( - "run/" - ) - ) -] -NON_GAE_STANDARD_SAMPLES_PY2 = sorted( - list((set(ALL_TESTED_SAMPLES) - set(GAE_STANDARD_SAMPLES)) - set(PY3_ONLY_SAMPLES)) -) + +PY2_ONLY_SAMPLES = GAE_STANDARD_SAMPLES + NON_GAE_STANDARD_SAMPLES_PY3 = sorted( list(set(ALL_TESTED_SAMPLES) - set(GAE_STANDARD_SAMPLES)) ) @@ -189,7 +170,7 @@ def _session_tests(session, sample, post_install=None): @nox.session(python="2.7") -@nox.parametrize("sample", GAE_STANDARD_SAMPLES) +@nox.parametrize("sample", PY2_ONLY_SAMPLES) def gae(session, sample): """Runs py.test for an App Engine standard sample.""" @@ -199,14 +180,7 @@ def gae(session, sample): os.mkdir(os.path.join(sample, "lib")) _session_tests(session, sample, _setup_appengine_sdk) - - -@nox.session(python="2.7") -@nox.parametrize("sample", NON_GAE_STANDARD_SAMPLES_PY2) -def py2(session, sample): - """Runs py.test for a sample using Python 2.7""" - _session_tests(session, sample) - + @nox.session(python=["3.6", "3.7"]) @nox.parametrize("sample", NON_GAE_STANDARD_SAMPLES_PY3) diff --git a/noxfile.py b/noxfile.py index d4fb1ea842e..f2698931fa9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -167,26 +167,11 @@ def _setup_appengine_sdk(session): for sample in ALL_TESTED_SAMPLES if sample.startswith("./appengine/standard/") ] -PY2_ONLY_SAMPLES = GAE_STANDARD_SAMPLES -PY3_ONLY_SAMPLES = [ - sample - for sample in ALL_TESTED_SAMPLES - if ( - sample.startswith("./appengine/standard_python37") - or sample.startswith("./functions/") - or sample.startswith("./bigquery/pandas-gbq-migration") - or sample.startswith("./run/system-package") - or sample.startswith("./run/hello-broken") - ) -] -NON_GAE_STANDARD_SAMPLES_PY2 = sorted( - list((set(ALL_TESTED_SAMPLES) - set(GAE_STANDARD_SAMPLES)) - set(PY3_ONLY_SAMPLES)) -) + NON_GAE_STANDARD_SAMPLES_PY3 = sorted( - list(set(ALL_TESTED_SAMPLES) - set(PY2_ONLY_SAMPLES)) + list(set(ALL_TESTED_SAMPLES) - set(GAE_STANDARD_SAMPLES)) ) - # Filter sample directories if on a CI like Travis or Circle to only run tests # for changed samples. CHANGED_FILES = _get_changed_files() @@ -196,13 +181,9 @@ def _setup_appengine_sdk(session): ALL_TESTED_SAMPLES = _filter_samples(ALL_TESTED_SAMPLES, CHANGED_FILES) ALL_SAMPLE_DIRECTORIES = _filter_samples(ALL_SAMPLE_DIRECTORIES, CHANGED_FILES) GAE_STANDARD_SAMPLES = _filter_samples(GAE_STANDARD_SAMPLES, CHANGED_FILES) - NON_GAE_STANDARD_SAMPLES_PY2 = _filter_samples( - NON_GAE_STANDARD_SAMPLES_PY2, CHANGED_FILES + NON_GAE_STANDARD_SAMPLES_PY3 = _filter_samples( + NON_GAE_STANDARD_SAMPLES_PY3, CHANGED_FILES ) - NON_GAE_STANDARD_SAMPLES_PY3 = _filter_samples( - NON_GAE_STANDARD_SAMPLES_PY3, CHANGED_FILES - ) - def _session_tests(session, sample, post_install=None): """Runs py.test for a particular sample.""" @@ -239,13 +220,6 @@ def gae(session, sample): _session_tests(session, sample, _setup_appengine_sdk) -@nox.session(python="2.7") -@nox.parametrize("sample", NON_GAE_STANDARD_SAMPLES_PY2) -def py27(session, sample): - """Runs py.test for a sample using Python 2.7""" - _session_tests(session, sample) - - @nox.session(python="3.6") @nox.parametrize("sample", NON_GAE_STANDARD_SAMPLES_PY3) def py36(session, sample):