gitlab-runner-tart-driver 0.3.3__tar.gz → 0.3.4__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. {gitlab-runner-tart-driver-0.3.3/gitlab_runner_tart_driver.egg-info → gitlab-runner-tart-driver-0.3.4}/PKG-INFO +1 -8
  2. gitlab-runner-tart-driver-0.3.4/gitlab_runner_tart_driver/__init__.py +1 -0
  3. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/commands/prepare.py +14 -8
  4. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/commands/run.py +19 -3
  5. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4/gitlab_runner_tart_driver.egg-info}/PKG-INFO +1 -8
  6. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/setup.py +1 -1
  7. gitlab-runner-tart-driver-0.3.3/gitlab_runner_tart_driver/__init__.py +0 -1
  8. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/LICENSE.txt +0 -0
  9. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/MANIFEST.in +0 -0
  10. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/README.md +0 -0
  11. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/__main__.py +0 -0
  12. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/cli.py +0 -0
  13. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/commands/__init__.py +0 -0
  14. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/commands/cleanup.py +0 -0
  15. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/commands/config.py +0 -0
  16. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/modules/__init__.py +0 -0
  17. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/modules/gitlab_custom_command_config.py +0 -0
  18. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/modules/gitlab_custom_driver_config.py +0 -0
  19. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/modules/tart.py +0 -0
  20. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/modules/utils.py +0 -0
  21. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver/scripts/install-gitlab-runner.sh.j2 +0 -0
  22. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver.egg-info/SOURCES.txt +0 -0
  23. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver.egg-info/dependency_links.txt +0 -0
  24. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver.egg-info/entry_points.txt +0 -0
  25. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver.egg-info/not-zip-safe +0 -0
  26. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver.egg-info/requires.txt +0 -0
  27. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/gitlab_runner_tart_driver.egg-info/top_level.txt +0 -0
  28. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/pyproject.toml +0 -0
  29. {gitlab-runner-tart-driver-0.3.3 → gitlab-runner-tart-driver-0.3.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitlab-runner-tart-driver
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Home-page: https://gitlab.com/schmieder.matthias/gitlab-runner-tart-driver
5
5
  Author: Matthias Schmieder
6
6
  Author-email: schmieder.matthias@gmail.com
@@ -12,13 +12,6 @@ Classifier: Topic :: Software Development :: Version Control
12
12
  Requires-Python: >=3.9
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE.txt
15
- Requires-Dist: click
16
- Requires-Dist: pydantic>=2.0.0
17
- Requires-Dist: pydantic-settings
18
- Requires-Dist: paramiko
19
- Requires-Dist: psutil
20
- Requires-Dist: tabulate
21
- Requires-Dist: jinja2
22
15
 
23
16
  # Gitlab Runner Custom Tart Driver
24
17
 
@@ -0,0 +1 @@
1
+ __version__ = "0.3.4"
@@ -115,6 +115,12 @@ def prepare(
115
115
  if not p.tart_executor_timeout:
116
116
  p.tart_executor_timeout = timeout
117
117
 
118
+ # retrieve the SYSTEM_FAILURE_EXIT_CODE from the environment
119
+ system_failure_exit_code = os.getenv("SYSTEM_FAILURE_EXIT_CODE", None)
120
+ if not system_failure_exit_code:
121
+ click.secho("[WARNING] SYSTEM_FAILURE_EXIT_CODE not set, defaulting to '1'", fg="red")
122
+ system_failure_exit_code = 1
123
+
118
124
  tart = Tart(exec_path=tart_executable)
119
125
  tart_images = tart.list()
120
126
  tart_vm_map = {}
@@ -157,7 +163,7 @@ def prepare(
157
163
  tart.pull(p.ci_job_image)
158
164
  except:
159
165
  click.secho(f"[ERROR] Failed to pull image '{p.ci_job_image}'", fg="red")
160
- sys.exit(1)
166
+ sys.exit(system_failure_exit_code)
161
167
  else:
162
168
  click.echo(f"[INFO] Skipping '{p.ci_job_image}' [pull_policy={p.pull_policy}]")
163
169
 
@@ -182,14 +188,14 @@ def prepare(
182
188
  click.secho(
183
189
  f"[ERROR] The limit of running VMs [{p.tart_max_vm_count}] is exceeded [{len(list_running_vms)}].", fg="red"
184
190
  )
185
- sys.exit(1)
191
+ sys.exit(system_failure_exit_code)
186
192
 
187
193
  click.echo(f"[INFO] Cloning VM instance '{tart_vm_name}' from '{p.ci_job_image}'")
188
194
  try:
189
195
  tart.clone(p.ci_job_image, tart_vm_name)
190
196
  except:
191
197
  click.secho(f"[ERROR] failed to clone image f'{p.ci_job_image}'", fg="red")
192
- sys.exit(1)
198
+ sys.exit(system_failure_exit_code)
193
199
 
194
200
  if cpu or memory or p.display:
195
201
  click.echo(f"[INFO] Configuring instance '{tart_vm_name}' from '{p.ci_job_image}'")
@@ -232,17 +238,17 @@ def prepare(
232
238
  tart.run(tart_vm_name, volume_mounts, no_graphics=p.headless, softnet=p.softnet_enabled)
233
239
  except:
234
240
  click.secho(f"[ERROR] Failed to start VM '{tart_vm_name}'", fg="red")
235
- sys.exit(1)
241
+ sys.exit(system_failure_exit_code)
236
242
 
237
243
  try:
238
244
  ip = tart.ip(tart_vm_name, timeout=p.timeout)
239
245
  except:
240
246
  click.secho(f"[ERROR] Failed to get IP of VM '{tart_vm_name}'", fg="red")
241
- sys.exit(1)
247
+ sys.exit(system_failure_exit_code)
242
248
 
243
249
  if not ip:
244
250
  click.echo(f"[ERROR] Error, VM was not reacheable after '{p.timeout}' seconds")
245
- sys.exit(1)
251
+ sys.exit(system_failure_exit_code)
246
252
 
247
253
  try:
248
254
  ssh_session = tart.ssh_session(name=p.vm_name(), username=p.ssh_username, password=p.ssh_password)
@@ -268,7 +274,7 @@ def prepare(
268
274
  )
269
275
  except:
270
276
  click.secho(f"[ERROR] Failed so prepare VM '{tart_vm_name}'", fg="red")
271
- sys.exit(1)
277
+ sys.exit(system_failure_exit_code)
272
278
 
273
279
  if p.install_gitlab_runner:
274
280
  click.echo(
@@ -278,7 +284,7 @@ def prepare(
278
284
  tart.install_gitlab_runner(name=tart_vm_name, username=p.ssh_username, password=p.ssh_password)
279
285
  except:
280
286
  click.secho(f"[ERROR] Failed to install GitLab Runner '{gitlab_runner_version}'", fg="red")
281
- sys.exit(1)
287
+ sys.exit(system_failure_exit_code)
282
288
 
283
289
  tart.print_spec(tart_vm_name)
284
290
 
@@ -32,6 +32,18 @@ def run(ssh_timeout, tart_executable, shell, script, stage):
32
32
  """Run commands."""
33
33
  p = GitLabCustomCommandConfig()
34
34
 
35
+ # retrieve the BUILD_FAILURE_EXIT_CODE from the environment
36
+ build_failure_exit_code = os.getenv("BUILD_FAILURE_EXIT_CODE", None)
37
+ if not build_failure_exit_code:
38
+ click.secho("[WARNING] BUILD_FAILURE_EXIT_CODE not set, defaulting to '1'", fg="red")
39
+ build_failure_exit_code = 1
40
+
41
+ # retrieve the SYSTEM_FAILURE_EXIT_CODE from the environment
42
+ system_failure_exit_code = os.getenv("SYSTEM_FAILURE_EXIT_CODE", None)
43
+ if not system_failure_exit_code:
44
+ click.secho("[WARNING] SYSTEM_FAILURE_EXIT_CODE not set, defaulting to '1'", fg="red")
45
+ system_failure_exit_code = 1
46
+
35
47
  if not p.tart_executor_shell:
36
48
  p.tart_executor_shell = shell
37
49
  ######################################################################
@@ -48,13 +60,13 @@ def run(ssh_timeout, tart_executable, shell, script, stage):
48
60
  f"[{stage}][ERROR] Could not establish SSH conntection to '{tart_vm_name}' after '{ssh_timeout}' seconds.",
49
61
  fg="red",
50
62
  )
51
- sys.exit(1)
63
+ sys.exit(system_failure_exit_code)
52
64
 
53
65
  try:
54
66
  ssh_session = tart.ssh_session(name=p.vm_name(), username=p.ssh_username, password=p.ssh_password)
55
67
  except:
56
68
  click.secho(f"[{stage}][ERROR] Could not establish SSH session with '{p.ssh_username}@{tart_ip}'", fg="red")
57
- sys.exit(1)
69
+ sys.exit(system_failure_exit_code)
58
70
 
59
71
  remote_temp_dir = "/opt/temp"
60
72
  script_name = os.path.basename(script)
@@ -67,4 +79,8 @@ def run(ssh_timeout, tart_executable, shell, script, stage):
67
79
  # ssh_session.exec_ssh_command(f"cd {remote_build_dir}")
68
80
  script_exit_code = ssh_session.exec_ssh_command(f"{p.shell} -l {remote_script_path}", get_pty=True)
69
81
 
70
- sys.exit(script_exit_code)
82
+ if script_exit_code != 0:
83
+ click.secho(f"[{stage}][ERROR] Script '{script}' failed with exit code '{script_exit_code}'", fg="red")
84
+ sys.exit(build_failure_exit_code)
85
+
86
+ sys.exit(0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitlab-runner-tart-driver
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Home-page: https://gitlab.com/schmieder.matthias/gitlab-runner-tart-driver
5
5
  Author: Matthias Schmieder
6
6
  Author-email: schmieder.matthias@gmail.com
@@ -12,13 +12,6 @@ Classifier: Topic :: Software Development :: Version Control
12
12
  Requires-Python: >=3.9
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE.txt
15
- Requires-Dist: click
16
- Requires-Dist: pydantic>=2.0.0
17
- Requires-Dist: pydantic-settings
18
- Requires-Dist: paramiko
19
- Requires-Dist: psutil
20
- Requires-Dist: tabulate
21
- Requires-Dist: jinja2
22
15
 
23
16
  # Gitlab Runner Custom Tart Driver
24
17
 
@@ -10,7 +10,7 @@ this_directory = os.path.abspath(os.path.dirname(__file__))
10
10
  with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
11
11
  long_description = f.read()
12
12
 
13
- version = "0.3.3"
13
+ version = "0.3.4"
14
14
 
15
15
  version = f"{version}{os.environ.get('PIP_VERSION_POSTFIX','')}"
16
16
 
@@ -1 +0,0 @@
1
- __version__ = "0.3.3"