Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 29 additions & 0 deletions .github/workflows/leaderboard_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Leaderboard Build Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
leaderboard:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'

- name: Install dependencies (incl. leaderboard extra)
run: |
pip install ".[dev,leaderboard]"

- name: Run leaderboard build test
run: |
make leaderboard-build-test
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lint-check:

test:
@echo "--- 🧪 Running tests ---"
pytest -n auto -m "not test_datasets"
pytest -n auto -m "not (test_datasets or leaderboard_stability)"


test-with-coverage:
Expand Down Expand Up @@ -52,6 +52,9 @@ dataset-load-test:
@echo "--- 🚀 Running dataset load test ---"
pytest -n auto -m test_datasets

leaderboard-build-test:
@echo "--- 🚀 Running leaderboard build test ---"
pytest -n auto -m leaderboard_stability

run-leaderboard:
@echo "--- 🚀 Running leaderboard locally ---"
Expand Down
33 changes: 33 additions & 0 deletions tests/test_leaderboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from __future__ import annotations

import multiprocessing
import time

import pytest

TIMEOUT = 300


def run_leaderboard_app():
"""Function to launch the leaderboard app."""
from mteb.leaderboard.app import get_leaderboard_app

app = get_leaderboard_app()
app.launch(server_name="0.0.0.0", server_port=7860, prevent_thread_lock=True)


@pytest.mark.timeout(TIMEOUT)
@pytest.mark.leaderboard_stability
def test_leaderboard_app_does_not_crash():
"""Test to ensure the leaderboard app does not crash within the first 5 minutes."""
process = multiprocessing.Process(target=run_leaderboard_app)
process.start()

try:
for _ in range(TIMEOUT):
if not process.is_alive():
pytest.fail("Leaderboard app crashed during the test.")
time.sleep(1)
finally:
process.terminate()
process.join()