Skip to content

Commit

Permalink
Ability to run locally (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev authored Mar 2, 2024
1 parent cdca866 commit e8a7526
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 38 deletions.
39 changes: 5 additions & 34 deletions .github/workflows/lila.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,21 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
container: ubuntu:22.04
services:
lila:
image: ghcr.io/lichess-org/lila-docker:ci
image: ghcr.io/lichess-org/lila-docker:ci2
options: --restart=always
env:
MONGO_URL: mongodb://mongodb?appName=lila
REDIS_URL: redis://redis
mongodb:
image: mongo:5.0-focal
redis:
image: redis:7-alpine
steps:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pymongo requests
- name: Checkout lila-db-seed
uses: actions/checkout@v4
with:
repository: lichess-org/lila-db-seed
- name: Seed database
run: |
./spamdb/spamdb.py \
--uri=mongodb://mongodb/lichess \
--drop-db \
--password=password \
--su-password=password \
--streamers \
--coaches \
--tokens
- name: Install curl
run: apt-get update && apt-get install -y curl
- name: Checkout berserk
uses: actions/checkout@v4
- name: Install berserk
run: python -m pip install -e .
- name: Run tests
run: |
python integration/sample.py
./integration/run.sh
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
15 changes: 15 additions & 0 deletions integration/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -e

python3 -m pip install -e . --no-cache-dir

attempts=0
while [ $attempts -lt 30 ]; do
if curl -s http://lila:9663 >/dev/null; then
break
fi
echo "⌛ Waiting for lila to start..."
sleep 1
attempts=$((attempts + 1))
done

python3 integration/sample.py
3 changes: 1 addition & 2 deletions integration/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
me = client.account.get()
assert me['id'] == 'bobby'

email = client.account.get_email()
assert email == 'bobby@localhost'
assert client.account.get_email() == 'bobby@localhost'

assert client.account.get_kid_mode() == False
client.account.set_kid_mode(True)
Expand Down
22 changes: 22 additions & 0 deletions integration/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -e

IMAGE=ghcr.io/lichess-org/lila-docker:ci2

cleanup_containers() {
docker rm --force lila > /dev/null 2>&1 || true
docker rm --force app > /dev/null 2>&1 || true
docker network rm lila-network > /dev/null 2>&1 || true
}

echo "Running integration tests"

cleanup_containers
docker network create lila-network || true
docker run -d --name lila --network lila-network $IMAGE

docker run --name app --network lila-network -v $(pwd):/app -w /app $IMAGE sh -c "./integration/run.sh"

echo "✅ Integration tests passed"

cleanup_containers
echo "✅ Done"

0 comments on commit e8a7526

Please sign in to comment.