name: Test Suite
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
ABUSEIPDB_API_KEY: ${{ secrets.ABUSEIPDB_API_KEY_TEST }}
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12']
name: Test Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run unit tests
run: |
pytest tests/ \
--cov=mcp_abuseipdb \
--cov-report=xml \
--cov-report=term-missing \
--ignore=tests/test_docker.py \
--ignore=tests/test_integration.py \
-v
# Codecov upload disabled due to rate limiting; re-enable when token available
integration-test:
runs-on: ubuntu-latest
name: Integration Tests
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run integration tests
run: |
pytest tests/test_integration.py -v
env:
ABUSEIPDB_API_KEY: mock_key_for_testing
package-test:
runs-on: ubuntu-latest
name: Package Installation Test
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Test package installation
run: |
python -m pip install --upgrade pip
pip install build
python -m build
pip install dist/*.whl
- name: Test package import
run: |
python -c "import mcp_abuseipdb; print('Package imported successfully')"
- name: Test CLI entry point
run: |
python -c "
try:
from mcp_abuseipdb.server import main
print('CLI entry point accessible')
except ImportError as e:
print(f'CLI import failed: {e}')
exit(1)
"
env:
ABUSEIPDB_API_KEY: test_key
dependency-check:
runs-on: ubuntu-latest
name: Dependency Analysis
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install pip-audit
run: pip install pip-audit
- name: Install project dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install .
- name: Generate requirements for audit
run: |
python -c "import pathlib, tomllib; data = tomllib.loads(pathlib.Path('pyproject.toml').read_text()); deps = list(dict.fromkeys(data.get('project', {}).get('dependencies', []))); dev_deps = data.get('project', {}).get('optional-dependencies', {}).get('dev', []); deps.extend(x for x in dev_deps if x not in deps); pathlib.Path('pip-audit-requirements.txt').write_text('\n'.join(deps) + '\n')"
- name: Run pip-audit
run: pip-audit -r pip-audit-requirements.txt