From 89ce85a8e62788ae86711e61b189a83751b794b2 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 2 Mar 2024 14:30:39 -0500 Subject: [PATCH 1/7] wip --- .github/workflows/lila.yml | 42 ++------------------------------------ integration/run.sh | 13 ++++++++++++ integration/test | 22 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 40 deletions(-) create mode 100755 integration/run.sh create mode 100755 integration/test diff --git a/.github/workflows/lila.yml b/.github/workflows/lila.yml index 577830c..062123b 100644 --- a/.github/workflows/lila.yml +++ b/.github/workflows/lila.yml @@ -7,52 +7,14 @@ on: jobs: lila: runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["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: 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 diff --git a/integration/run.sh b/integration/run.sh new file mode 100755 index 0000000..5d8d406 --- /dev/null +++ b/integration/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash -e + +python3 -m pip install -e . --no-cache-dir + +while true; do + if curl -s http://lila:9663 >/dev/null; then + break + fi + echo "⌛ Waiting for lila to start..." + sleep 1 +done + +python3 integration/sample.py diff --git a/integration/test b/integration/test new file mode 100755 index 0000000..7951937 --- /dev/null +++ b/integration/test @@ -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" From 285ec38afd1375515d8cf2b6724e8898fa817098 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 2 Mar 2024 14:34:24 -0500 Subject: [PATCH 2/7] setup-python --- .github/workflows/lila.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/lila.yml b/.github/workflows/lila.yml index 062123b..0827bdd 100644 --- a/.github/workflows/lila.yml +++ b/.github/workflows/lila.yml @@ -7,12 +7,19 @@ on: jobs: lila: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12"] container: ubuntu:22.04 services: lila: image: ghcr.io/lichess-org/lila-docker:ci2 options: --restart=always steps: + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} - name: Checkout berserk uses: actions/checkout@v4 - name: Run tests From 1165c3889d078b46b8f4aa000c029d41a709ef95 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 2 Mar 2024 14:37:26 -0500 Subject: [PATCH 3/7] default container --- .github/workflows/lila.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lila.yml b/.github/workflows/lila.yml index 0827bdd..2b4db86 100644 --- a/.github/workflows/lila.yml +++ b/.github/workflows/lila.yml @@ -10,7 +10,6 @@ jobs: strategy: matrix: python-version: ["3.12"] - container: ubuntu:22.04 services: lila: image: ghcr.io/lichess-org/lila-docker:ci2 From 8c48fde16decacfbd8e1bdb996f0c65c415b8566 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 2 Mar 2024 14:45:02 -0500 Subject: [PATCH 4/7] expose port --- .github/workflows/lila.yml | 2 ++ integration/run.sh | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lila.yml b/.github/workflows/lila.yml index 2b4db86..203d469 100644 --- a/.github/workflows/lila.yml +++ b/.github/workflows/lila.yml @@ -14,6 +14,8 @@ jobs: lila: image: ghcr.io/lichess-org/lila-docker:ci2 options: --restart=always + ports: + - 9663:9663 steps: - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v5 diff --git a/integration/run.sh b/integration/run.sh index 5d8d406..90f420a 100755 --- a/integration/run.sh +++ b/integration/run.sh @@ -2,12 +2,13 @@ python3 -m pip install -e . --no-cache-dir -while true; do +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 From 44f1390d2c24f80d481830f9a3af25937d6dacbe Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 2 Mar 2024 14:56:33 -0500 Subject: [PATCH 5/7] install curl --- .github/workflows/lila.yml | 3 +++ integration/run.sh | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/lila.yml b/.github/workflows/lila.yml index 203d469..de387cb 100644 --- a/.github/workflows/lila.yml +++ b/.github/workflows/lila.yml @@ -10,6 +10,7 @@ jobs: strategy: matrix: python-version: ["3.12"] + container: ubuntu:22.04 services: lila: image: ghcr.io/lichess-org/lila-docker:ci2 @@ -21,6 +22,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install curl + run: apt-get update && apt-get install -y curl - name: Checkout berserk uses: actions/checkout@v4 - name: Run tests diff --git a/integration/run.sh b/integration/run.sh index 90f420a..aed15a1 100755 --- a/integration/run.sh +++ b/integration/run.sh @@ -7,6 +7,7 @@ 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 From 343ff8a60e1e8a63c474b6bf4ef20c649ec86bd3 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 2 Mar 2024 14:59:26 -0500 Subject: [PATCH 6/7] fail test --- .github/workflows/lila.yml | 2 -- integration/sample.py | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lila.yml b/.github/workflows/lila.yml index de387cb..cfe1a7d 100644 --- a/.github/workflows/lila.yml +++ b/.github/workflows/lila.yml @@ -15,8 +15,6 @@ jobs: lila: image: ghcr.io/lichess-org/lila-docker:ci2 options: --restart=always - ports: - - 9663:9663 steps: - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v5 diff --git a/integration/sample.py b/integration/sample.py index 7e335cf..cfeebba 100644 --- a/integration/sample.py +++ b/integration/sample.py @@ -4,10 +4,9 @@ client = berserk.Client(session, base_url="http://lila:9663") me = client.account.get() -assert me['id'] == 'bobby' +assert me['id'] == 'bobby123' -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) From fc7a16d2af4aea53464f96532954c44ac1be4020 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 2 Mar 2024 15:01:06 -0500 Subject: [PATCH 7/7] matrix --- .github/workflows/lila.yml | 2 +- .github/workflows/test.yml | 2 +- .github/workflows/typing.yml | 2 +- integration/sample.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lila.yml b/.github/workflows/lila.yml index cfe1a7d..197dfdf 100644 --- a/.github/workflows/lila.yml +++ b/.github/workflows/lila.yml @@ -9,7 +9,7 @@ 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: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f16cee2..58cb035 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: diff --git a/.github/workflows/typing.yml b/.github/workflows/typing.yml index 83f8131..629ca2f 100644 --- a/.github/workflows/typing.yml +++ b/.github/workflows/typing.yml @@ -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 diff --git a/integration/sample.py b/integration/sample.py index cfeebba..0f2af38 100644 --- a/integration/sample.py +++ b/integration/sample.py @@ -4,7 +4,7 @@ client = berserk.Client(session, base_url="http://lila:9663") me = client.account.get() -assert me['id'] == 'bobby123' +assert me['id'] == 'bobby' assert client.account.get_email() == 'bobby@localhost'