mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-09-13 04:04:09 +00:00
114 lines
3.2 KiB
YAML
114 lines
3.2 KiB
YAML
name: CI
|
|
|
|
# This workflow runs tests and code quality checks
|
|
# It runs on every push and pull request to main and develop branches
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
# Permissions needed for this workflow
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
# Job 1: Run Tests and Check Coverage
|
|
test-and-coverage:
|
|
name: Test & Coverage (${{ matrix.python-version }})
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false # Don't stop other versions if one fails
|
|
matrix:
|
|
python-version: ['3.10', '3.11', '3.12']
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Free Disk Space (Ubuntu)
|
|
uses: jlumbroso/free-disk-space@main
|
|
with:
|
|
tool-cache: false
|
|
android: true
|
|
dotnet: true
|
|
haskell: true
|
|
large-packages: true
|
|
docker-images: true
|
|
swap-storage: true
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Cache pip packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -e ".[dev]"
|
|
|
|
- name: Verify installation
|
|
run: python -c "import semantica; print(f'Version: {semantica.__version__}')"
|
|
|
|
- name: Run tests
|
|
# Runs pytest only if tests directory exists
|
|
run: |
|
|
if [ -d "tests" ] && [ "$(find tests -name 'test_*.py' -o -name '*_test.py' | wc -l)" -gt 0 ]; then
|
|
pytest --cov=semantica --cov-report=xml --cov-report=term-missing -v
|
|
else
|
|
echo "No tests found. Skipping."
|
|
fi
|
|
|
|
- name: Upload coverage to Codecov
|
|
# Only upload coverage for Python 3.11 to avoid duplicates
|
|
if: matrix.python-version == '3.11'
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
file: ./coverage.xml
|
|
flags: unittests
|
|
name: codecov-umbrella
|
|
fail_ci_if_error: false
|
|
|
|
# Job 2: Check Code Quality (Linting)
|
|
quality-checks:
|
|
name: Code Quality Checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -e ".[dev]"
|
|
|
|
- name: Check formatting (black)
|
|
# Fails if code is not formatted correctly
|
|
run: black --check semantica/
|
|
|
|
- name: Check import sorting (isort)
|
|
# Fails if imports are not sorted correctly
|
|
run: isort --check-only semantica/
|
|
|
|
- name: Run linter (flake8)
|
|
# Fails if there are syntax errors or style violations
|
|
run: flake8 semantica/
|
|
|
|
- name: Type check (mypy)
|
|
# Fails if there are type errors
|
|
run: mypy semantica/
|