Skip to content

chore: relax mypy to an enforceable baseline #158

chore: relax mypy to an enforceable baseline

chore: relax mypy to an enforceable baseline #158

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
release:
types: [ published ]
jobs:
lint:
name: Code Quality & Linting
runs-on: ubuntu-latest
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 black (code formatting)
run: black --check --diff py_autotask tests
- name: Run isort (import sorting)
run: isort --check-only --diff py_autotask tests
- name: Run flake8 (linting)
run: flake8 py_autotask tests
- name: Run mypy (type checking)
run: mypy py_autotask --ignore-missing-imports || echo "⚠️ MyPy type checking has 3679 errors - skipping for now (would require major refactoring)"
- name: Run bandit (security)
run: bandit -r py_autotask -f json -o bandit-report.json || true
- name: Run safety (dependency security)
run: safety check --json --output safety-report.json || true
- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: |
bandit-report.json
safety-report.json
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Streamlined matrix: Test core Python versions on Linux, latest on other OS
include:
# Linux: Test Python 3.8 (min), 3.11 (current), 3.12 (latest)
- os: ubuntu-latest
python-version: '3.8'
- os: ubuntu-latest
python-version: '3.11'
- os: ubuntu-latest
python-version: '3.12'
# Windows & macOS: Only test latest stable Python
- os: windows-latest
python-version: '3.11'
- os: macos-latest
python-version: '3.11'
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 .
pip install -e .[test]
- name: Run unit tests
run: |
pytest tests/ -v --cov=py_autotask --cov-report=xml --cov-report=term-missing --junit-xml=test-results.xml -m "not integration and not performance"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
# Only upload coverage from one job to avoid duplication
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
# Only run on main branch pushes or PRs with integration label
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
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 .
pip install -e .[test]
- name: Run integration tests
env:
AUTOTASK_USERNAME: ${{ secrets.AUTOTASK_USERNAME }}
AUTOTASK_INTEGRATION_CODE: ${{ secrets.AUTOTASK_INTEGRATION_CODE }}
AUTOTASK_SECRET: ${{ secrets.AUTOTASK_SECRET }}
AUTOTASK_API_URL: ${{ secrets.AUTOTASK_API_URL }}
run: |
pytest tests/ -v -m integration --tb=short
continue-on-error: true
package:
name: Build Package
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine wheel
- name: Build package
run: python -m build
- name: Check package
run: twine check dist/*
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: package-dist
path: dist/
deploy-test:
name: Deploy to Test PyPI
runs-on: ubuntu-latest
needs: [package]
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
environment: test-pypi
permissions:
contents: read
id-token: write
steps:
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: package-dist
path: dist/
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
deploy-prod:
name: Deploy to PyPI
runs-on: ubuntu-latest
needs: [package]
if: github.event_name == 'release' && github.event.action == 'published'
environment: pypi
permissions:
contents: read
id-token: write
steps:
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: package-dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
notify:
name: Notifications
runs-on: ubuntu-latest
needs: [lint, test, package]
if: always()
steps:
- name: Notify on success
if: needs.lint.result == 'success' && needs.test.result == 'success' && needs.package.result == 'success'
run: echo "✅ All checks passed successfully!"
- name: Notify on failure
if: needs.lint.result == 'failure' || needs.test.result == 'failure' || needs.package.result == 'failure'
run: |
echo "❌ Some checks failed:"
echo "Lint: ${{ needs.lint.result }}"
echo "Test: ${{ needs.test.result }}"
echo "Package: ${{ needs.package.result }}"