cki_tox_pipeline.md

Flowchart of the tox-based pipeline stages (linting/testing) in CKI projects.
flowchart TB
    subgraph "GitLab CI/CD Pipeline"
        A0["Project .gitlab-ci.yml"] --> A1["include: cki-templates.yml"]
        A1 --> A["Tests / Linting Pipeline Stage<br/>(inherited from templates)"]
        A --> B["cki-tools:production container"]
    end

    subgraph "cki-tools:production container"

    subgraph "Repository Setup"
        B --> C["tox -e &lt;lint/test&gt;"]
        C --> E["cki_lint.sh/cki_test.sh"]
    end

    subgraph "Preparation Phase (cki_prepare.sh)"
        E --> F{"CKI_SKIP_PREPARE?"}
        F -->|false| H["Install dependencies"]
        H --> I["Check and update cki-lib version<br/>(in CI/MR jobs)"]
        I --> J{"cki_lib_pip_url<br/>override?"}
        J -->|yes| K["Uninstall & reinstall<br/>cki-lib + extras"]
        J -->|no| M["Process other<br/>*_pip_url overrides"]
        K --> M
        M --> N["Continue execution"]
        F -->|true| N
    end

    subgraph "Script Execution"
        N --> O{"Script Type"}
        O -->|cki_lint.sh| P["Configure linters<br/>(flake8, ruff, etc.)"]
        O -->|cki_test.sh| Q["Configure pytest<br/>& coverage"]

        P --> R["Check disabled/ignored<br/>linters"]
        R --> S["maybe_run_linter &lt;linter&gt;"]

        Q --> T["run_pytest with coverage"]
    end

    subgraph "Linter Execution Loop"
        S --> U{"Linter disabled?"}
        U -->|yes| V["Skip linter<br/>"]
        U -->|no| W["run_&lt;linter&gt; function"]
        W --> X["Execute actual linter<br/>(flake8, ruff, pylint, etc.)"]
        X --> Y{"Linter passed?"}
        Y -->|yes| Z["Continue to next"]
        Y -->|no| AA["Record failure/warning<br/>(based on ignored list)"]
        AA --> Z
        V --> Z
        Z --> AB{"More linters?"}
        AB -->|yes| S
        AB -->|no| AC["Check results"]
    end

    subgraph "Test Execution (pytest)"
        T --> AD["Run pytest with<br/>coverage tracking"]
        AD --> AE["Generate coverage reports<br/>(HTML, XML, terminal)"]
        AE --> AF{"Coverage enabled?"}
        AF -->|no| AG["Skip coverage check"]
        AF -->|yes| AH["Calculate coverage<br/>percentage"]
        AH --> AI{"Coverage decreased?"}
        AI -->|no| AG
        AI -->|yes| AJ{"Skip coverage<br/>check flag?"}
        AJ -->|yes| AG
        AJ -->|no| AK["Fail with coverage error"]
        AG --> AL["Complete testing"]
        AK --> AL
    end

    subgraph "Final Results"
        AC --> AM{"Any failures?"}
        AM -->|warnings only| AN["Exit 0<br/>(create .cki_lint_warn)"]
        AM -->|failures| AO["Exit 1"]
        AM -->|success| AP["Exit 0"]

        AL --> AQ{"Test failures?"}
        AQ -->|yes| AR["Exit 1"]
        AQ -->|no| AS["Exit 0"]
    end

    end