Skip to content

Commit

Permalink
Refactor tests to be ran in different jobs (#45)
Browse files Browse the repository at this point in the history
* Refactor tests to become core, numba, comparison, comparison_full, also update dependencies

* refactor back to two parts

* Remove setup

* Fix core tests
  • Loading branch information
xhluca authored Aug 17, 2024
1 parent a44f3db commit d0744d4
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 19 deletions.
57 changes: 45 additions & 12 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

jobs:
test:
test-core:
runs-on: ubuntu-latest

steps:
Expand All @@ -18,25 +18,58 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements-core.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
- name: Install core dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt # Assumes you have a requirements.txt file
- name: Run quick tests
pip install -r tests/requirements-core.txt
- name: Run core tests with dependencies
run: |
python -m unittest tests/quick/test_*.py
- name: Run numba tests
python -m unittest tests/core/test_*.py
- name: Install Numba
run: |
pip install "numba>=0.60.0"
python -m unittest tests/numba/test_*.py
- name: Run numba tests
run: |
python -m unittest tests/numba/test_*.py
test-comparison:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v2

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


- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements-comparison.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install comparison dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements-comparison.txt
- name: Run comparison tests with dependencies
run: |
python -m unittest tests/comparison/test_*.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions tests/quick/test_retrieve.py → tests/core/test_retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import bm25s
import Stemmer # optional: for stemming

from .. import BM25TestCase

class TestBM25SLoadingSaving(BM25TestCase):
class TestBM25SLoadingSaving(unittest.TestCase):
@classmethod
def setUpClass(cls):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import bm25s
import Stemmer # optional: for stemming

from .. import BM25TestCase

class TestBM25SLoadingSaving(BM25TestCase):
class TestBM25SLoadingSaving(unittest.TestCase):
@classmethod
def setUpClass(cls):

Expand Down
2 changes: 1 addition & 1 deletion tests/quick/test_topk.py → tests/core/test_topk.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_topk_jax_sorted(self):
@unittest.skipUnless(JAX_IS_AVAILABLE, "JAX is not available")
def test_topk_jax_unsorted(self):
result_scores, result_indices = topk(jnp.array(self.scores), self.k, backend="jax", sorted=False)
self.check_results(result_scores, result_indices, sorted=False)
self.check_results(result_scores, result_indices, sorted=True)

def test_topk_auto_backend(self):
result_scores, result_indices = topk(self.scores, self.k, backend="auto", sorted=True)
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions tests/requirements-core.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e .[full]

0 comments on commit d0744d4

Please sign in to comment.