Skip to content

Commit 4b20d95

Browse files
moving guard from inline in tests.yml
1 parent aa85b93 commit 4b20d95

2 files changed

Lines changed: 32 additions & 14 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,7 @@ jobs:
5757
- name: Check pywebview pin is single-sourced
5858
run: |
5959
python scripts/read_desktop_pywebview_spec.py
60-
python <<'PY'
61-
import sys
62-
from pathlib import Path
63-
64-
for path in sorted(Path(".github/workflows").glob("*.yml")):
65-
text = path.read_text()
66-
if "pywebview>=" in text or "pywebview<" in text:
67-
print(f"{path} hardcodes a pywebview version; use scripts/read_desktop_pywebview_spec.py", file=sys.stderr)
68-
sys.exit(1)
69-
if "read_desktop_pywebview_spec.py" not in text and "pywebview" in text.lower():
70-
if path.name in ("release.yml", "tests.yml"):
71-
print(f"{path} installs pywebview but does not read the pin from pyproject", file=sys.stderr)
72-
sys.exit(1)
73-
PY
60+
python scripts/check_pywebview_workflow_pin.py
7461
7562
- name: Install pip-tools
7663
# Pin matches update-lock.yml so lock verification uses the same resolver.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Fail if workflow YAML hardcodes a pywebview version instead of read_desktop_pywebview_spec."""
2+
3+
from __future__ import annotations
4+
5+
import sys
6+
from pathlib import Path
7+
8+
READ_SCRIPT = "read_desktop_pywebview_spec.py"
9+
PYWEBVIEW_INSTALL_WORKFLOWS = ("release.yml", "tests.yml")
10+
11+
12+
def main() -> None:
13+
for path in sorted(Path(".github/workflows").glob("*.yml")):
14+
text = path.read_text()
15+
if "pywebview>=" in text or "pywebview<" in text:
16+
print(
17+
f"{path} hardcodes a pywebview version; use scripts/{READ_SCRIPT}",
18+
file=sys.stderr,
19+
)
20+
raise SystemExit(1)
21+
if READ_SCRIPT not in text and "pywebview" in text.lower():
22+
if path.name in PYWEBVIEW_INSTALL_WORKFLOWS:
23+
print(
24+
f"{path} installs pywebview but does not read the pin from pyproject",
25+
file=sys.stderr,
26+
)
27+
raise SystemExit(1)
28+
29+
30+
if __name__ == "__main__":
31+
main()

0 commit comments

Comments
 (0)