2025-10-11 23:21:28 -07:00
|
|
|
name: 🚀 Deploy
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches:
|
|
|
|
|
- main
|
|
|
|
|
pull_request: {}
|
|
|
|
|
|
2026-05-21 15:52:00 -07:00
|
|
|
concurrency:
|
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
|
|
2025-10-11 23:21:28 -07:00
|
|
|
permissions:
|
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
|
|
jobs:
|
2025-10-21 12:47:11 -07:00
|
|
|
test:
|
|
|
|
|
name: 🧪 Test
|
|
|
|
|
runs-on: ubuntu-latest
|
2026-05-21 15:52:00 -07:00
|
|
|
timeout-minutes: 20
|
2026-04-01 00:59:21 -07:00
|
|
|
|
2025-10-21 12:47:11 -07:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
- name: ⬇️ Checkout repo
|
2026-05-21 15:52:00 -07:00
|
|
|
uses: https://github.com/actions/checkout@v4
|
2025-10-21 12:47:11 -07:00
|
|
|
|
|
|
|
|
- name: 📥 Install dependencies
|
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
|
|
- name: 🧪 Run unit tests
|
|
|
|
|
run: npm run test:run
|
|
|
|
|
env:
|
2026-05-21 16:14:27 -07:00
|
|
|
DATABASE_URL: postgresql://test:test@postgres:5432/brackt_test
|
Add FIFA World Cup 2026 support with group stage display and Monte Carlo simulator (#242)
* 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>
2026-03-29 10:27:47 -07:00
|
|
|
NODE_OPTIONS: --max-old-space-size=4096
|
2025-10-21 12:47:11 -07:00
|
|
|
|
Optimize CI pipeline: merge check jobs, remove docker install, improve layer caching
- Merge typecheck + lint into a single `check` job to eliminate one full
job lifecycle and one npm ci invocation (~2-4 min savings)
- Remove `apt-get install docker.io` step — Docker CLI and buildx v0.23.0
are now pre-installed in the custom brackt-runner:latest image
- Reorder Dockerfile build-env COPY layers so node_modules and config
files are copied before source, improving registry cache hit granularity
- Expand .dockerignore to exclude .forgejo, .git, docs, plans, cypress,
logs, .env files, and tsbuildinfo files from the build context
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 21:37:01 -07:00
|
|
|
check:
|
|
|
|
|
name: ʦ🔍 Typecheck & Lint
|
2025-10-11 23:21:28 -07:00
|
|
|
runs-on: ubuntu-latest
|
Optimize CI pipeline: merge check jobs, remove docker install, improve layer caching
- Merge typecheck + lint into a single `check` job to eliminate one full
job lifecycle and one npm ci invocation (~2-4 min savings)
- Remove `apt-get install docker.io` step — Docker CLI and buildx v0.23.0
are now pre-installed in the custom brackt-runner:latest image
- Reorder Dockerfile build-env COPY layers so node_modules and config
files are copied before source, improving registry cache hit granularity
- Expand .dockerignore to exclude .forgejo, .git, docs, plans, cypress,
logs, .env files, and tsbuildinfo files from the build context
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 21:37:01 -07:00
|
|
|
timeout-minutes: 15
|
2026-03-22 20:33:43 -07:00
|
|
|
steps:
|
|
|
|
|
- name: ⬇️ Checkout repo
|
2026-05-21 15:52:00 -07:00
|
|
|
uses: https://github.com/actions/checkout@v4
|
2026-03-22 20:33:43 -07:00
|
|
|
|
|
|
|
|
- name: 📥 Install dependencies
|
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
|
|
- name: 🔍 Lint (oxlint)
|
|
|
|
|
run: npm run lint
|
|
|
|
|
|
Optimize CI pipeline: merge check jobs, remove docker install, improve layer caching
- Merge typecheck + lint into a single `check` job to eliminate one full
job lifecycle and one npm ci invocation (~2-4 min savings)
- Remove `apt-get install docker.io` step — Docker CLI and buildx v0.23.0
are now pre-installed in the custom brackt-runner:latest image
- Reorder Dockerfile build-env COPY layers so node_modules and config
files are copied before source, improving registry cache hit granularity
- Expand .dockerignore to exclude .forgejo, .git, docs, plans, cypress,
logs, .env files, and tsbuildinfo files from the build context
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 21:37:01 -07:00
|
|
|
- name: 🔎 Type check
|
|
|
|
|
run: npm run typecheck
|
|
|
|
|
|
2025-10-11 23:21:28 -07:00
|
|
|
build:
|
|
|
|
|
name: 🐳 Build
|
Optimize CI pipeline: merge check jobs, remove docker install, improve layer caching
- Merge typecheck + lint into a single `check` job to eliminate one full
job lifecycle and one npm ci invocation (~2-4 min savings)
- Remove `apt-get install docker.io` step — Docker CLI and buildx v0.23.0
are now pre-installed in the custom brackt-runner:latest image
- Reorder Dockerfile build-env COPY layers so node_modules and config
files are copied before source, improving registry cache hit granularity
- Expand .dockerignore to exclude .forgejo, .git, docs, plans, cypress,
logs, .env files, and tsbuildinfo files from the build context
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 21:37:01 -07:00
|
|
|
needs: [test, check]
|
2025-10-11 23:21:28 -07:00
|
|
|
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
|
|
|
|
|
runs-on: ubuntu-latest
|
2026-05-21 15:52:00 -07:00
|
|
|
timeout-minutes: 30
|
2025-10-11 23:21:28 -07:00
|
|
|
steps:
|
|
|
|
|
- name: ⬇️ Checkout repo
|
2026-05-21 15:52:00 -07:00
|
|
|
uses: https://github.com/actions/checkout@v4
|
2025-10-11 23:21:28 -07:00
|
|
|
|
|
|
|
|
- name: 🐳 Set up Docker Buildx
|
2026-05-21 15:52:00 -07:00
|
|
|
uses: https://github.com/docker/setup-buildx-action@v3
|
2025-10-11 23:21:28 -07:00
|
|
|
|
|
|
|
|
- name: 🔓 Login to Container Registry
|
2026-05-21 15:52:00 -07:00
|
|
|
uses: https://github.com/docker/login-action@v3
|
2025-10-11 23:21:28 -07:00
|
|
|
with:
|
|
|
|
|
registry: ${{ vars.CONTAINER_REGISTRY }}
|
|
|
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
|
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
|
|
2025-10-13 11:01:12 -07:00
|
|
|
- name: 🗄️ Build and Push to Container Registry
|
2026-05-21 15:52:00 -07:00
|
|
|
uses: https://github.com/docker/build-push-action@v5
|
2025-10-11 23:21:28 -07:00
|
|
|
with:
|
|
|
|
|
context: .
|
|
|
|
|
push: true
|
2026-05-31 04:35:05 +00:00
|
|
|
platforms: linux/amd64
|
2025-10-11 23:21:28 -07:00
|
|
|
tags: ${{ vars.CONTAINER_REGISTRY }}/brackt:latest
|
2026-05-21 15:52:00 -07:00
|
|
|
cache-from: type=registry,ref=${{ vars.CONTAINER_REGISTRY }}/brackt:buildcache
|
|
|
|
|
cache-to: type=registry,ref=${{ vars.CONTAINER_REGISTRY }}/brackt:buildcache,mode=max
|
2026-05-31 04:35:05 +00:00
|
|
|
secret-files: |
|
|
|
|
|
npmrc=./.npmrc
|
2025-10-11 23:21:28 -07:00
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
|
name: 🚀 Deploy
|
|
|
|
|
runs-on: ubuntu-latest
|
2026-05-21 15:52:00 -07:00
|
|
|
timeout-minutes: 10
|
2025-10-21 12:57:03 -07:00
|
|
|
needs: [build]
|
2025-10-11 23:21:28 -07:00
|
|
|
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
|
|
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
- name: 🚀 Deploy app to server
|
2026-05-21 15:52:00 -07:00
|
|
|
uses: https://github.com/appleboy/ssh-action@v1.0.3
|
2025-10-11 23:21:28 -07:00
|
|
|
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 }}
|
2026-04-06 00:07:36 -04:00
|
|
|
envs: REGISTRY_USERNAME,REGISTRY_PASSWORD,CONTAINER_REGISTRY
|
2025-10-11 23:21:28 -07:00
|
|
|
script: |
|
2026-04-05 22:50:23 -04:00
|
|
|
set -e
|
2025-10-11 23:21:28 -07:00
|
|
|
docker login $CONTAINER_REGISTRY -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
|
|
|
|
|
cd brackt
|
|
|
|
|
docker compose pull
|
2026-04-06 00:44:04 -04:00
|
|
|
if ! docker compose up --no-deps migrate; then
|
2026-04-06 00:07:36 -04:00
|
|
|
echo "Migration failed:"
|
|
|
|
|
docker compose logs migrate
|
2026-04-01 00:59:21 -07:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2026-04-06 00:07:36 -04:00
|
|
|
docker compose up -d --remove-orphans
|