spl-core 7.7.0__py3-none-any.whl → 7.8.0rc1__py3-none-any.whl

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.
spl_core/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "7.7.0"
1
+ __version__ = "7.8.0-rc.1"
@@ -0,0 +1,99 @@
1
+ from dataclasses import dataclass
2
+ from pathlib import Path
3
+ from typing import List, Optional
4
+
5
+ from mashumaro.mixins.json import DataClassJSONMixin
6
+ from py_app_dev.core.logging import logger
7
+ from py_app_dev.core.subprocess import SubprocessExecutor
8
+ from pypeline.domain.pipeline import PipelineStep
9
+ from pypeline_semantic_release.steps import CIContext
10
+
11
+
12
+ @dataclass
13
+ class PR_Changes(DataClassJSONMixin):
14
+ """Dataclass for storing PR changes."""
15
+
16
+ ci_system: str
17
+ target_branch: str
18
+ current_branch: str
19
+ commit_id: str
20
+ changed_files: List[str]
21
+
22
+
23
+ class CollectPRChanges(PipelineStep):
24
+ """Collect changed files from a pull request."""
25
+
26
+ def run(self) -> None:
27
+ logger.info(f"{self.get_name()}")
28
+ ci_contexts = self.execution_context.data_registry.find_data(CIContext)
29
+ if len(ci_contexts) > 0:
30
+ ci_context = ci_contexts[0]
31
+ logger.info(f"CI context: {ci_context}")
32
+ if ci_context.is_pull_request:
33
+ logger.info(f"Collecting PR changes between branch {ci_context.target_branch} and {ci_context.current_branch}")
34
+ changed_files = self._get_changed_files(ci_context.target_branch, ci_context.current_branch)
35
+ output_file = self.get_outputs()[0]
36
+ output_file.parent.mkdir(parents=True, exist_ok=True)
37
+ output_file.write_text(
38
+ str(
39
+ PR_Changes(
40
+ ci_system=ci_context.ci_system.name, target_branch=ci_context.target_branch, current_branch=ci_context.current_branch, commit_id=self._get_commit_id(ci_context), changed_files=changed_files
41
+ ).to_json()
42
+ ),
43
+ encoding="utf-8",
44
+ )
45
+ logger.info(f"PR changes saved to {output_file}")
46
+
47
+ def _get_changed_files(self, target_branch: str, current_branch: str) -> List[str]:
48
+ """Get list of changed files in the current branch/PR"""
49
+ try:
50
+ result = SubprocessExecutor(["git", "fetch", "origin", current_branch]).execute(handle_errors=False)
51
+ if result and result.returncode == 0:
52
+ result = SubprocessExecutor(["git", "diff", "--name-only", f"origin/{target_branch}...origin/{current_branch}"]).execute(handle_errors=False)
53
+
54
+ if result and result.returncode == 0 and result.stdout.strip():
55
+ files = [line.strip() for line in result.stdout.strip().split("\n") if line.strip()]
56
+ return files
57
+
58
+ except Exception as e:
59
+ logger.error(f"Git command failed: {e}")
60
+ return [] # Ensure a list is always returned
61
+ return []
62
+
63
+ def get_inputs(self) -> List[Path]:
64
+ return []
65
+
66
+ def get_outputs(self) -> List[Path]:
67
+ return [self.output_dir.joinpath("pr_changes.json")]
68
+
69
+ def get_name(self) -> str:
70
+ return self.__class__.__name__
71
+
72
+ def update_execution_context(self) -> None:
73
+ pass
74
+
75
+ def get_config(self) -> dict[str, str] | None:
76
+ """
77
+ Get runnable configuration.
78
+
79
+ (!) Do NOT put sensitive information in the configuration. It will be stored in a file.
80
+ """
81
+ return {"latest_commit": self._get_commit_id()}
82
+
83
+ def _get_commit_id(self, ci_context: Optional[CIContext] = None) -> str:
84
+ """Get the latest commit ID in the current branch."""
85
+ try:
86
+ if not ci_context:
87
+ ci_contexts = self.execution_context.data_registry.find_data(CIContext)
88
+ if len(ci_contexts) == 0:
89
+ logger.info("No CI context found.")
90
+ return ""
91
+ ci_context = ci_contexts[0]
92
+ logger.info(f"CI context: {ci_context}")
93
+ if isinstance(ci_context, CIContext) and ci_context.is_pull_request:
94
+ result = SubprocessExecutor(["git", "rev-parse", f"origin/{ci_context.current_branch}"]).execute(handle_errors=False)
95
+ if result and result.returncode == 0:
96
+ return result.stdout.strip()
97
+ except Exception as e:
98
+ logger.info(f"Failed to get commit ID: {e}")
99
+ return ""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: spl-core
3
- Version: 7.7.0
3
+ Version: 7.8.0rc1
4
4
  Summary: Software Product Line Support for CMake
5
5
  License: MIT
6
6
  Author: Avengineers
@@ -23,6 +23,7 @@ Requires-Dist: kconfiglib (>=14.1,<15.0)
23
23
  Requires-Dist: mlx-traceability (>=10.0,<11.0)
24
24
  Requires-Dist: myst-parser (>=0.16)
25
25
  Requires-Dist: py-app-dev (>=2.1,<3.0)
26
+ Requires-Dist: pypeline-semantic-release (>=0.4.1,<0.5.0)
26
27
  Requires-Dist: sphinx (>=7.3,<8.0)
27
28
  Requires-Dist: sphinx-book-theme (>=1.1,<2.0)
28
29
  Requires-Dist: sphinx-copybutton (>=0.5,<0.6)
@@ -1,4 +1,4 @@
1
- spl_core/__init__.py,sha256=47fvHIkSmhyHn0x0ry3g-q6AbbaUsW0cVGEQdzOPvBw,22
1
+ spl_core/__init__.py,sha256=GRRA8g5ffdV82Y5XdlAFf1TTG9dlmQbKuqrPmT3tho0,27
2
2
  spl_core/__run.py,sha256=DphnN7_Bjiw_mOOztsHxTDHS8snz1g2MMWAaJpZxPKM,361
3
3
  spl_core/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  spl_core/common/path.py,sha256=sDujd3n4XP1XGjHc7ImXEdjihO6A8BOIDbKCf7HgQ0Y,462
@@ -59,11 +59,12 @@ spl_core/kickstart/templates/project/tools/toolchains/clang/toolchain.cmake,sha2
59
59
  spl_core/kickstart/templates/project/tools/toolchains/gcc/toolchain.cmake,sha256=AmLzPyhTgfc_Dsre4AlsvSOkVGW6VswWvrEnUL8JLhA,183
60
60
  spl_core/main.py,sha256=_hL4j155WZMXog_755bgAH1PeUwvTdJZvVdVw9EWhvo,1225
61
61
  spl_core/spl.cmake,sha256=W8h-Zj-N302qxMrRG8MhoEkJ0io92bWGp4Y5r8LBQnc,4535
62
+ spl_core/steps/collect_pr_changes.py,sha256=2izqHH9kG6ozBnh1HN2dX0C4o9dU2vvq9xCB8yYSYLY,4281
62
63
  spl_core/test_utils/archive_artifacts_collection.py,sha256=x7LH5dGIvssyhXsTFzB6rjgb5D2efKvHVpnjId3MNDk,5126
63
64
  spl_core/test_utils/base_variant_test_runner.py,sha256=Oq27lkJlpB_y-p2_8S23F5zjn1438HW148q-hQNz3EY,3795
64
65
  spl_core/test_utils/spl_build.py,sha256=bSM6hwhTH9aRryvUvtSPDfk_zoZuKEO5g3QXK4SIrco,8442
65
- spl_core-7.7.0.dist-info/LICENSE,sha256=UjjA0o8f5tT3wVm7qodTLAhPWLl6kgVyn9FPAd1VeYY,1099
66
- spl_core-7.7.0.dist-info/METADATA,sha256=vQKMDRbm6_XfeGLUHER-VjAWu78M3xPExLG7ZfkUvqc,5157
67
- spl_core-7.7.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
68
- spl_core-7.7.0.dist-info/entry_points.txt,sha256=18_sdVY93N1GVBiAHxQ_F9ZM-bBvOmVMOMn7PNe2EqU,45
69
- spl_core-7.7.0.dist-info/RECORD,,
66
+ spl_core-7.8.0rc1.dist-info/LICENSE,sha256=UjjA0o8f5tT3wVm7qodTLAhPWLl6kgVyn9FPAd1VeYY,1099
67
+ spl_core-7.8.0rc1.dist-info/METADATA,sha256=Zrld_N3uhLTstu9K15tNlz4Hl9MeBF0OosW-DjPj3Ig,5218
68
+ spl_core-7.8.0rc1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
69
+ spl_core-7.8.0rc1.dist-info/entry_points.txt,sha256=18_sdVY93N1GVBiAHxQ_F9ZM-bBvOmVMOMn7PNe2EqU,45
70
+ spl_core-7.8.0rc1.dist-info/RECORD,,