Skip to content

Commit 2ff31b7

Browse files
committed
test: make package metadata regression portable
1 parent 41aa348 commit 2ff31b7

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎tests/test_package_workflow.py‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import os
44
import re
5+
import shutil
56
import subprocess
67
import tempfile
78
from pathlib import Path
89

10+
import pytest
911
import yaml
1012

1113

@@ -34,21 +36,28 @@ def test_package_workflow_resolves_branch_source_ref_for_testpypi_dispatch() ->
3436
workflow = yaml.safe_load((root / ".github/workflows/package.yml").read_text(encoding="utf-8"))
3537
metadata_step = next(step for step in workflow["jobs"]["build"]["steps"] if step.get("id") == "metadata")
3638

39+
bash = shutil.which("bash")
40+
if bash is None:
41+
pytest.skip("bash is required to execute the workflow metadata step")
42+
3743
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
3948
environment = os.environ.copy()
4049
environment.update(
4150
{
4251
"GITHUB_REF": "refs/heads/testpypi-rehearsal",
4352
"GITHUB_REF_TYPE": "branch",
4453
"GITHUB_SHA": "a" * 40,
45-
"GITHUB_OUTPUT": str(output_path),
54+
"GITHUB_OUTPUT": output_name,
4655
"REQUESTED_RELEASE_TAG": "",
4756
}
4857
)
4958
subprocess.run(
50-
["bash", "-euo", "pipefail", "-c", metadata_step["run"]],
51-
cwd=root,
59+
[bash, "-euo", "pipefail", "-c", metadata_step["run"]],
60+
cwd=sandbox,
5261
env=environment,
5362
check=True,
5463
capture_output=True,
@@ -116,7 +125,6 @@ def test_package_workflow_gates_tag_publication_on_release_documentation() -> No
116125
assert "--artifacts-dir dist" in workflow
117126
assert "PYPI-BYTE-VERIFICATION.json" in workflow
118127
assert "if: ${{ always() }}" in workflow
119-
assert "needs: [build, smoke, provenance, publish, attest, verify_pypi]" in workflow
120128
assert "needs: [build, smoke, provenance, attest, verify_attestations, publish, verify_pypi]" in workflow
121129

122130

0 commit comments

Comments
 (0)