mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
Merge pull request #2 from kristoferssolo/gh-actions
Add GitHub actions
This commit is contained in:
commit
fa6a0e97e0
25
.github/workflows/lint.yml
vendored
Normal file
25
.github/workflows/lint.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
name: Lint
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
python-version: ["3.10", "3.11"]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements_dev.txt
|
||||||
|
- name: Analysing the code with mypy
|
||||||
|
run: |
|
||||||
|
mypy $(git ls-files '*.py')
|
||||||
|
- name: Analysing the code with ruff
|
||||||
|
run: |
|
||||||
|
ruff check $(git ls-files '*.py')
|
||||||
25
.github/workflows/release.yml
vendored
Normal file
25
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
name: Release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install build
|
||||||
|
- name: Build package
|
||||||
|
run: python -m build
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
files: dist/*.tar.gz
|
||||||
23
.github/workflows/tests.yml
vendored
Normal file
23
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
name: Tests
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
python-version: ["3.10", "3.11"]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install -r requirements_dev.txt
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
pytest
|
||||||
21
.github/workflows/typst.yml
vendored
Normal file
21
.github/workflows/typst.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: Build Typst document
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
typst-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Build Typst
|
||||||
|
uses: lvignoli/typst-action@main
|
||||||
|
with:
|
||||||
|
source_file: |
|
||||||
|
typst/main.typ
|
||||||
|
- name: Push changes
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
|
with:
|
||||||
|
file_pattern: "typst/*.pdf"
|
||||||
|
commit_message: "chore(build): auto-build pdf"
|
||||||
|
commit_user_name: "github-actions[bot]"
|
||||||
|
commit_user_email: "github-actions[bot]@users.noreply.github.com"
|
||||||
|
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
|
||||||
@ -1,4 +1,5 @@
|
|||||||
# Tetris
|
# Tetris
|
||||||
|
 
|
||||||
|
|
||||||
<!-- toc -->
|
<!-- toc -->
|
||||||
|
|
||||||
|
|||||||
@ -8,22 +8,22 @@ version = "0.1.0"
|
|||||||
description = "Tetris game"
|
description = "Tetris game"
|
||||||
authors = [{ name = "Kristofers Solo", email = "dev@kristofers.xyz" }]
|
authors = [{ name = "Kristofers Solo", email = "dev@kristofers.xyz" }]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.10"
|
||||||
license = { file = "LICENSE" }
|
license = { file = "LICENSE" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"attrs==23.1.0",
|
"attrs==23.1.0",
|
||||||
"loguru==0.7.2",
|
"loguru==0.7.2",
|
||||||
"numpy==1.26.3",
|
"numpy==1.26.3",
|
||||||
"pygame-ce==2.4.0",
|
"pygame-ce==2.4.0",
|
||||||
"toml==0.10.2",
|
"toml==0.10.2",
|
||||||
]
|
]
|
||||||
keywords = ["tetris", "game", "pygame"]
|
keywords = ["tetris", "game", "pygame"]
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
"License :: OSI Approved :: GPLv3 License",
|
"License :: OSI Approved :: GPLv3 License",
|
||||||
"Programming Language :: Python :: 3 :: Only",
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
"Programming Language :: Python :: 3.12",
|
"Programming Language :: Python :: 3.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
@ -45,40 +45,41 @@ warn_unused_configs = true
|
|||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
extend-select = [
|
extend-select = [
|
||||||
"B",
|
"B",
|
||||||
"BLE",
|
"BLE",
|
||||||
"C4",
|
"C4",
|
||||||
"ERA",
|
"ERA",
|
||||||
"I",
|
"I",
|
||||||
"ICN",
|
"ICN",
|
||||||
"INP",
|
"INP",
|
||||||
"ISC",
|
"ISC",
|
||||||
"N",
|
"N",
|
||||||
"NPY",
|
"NPY",
|
||||||
"PGH",
|
"PGH",
|
||||||
"PIE",
|
"PIE",
|
||||||
# "PTH",
|
# "PTH",
|
||||||
"Q",
|
"Q",
|
||||||
"RET",
|
"RET",
|
||||||
"RSE",
|
"RSE",
|
||||||
"RUF",
|
"RUF",
|
||||||
"S",
|
"S",
|
||||||
"SIM",
|
"SIM",
|
||||||
"T20",
|
"T20",
|
||||||
"TCH",
|
"TCH",
|
||||||
"TID",
|
"TID",
|
||||||
"YTT",
|
"YTT",
|
||||||
]
|
]
|
||||||
ignore = ["E741"]
|
ignore = ["E741"]
|
||||||
show-fixes = true
|
show-fixes = true
|
||||||
line-length = 120
|
line-length = 120
|
||||||
indent-width = 4
|
indent-width = 4
|
||||||
target-version = "py38"
|
target-version = "py310"
|
||||||
|
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
extend-select = ["I"]
|
extend-select = ["I"]
|
||||||
preview = true
|
preview = true
|
||||||
|
fixable = ["ALL"]
|
||||||
|
|
||||||
[tool.ruff.format]
|
[tool.ruff.format]
|
||||||
quote-style = "double"
|
quote-style = "double"
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
mypy==1.8.0
|
mypy==1.8.0
|
||||||
pytest==7.4.3
|
pytest==7.4.3
|
||||||
ruff==0.1.9
|
ruff==0.1.9
|
||||||
|
types-toml==0.10.8.7
|
||||||
|
|||||||
@ -355,10 +355,10 @@ class Tetris(BaseScreen):
|
|||||||
def _initialize_timers(self) -> None:
|
def _initialize_timers(self) -> None:
|
||||||
"""Initialize game timers."""
|
"""Initialize game timers."""
|
||||||
self.timers = Timers(
|
self.timers = Timers(
|
||||||
Timer(self.initial_block_speed, True, self.move_down),
|
Timer(self.initial_block_speed, True, self.move_down), # type: ignore
|
||||||
Timer(CONFIG.game.movment_delay),
|
Timer(CONFIG.game.movment_delay), # type: ignore
|
||||||
Timer(CONFIG.game.rotation_delay),
|
Timer(CONFIG.game.rotation_delay), # type: ignore
|
||||||
Timer(CONFIG.game.drop_delay),
|
Timer(CONFIG.game.drop_delay), # type: ignore
|
||||||
)
|
)
|
||||||
self.timers.vertical.activate()
|
self.timers.vertical.activate()
|
||||||
|
|
||||||
|
|||||||
6
tests/test_blank.py
Normal file
6
tests/test_blank.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
class TestBlank(unittest.TestCase):
|
||||||
|
def test(self) -> None:
|
||||||
|
pass
|
||||||
@ -57,10 +57,10 @@ def run() -> None:
|
|||||||
game.Main(GameMode.PLAYER).run()
|
game.Main(GameMode.PLAYER).run()
|
||||||
|
|
||||||
|
|
||||||
def main(args: argparse.ArgumentParser) -> None:
|
def main(args) -> None:
|
||||||
if args.debug:
|
if args.debug: # type: ignore
|
||||||
level = "debug"
|
level = "debug"
|
||||||
elif args.verbose:
|
elif args.verbose: # type: ignore
|
||||||
level = "info"
|
level = "info"
|
||||||
else:
|
else:
|
||||||
level = "warning"
|
level = "warning"
|
||||||
@ -72,4 +72,4 @@ def main(args: argparse.ArgumentParser) -> None:
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
main(args)
|
main(args) # type: ignore
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user