|
2 | 2 |
|
3 | 3 | import os |
4 | 4 | import re |
| 5 | +import shutil |
5 | 6 | import subprocess |
6 | 7 | import tempfile |
7 | 8 | from pathlib import Path |
8 | 9 |
|
| 10 | +import pytest |
9 | 11 | import yaml |
10 | 12 |
|
11 | 13 |
|
@@ -34,21 +36,28 @@ def test_package_workflow_resolves_branch_source_ref_for_testpypi_dispatch() -> |
34 | 36 | workflow = yaml.safe_load((root / ".github/workflows/package.yml").read_text(encoding="utf-8")) |
35 | 37 | metadata_step = next(step for step in workflow["jobs"]["build"]["steps"] if step.get("id") == "metadata") |
36 | 38 |
|
| 39 | + bash = shutil.which("bash") |
| 40 | + if bash is None: |
| 41 | + pytest.skip("bash is required to execute the workflow metadata step") |
| 42 | + |
37 | 43 | with tempfile.TemporaryDirectory() as directory: |
38 | | - output_path = Path(directory) / "github-output" |
| 44 | + sandbox = Path(directory) |
| 45 | + (sandbox / "VERSION").write_text((root / "VERSION").read_text(encoding="utf-8"), encoding="utf-8") |
| 46 | + output_name = "github-output" |
| 47 | + output_path = sandbox / output_name |
39 | 48 | environment = os.environ.copy() |
40 | 49 | environment.update( |
41 | 50 | { |
42 | 51 | "GITHUB_REF": "refs/heads/testpypi-rehearsal", |
43 | 52 | "GITHUB_REF_TYPE": "branch", |
44 | 53 | "GITHUB_SHA": "a" * 40, |
45 | | - "GITHUB_OUTPUT": str(output_path), |
| 54 | + "GITHUB_OUTPUT": output_name, |
46 | 55 | "REQUESTED_RELEASE_TAG": "", |
47 | 56 | } |
48 | 57 | ) |
49 | 58 | subprocess.run( |
50 | | - ["bash", "-euo", "pipefail", "-c", metadata_step["run"]], |
51 | | - cwd=root, |
| 59 | + [bash, "-euo", "pipefail", "-c", metadata_step["run"]], |
| 60 | + cwd=sandbox, |
52 | 61 | env=environment, |
53 | 62 | check=True, |
54 | 63 | capture_output=True, |
@@ -116,7 +125,6 @@ def test_package_workflow_gates_tag_publication_on_release_documentation() -> No |
116 | 125 | assert "--artifacts-dir dist" in workflow |
117 | 126 | assert "PYPI-BYTE-VERIFICATION.json" in workflow |
118 | 127 | assert "if: ${{ always() }}" in workflow |
119 | | - assert "needs: [build, smoke, provenance, publish, attest, verify_pypi]" in workflow |
120 | 128 | assert "needs: [build, smoke, provenance, attest, verify_attestations, publish, verify_pypi]" in workflow |
121 | 129 |
|
122 | 130 |
|
|
0 commit comments