|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main, develop] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + lint: |
| 12 | + name: Lint and Type Check |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: '3.11' |
| 23 | + cache: 'pip' |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install -r requirements-dev.txt |
| 29 | +
|
| 30 | + - name: Run flake8 |
| 31 | + run: | |
| 32 | + flake8 cli_audit tests --count --select=E9,F63,F7,F82 --show-source --statistics |
| 33 | + flake8 cli_audit tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 34 | +
|
| 35 | + - name: Run mypy |
| 36 | + run: | |
| 37 | + mypy cli_audit --ignore-missing-imports |
| 38 | + continue-on-error: true |
| 39 | + |
| 40 | + test: |
| 41 | + name: Test Suite |
| 42 | + runs-on: ${{ matrix.os }} |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 47 | + python-version: ['3.9', '3.10', '3.11', '3.12'] |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Set up Python ${{ matrix.python-version }} |
| 54 | + uses: actions/setup-python@v5 |
| 55 | + with: |
| 56 | + python-version: ${{ matrix.python-version }} |
| 57 | + cache: 'pip' |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + run: | |
| 61 | + python -m pip install --upgrade pip |
| 62 | + pip install -r requirements-dev.txt |
| 63 | +
|
| 64 | + - name: Run unit tests |
| 65 | + run: | |
| 66 | + pytest tests/unit -v --cov=cli_audit --cov-report=xml --cov-report=term |
| 67 | +
|
| 68 | + - name: Run integration tests |
| 69 | + run: | |
| 70 | + pytest tests/integration -v --cov=cli_audit --cov-append --cov-report=xml --cov-report=term |
| 71 | +
|
| 72 | + - name: Upload coverage to Codecov |
| 73 | + uses: codecov/codecov-action@v4 |
| 74 | + with: |
| 75 | + file: ./coverage.xml |
| 76 | + flags: unittests |
| 77 | + name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} |
| 78 | + fail_ci_if_error: false |
| 79 | + |
| 80 | + security: |
| 81 | + name: Security Scan |
| 82 | + runs-on: ubuntu-latest |
| 83 | + |
| 84 | + steps: |
| 85 | + - name: Checkout code |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Set up Python |
| 89 | + uses: actions/setup-python@v5 |
| 90 | + with: |
| 91 | + python-version: '3.11' |
| 92 | + |
| 93 | + - name: Install dependencies |
| 94 | + run: | |
| 95 | + python -m pip install --upgrade pip |
| 96 | + pip install bandit safety |
| 97 | +
|
| 98 | + - name: Run bandit |
| 99 | + run: | |
| 100 | + bandit -r cli_audit -f json -o bandit-report.json || true |
| 101 | + bandit -r cli_audit |
| 102 | + continue-on-error: true |
| 103 | + |
| 104 | + - name: Run safety check |
| 105 | + run: | |
| 106 | + safety check --json || true |
| 107 | + safety check |
| 108 | + continue-on-error: true |
| 109 | + |
| 110 | + build: |
| 111 | + name: Build Distribution |
| 112 | + runs-on: ubuntu-latest |
| 113 | + needs: [lint, test] |
| 114 | + |
| 115 | + steps: |
| 116 | + - name: Checkout code |
| 117 | + uses: actions/checkout@v4 |
| 118 | + |
| 119 | + - name: Set up Python |
| 120 | + uses: actions/setup-python@v5 |
| 121 | + with: |
| 122 | + python-version: '3.11' |
| 123 | + |
| 124 | + - name: Install build tools |
| 125 | + run: | |
| 126 | + python -m pip install --upgrade pip |
| 127 | + pip install build twine |
| 128 | +
|
| 129 | + - name: Build package |
| 130 | + run: | |
| 131 | + python -m build |
| 132 | +
|
| 133 | + - name: Check package |
| 134 | + run: | |
| 135 | + twine check dist/* |
| 136 | +
|
| 137 | + - name: Upload artifacts |
| 138 | + uses: actions/upload-artifact@v4 |
| 139 | + with: |
| 140 | + name: distributions |
| 141 | + path: dist/ |
| 142 | + |
| 143 | + docs: |
| 144 | + name: Documentation Check |
| 145 | + runs-on: ubuntu-latest |
| 146 | + |
| 147 | + steps: |
| 148 | + - name: Checkout code |
| 149 | + uses: actions/checkout@v4 |
| 150 | + |
| 151 | + - name: Set up Python |
| 152 | + uses: actions/setup-python@v5 |
| 153 | + with: |
| 154 | + python-version: '3.11' |
| 155 | + |
| 156 | + - name: Check README |
| 157 | + run: | |
| 158 | + python -m pip install --upgrade pip |
| 159 | + pip install markdown |
| 160 | + python -c "import markdown; markdown.markdown(open('README.md').read())" |
| 161 | +
|
| 162 | + - name: Validate YAML configs |
| 163 | + run: | |
| 164 | + pip install pyyaml |
| 165 | + python -c "import yaml; yaml.safe_load(open('.cli-audit.yml').read())" || echo "No config file" |
| 166 | +
|
| 167 | + integration-e2e: |
| 168 | + name: End-to-End Integration |
| 169 | + runs-on: ubuntu-latest |
| 170 | + needs: [test] |
| 171 | + |
| 172 | + steps: |
| 173 | + - name: Checkout code |
| 174 | + uses: actions/checkout@v4 |
| 175 | + |
| 176 | + - name: Set up Python |
| 177 | + uses: actions/setup-python@v5 |
| 178 | + with: |
| 179 | + python-version: '3.11' |
| 180 | + |
| 181 | + - name: Install package |
| 182 | + run: | |
| 183 | + python -m pip install --upgrade pip |
| 184 | + pip install -e . |
| 185 | +
|
| 186 | + - name: Test CLI execution |
| 187 | + run: | |
| 188 | + python cli_audit.py --help |
| 189 | + CLI_AUDIT_JSON=1 python cli_audit.py --only python-core | jq '.' |
| 190 | +
|
| 191 | + - name: Test programmatic API |
| 192 | + run: | |
| 193 | + python -c "from cli_audit import Config, Environment, load_config; c = Config(); print('✓ API works')" |
0 commit comments