Skip to content

CI: Implement basic linting and testing workflow #120

@senomorf

Description

@senomorf

Objective

Implement basic Continuous Integration workflow to run linting and unit tests on every pull request and push, providing immediate feedback on code quality and preventing regressions.

Current State

No CI/CD exists for LoadShaper application:

  • .github/workflows/ contains only AI-powered code review workflows
  • No automated quality checks for Python code
  • No automated test execution
  • Manual verification of code changes

Target State

Basic CI workflow that provides immediate value:

  • Lint Python code on every PR/push using flake8 or pylint
  • Run existing unit test suite (pytest -q)
  • Fail fast on quality issues
  • Simple, lightweight workflow focused on core quality gates

Implementation Approach

GitHub Actions Workflow

File: .github/workflows/ci.yml

name: CI

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12"]
    
    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 -r requirements.txt
          pip install -r requirements-dev.txt
          
      - name: Lint with flake8
        run: |
          # Stop build if there are syntax errors or undefined names
          flake8 loadshaper.py --count --select=E9,F63,F7,F82 --show-source --statistics
          # Treat all other issues as warnings
          flake8 loadshaper.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
          
      - name: Run unit tests
        run: pytest -q --tb=short
        
      - name: Test basic functionality
        run: |
          # Quick smoke test - validate imports and basic functionality
          python -c "import loadshaper; print('LoadShaper imports successfully')"

Why This Approach

High Value, Low Effort

  • Immediate benefit: Catches syntax errors, import issues, test regressions
  • Simple implementation: Single workflow file, uses standard Python tools
  • Fast feedback: Developers get quick feedback on PRs

Focused on Essentials

  • Linting: Catches basic code quality issues
  • Testing: Ensures existing test suite continues to pass
  • Multi-Python support: Tests compatibility across Python versions
  • Smoke test: Verifies basic import functionality

Foundation for Future CI

  • Establishes the CI infrastructure
  • Provides base for adding Docker builds, security scans, etc.
  • Creates the quality gate pattern for future enhancements

Success Criteria

CI Workflow

  • Workflow runs on every PR and push to main/master
  • Tests run across Python 3.10, 3.11, 3.12
  • Linting catches syntax errors and basic quality issues
  • All existing tests continue to pass
  • Workflow completes in under 5 minutes

Developer Experience

  • Clear feedback on PR quality issues
  • Fast failure on critical problems (syntax errors)
  • Non-blocking warnings for style issues
  • Easy to understand failure messages

Quality Gates

  • No PRs merge with failing tests
  • No PRs merge with syntax errors
  • Style warnings provide guidance without blocking

Related Issues

  • Foundation for: #[SECURITY_SCAN_ISSUE] (vulnerability scanning requires CI foundation)
  • Foundation for: #[DOCKER_BUILD_ISSUE] (automated builds require CI infrastructure)
  • Addresses gap from: Closed CI/CD Automation Pipeline #82 (over-scoped CI/CD pipeline)

Testing Requirements

Workflow Testing

  • Test workflow with intentional syntax error (should fail)
  • Test workflow with failing test (should fail)
  • Test workflow with style warnings (should succeed with warnings)
  • Verify workflow runs on fork PRs correctly

Integration Validation

  • Workflow integrates with existing development process
  • No conflicts with existing AI-powered review workflows
  • Performance acceptable for development velocity

Priority: P1-important - Foundation for all future CI/CD work
Effort: Low - Single workflow file, standard Python tooling
Value: High - Immediate quality improvement and regression prevention

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-importantReliability & usability (fix soon)ci-cdCI/CD automation taskstestingTest suites and CI

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions