|
44 | 44 | # 'cloud_run' # Test session for Cloud Run application. |
45 | 45 | 'opt_in_sessions': [], |
46 | 46 |
|
47 | | - # Only relevant for the `cloud_run` session. Specify the file |
48 | | - # names for your e2e test. |
49 | | - 'cloud_run_e2e_test_files': ['e2e_test.py'], |
50 | | - |
51 | 47 | # An envvar key for determining the project id to use. Change it |
52 | | - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using |
53 | | - # a build specific Cloud project. |
| 48 | + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a |
| 49 | + # build specific Cloud project. You can also use your own string |
| 50 | + # to use your own Cloud project. |
54 | 51 | 'gcloud_project_env': 'GCLOUD_PROJECT', |
55 | 52 | # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', |
56 | 53 |
|
@@ -143,11 +140,25 @@ def lint(session): |
143 | 140 | session.install("flake8", "flake8-import-order") |
144 | 141 |
|
145 | 142 | local_names = _determine_local_import_names(".") |
146 | | - args = FLAKE8_COMMON_ARGS + [ |
| 143 | + options = [ |
147 | 144 | "--application-import-names", |
148 | | - ",".join(local_names), |
149 | | - ".", |
| 145 | + ",".join(local_names) |
150 | 146 | ] |
| 147 | + |
| 148 | + # We currently look at pytest.ini for flake8 config. |
| 149 | + # You can add your own exclude and ignore by using `extend-` |
| 150 | + # |
| 151 | + # Example config: |
| 152 | + # [flake8] |
| 153 | + # extend-ignore = I100 |
| 154 | + # extend-exclude = myapp1,myapp2 |
| 155 | + if os.path.isfile("pytest.ini"): |
| 156 | + options += [ |
| 157 | + "--append-config", |
| 158 | + "pytest.ini", |
| 159 | + ] |
| 160 | + options.append(".") |
| 161 | + args = FLAKE8_COMMON_ARGS + options |
151 | 162 | session.run("flake8", *args) |
152 | 163 |
|
153 | 164 |
|
@@ -199,37 +210,10 @@ def py(session): |
199 | 210 | @nox.session |
200 | 211 | def cloud_run(session): |
201 | 212 | """Run tests for cloud run.""" |
202 | | - if 'cloud_run' not in TEST_CONFIG['opt_in_sessions']: |
| 213 | + if 'cloud_run' in TEST_CONFIG['opt_in_sessions']: |
| 214 | + _session_tests(session) |
| 215 | + else: |
203 | 216 | session.skip('SKIPPED: cloud_run tests are disabled for this sample.') |
204 | | - return |
205 | | - |
206 | | - if os.path.exists("requirements.txt"): |
207 | | - session.install("-r", "requirements.txt") |
208 | | - |
209 | | - if os.path.exists("requirements-test.txt"): |
210 | | - session.install("-r", "requirements-test.txt") |
211 | | - |
212 | | - user_envs = get_pytest_env_vars() |
213 | | - |
214 | | - # Activate service account on Kokoro. |
215 | | - if os.environ.get("KOKORO_JOB_NAME"): |
216 | | - # Activate service account |
217 | | - key_file = os.environ['GOOGLE_APPLICATION_CREDENTIALS'] |
218 | | - session.run( |
219 | | - "gcloud", "auth", "activate-service-account", |
220 | | - "--key-file={}".format(key_file) |
221 | | - ) |
222 | | - |
223 | | - test_files = TEST_CONFIG['cloud_run_e2e_test_files'] |
224 | | - session.run( |
225 | | - "pytest", |
226 | | - *(PYTEST_COMMON_ARGS + session.posargs + test_files), |
227 | | - # Pytest will return 5 when no tests are collected. This can happen |
228 | | - # on travis where slow and flaky tests are excluded. |
229 | | - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html |
230 | | - success_codes=[0, 5], |
231 | | - env=user_envs |
232 | | - ) |
233 | 217 |
|
234 | 218 | # |
235 | 219 | # Readmegen |
|
0 commit comments