|
| 1 | +# |
| 2 | +# Master CI/CD Pipeline |
| 3 | +# |
| 4 | +# This workflow orchestrates all CI/CD jobs. Comment out any jobs you want to skip during development. |
| 5 | +# OS and Python version configuration is centralized in config.yml. |
| 6 | +# |
| 7 | + |
| 8 | +name: CI/CD |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + branches: [main, develop] |
| 13 | + pull_request: |
| 14 | + branches: [main, develop] |
| 15 | + workflow_dispatch: # Allow manual triggering |
| 16 | + |
| 17 | +jobs: |
| 18 | + # ============================================================ |
| 19 | + # Load Configuration |
| 20 | + # ============================================================ |
| 21 | + load-config: |
| 22 | + uses: ./.github/workflows/config.yml |
| 23 | + |
| 24 | + # ============================================================ |
| 25 | + # Pipeline Jobs - Comment out any you want to skip |
| 26 | + # ============================================================ |
| 27 | + |
| 28 | + # Job 1: Run tests across all OS/Python combinations |
| 29 | + test: |
| 30 | + name: Test (${{ matrix.os }}, Python ${{ matrix.python-version }}) |
| 31 | + needs: load-config |
| 32 | + runs-on: ${{ matrix.os }} |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + os: ${{ fromJSON(needs.load-config.outputs.os-matrix) }} |
| 37 | + python-version: ${{ fromJSON(needs.load-config.outputs.python-matrix) }} |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + submodules: recursive |
| 43 | + |
| 44 | + - name: Set up Python |
| 45 | + uses: actions/setup-python@v5 |
| 46 | + with: |
| 47 | + python-version: ${{ matrix.python-version }} |
| 48 | + cache: 'pip' |
| 49 | + |
| 50 | + - name: Install system dependencies (Linux) |
| 51 | + if: runner.os == 'Linux' |
| 52 | + run: | |
| 53 | + sudo apt-get update |
| 54 | + sudo apt-get install -y cmake ninja-build libssl-dev pkg-config autoconf automake libtool |
| 55 | +
|
| 56 | + - name: Install system dependencies (macOS) |
| 57 | + if: runner.os == 'macOS' |
| 58 | + run: brew install cmake ninja openssl@3 libnghttp2 |
| 59 | + |
| 60 | + - name: Install system dependencies (Windows) |
| 61 | + if: runner.os == 'Windows' |
| 62 | + run: choco install cmake -y |
| 63 | + |
| 64 | + - name: Setup MSVC (Windows) |
| 65 | + if: runner.os == 'Windows' |
| 66 | + uses: microsoft/setup-msbuild@v2 |
| 67 | + |
| 68 | + - name: Setup vendor dependencies |
| 69 | + run: | |
| 70 | + chmod +x scripts/setup_vendors.sh |
| 71 | + ./scripts/setup_vendors.sh |
| 72 | + shell: bash |
| 73 | + |
| 74 | + - name: Install package |
| 75 | + run: pip install -e ".[dev]" |
| 76 | + |
| 77 | + - name: Lint |
| 78 | + run: ruff check src/ tests/ |
| 79 | + |
| 80 | + - name: Run tests |
| 81 | + run: pytest tests/ -v --cov=httpmorph --cov-report=xml |
| 82 | + |
| 83 | + - name: Upload coverage |
| 84 | + if: matrix.os == needs.load-config.outputs.primary-os && matrix.python-version == needs.load-config.outputs.primary-python |
| 85 | + uses: codecov/codecov-action@v4 |
| 86 | + with: |
| 87 | + file: ./coverage.xml |
| 88 | + |
| 89 | + # Job 2: Run benchmarks (comment out to skip) |
| 90 | + # benchmark: |
| 91 | + # name: Benchmark |
| 92 | + # needs: [load-config, test] |
| 93 | + # runs-on: ${{ needs.load-config.outputs.primary-os }} |
| 94 | + |
| 95 | + # steps: |
| 96 | + # - uses: actions/checkout@v4 |
| 97 | + |
| 98 | + # - name: Set up Python |
| 99 | + # uses: actions/setup-python@v5 |
| 100 | + # with: |
| 101 | + # python-version: ${{ needs.load-config.outputs.primary-python }} |
| 102 | + # cache: 'pip' |
| 103 | + |
| 104 | + # - name: Install dependencies |
| 105 | + # run: | |
| 106 | + # sudo apt-get update && sudo apt-get install -y cmake ninja-build libssl-dev |
| 107 | + # chmod +x scripts/setup_vendors.sh |
| 108 | + # ./scripts/setup_vendors.sh |
| 109 | + # pip install -e ".[dev,benchmark]" |
| 110 | + |
| 111 | + # - name: Run benchmarks |
| 112 | + # run: pytest benchmarks/ --benchmark-only --benchmark-json=benchmark.json |
| 113 | + |
| 114 | + # - name: Store benchmark |
| 115 | + # uses: benchmark-action/github-action-benchmark@v1 |
| 116 | + # with: |
| 117 | + # tool: 'pytest' |
| 118 | + # output-file-path: benchmark.json |
| 119 | + # github-token: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + # auto-push: true |
| 121 | + |
| 122 | + # Job 3: Type checking (comment out to skip) |
| 123 | + # typecheck: |
| 124 | + # name: Type Check |
| 125 | + # needs: load-config |
| 126 | + # runs-on: ${{ needs.load-config.outputs.primary-os }} |
| 127 | + # |
| 128 | + # steps: |
| 129 | + # - uses: actions/checkout@v4 |
| 130 | + # |
| 131 | + # - name: Set up Python |
| 132 | + # uses: actions/setup-python@v5 |
| 133 | + # with: |
| 134 | + # python-version: ${{ needs.load-config.outputs.primary-python }} |
| 135 | + # cache: 'pip' |
| 136 | + # |
| 137 | + # - name: Install package |
| 138 | + # run: pip install -e ".[dev]" |
| 139 | + # |
| 140 | + # - name: Run mypy |
| 141 | + # run: mypy src/ |
| 142 | + |
| 143 | + # Job 4: Security scanning (comment out to skip) |
| 144 | + # security: |
| 145 | + # name: Security Scan |
| 146 | + # needs: load-config |
| 147 | + # runs-on: ${{ needs.load-config.outputs.primary-os }} |
| 148 | + # |
| 149 | + # steps: |
| 150 | + # - uses: actions/checkout@v4 |
| 151 | + # |
| 152 | + # - name: Set up Python |
| 153 | + # uses: actions/setup-python@v5 |
| 154 | + # with: |
| 155 | + # python-version: ${{ needs.load-config.outputs.primary-python }} |
| 156 | + # |
| 157 | + # - name: Run bandit |
| 158 | + # run: | |
| 159 | + # pip install bandit |
| 160 | + # bandit -r src/ -f json -o bandit-report.json |
| 161 | + # |
| 162 | + # - name: Upload security report |
| 163 | + # uses: actions/upload-artifact@v4 |
| 164 | + # with: |
| 165 | + # name: security-report |
| 166 | + # path: bandit-report.json |
| 167 | + |
| 168 | + # ============================================================ |
| 169 | + # Status Check - All jobs must pass |
| 170 | + # ============================================================ |
| 171 | + all-checks-passed: |
| 172 | + name: All Checks Passed |
| 173 | + needs: [test] # Add other job dependencies here when uncommented |
| 174 | + runs-on: ubuntu-latest |
| 175 | + if: always() |
| 176 | + |
| 177 | + steps: |
| 178 | + - name: Check all jobs succeeded |
| 179 | + run: | |
| 180 | + if [ "${{ needs.test.result }}" != "success" ]; then |
| 181 | + echo "❌ Tests failed" |
| 182 | + exit 1 |
| 183 | + fi |
| 184 | + # Uncomment when benchmark job is enabled |
| 185 | + # if [ "${{ needs.benchmark.result }}" != "success" ]; then |
| 186 | + # echo "❌ Benchmarks failed" |
| 187 | + # exit 1 |
| 188 | + # fi |
| 189 | + echo "✅ All checks passed!" |
0 commit comments