|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "**" |
| 7 | + tags: |
| 8 | + - "v*.*.*" |
| 9 | + pull_request: |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + confirm_publish: |
| 13 | + description: "Type true to publish the Docker image to GHCR" |
| 14 | + required: true |
| 15 | + default: "false" |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +env: |
| 21 | + IMAGE_NAME: ghcr.io/baseintelligence/hypercluster |
| 22 | + # Pin matches pyproject dependencies (release wheel). staging script re-reads pyproject. |
| 23 | + PYTHON_VERSION: "3.12" |
| 24 | + |
| 25 | +jobs: |
| 26 | + lint: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + - name: Install uv |
| 31 | + uses: astral-sh/setup-uv@v5 |
| 32 | + with: |
| 33 | + enable-cache: true |
| 34 | + - name: Set up Python |
| 35 | + run: uv python install ${{ env.PYTHON_VERSION }} |
| 36 | + - name: Install dependencies |
| 37 | + run: uv sync --extra dev |
| 38 | + - name: Ruff lint |
| 39 | + run: uv run ruff check . |
| 40 | + - name: Mypy type check |
| 41 | + run: uv run mypy |
| 42 | + |
| 43 | + format: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + - name: Install uv |
| 48 | + uses: astral-sh/setup-uv@v5 |
| 49 | + with: |
| 50 | + enable-cache: true |
| 51 | + - name: Set up Python |
| 52 | + run: uv python install ${{ env.PYTHON_VERSION }} |
| 53 | + - name: Install dependencies |
| 54 | + run: uv sync --extra dev |
| 55 | + - name: Ruff format check |
| 56 | + run: uv run ruff format --check . |
| 57 | + |
| 58 | + no-verda: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + - name: Install uv |
| 63 | + uses: astral-sh/setup-uv@v5 |
| 64 | + with: |
| 65 | + enable-cache: true |
| 66 | + - name: Set up Python |
| 67 | + run: uv python install ${{ env.PYTHON_VERSION }} |
| 68 | + - name: Install dependencies |
| 69 | + run: uv sync --extra dev |
| 70 | + - name: Product path no-verda fence |
| 71 | + run: uv run python scripts/check_no_verda.py |
| 72 | + - name: Module entrypoint no-verda audit |
| 73 | + run: | |
| 74 | + uv run python -c " |
| 75 | + from pathlib import Path |
| 76 | + from hypercluster.no_verda import run_product_verda_audit |
| 77 | + report = run_product_verda_audit(Path('.').resolve()) |
| 78 | + print('\n'.join(report.summary_lines())) |
| 79 | + raise SystemExit(0 if report.ok else 1) |
| 80 | + " |
| 81 | +
|
| 82 | + test: |
| 83 | + runs-on: ubuntu-latest |
| 84 | + timeout-minutes: 30 |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v4 |
| 87 | + - name: Install uv |
| 88 | + uses: astral-sh/setup-uv@v5 |
| 89 | + with: |
| 90 | + enable-cache: true |
| 91 | + - name: Set up Python |
| 92 | + run: uv python install ${{ env.PYTHON_VERSION }} |
| 93 | + - name: Install dependencies |
| 94 | + run: uv sync --extra dev |
| 95 | + - name: Pytest with coverage |
| 96 | + # live_verda + integration stay opt-in (real cloud / SSH). Default addopts |
| 97 | + # already deselect them; restate markers for job clarity. |
| 98 | + run: >- |
| 99 | + uv run pytest |
| 100 | + -m "not live_verda and not integration" |
| 101 | + --cov=hypercluster |
| 102 | + --cov-report=term-missing |
| 103 | + --cov-fail-under=70 |
| 104 | +
|
| 105 | + docker-build: |
| 106 | + needs: |
| 107 | + - lint |
| 108 | + - format |
| 109 | + - no-verda |
| 110 | + - test |
| 111 | + runs-on: ubuntu-latest |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v4 |
| 114 | + - name: Stage Base SDK wheel into docker/vendor |
| 115 | + run: bash scripts/stage_base_wheel.sh |
| 116 | + - uses: docker/setup-buildx-action@v3 |
| 117 | + - name: Build hypercluster runtime image |
| 118 | + uses: docker/build-push-action@v6 |
| 119 | + with: |
| 120 | + context: . |
| 121 | + file: Dockerfile |
| 122 | + target: runtime |
| 123 | + push: false |
| 124 | + tags: ${{ env.IMAGE_NAME }}:ci-${{ github.sha }} |
| 125 | + |
| 126 | + docker-publish: |
| 127 | + if: >- |
| 128 | + github.event_name != 'pull_request' && |
| 129 | + (github.ref == 'refs/heads/main' || |
| 130 | + startsWith(github.ref, 'refs/tags/v') || |
| 131 | + (github.event_name == 'workflow_dispatch' && inputs.confirm_publish == 'true')) |
| 132 | + needs: |
| 133 | + - docker-build |
| 134 | + runs-on: ubuntu-latest |
| 135 | + permissions: |
| 136 | + contents: read |
| 137 | + packages: write |
| 138 | + steps: |
| 139 | + - uses: actions/checkout@v4 |
| 140 | + - name: Stage Base SDK wheel into docker/vendor |
| 141 | + run: bash scripts/stage_base_wheel.sh |
| 142 | + - uses: docker/setup-buildx-action@v3 |
| 143 | + - name: Log in to GHCR |
| 144 | + uses: docker/login-action@v3 |
| 145 | + with: |
| 146 | + registry: ghcr.io |
| 147 | + username: ${{ github.actor }} |
| 148 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 149 | + - name: Generate Docker metadata |
| 150 | + id: meta |
| 151 | + uses: docker/metadata-action@v5 |
| 152 | + with: |
| 153 | + images: ${{ env.IMAGE_NAME }} |
| 154 | + tags: | |
| 155 | + type=ref,event=branch |
| 156 | + type=semver,pattern={{version}} |
| 157 | + type=semver,pattern={{raw}} |
| 158 | + type=sha,prefix=sha- |
| 159 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} |
| 160 | + - name: Build and publish image |
| 161 | + uses: docker/build-push-action@v6 |
| 162 | + with: |
| 163 | + context: . |
| 164 | + file: Dockerfile |
| 165 | + target: runtime |
| 166 | + push: true |
| 167 | + tags: ${{ steps.meta.outputs.tags }} |
| 168 | + labels: ${{ steps.meta.outputs.labels }} |
| 169 | + |
| 170 | + github-release: |
| 171 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 172 | + needs: |
| 173 | + - docker-publish |
| 174 | + runs-on: ubuntu-latest |
| 175 | + permissions: |
| 176 | + contents: write |
| 177 | + steps: |
| 178 | + - name: Prepare release metadata |
| 179 | + id: release |
| 180 | + run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
| 181 | + - name: Create GitHub release |
| 182 | + uses: softprops/action-gh-release@v2 |
| 183 | + with: |
| 184 | + tag_name: ${{ github.ref_name }} |
| 185 | + name: Hypercluster ${{ steps.release.outputs.version }} |
| 186 | + generate_release_notes: true |
| 187 | + append_body: true |
| 188 | + draft: false |
| 189 | + prerelease: ${{ contains(github.ref_name, '-') }} |
| 190 | + make_latest: ${{ !contains(github.ref_name, '-') }} |
| 191 | + body: | |
| 192 | + ## Container Image |
| 193 | +
|
| 194 | + - `ghcr.io/baseintelligence/hypercluster:${{ steps.release.outputs.version }}` |
| 195 | + - `ghcr.io/baseintelligence/hypercluster:${{ github.ref_name }}` |
| 196 | + - `ghcr.io/baseintelligence/hypercluster:sha-${{ github.sha }}` |
| 197 | +
|
| 198 | + ## Deployment Notes |
| 199 | +
|
| 200 | + BASE master deployments should pin the SemVer image tag plus the |
| 201 | + immutable `@sha256` digest. The `latest` tag is published only from |
| 202 | + `main`, not from release tags. |
0 commit comments