pybuilder-integration 84__tar.gz → 86__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. {pybuilder-integration-84 → pybuilder-integration-86}/PKG-INFO +1 -1
  2. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration/properties.py +2 -0
  3. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration/tasks.py +41 -21
  4. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration.egg-info/PKG-INFO +1 -1
  5. {pybuilder-integration-84 → pybuilder-integration-86}/setup.py +1 -1
  6. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration/__init__.py +0 -0
  7. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration/artifact_manager.py +0 -0
  8. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration/cloudwatchlogs_utility.py +0 -0
  9. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration/directory_utility.py +0 -0
  10. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration/exec_utility.py +0 -0
  11. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration/tool_utility.py +0 -0
  12. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration.egg-info/SOURCES.txt +0 -0
  13. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration.egg-info/dependency_links.txt +0 -0
  14. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration.egg-info/namespace_packages.txt +0 -0
  15. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration.egg-info/requires.txt +0 -0
  16. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration.egg-info/top_level.txt +0 -0
  17. {pybuilder-integration-84 → pybuilder-integration-86}/pybuilder_integration.egg-info/zip-safe +0 -0
  18. {pybuilder-integration-84 → pybuilder-integration-86}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybuilder-integration
3
- Version: 84
3
+ Version: 86
4
4
  Summary: A pybuilder plugin that runs integration tests (Tavern & Cypress) against a target.
5
5
  Home-page: https://github.com/rspitler/pybuilder-integration
6
6
  Author:
@@ -3,6 +3,7 @@ ENVIRONMENT = "ENVIRONMENT"
3
3
  ENVIRONMENT_VARIABLES = "cypress_environment_variables"
4
4
  ARTIFACT_MANAGER = "integration_artifact_manager"
5
5
  CYPRESS_TEST_DIR = "cypress_test_dir"
6
+ CYPRESS_CONFIG_FILE = "cypress_config_file"
6
7
  INTEGRATION_TARGET_URL = "integration_target_url"
7
8
  TAVERN_ADDITIONAL_ARGS = "tavern_addition_args"
8
9
  WORKING_TEST_DIR = "verify_environment_new_test_dir"
@@ -10,6 +11,7 @@ TAVERN_TEST_DIR = "tavern_test_dir"
10
11
  DEFAULT_TAVERN_TEST_DIR = "src/integrationtest/tavern"
11
12
  PROMOTE_ARTIFACT = "promote"
12
13
  ROLE = "role"
14
+ SHOULD_SKIP_LATEST = "skip_verify_latest"
13
15
  APPLICATION = "application"
14
16
  APPLICATION_GROUP = "application_group"
15
17
  RUN_PARALLEL = "pytest_parallel"
@@ -2,7 +2,7 @@ import os
2
2
  import shutil
3
3
 
4
4
  import pytest
5
- from pybuilder.core import Project, Logger, init, RequirementsFile
5
+ from pybuilder.core import Project, Logger, RequirementsFile
6
6
  from pybuilder.errors import BuildFailedException
7
7
  from pybuilder.install_utils import install_dependencies
8
8
  from pybuilder.reactor import Reactor
@@ -11,7 +11,7 @@ from pybuilder.utils import Timer
11
11
  from pybuilder_integration import exec_utility, tool_utility
12
12
  from pybuilder_integration.artifact_manager import get_artifact_manager
13
13
  from pybuilder_integration.cloudwatchlogs_utility import CloudwatchLogs
14
- from pybuilder_integration.directory_utility import prepare_dist_directory, get_working_distribution_directory, \
14
+ from pybuilder_integration.directory_utility import get_working_distribution_directory, \
15
15
  package_artifacts, prepare_reports_directory, get_local_zip_artifact_path, prepare_logs_directory
16
16
  from pybuilder_integration.properties import *
17
17
  from pybuilder_integration.tool_utility import install_cypress
@@ -24,7 +24,8 @@ def integration_artifact_push(project: Project, logger: Logger, reactor: Reactor
24
24
  artifact_file = get_local_zip_artifact_path(tool=tool, project=project, include_ending=True)
25
25
  if os.path.exists(artifact_file):
26
26
  logger.info(
27
- f"Starting upload of integration artifact: {os.path.basename(artifact_file)} to: {manager.friendly_name}")
27
+ f"Starting upload of integration artifact: {os.path.basename(artifact_file)} to: {manager.friendly_name}"
28
+ )
28
29
  manager.upload(file=artifact_file, project=project, logger=logger, reactor=reactor)
29
30
 
30
31
 
@@ -39,6 +40,13 @@ def verify_environment(project: Project, logger: Logger, reactor: Reactor):
39
40
  integration_artifact_push(project=project, logger=logger, reactor=reactor)
40
41
 
41
42
 
43
+ def _should_run_latest(test_dir, project):
44
+ if project.get_property(SHOULD_SKIP_LATEST, False):
45
+ if project.get_property(ROLE) == test_dir:
46
+ return False
47
+ return True
48
+
49
+
42
50
  def _run_tests_in_directory(dist_directory, logger, project, reactor, latest=False):
43
51
  _run_tavern_tests_in_dist_dir(dist_directory, latest, logger, project, reactor)
44
52
  _run_cypress_tests_in_dist_dir(dist_directory, latest, logger, project, reactor)
@@ -50,10 +58,10 @@ def _run_cypress_tests_in_dist_dir(dist_directory, latest, logger, project, reac
50
58
  if os.path.exists(cypress_test_path):
51
59
  logger.info(f"Found cypress tests - starting run latest: {latest}")
52
60
  if latest:
53
- for dir in os.listdir(cypress_test_path):
54
- if os.path.isdir(f"{cypress_test_path}/{dir}"):
55
- logger.info(f"Running {dir}")
56
- _run_cypress_tests_in_directory(work_dir=f"{cypress_test_path}/{dir}",
61
+ for test_dir in os.listdir(cypress_test_path):
62
+ if os.path.isdir(f"{cypress_test_path}/{test_dir}") and _should_run_latest(test_dir, project):
63
+ logger.info(f"Running {test_dir}")
64
+ _run_cypress_tests_in_directory(work_dir=f"{cypress_test_path}/{test_dir}",
57
65
  logger=logger,
58
66
  project=project,
59
67
  reactor=reactor)
@@ -72,14 +80,14 @@ def _run_tavern_tests_in_dist_dir(dist_directory, latest, logger, project, react
72
80
  if os.path.exists(tavern_test_path):
73
81
  logger.info(f"Found tavern tests - starting run latest: {latest}")
74
82
  if latest:
75
- for dir in os.listdir(tavern_test_path):
76
- if os.path.isdir(f"{tavern_test_path}/{dir}"):
77
- logger.info(f"Running {dir}")
78
- _run_tavern_tests_in_dir(test_dir=f"{tavern_test_path}/{dir}",
83
+ for tavern_dir in os.listdir(tavern_test_path):
84
+ if os.path.isdir(f"{tavern_test_path}/{tavern_dir}") and _should_run_latest(tavern_dir, project):
85
+ logger.info(f"Running {tavern_dir}")
86
+ _run_tavern_tests_in_dir(test_dir=f"{tavern_test_path}/{tavern_dir}",
79
87
  logger=logger,
80
88
  project=project,
81
89
  reactor=reactor,
82
- role=os.path.basename(dir))
90
+ role=os.path.basename(tavern_dir))
83
91
  else:
84
92
  _run_tavern_tests_in_dir(test_dir=f"{tavern_test_path}",
85
93
  logger=logger,
@@ -121,14 +129,14 @@ def _run_cypress_tests_in_directory(work_dir, logger, project, reactor: Reactor)
121
129
  f"mochaFile={results_file}"]
122
130
  if project.get_property("record_cypress", True):
123
131
  args.append('--record')
124
- _add_config_file(args, environment, work_dir)
132
+ _add_config_file(project, args, environment, work_dir)
125
133
  environment_variables = project.get_property(ENVIRONMENT_VARIABLES, {})
126
134
  logger.info(f"Running cypress on host: {target_url}")
127
135
  exec_utility.exec_command(command_name=executable, args=args,
128
136
  failure_message="Failed to execute cypress tests", log_file_name='cypress_run.log',
129
137
  project=project, reactor=reactor, logger=logger, working_dir=work_dir, report=False,
130
138
  env_vars=environment_variables)
131
- # workaround but cypress output are relative to location of cypress.json so we need to collapse
139
+ # workaround but cypress output are relative to location of cypress.json, so we need to collapse
132
140
  if os.path.exists(f"{work_dir}/target"):
133
141
  shutil.copytree(f"{work_dir}/target", "./target", dirs_exist_ok=True)
134
142
  total_time.stop()
@@ -136,13 +144,25 @@ def _run_cypress_tests_in_directory(work_dir, logger, project, reactor: Reactor)
136
144
  return True
137
145
 
138
146
 
139
- def _add_config_file(args, environment, work_dir):
140
- for ending in ['ts','json']:
141
- config_file_path = f'{environment}-config.{ending}'
142
- if os.path.exists(os.path.join(work_dir, config_file_path)):
143
- args.append("--config-file")
144
- args.append(config_file_path)
145
- return
147
+ def _add_config_file(project, args, environment, work_dir):
148
+
149
+ # Environment variable override
150
+ cypress_config_file_override = os.environ.get('CYPRESS_CONFIG_FILE')
151
+ if cypress_config_file_override:
152
+ project.set_property(CYPRESS_CONFIG_FILE, cypress_config_file_override)
153
+
154
+ # Check project for config file else test file system for environment named file
155
+ cypress_config_file = project.get_property(CYPRESS_CONFIG_FILE)
156
+ if cypress_config_file and os.path.exists(os.path.join(work_dir, cypress_config_file)):
157
+ args.append("--config-file")
158
+ args.append(cypress_config_file)
159
+ else:
160
+ for ending in ['ts', 'json']:
161
+ config_file_path = f'{environment}-config.{ending}'
162
+ if os.path.exists(os.path.join(work_dir, config_file_path)):
163
+ args.append("--config-file")
164
+ args.append(config_file_path)
165
+ return
146
166
 
147
167
 
148
168
  def verify_tavern(project: Project, logger: Logger, reactor: Reactor):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybuilder-integration
3
- Version: 84
3
+ Version: 86
4
4
  Summary: A pybuilder plugin that runs integration tests (Tavern & Cypress) against a target.
5
5
  Home-page: https://github.com/rspitler/pybuilder-integration
6
6
  Author:
@@ -21,7 +21,7 @@ class install(_install):
21
21
  if __name__ == '__main__':
22
22
  setup(
23
23
  name = 'pybuilder-integration',
24
- version = '84',
24
+ version = '86',
25
25
  description = 'A pybuilder plugin that runs integration tests (Tavern & Cypress) against a target.',
26
26
  long_description = 'A pybuilder plugin that runs integration tests against a target. This is intended to be a broader scope than unit-tests encompassing dependant functionality.',
27
27
  long_description_content_type = None,