Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build Release Artifacts

on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version for the release'
required: true
default: 'latest'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller

- name: Run tests
run: |
python -m unittest discover tests -v

- name: Build executable (Linux/macOS)
if: runner.os != 'Windows'
run: |
pyinstaller --onefile --add-data "configuration:configuration" --add-data "resources:resources" --name "space-raid-${{ runner.os }}" __init__.py

- name: Build executable (Windows)
if: runner.os == 'Windows'
run: |
pyinstaller --onefile --add-data "configuration;configuration" --add-data "resources;resources" --name "space-raid-Windows" __init__.py

- name: Create portable package (Linux/macOS)
if: runner.os != 'Windows'
run: |
mkdir -p space-raid-portable-${{ runner.os }}
cp -r configuration space-raid-portable-${{ runner.os }}/
cp -r resources space-raid-portable-${{ runner.os }}/
cp -r objects space-raid-portable-${{ runner.os }}/
cp -r other space-raid-portable-${{ runner.os }}/
cp __init__.py space-raid-portable-${{ runner.os }}/
cp requirements.txt space-raid-portable-${{ runner.os }}/
cp README.md space-raid-portable-${{ runner.os }}/
cp LICENSE space-raid-portable-${{ runner.os }}/
echo "#!/bin/bash" > space-raid-portable-${{ runner.os }}/run.sh
echo "python3 __init__.py" >> space-raid-portable-${{ runner.os }}/run.sh
chmod +x space-raid-portable-${{ runner.os }}/run.sh
tar -czf space-raid-portable-${{ runner.os }}.tar.gz space-raid-portable-${{ runner.os }}/

- name: Create portable package (Windows)
if: runner.os == 'Windows'
run: |
mkdir space-raid-portable-Windows
xcopy configuration space-raid-portable-Windows\configuration\ /E /I
xcopy resources space-raid-portable-Windows\resources\ /E /I
xcopy objects space-raid-portable-Windows\objects\ /E /I
xcopy other space-raid-portable-Windows\other\ /E /I
copy __init__.py space-raid-portable-Windows\
copy requirements.txt space-raid-portable-Windows\
copy README.md space-raid-portable-Windows\
copy LICENSE space-raid-portable-Windows\
echo python __init__.py > space-raid-portable-Windows\run.bat
powershell Compress-Archive -Path space-raid-portable-Windows -DestinationPath space-raid-portable-Windows.zip

- name: Upload executable artifacts
uses: actions/upload-artifact@v3
with:
name: space-raid-executable-${{ runner.os }}
path: |
dist/space-raid-*

- name: Upload portable artifacts (Linux/macOS)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v3
with:
name: space-raid-portable-${{ runner.os }}
path: space-raid-portable-${{ runner.os }}.tar.gz

- name: Upload portable artifacts (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: space-raid-portable-Windows
path: space-raid-portable-Windows.zip

release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'

steps:
- name: Download all artifacts
uses: actions/download-artifact@v3

- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
space-raid-*/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests
run: |
python -m unittest discover tests -p "*tests.py" -v

- name: Lint with built-in tools
run: |
python -m py_compile __init__.py
find . -name "*.py" -not -path "./other/*" -exec python -m py_compile {} \;

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r requirements.txt

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=other/py_text_input.py
22 changes: 16 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches: [ master, main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [ master, main ]
schedule:
- cron: '35 13 * * 6'

Expand All @@ -38,11 +38,21 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +63,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +77,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Space Raid
River Raid based of Space Raid implementation in Python
River Raid based Space Raid implementation in Python

How to run the game:
Install python 3.4
Install pygame (pip install pygame)
Run python __init__.py
## Requirements
- Python 3.8+ (tested with Python 3.12)

## How to run the game:
1. Install Python 3.8 or higher
2. Install dependencies: `pip install -r requirements.txt`
3. Run the game: `python __init__.py`

## Development
To run tests:
```bash
python -m unittest discover tests -v
```

47 changes: 47 additions & 0 deletions check_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
"""
Space Raid - Python Version and Environment Check
This script validates that the game is compatible with the current Python version.
"""

import sys
import pygame

def main():
print("=" * 60)
print("🚀 Space Raid - Python Environment Check")
print("=" * 60)

# Python version check
print(f"✅ Python Version: {sys.version}")
print(f"✅ Python Version Info: {sys.version_info}")

# Dependencies check
print(f"✅ Pygame Version: {pygame.version.ver}")
print(f"✅ SDL Version: {pygame.version.SDL}")

# Compatibility check
if sys.version_info >= (3, 8):
print("✅ Python version is compatible (3.8+)")
else:
print("❌ Python version is too old. Please upgrade to Python 3.8+")
return 1

# Try importing core game modules
try:
import objects.player
import objects.leaderboards.leaderboard_service
import objects.resources.ResourcesContext
print("✅ All core game modules import successfully")
except ImportError as e:
print(f"❌ Failed to import core modules: {e}")
return 1

print("=" * 60)
print("🎮 Space Raid is ready to run!")
print("To start the game: python __init__.py")
print("=" * 60)
return 0

if __name__ == '__main__':
sys.exit(main())
1 change: 1 addition & 0 deletions objects/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Objects package initialization
1 change: 1 addition & 0 deletions objects/globals/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Globals package initialization
1 change: 1 addition & 0 deletions objects/leaderboards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Leaderboards package initialization
1 change: 1 addition & 0 deletions objects/mobs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Mobs package initialization
1 change: 1 addition & 0 deletions objects/mobs/generators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Generators package initialization
1 change: 1 addition & 0 deletions objects/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Resources package initialization
1 change: 1 addition & 0 deletions objects/resources/i18n/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# i18n package initialization
1 change: 1 addition & 0 deletions objects/screens/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Screens package initialization
1 change: 1 addition & 0 deletions objects/ui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# UI package initialization
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pygame>=2.0.0
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Tests package initialization
1 change: 1 addition & 0 deletions tests/config_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Config parser tests package initialization
12 changes: 6 additions & 6 deletions tests/config_parser/config_parser_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ def test_read_from_default_section(self):
service = ConfigReader(config_reader)

single_value = service.get_config_property('some_value')
self.assertEquals('5', single_value)
self.assertEqual('5', single_value)

multi_value = service.get_config_property_value_list('list_of_values')
self.assertEquals(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], multi_value)
self.assertEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], multi_value)

def test_read_from_custom_section(self):
config_reader = configparser.ConfigParser()
config_reader.read(self.test_file_path)
service = ConfigReader(config_reader, 'OTHER')

single_value = service.get_config_property('some_value')
self.assertEquals('1', single_value)
self.assertEqual('1', single_value)

multi_value = service.get_config_property_value_list('list_of_values')
self.assertEquals(['9', '8', '7', '6', '5', '4', '3', '2', '1', '0'], multi_value)
self.assertEqual(['9', '8', '7', '6', '5', '4', '3', '2', '1', '0'], multi_value)

def test_read_from_empty_section_section(self):
config_reader = configparser.ConfigParser()
config_reader.read(self.test_file_path)
service = ConfigReader(config_reader, 'EMPTY_SECTION')

single_value = service.get_config_property('some_value')
self.assertEquals('5', single_value)
self.assertEqual('5', single_value)

multi_value = service.get_config_property_value_list('list_of_values')
self.assertEquals(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], multi_value)
self.assertEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], multi_value)

def test_property_not_exist(self):
config_reader = configparser.ConfigParser()
Expand Down
1 change: 1 addition & 0 deletions tests/leader_board/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Leader board tests package initialization
Loading