Skip to content

Commit 32f2f67

Browse files
authored
Merge pull request #37 from carlosmada22/14-unit-testing
Unit tests developed for each main function
2 parents d99fa68 + b17dde2 commit 32f2f67

22 files changed

+1019
-1193
lines changed

.github/workflows/ci.yml

Lines changed: 86 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
name: Installing and Testing
2-
on: [push]
1+
name: CI Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- main
310

4-
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
5-
# `contents` is for permission to the contents of the repository.
6-
# `pull-requests` is for permission to pull request
711
permissions:
812
contents: write
913
checks: write
@@ -13,32 +17,89 @@ env:
1317
UV_SYSTEM_PYTHON: true
1418

1519
jobs:
16-
install-and-test:
20+
linting-and-formatting:
21+
name: Ruff Lint & Format
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Ruff Check
26+
uses: chartboost/ruff-action@v1
27+
with:
28+
args: "check ."
29+
- name: Ruff Format Check
30+
uses: chartboost/ruff-action@v1
31+
with:
32+
args: "format . --check"
33+
34+
unit-tests-and-coverage:
35+
name: Unit Tests, Mypy & Coverage (Python ${{ matrix.python_version }})
1736
runs-on: ubuntu-latest
1837
strategy:
1938
fail-fast: false
2039
matrix:
2140
python_version: ["3.10", "3.11", "3.12"]
2241
steps:
23-
- uses: actions/checkout@v4
24-
- name: Set up Python ${{matrix.python_version}}
25-
uses: actions/setup-python@v5
26-
with:
27-
python-version: ${{matrix.python_version}}
28-
- name: Install uv
29-
run: |
30-
curl -LsSf https://astral.sh/uv/install.sh | sh
31-
- name: Install dependencies
32-
run: |
33-
pip install --upgrade pip
34-
uv pip install -e '.[dev]'
35-
# - name: mypy
36-
# run: |
37-
# python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional bam_masterdata tests
38-
- name: Test with pytest
39-
run: |
40-
python -m pytest -sv --ignore=tests/cli --ignore=tests/metadata/test_entities_dict.py tests
42+
- uses: actions/checkout@v4
43+
- name: Set up Python ${{matrix.python_version}}
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{matrix.python_version}}
47+
- name: Install uv
48+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
49+
- name: Install dependencies
50+
run: |
51+
uv pip install -e '.[dev]'
52+
uv pip install coveralls
53+
54+
- name: Mypy Type Checking
55+
# --- THE FIX IS HERE ---
56+
# This step will now ONLY run on pull requests or on pushes to the main branch.
57+
# It will be SKIPPED on pushes to feature branches.
58+
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
59+
run: |
60+
echo "Running Mypy because this is a pull request or a push to main..."
61+
python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional src/desi tests
62+
63+
- name: Run Unit Tests & Build coverage file
64+
run: |
65+
pytest --cov-config=.coveragerc --junitxml=pytest.xml --cov=src/desi -m "not integration" --ignore=tests/cli --ignore=tests/metadata/test_entities_dict.py tests | tee pytest-coverage.txt
66+
67+
- name: Pytest coverage comment
68+
if: matrix.python_version == '3.12'
69+
uses: MishaKav/pytest-coverage-comment@main
70+
with:
71+
pytest-coverage-path: pytest-coverage.txt
72+
junitxml-path: pytest.xml
73+
- name: Submit to coveralls
74+
if: matrix.python_version == '3.12'
75+
continue-on-error: true
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
run: |
79+
coveralls --service=github
80+
81+
integration-tests:
82+
name: Integration Tests
83+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
84+
needs: [linting-and-formatting, unit-tests-and-coverage]
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v4
88+
- name: Set up Python 3.12
89+
uses: actions/setup-python@v5
90+
with:
91+
python-version: 3.12
92+
- name: Install uv
93+
run: |
94+
curl -LsSf https://astral.sh/uv/install.sh | sh
95+
- name: Install dependencies
96+
run: uv pip install -e '.[dev]'
97+
- name: Run Integration Tests
98+
run: |
99+
python -m pytest -sv -m "integration" tests/
100+
41101
build-and-install:
102+
name: Build and Install
42103
runs-on: ubuntu-latest
43104
steps:
44105
- uses: actions/checkout@v4
@@ -55,18 +116,4 @@ jobs:
55116
python -m build --sdist
56117
- name: Install the package
57118
run: |
58-
uv pip install dist/*.tar.gz
59-
ruff-linting:
60-
runs-on: ubuntu-latest
61-
steps:
62-
- uses: actions/checkout@v4
63-
- uses: chartboost/ruff-action@v1
64-
with:
65-
args: "check ."
66-
ruff-formatting:
67-
runs-on: ubuntu-latest
68-
steps:
69-
- uses: actions/checkout@v4
70-
- uses: chartboost/ruff-action@v1
71-
with:
72-
args: "format . --check --verbose"
119+
uv pip install dist/*.tar.gz

.github/workflows/coveralls.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Data folders
2+
data/
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[codz]

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,6 @@ DeSi/
312312
│ ├── cli.py # Web CLI interface
313313
│ ├── 📁 templates/ # HTML templates
314314
│ └── 📁 static/ # CSS, JS, images
315-
├── 📁 scripts/ # Utility scripts
316-
│ ├── run_complete_pipeline.py # End-to-end pipeline runner
317-
│ ├── integration_test.py # Integration testing
318-
│ └── ingest_to_vectordb.py # Direct vector DB ingestion
319315
├── 📁 tests/ # Unit and integration tests
320316
├── 📁 data/ # Data storage
321317
│ ├── 📁 raw/ # Scraped raw content

desi_vectordb/chroma.sqlite3

0 Bytes
Binary file not shown.

scripts/ingest_to_vectordb.py

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)