* Add FIFA World Cup 2026 support with group stage display and Monte Carlo simulator, fixes #127 - New `groupStageMatches` table for recording group play results (W/D/L, scores, matchday, schedule) - `computeGroupStandings()` model function: pts → GD → GF → name tiebreaker ordering - `GroupStageStandings` component showing all 12 groups with standings table and manager column - Admin bracket UI: group match score entry, per-group standings, "Recalculate Floors" action - `WorldCupSimulator`: 50k Monte Carlo covering group stage + best-8 3rd-place + knockout + 3rd place game - Fuzzy name matching for national team Elo lookup (exact → substring → word-overlap), warns on miss - Partial group completion: completed matches replayed with real scores, remaining matches simulated - Elo priority: admin-entered sourceElo > futures odds converted to Elo > hardcoded national team ratings - `fifa_48` bracket template: added Third Place Game round with `loserFeedsInto` on Semifinals - Scoring rules: distinct 3rd/4th place for `fifa_48` (not averaged), QF losers share 5th–8th equally - Floor scoring: SF participants guaranteed 4th (provisional), finalized after 3rd place game - `recalculate-floors` admin action deletes and replays all results from scratch (fixes stale guard bug) - Unique index on `(tournamentGroupId, participant1Id, participant2Id)` to prevent duplicate pairings - Batch `findMatchesByGroupIds()` replacing N sequential queries in the sport season loader - League home mini-standings now shows `actualPoints` (includes floor) instead of `totalPoints` only - Elo ratings admin page supports World Cup (same bulk-import flow as snooker) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix TypeScript errors: update GroupStandingData type to use findMatchesByGroupIds Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Increase Node heap to 4GB for unit tests in CI to prevent OOM Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix OOM in CI: make WorldCupSimulator simulation count configurable for tests Tests now pass numSimulations=500 instead of the production default of 50,000. Six simulator tests × 50k iterations each was exhausting the 4GB heap on GitHub Actions runners. Also reduce simGroupMatch stat tests from 50k to 5k iterations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
175 lines
5.6 KiB
YAML
175 lines
5.6 KiB
YAML
name: 🚀 Deploy
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request: {}
|
|
|
|
permissions:
|
|
actions: write
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
name: 🧪 Test
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15
|
|
env:
|
|
POSTGRES_USER: test
|
|
POSTGRES_PASSWORD: test
|
|
POSTGRES_DB: brackt_test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
|
|
steps:
|
|
- name: 🛑 Cancel Previous Runs
|
|
uses: styfle/cancel-workflow-action@0.12.1
|
|
|
|
- name: ⬇️ Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: ⎔ Setup node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'npm'
|
|
|
|
- name: 📥 Install dependencies
|
|
run: npm ci
|
|
|
|
- name: 🧪 Run unit tests
|
|
run: npm run test:run
|
|
env:
|
|
DATABASE_URL: postgresql://test:test@localhost:5432/brackt_test
|
|
NODE_OPTIONS: --max-old-space-size=4096
|
|
|
|
typecheck:
|
|
name: ʦ TypeScript
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 🛑 Cancel Previous Runs
|
|
uses: styfle/cancel-workflow-action@0.12.1
|
|
|
|
- name: ⬇️ Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: ⎔ Setup node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'npm'
|
|
|
|
- name: 📥 Install dependencies
|
|
run: npm ci
|
|
|
|
- name: 🔎 Type check
|
|
run: npm run typecheck
|
|
|
|
lint:
|
|
name: 🔍 Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 🛑 Cancel Previous Runs
|
|
uses: styfle/cancel-workflow-action@0.12.1
|
|
|
|
- name: ⬇️ Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: ⎔ Setup node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'npm'
|
|
|
|
- name: 📥 Install dependencies
|
|
run: npm ci
|
|
|
|
- name: 🔍 Lint (oxlint)
|
|
run: npm run lint
|
|
|
|
build:
|
|
name: 🐳 Build
|
|
needs: [test, typecheck, lint]
|
|
# only build/deploy main branch on pushes
|
|
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 🛑 Cancel Previous Runs
|
|
uses: styfle/cancel-workflow-action@0.12.1
|
|
|
|
- name: ⬇️ Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 🐳 Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# Setup cache
|
|
- name: ⚡️ Cache Docker layers
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: 🔓 Login to Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ vars.CONTAINER_REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: 🗄️ Build and Push to Container Registry
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ vars.CONTAINER_REGISTRY }}/brackt:latest
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
|
build-args: |
|
|
DATABASE_URL=${{ secrets.PROD_DATABASE_URL }}
|
|
|
|
# This ugly bit is necessary if you don't want your cache to grow forever
|
|
# till it hits GitHub's limit of 10GB.
|
|
# Temp fix
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
- name: 🚚 Move cache
|
|
run: |
|
|
rm -rf /tmp/.buildx-cache
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
|
|
deploy:
|
|
name: 🚀 Deploy
|
|
runs-on: ubuntu-latest
|
|
needs: [build]
|
|
# only deploy main/dev branch on pushes
|
|
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
|
|
|
|
steps:
|
|
- name: 🚀 Deploy app to server
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
env:
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
CONTAINER_REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
port: ${{ secrets.DEPLOY_PORT }}
|
|
username: ${{ secrets.DEPLOY_USER }}
|
|
key: ${{ secrets.DEPLOY_KEY }}
|
|
envs: REGISTRY_USERNAME,REGISTRY_PASSWORD,CONTAINER_REGISTRY
|
|
script: |
|
|
docker login $CONTAINER_REGISTRY -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
|
|
cd brackt
|
|
docker compose pull
|
|
docker compose up -d
|