|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + FORCE_COLOR: 1 |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }} |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + os: [ubuntu-latest] |
| 21 | + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set up Python ${{ matrix.python-version }} |
| 28 | + uses: actions/setup-python@v4 |
| 29 | + with: |
| 30 | + python-version: ${{ matrix.python-version }} |
| 31 | + |
| 32 | + - name: Get pip cache dir |
| 33 | + id: pip-cache |
| 34 | + run: | |
| 35 | + echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT |
| 36 | +
|
| 37 | + - name: Cache pip dependencies |
| 38 | + uses: actions/cache@v3 |
| 39 | + with: |
| 40 | + path: ${{ steps.pip-cache.outputs.dir }} |
| 41 | + key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/tests/requirements.txt') }} |
| 42 | + restore-keys: | |
| 43 | + ${{ runner.os }}-pip-${{ matrix.python-version }}- |
| 44 | + ${{ runner.os }}-pip- |
| 45 | +
|
| 46 | + - name: Install dependencies |
| 47 | + run: | |
| 48 | + python -m pip install --upgrade pip setuptools wheel |
| 49 | + pip install -e .[dev] |
| 50 | +
|
| 51 | + - name: Lint with flake8 |
| 52 | + run: | |
| 53 | + # Stop the build if there are Python syntax errors or undefined names |
| 54 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 55 | + # Exit-zero treats all errors as warnings |
| 56 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics |
| 57 | +
|
| 58 | + - name: Type check with mypy |
| 59 | + run: | |
| 60 | + mypy himl/ --ignore-missing-imports |
| 61 | +
|
| 62 | + - name: Run tests with pytest |
| 63 | + run: | |
| 64 | + python -m pytest tests/ -v --tb=short --cov=himl --cov-report=xml --cov-report=term-missing --cov-fail-under=80 |
| 65 | +
|
| 66 | + - name: Upload coverage to Codecov |
| 67 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.14' |
| 68 | + uses: codecov/codecov-action@v3 |
| 69 | + with: |
| 70 | + file: ./coverage.xml |
| 71 | + flags: unittests |
| 72 | + name: codecov-umbrella |
| 73 | + fail_ci_if_error: false |
| 74 | + |
| 75 | + security: |
| 76 | + name: Security checks |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Set up Python |
| 83 | + uses: actions/setup-python@v4 |
| 84 | + with: |
| 85 | + python-version: '3.14' |
| 86 | + |
| 87 | + - name: Install security tools |
| 88 | + run: | |
| 89 | + python -m pip install --upgrade pip |
| 90 | + pip install bandit[toml] safety |
| 91 | +
|
| 92 | + - name: Run security checks with bandit |
| 93 | + run: | |
| 94 | + bandit -r himl/ -f json -o bandit-report.json || true |
| 95 | + bandit -r himl/ --severity-level medium |
| 96 | +
|
| 97 | + - name: Check dependencies for known security vulnerabilities |
| 98 | + run: | |
| 99 | + pip install -e . |
| 100 | + safety check --json --output safety-report.json || true |
| 101 | + safety check |
| 102 | +
|
| 103 | + - name: Upload security reports |
| 104 | + if: always() |
| 105 | + uses: actions/upload-artifact@v3 |
| 106 | + with: |
| 107 | + name: security-reports |
| 108 | + path: | |
| 109 | + bandit-report.json |
| 110 | + safety-report.json |
| 111 | +
|
| 112 | + build: |
| 113 | + name: Build package |
| 114 | + runs-on: ubuntu-latest |
| 115 | + steps: |
| 116 | + - name: Checkout code |
| 117 | + uses: actions/checkout@v4 |
| 118 | + with: |
| 119 | + fetch-depth: 0 # Needed for setuptools_scm |
| 120 | + |
| 121 | + - name: Set up Python |
| 122 | + uses: actions/setup-python@v4 |
| 123 | + with: |
| 124 | + python-version: '3.14' |
| 125 | + |
| 126 | + - name: Install build dependencies |
| 127 | + run: | |
| 128 | + python -m pip install --upgrade pip |
| 129 | + pip install build twine |
| 130 | +
|
| 131 | + - name: Build package |
| 132 | + run: | |
| 133 | + python -m build |
| 134 | +
|
| 135 | + - name: Check package |
| 136 | + run: | |
| 137 | + twine check dist/* |
| 138 | +
|
| 139 | + - name: Test package installation |
| 140 | + run: | |
| 141 | + pip install dist/*.whl |
| 142 | + himl --help |
| 143 | + himl-config-merger --help |
| 144 | +
|
| 145 | + - name: Upload build artifacts |
| 146 | + uses: actions/upload-artifact@v3 |
| 147 | + with: |
| 148 | + name: dist-${{ github.sha }} |
| 149 | + path: dist/ |
| 150 | + retention-days: 30 |
| 151 | + |
| 152 | + integration: |
| 153 | + name: Integration tests |
| 154 | + runs-on: ubuntu-latest |
| 155 | + needs: [test, build] |
| 156 | + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' |
| 157 | + steps: |
| 158 | + - name: Checkout code |
| 159 | + uses: actions/checkout@v4 |
| 160 | + |
| 161 | + - name: Set up Python |
| 162 | + uses: actions/setup-python@v4 |
| 163 | + with: |
| 164 | + python-version: '3.14' |
| 165 | + |
| 166 | + - name: Download build artifacts |
| 167 | + uses: actions/download-artifact@v3 |
| 168 | + with: |
| 169 | + name: dist-${{ github.sha }} |
| 170 | + path: dist/ |
| 171 | + |
| 172 | + - name: Install package from wheel |
| 173 | + run: | |
| 174 | + python -m pip install --upgrade pip |
| 175 | + pip install dist/*.whl |
| 176 | +
|
| 177 | + - name: Run integration tests |
| 178 | + run: | |
| 179 | + # Test CLI tools work |
| 180 | + himl --help |
| 181 | + himl-config-merger --help |
| 182 | +
|
| 183 | + # Test basic functionality with examples |
| 184 | + if [ -d "examples" ]; then |
| 185 | + cd examples |
| 186 | + if [ -d "simple" ]; then |
| 187 | + himl simple/production --format yaml |
| 188 | + fi |
| 189 | + fi |
0 commit comments