Skip to content

Commit 1d5781a

Browse files
committed
Add repo to game requirements.txt
1 parent c350225 commit 1d5781a

3 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Repo URL Guard
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: repo-url-guard-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check-repo-url:
16+
name: Check engine.REPO_URL
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
if: github.event_name != 'push' || !github.event.repository.fork
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v5
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: "3.12"
29+
cache: "pip"
30+
31+
- name: Install dependencies
32+
shell: bash
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
37+
- name: Compare engine.REPO_URL with this repository
38+
shell: bash
39+
env:
40+
EXPECTED_URL: ${{ github.server_url }}/${{ github.repository }}
41+
run: |
42+
python - <<'PY'
43+
import os
44+
import sys
45+
46+
import engine
47+
48+
expected = os.environ["EXPECTED_URL"]
49+
actual = getattr(engine, "REPO_URL", None)
50+
51+
if actual is None:
52+
sys.exit("engine.REPO_URL is not defined.")
53+
54+
if not isinstance(actual, str):
55+
sys.exit(f"engine.REPO_URL must be a string, got {type(actual).__name__}.")
56+
57+
def normalize(url: str) -> str:
58+
return url.rstrip("/").removesuffix(".git")
59+
60+
print(f"engine.REPO_URL: {actual!r}")
61+
print(f"Expected: {expected!r}")
62+
63+
if normalize(actual) != normalize(expected):
64+
sys.exit(
65+
f"engine.REPO_URL is {actual!r} but this repository is {expected!r}. "
66+
"Update REPO_URL in engine/__init__.py."
67+
)
68+
69+
print("engine.REPO_URL matches this repository.")
70+
PY

engine/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77

88
import colorama
99

10+
REPO_URL = "https://github.com/Natuworkguy/ABS-Engine"
11+
1012
colorama.just_fix_windows_console()

engine/saveload.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from typing import Optional, Any
1212
from pathlib import Path
1313

14+
from . import REPO_URL
1415
from .logger import logger, Status as LoggerStatus
1516

1617
import sys
@@ -90,6 +91,13 @@ def save_project(engine: Any, dir_str: Optional[str] = None) -> Optional[str]:
9091
""".strip()
9192
)
9293

94+
with open(dir / "requirements.txt", "w") as f:
95+
f.write(
96+
f"""
97+
git+{REPO_URL}
98+
""".strip()
99+
)
100+
93101
messagebox.showinfo("Success", "Project saved successfully.")
94102

95103
return str(gamefile)

0 commit comments

Comments
 (0)