Skip to content

Commit ac7e50b

Browse files
authored
fix(agent-integrations): bump AIX embedded Python version in patch upgrade task (#54702)
### What does this PR do? Adds a new `_prepare_aix_update` step to `tasks/python_version.py` so the `python-version.update` task also bumps `PYTHON_VERSION` in `packaging/aix/lib/env.sh`. Also updates the `upgrade-python-patch-version` workflow's PR description to mention this file, and adds a unit test covering the new function. ### Motivation PR #54696 (the automated Python patch bump) only updated the Omnibus and Bazel Python references. As flagged in [review feedback](#54696 (comment)), the AIX packaging path (`packaging/aix/lib/env.sh`, sourced by `packaging/aix/stages/02-python.sh`) has its own `PYTHON_VERSION` variable that was left out of sync, so AIX Agent builds continued embedding the old patch version. ### Describe how you validated your changes Ran the existing unit test suite plus the new `TestAixUpdate` test via `dda inv invoke-unit-tests.run --tests python_version` — all 17 tests pass. Co-authored-by: nicolas.schweitzer <nicolas.schweitzer@datadoghq.com>
1 parent 76964f2 commit ac7e50b

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

.github/workflows/upgrade-python-patch-version.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
- Updated `omnibus/config/software/python3.rb` with new version and SHA256
7777
- Updated `deps/cpython/cpython.MODULE.bazel` with new version and SHA256
7878
- Updated `test/new-e2e/tests/agent-platform/common/agent_behaviour.go` with expected version
79+
- Updated `packaging/aix/lib/env.sh` with new version
7980
- Created release note documenting the upgrade
8081
8182
### Motivation

tasks/python_version.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def update(
8989
updates.append(_prepare_omnibus_update(target_version))
9090
updates.append(_prepare_bazel_update(target_version, sha256_hash))
9191
updates.append(_prepare_test_update(target_version))
92+
updates.append(_prepare_aix_update(target_version))
9293
except Exit:
9394
# If any validation fails, don't write anything
9495
raise
@@ -292,6 +293,24 @@ def _prepare_test_update(version: str) -> tuple[Path, str]:
292293
return (file_path, new_content)
293294

294295

296+
def _prepare_aix_update(version: str) -> tuple[Path, str]:
297+
"""Prepare Python version update for the AIX packaging scripts.
298+
299+
Returns:
300+
Tuple of (file_path, new_content) ready to write
301+
"""
302+
file_path = Path("packaging/aix/lib/env.sh")
303+
content = file_path.read_text()
304+
305+
pattern = r'^(PYTHON_VERSION=")([0-9.]+)(")$'
306+
new_content, count = re.subn(pattern, rf'\g<1>{version}\g<3>', content, flags=re.MULTILINE)
307+
308+
if count != 1:
309+
raise Exit(f"Expected 1 PYTHON_VERSION match in {file_path}, found {count}")
310+
311+
return (file_path, new_content)
312+
313+
295314
def _create_releasenote(ctx: Context, old_version: str, new_version: str) -> str | None:
296315
"""Create a release note for the Python patch version update."""
297316
template = f"""---

tasks/unit_tests/python_version_tests.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,32 @@ def test_update_test_python_version(self, mock_path):
202202
self.assertIn('ExpectedPythonVersion2 = "2.7.18"', new_content)
203203

204204

205+
class TestAixUpdate(unittest.TestCase):
206+
@unittest.mock.patch('tasks.python_version.Path')
207+
def test_update_aix_python_version(self, mock_path):
208+
"""Test preparing version update for AIX packaging env.sh."""
209+
from tasks.python_version import _prepare_aix_update
210+
211+
original_content = '''# lib/env.sh — shared environment sourced by every stage script
212+
213+
PYTHON_VERSION="3.13.7"
214+
PYTHON_MAJ_MIN="${PYTHON_VERSION%.*}"
215+
export PYTHON_VERSION PYTHON_MAJ_MIN
216+
'''
217+
218+
# Mock file operations
219+
mock_file = unittest.mock.MagicMock()
220+
mock_file.read_text.return_value = original_content
221+
mock_path.return_value = mock_file
222+
223+
# Prepare update to new version
224+
file_path, new_content = _prepare_aix_update("3.13.9")
225+
226+
# Verify version was updated
227+
self.assertIn('PYTHON_VERSION="3.13.9"', new_content)
228+
self.assertNotIn('PYTHON_VERSION="3.13.7"', new_content)
229+
230+
205231
class TestGetPythonSha256Hash(unittest.TestCase):
206232
VALID_SBOM = json.dumps(
207233
{

0 commit comments

Comments
 (0)