Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2d567cd
modernize battlechess
Nov 24, 2023
19b1601
package battlechess, put tests in its own directory
Nov 24, 2023
6dfe643
move battlechess standalone (v1) to another directory
Nov 24, 2023
a6ab642
update readme
Nov 24, 2023
8e7d7e9
apply ruff linting fixes
Nov 24, 2023
eca93d1
fix deprecation tests
Nov 24, 2023
8ae8bb9
fix all tests and deprecations
Nov 25, 2023
55fbc3a
update github actions to use poetry
Nov 26, 2023
ac2fcef
github action use virtualenv
Nov 26, 2023
230700c
use environment variables via decouple instead of config.py
Nov 26, 2023
eb48837
add environment secret to github action
Nov 26, 2023
7131580
upgrade requirements just in case, add example .env
Nov 26, 2023
c797012
chore: move all standalone code to directory, update readme
Dec 24, 2023
2daf230
change response to no random games to 404
Jan 6, 2024
f181908
remove trailing / from all endpoints
Jan 7, 2024
9e45222
return btch user instead of db ids
Jan 8, 2024
1bda628
improve error message indicating it's a coordinate
Jan 9, 2024
8db5a4c
wip: add schemas as response models to all endpoints, wip passing fil…
Jan 10, 2024
f3393fe
support optional game status filter on game listing
Jan 11, 2024
350fce1
just return OK if joining a game the player is already in
Jan 20, 2024
018315f
return precondition failed when asking for snaps on a waiting game
Jan 21, 2024
34d3844
don't prepare snap if game is over (replay), add status endpoint, fix…
Jan 21, 2024
a83110c
use decouple with defaults, update dependencies, add dockerfile
Feb 1, 2024
9112657
404 on game uuid not found
Feb 4, 2024
b48da80
create game and user created_at default to now
Feb 5, 2024
0f87ec0
:warning: remove passlib since it's deprecated
Feb 10, 2024
6241bdb
long poll semi-test
Feb 8, 2024
75e5dbf
switch from unittest to pytest
Feb 8, 2024
3f6e3af
moved all functions to fixtures
Feb 8, 2024
711d86b
fixed api tests, now using pytest fixtures
Feb 8, 2024
7ce2350
moved board tests to pytest
Feb 8, 2024
60bfa60
add sqlalchemy-utils dependency
Feb 9, 2024
3043422
403 on wrong turn move. Closes #2
Feb 10, 2024
881eaa6
trying to make async tests
Feb 9, 2024
13434b8
asyncio testing working
Feb 10, 2024
4741564
proper async long_polling testing with create_task
Feb 10, 2024
32d1d1a
async turn with better doc
Feb 10, 2024
5ebc193
db refresh on turn//me
Feb 11, 2024
a46e62d
increase turn recheck to 2 seconds
Feb 12, 2024
cae7147
remove long_polling from /turn, use /turn/me for longpolling
Feb 11, 2024
d494682
adapt tests to returning 412 when asking for turn on a finished game
Feb 12, 2024
943d5bf
fix linting errors
Feb 14, 2024
005e6b3
fix more linting tests
Feb 14, 2024
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
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fly.toml
app
battlechess_standalone
client
data
ia
tests
.vscode
.pytest_cache
.github
28 changes: 28 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true

[*.sql]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true

[*.yaml, *.yml]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
extend-ignore = E226,E302,E41,W503,E203
max-line-length = 105
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist
31 changes: 22 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,38 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
python-version: ["3.8", "3.9", "3.10"]
poetry-version: ["1.7.1"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Run image
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: poetry install
#- 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
- name: Test with pytest
run: |
pytest
run: poetry run pytest -v
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ bin
.vscode
sql_app.db
test.db
*.db
*.sqlite

.env
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=black
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
args: ['--unsafe']
- id: trailing-whitespace
- id: detect-private-key
- id: name-tests-test
args: ["--pytest-test-first"]
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.11.5
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.0.261"
hooks:
- id: ruff
fail_fast: false
files: ".*"
exclude: "desktop.ini"
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# https://hub.docker.com/_/python
FROM python:3.10-slim-bookworm

ENV PYTHONUNBUFFERED True

RUN apt-get update && apt-get install -y \
python3-pip \
python3-venv \
python3-dev \
python3-setuptools \
python3-wheel

RUN mkdir -p /app
WORKDIR /app

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY . ./

EXPOSE 8000

CMD ["uvicorn", "battlechess.server.btchApi:app", "--host", "0.0.0.0", "--port", "8000"]
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: uvicorn battlechess.server.btchApi:app --host=0.0.0.0 --port=${PORT:-5000}
6 changes: 5 additions & 1 deletion Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ That new rule has some direct consequences on the gameplay.

## Installation :

### Battlechess standalone (LAN)

- What you need :
* [python 3.7](https://www.python.org/downloads/) (or more I guess...)
* [pygame 1.9.2](http://www.pygame.org/download.shtml). On OS X with python 2.7, you should donwload this [installation file](http://www.pygame.org/ftp/pygame-1.9.2pre-py2.7-macosx10.7.mpkg.zip)
Expand All @@ -57,9 +59,11 @@ That new rule has some direct consequences on the gameplay.
`python battleChess.py -p http://sxbn.org/~antoine/games/2014_03_07_14_06_37_lance_hardwood_Vs_sniper.txt`
`python battleChess.py -p ./2014_03_07_14_06_37_lance_hardwood_Vs_sniper.txt`

### Battlechess api server

- Using the server application :
If you want to host your own server (you don't have to). You just need to run the api with
`$ uvicorn server.btchApi:app --reload`
`$ uvicorn battleches.server.btchApi:app --reload`
program on a computer that can be reached through the network. Change the port and hostname if you want and pass those informations to the client application. Check `$ uvicorn --help`.
You'll need to install the packages listed in `requirements.txt`. You can do so with `$ pip install -r requirements.txt`

Expand Down
98 changes: 0 additions & 98 deletions Readme.txt

This file was deleted.

File renamed without changes.
Loading