diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..a6b7d3d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [ dev ] + pull_request: + branches: [ dev ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.14" + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run tests + run: pytest + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.14" + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run pylint + run: pylint src --rcfile=.pylintrc --fail-under=9.5 diff --git a/.gitignore b/.gitignore index bda025b..2ab8488 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .idea /generation -src/utils/generation/ __pycache__/ .python-version diff --git a/.pylintrc b/.pylintrc index 86c9322..8417cf1 100644 --- a/.pylintrc +++ b/.pylintrc @@ -99,10 +99,6 @@ recursive=no # source root. source-roots= -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. unsafe-load-any-extension=no diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e85ba17 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.pytest.ini_options] +pythonpath = ["src"] +testpaths = ["test"] diff --git a/requirements.txt b/requirements.txt index 19dd031..5247ce4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ black~=26.5.1 pylint~=4.0.2 flake8~=7.3.0 mypy~=2.3.0 -pillow~=12.3.0 \ No newline at end of file +pillow~=12.3.0 +pytest~=9.1.1 \ No newline at end of file diff --git a/src/utils/globals.py b/src/utils/globals.py index 33a7388..f14beb9 100644 --- a/src/utils/globals.py +++ b/src/utils/globals.py @@ -52,9 +52,8 @@ class Color(Enum): # Json BASE_INDENT = " " JSON_SUFFIX = ".json" -APPLICATION_PATH = os.path.realpath( - os.path.dirname(__file__).replace("\\src", "").replace("\\utils", "") -) +_CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) +APPLICATION_PATH = os.path.dirname(os.path.dirname(_CURRENT_DIR)) DEFAULT_FLOOR_NAME = "floor" DEFAULT_FLOOR_DIRECTORY = "generation" diff --git a/test/floor_test.py b/test/floor_test.py index 8fa85b1..5a273a6 100644 --- a/test/floor_test.py +++ b/test/floor_test.py @@ -18,7 +18,7 @@ def setUp(self) -> None: self._floor_with_rooms.add_room(5, 5) def test_to_json(self): - expected = '{\n "_rooms": []\n}' + expected = '{\n "_seed": "1",\n "_rooms": []\n}' self.assertEqual(expected, self._floor.to_json(1)) def test_contains_room(self): diff --git a/test/globals_test.py b/test/globals_test.py index dded816..383cf6c 100644 --- a/test/globals_test.py +++ b/test/globals_test.py @@ -49,7 +49,7 @@ def test_door_faces(self): self.assertEqual(expected, globals.DoorFace.list()) def test_room_types(self): - expected = [0, 1, 2, 3, 4, 5, 6] + expected = [0, 1, 2, 3, 4, 5, 6, 7] self.assertEqual(expected, RoomType.list()) def test_special_rooms(self): @@ -62,15 +62,16 @@ def test_door_color(self): def test_room_colors(self): expected = { - RoomType.NORMAL_ROOM: Color.VIOLET, - RoomType.DEAD_END: Color.VIOLET, + RoomType.NORMAL_ROOM: Color.LIGHT_GRAY, + RoomType.DEAD_END: Color.LIGHT_GRAY, RoomType.ITEM_ROOM: Color.GREEN, RoomType.SHOP_ROOM: Color.YELLOW, RoomType.START_ROOM: Color.ORANGE, - RoomType.TELEPORT_ROOM: Color.GRAY, + RoomType.TELEPORT_ROOM: Color.VIOLET, RoomType.BOSS_ROOM: Color.RED, + RoomType.SECRET_ROOM: Color.BLUE, } - self.assertEqual(expected, globals.Room_Colors) + self.assertEqual(expected, room_type.room_colors) def test_room_width(self): self.assertEqual(120, globals.ROOM_WIDTH) @@ -91,10 +92,8 @@ def test_json_suffix(self): self.assertEqual(".json", globals.JSON_SUFFIX) def test_path(self): - self.assertEqual( - os.path.realpath(os.path.dirname(__file__).replace("\\test", "")), - globals.APPLICATION_PATH, - ) + project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + self.assertEqual(project_root, globals.APPLICATION_PATH) if __name__ == "__main__":