Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lila github action #73

Merged
merged 18 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
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
33 changes: 33 additions & 0 deletions .github/workflows/lila.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lila integration test

on:
- push
- pull_request

jobs:
lila:
runs-on: ubuntu-latest
strategy:
matrix:
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:main
options: --restart=always
steps:
- 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 pytest
- name: Install curl
run: apt-get update && apt-get install -y curl
- name: Checkout berserk
uses: actions/checkout@v4
- name: Run tests
run: |
./integration/run-tests.sh
4 changes: 2 additions & 2 deletions .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 All @@ -34,4 +34,4 @@ jobs:
- name: Install dependencies
run: poetry install --with dev
- name: Test
run: poetry run pytest
run: poetry run pytest tests
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
19 changes: 19 additions & 0 deletions integration/local
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -e

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

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
docker run --name lila --network lila-network -d $IMAGE
docker run --name app --network lila-network -v $(pwd):/app -w /app $IMAGE ./integration/run-tests.sh
kraktus marked this conversation as resolved.
Show resolved Hide resolved

cleanup_containers
echo "✅ Done"
15 changes: 15 additions & 0 deletions integration/run-tests.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

pytest integration
40 changes: 40 additions & 0 deletions integration/test_lila_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import berserk
import pytest


@pytest.fixture(scope="module")
def client():
session = berserk.TokenSession('lip_bobby')
client = berserk.Client(
session, base_url="http://lila:9663")
yield client


def test_account_get(client):
me = client.account.get()
assert me['id'] == 'bobby'


def test_account_get_email(client):
assert client.account.get_email() == 'bobby@localhost'


def test_account_get_preferences(client):
preferences = client.account.get_preferences()
assert preferences['language'] == 'en-US'
assert preferences['prefs']['animation'] == 2


def test_account_kid_mode(client):
assert client.account.get_kid_mode() == False
client.account.set_kid_mode(True)
assert client.account.get_kid_mode() == True


def test_account_upgrade_to_bot():
session = berserk.TokenSession('lip_zerogames')
client = berserk.Client(
session, base_url="http://lila:9663")
assert 'title' not in client.account.get()
client.account.upgrade_to_bot()
assert client.account.get()['title'] == "BOT"
Loading