feat: ShellMate - SSH Chess TUI

Play chess in your terminal over SSH. No installs, no accounts.

Features:
- Beautiful terminal-filling chess board with ANSI colors
- Play against Stockfish AI (multiple difficulty levels)
- Two-step move interaction with visual feedback
- Leaderboard with PostgreSQL persistence
- SSH key persistence across restarts

Infrastructure:
- Docker containerized deployment
- CI/CD pipeline for dev/staging/production
- Health checks with auto-rollback
- Landing page at shellmate.sh

Tech: Python 3.12+, asyncssh, python-chess, Stockfish
This commit is contained in:
2026-02-01 20:05:58 +00:00
commit 590fbe045c
33 changed files with 3925 additions and 0 deletions

62
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,62 @@
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y stockfish
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run linter
run: |
ruff check src/ tests/
- name: Run type checker
run: |
mypy src/ --ignore-missing-imports
continue-on-error: true
- name: Run tests
run: |
pytest tests/ -v --tb=short
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: shellmate:test
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max

67
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
name: Deploy
on:
push:
branches: [main, develop, staging]
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'dev'
type: choice
options:
- dev
- staging
- production
jobs:
deploy:
runs-on: ubuntu-latest
needs: []
environment:
name: ${{ github.ref == 'refs/heads/main' && 'production' || github.ref == 'refs/heads/staging' && 'staging' || 'dev' }}
url: ${{ github.ref == 'refs/heads/main' && 'https://shellmate.sh' || github.ref == 'refs/heads/staging' && 'https://staging.shellmate.sh' || 'https://dev.shellmate.sh' }}
steps:
- uses: actions/checkout@v4
- name: Set environment variables
id: env
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "env_name=production" >> $GITHUB_OUTPUT
echo "ssh_host=shellmate.sh" >> $GITHUB_OUTPUT
echo "ssh_port=22" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/staging" ]]; then
echo "env_name=staging" >> $GITHUB_OUTPUT
echo "ssh_host=shellmate.sh" >> $GITHUB_OUTPUT
echo "ssh_port=2223" >> $GITHUB_OUTPUT
else
echo "env_name=dev" >> $GITHUB_OUTPUT
echo "ssh_host=shellmate.sh" >> $GITHUB_OUTPUT
echo "ssh_port=2222" >> $GITHUB_OUTPUT
fi
- name: Deploy to ${{ steps.env.outputs.env_name }}
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ steps.env.outputs.ssh_host }}
username: root
key: ${{ secrets.DEPLOY_SSH_KEY }}
port: ${{ steps.env.outputs.ssh_port }}
script: |
cd /opt/shellmate
git fetch origin
git checkout ${{ github.ref_name }}
git pull origin ${{ github.ref_name }}
docker compose up -d --build
echo "Deployed ${{ github.ref_name }} to ${{ steps.env.outputs.env_name }}"
- name: Deployment summary
run: |
echo "## Deployment Complete 🚀" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Environment:** ${{ steps.env.outputs.env_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY