Skip to content

Implement core graph generation features and project setup #2

Implement core graph generation features and project setup

Implement core graph generation features and project setup #2

Workflow file for this run

# Compgrapher CI/CD Workflow
# ==========================
# This workflow runs on every push and pull request to ensure code quality
# and proper functionality across multiple Python versions.
name: CI
on:
push:
branches: [main, master, develop]
paths-ignore:
- '**.md'
- 'docs/**'
- '.gitignore'
pull_request:
branches: [main, master, develop]
paths-ignore:
- '**.md'
- 'docs/**'
- '.gitignore'
workflow_dispatch: # Allow manual triggers
env:
PYTHON_DEFAULT_VERSION: "3.11"
jobs:
# ===========================================================================
# Linting and Code Quality
# ===========================================================================
lint:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black isort flake8
- name: Check formatting with Black
run: black --check --diff .
continue-on-error: true
- name: Check import sorting with isort
run: isort --check-only --diff .
continue-on-error: true
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
# ===========================================================================
# Unit Tests
# ===========================================================================
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- os: windows-latest
python-version: "3.11"
- os: macos-latest
python-version: "3.11"
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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('**/requirements.txt', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pyyaml
- name: Run tests
run: |
pytest tests/ -v --tb=short
- name: Run tests with coverage
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
run: |
pytest tests/ -v --cov=. --cov-report=xml --cov-report=html
- name: Upload coverage to Codecov
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
fail_ci_if_error: false
verbose: true
continue-on-error: true
# ===========================================================================
# Integration Tests
# ===========================================================================
integration:
name: Integration Tests
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyyaml
- name: Create test input directory
run: mkdir -p input/csv
- name: Create sample test data
run: |
cat > input/csv/test_data.csv << 'EOF'
POSITION TITLE,Employer A,Employer B,Employer C
Software Engineer,100,95,105
,80,75,85
Data Scientist,120,110,115
,90,85,95
EOF
- name: Run main script with test data
run: |
python main.py --input input/csv/test_data.csv --output png svg
continue-on-error: true
- name: Verify output files created
run: |
ls -la output/ || echo "Output directory not created"
ls -la output/png/ || echo "PNG output not created"
ls -la output/svg/ || echo "SVG output not created"
- name: Upload generated artifacts
uses: actions/upload-artifact@v4
with:
name: generated-graphs
path: output/
retention-days: 5
if: always()
# ===========================================================================
# Security Scanning
# ===========================================================================
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install bandit
run: pip install bandit[toml]
- name: Run security scan
run: bandit -r . -x ./tests,./output,./.venv -ll
continue-on-error: true
# ===========================================================================
# Build Package
# ===========================================================================
build:
name: Build Package
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Check package
run: twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 5
# ===========================================================================
# Type Checking (Optional)
# ===========================================================================
type-check:
name: Type Checking
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy pandas-stubs types-PyYAML
pip install -r requirements.txt
- name: Run type checking
run: mypy . --ignore-missing-imports
continue-on-error: true