-
Notifications
You must be signed in to change notification settings - Fork 1
test(actions): make setup-python contract upgrade-safe #2854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bf699b0
d6521fe
99a7b1d
3246f8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| import re | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
@@ -123,9 +124,8 @@ def test_cli_reports_invalid_plan_without_writing_handoff(tmp_path: Path) -> Non | |
|
|
||
| def test_workflow_has_no_write_or_apply_surface() -> None: | ||
| root = Path(__file__).parents[2] | ||
| workflow = ( | ||
| root / ".github" / "workflows" / "health-69-consumer-sync-shadow-evidence.yml" | ||
| ).read_text(encoding="utf-8") | ||
| workflow_path = root / ".github" / "workflows" / "health-69-consumer-sync-shadow-evidence.yml" | ||
| workflow = workflow_path.read_text(encoding="utf-8") | ||
|
|
||
| assert "contents: read" in workflow | ||
| assert "contents: write" not in workflow | ||
|
|
@@ -135,7 +135,13 @@ def test_workflow_has_no_write_or_apply_surface() -> None: | |
| assert "write_authority" not in workflow.lower() or "Write authority: false" in workflow | ||
| assert "persist-credentials: false" in workflow | ||
| assert "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1" in workflow | ||
| assert "actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1" in workflow | ||
| setup_python_refs = re.findall( | ||
| r"uses:\s+actions/setup-python@[0-9a-f]{40}\s+# v\d+\b", | ||
| workflow, | ||
| ) | ||
| assert len(setup_python_refs) == 1 | ||
| assert "pull_request:" in workflow | ||
| assert f"- '{workflow_path.relative_to(root).as_posix()}'" in workflow | ||
|
Comment on lines
+138
to
+144
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Validate actual workflow steps, not matching text. The regex counts only references that already match the pinned format. A second unpinned Parse the workflow and inspect each step's As per path instructions, synced workflow checks must reject unpinned third-party actions. 🤖 Prompt for AI AgentsSource: Path instructions |
||
| assert "actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a" in workflow | ||
| assert "pyyaml==6.0.2" in workflow | ||
| assert ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| from pathlib import Path | ||
|
|
||
| import yaml | ||
|
|
@@ -19,5 +20,15 @@ def test_template_drift_workflow_installs_pyyaml_before_checker() -> None: | |
| ) | ||
| prior_steps = steps[:checker_index] | ||
|
|
||
| assert any(step.get("uses") == "actions/setup-python@v6" for step in prior_steps) | ||
| setup_python_steps = [ | ||
| step | ||
| for step in prior_steps | ||
| if re.fullmatch(r"actions/setup-python@v\d+", str(step.get("uses", ""))) | ||
| ] | ||
|
|
||
| assert len(setup_python_steps) == 1 | ||
| assert any( | ||
| re.fullmatch(r"actions/setup-python@v\d+", str(step.get("uses", ""))) | ||
| for step in prior_steps | ||
| ) | ||
|
Comment on lines
+23
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Assert interpreter setup before the PyYAML installation. The test verifies that both setup-python and If the installation runs first, PyYAML can be installed for a different interpreter. The checker can then fail after setup-python selects the configured interpreter. Record both step indexes and assert:
As per path instructions, Python changes must prioritize correctness and test coverage. 🤖 Prompt for AI AgentsSource: Path instructions |
||
| assert any("pip install pyyaml" in step.get("run", "").lower() for step in prior_steps) | ||
Uh oh!
There was an error while loading. Please reload this page.