From f1d5ed2d896ca1852163a6dcd158eb491fbfc37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 23 Sep 2026 06:41:09 +0300 Subject: [PATCH] ci: deploy on a green push to main A push whose Validate and Build jobs both succeed now deploys that run's own release artifact. workflow_dispatch keeps the newest-green redeploy (tests=force still deploys the artifact that run just built). The capacity gate is unchanged and still read from compose x-rag-envelope. Local-Gate: 206369ac9e4deb52af2d99733a2f1d70dfd4c15b (1410 passed, 32s) --- .githooks/pre-push | 4 +- .github/workflows/main.yml | 84 +++++++++++++++++++++++--------------- PROJECT_STATE.md | 2 +- README.md | 40 ++++++++++-------- scripts/gate-local.sh | 2 +- 5 files changed, 77 insertions(+), 55 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index 138b800..818e4fe 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -5,8 +5,8 @@ # # git config core.hooksPath .githooks # -# The default path is: push and let GitHub run the suite, build, pack and (on a -# manual dispatch) deploy. An untested push is legitimate, so this hook does NOT +# The default path is: push and let GitHub run the suite, build, pack and +# deploy this run's artifact. An untested push is legitimate, so this hook does NOT # require a stamp. Its single job is to keep the opt-in fast lane honest. # # The fast lane is a commit carrying diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebc5f9b..1b049ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,29 +6,42 @@ # Containerfile'ından imaj (ENV bloğu dağıtım # varsayılanlarının TEK kaynağıdır) ve imaj tarball'ı + # compose dosyaları koşunun artefaktı olarak yüklenir. -# Deploy — SSH: kapasite ön kontrolü, imajı yükle, deploy sahipli -# stack.env'in HEZARFEN_TAG'ini ona çevir, compose.yaml + -# unit'i kur, stack'i yeniden başlat, `/health` ve -# `/ready` kapılarını geçir, olmazsa önceki tag'e dön. +# Deploy — push'ta OTOMATIK: SSH ile kapasite ön kontrolü, imajı +# yükle, deploy sahipli stack.env'in HEZARFEN_TAG'ini +# BU KOŞUNUN artefaktına çevir, compose.yaml + unit'i +# kur, stack'i yeniden başlat, `/health` ve `/ready` +# kapılarını geçir, olmazsa önceki tag'e dön. Yani yeşil +# bir push servisi kendiliğinden günceller. # -# ⚠️ DEPLOY SADECE ELLE (workflow_dispatch) KOŞAR — bilinçli: -# Servis, aynı sunucuda koşan backend+postgres+frontend+chatbot'un YANINA -# eklenir; kapasite ön kontrolü olmadan otomatik başlatmak canlı stack'i RAM -# için sıkıştırırdı. Gömme ve rerank artık UZAK API'de (dağıtım varsayılanı -# = api) → yerel modeller (~4,5 GB) indirilmez; ölçülen zarf torch ~0,4 GB + -# 0,53 GB/10k chunk = 1,1 GB (tek korpus) … 2,6 GB (3 korpus), bkz. -# PROJECT_STATE §11.2. Deploy işi eşiği compose.yaml'daki `x-rag-envelope` -# bloğundan OKUR — tek kaynak; sayıyı buraya ikinci kez yazmak, model -# çağından kalma 12 GB eşiğinin sessizce geri gelmesi demekti. -# Operatör yerel yola (RAG_EMBED_PROVIDER=local) dönerse zarf büyür ve -# GPU'suz makinede rerank 95,9 s sürer: ürün kapısı O-05 p50 <= 6 s GEÇİLMEZ -# — o yapılandırma için eşiği sunucuya elle yükseltmek gerekir. +# KAPASİTE KAPISI DEĞİŞMEDİ (kullanıcı kararı 2026-09-23: yeşil push artık +# kendiliğinden deploy eder; 2026-09-15'teki "yalnız elle" kararı kalktı). +# Eşik hâlâ compose.yaml `x-rag-envelope` bloğundan OKUNUR — tek kaynak; +# sayıyı buraya ikinci kez yazmak, model çağından kalma 12 GB eşiğinin +# sessizce geri gelmesi demekti. Yetmezse deploy sayılarıyla reddeder, +# eşiği gevşetmez. Gömme ve rerank UZAK API'de (dağıtım varsayılanı = api) +# → yerel modeller (~4,5 GB) indirilmez; ölçülen zarf torch ~0,4 GB + +# 0,53 GB/10k chunk = 1,1 GB (tek korpus) … 2,6 GB (3 korpus), bkz. +# PROJECT_STATE §11.2. +# Operatör yerel yola (RAG_EMBED_PROVIDER=local) dönerse zarf büyür ve +# GPU'suz makinede rerank 95,9 s sürer: ürün kapısı O-05 p50 <= 6 s +# GEÇİLMEZ — o yapılandırma için eşiği sunucuya elle yükseltmek gerekir. +# +# Validate ile Build and test paralel koşar; Deploy ikisi de yeşilse +# çalışır ve BU KOŞUNUN artefaktını alır (en yeni yeşil araması değil). +# Yeni bir push aynı ref'teki Validate/Build'i iptal eder; uçuştaki +# Deploy'u ASLA iptal etmez (iki deploy iç içe girerse stack karışır). +# +# workflow_dispatch (Actions -> Run workflow, ya da +# `gh workflow run main.yml --ref main`) süiti koşmadan en yeni yeşil +# build'in artefaktını yeniden deploy eder. `tests: force` önce bu +# ref'i derler ve test eder, sonra O KOŞUNUN taze artefaktını alır. # # TWO TEST PATHS — the default is the full one (same shape as hezarfen_backend): # # DEFAULT Push it and let GitHub do everything: suite, image, bundle, -# artifact. This is also the recovery path when the local machine -# is unavailable. +# artifact, and — when Validate and Build are both green — +# deploy of THIS run's artifact. This is also the recovery +# path when the local machine is unavailable. # SPECIAL Prove the suite on your own machine first (scripts/gate-local.sh # — ~32 s here). The suite currently HANGS on the runner: run # 35297989416 sat at 7% for 73 minutes until it was cancelled by @@ -36,7 +49,8 @@ # --amend, appends) a `Local-Gate: ( passed, s)` # trailer; the "Decide test gate" step verifies it against # HEAD^{tree} and only then skips the runner suite — CI still -# builds the image, proves it API-only, stages and uploads. +# builds the image, proves it API-only, stages, uploads and +# deploys this run's artifact. # A stale or copy-pasted trailer silently falls back to running # the suite, so the fallback costs time, never verification. # Opt the pre-push hook in per clone: @@ -56,10 +70,10 @@ on: push: branches: - main - # Deploy'un TEK kapısı — yukarıdaki başlık yorumuna bakın. - # `tests` is the escape hatch of the manual door: auto/skip redeploy the - # newest green artifact (the suite is not paid again), force builds and - # tests the dispatched ref first and deploys that fresh artifact. + # Elle yeniden deploy kapısı — yukarıdaki başlık yorumuna bakın. + # auto/skip: en yeni yeşil artefaktı yeniden deploy eder (süit tekrar + # ödenmez). force: bu ref'i önce derler ve test eder, o taze artefaktı + # deploy eder. workflow_dispatch: inputs: tests: @@ -302,20 +316,22 @@ jobs: concurrency: group: deploy cancel-in-progress: false - # Push'ta iki CI işi koşar ama deploy KOŞMAZ (kapı elle açılır); - # dispatch'te ikisi de atlanır ve `always()` bu atlamanın kapıyı - # geçmesini engeller. + # Push: yalnız validate VE build yeşilse — ikisi de sunucuyu kapılar; + # artefakt BU KOŞUNUNKİDİR (aşağıda needs.build.result == success). + # Dispatch: mevcut yol. auto/skip iki CI işini atlar ve en yeni yeşil + # build'i alır; tests=force build'i koşar ve bu koşunun artefaktını + # alır. `always()` atlamanın kapıdan geçmesini engeller. if: >- always() && - github.event_name == 'workflow_dispatch' && - (needs.validate.result == 'skipped' || needs.validate.result == 'success') && - (needs.build.result == 'skipped' || needs.build.result == 'success') + ((needs.validate.result == 'success' && needs.build.result == 'success') || + (github.event_name == 'workflow_dispatch' && + (needs.validate.result == 'skipped' || needs.validate.result == 'success') && + (needs.build.result == 'skipped' || needs.build.result == 'success'))) runs-on: ubuntu-24.04 steps: - # Elle deploy, BUILD işi yeşil olan en yeni koşuyu alır — ama yalnız bu - # koşuda build YOKSA: `tests: force` ile dispatch edildiğinde bu koşunun - # kendi taze artefaktı kullanılır (aşağıdaki adım), yoksa build edilen - # imaj hiçbir yere gitmezdi. + # Dispatch ve bu koşuda build YOKSA (auto/skip): BUILD işi yeşil olan + # en yeni push koşusunu alır. Push ve tests=force buraya düşmez — + # onların artefaktı aşağıdaki adımdır. - name: Find the newest green build if: needs.build.result == 'skipped' env: @@ -345,7 +361,7 @@ jobs: run-id: ${{ env.run_id }} github-token: ${{ github.token }} - # tests=force: the artifact this very run built and gated. + # Push, ve tests=force: artefakt bu koşunun kendisinin ürettiği sürüm. - name: Fetch this run's release if: needs.build.result == 'success' uses: actions/download-artifact@v4 diff --git a/PROJECT_STATE.md b/PROJECT_STATE.md index 405e498..e3b2292 100644 --- a/PROJECT_STATE.md +++ b/PROJECT_STATE.md @@ -98,7 +98,7 @@ ham veri + soru/cevap defteri: `outputs/EXP-009-model-karsilastirma/`), maliyet - **Servis girişi (2026-09-17 durumu):** HTTP servisi VAR — `src/service/http_app.py` (FastAPI; `/rag/chat`, `/rag/summarize`, `/rag/questions`, `/health`, `/ready`), `compose.yaml` + `Containerfile` + `deploy/hezarfen_rag_compose.service` + - `.github/workflows/main.yml` (elle tetiklenen VPS deploy). Backend bu HTTP'yi + `.github/workflows/main.yml` (yeşil push'ta otomatik VPS deploy, 2026-09-23; kapasite kapısı `x-rag-envelope`'dan okunur). Backend bu HTTP'yi ÇAĞIRMAZ; gerçek entegrasyon QUIC `hab/2` köprüsüdür ve **taşıması yazıldı** (`src/bridge/transport.py`, ¶11.4) → `rag.chat` artık telden servis edilir; `rag.index` SUNULUR (2026-09-18): not + ekler indekslenir — ek baytları kendi diff --git a/README.md b/README.md index 00d4166..742582d 100644 --- a/README.md +++ b/README.md @@ -97,25 +97,31 @@ kapısı bu iki sayıyı compose'dan okur (koda ikinci kez yazılmaz). `.github/workflows/main.yml` kardeş servislerle aynı şekli taşır: `Validate` (derleme kontrolü) ∥ `Build and test` (`python -m pytest tests/unit -q` süiti + -imaj + `release` artefaktı) → `Deploy` (SSH: imajı yükle, deploy sahipli -`stack.env`'in -`HEZARFEN_TAG`'ini çevir, unit'i kur, `/health` ve `/ready` kapılarını geçir, -geçmezse önceki tag'e dön). Unit'in kendisi sürümle birlikte iner: -`deploy/hezarfen_rag_compose.service`. - -**Deploy yalnız elle koşar** (`workflow_dispatch`) ve kapıda **kapasite ön -kontrolü** vardır: eşikler `compose.yaml`'daki `x-rag-envelope` bloğundan -okunur — RAM ≥ `mem_limit_mb` (**3072 MB**) ve disk ≥ **8 GB**; yetmezse -nedeniyle birlikte reddeder. Gerekçe ölçülmüş: API gömme + API rerank ile -yerel modeller hiç indirilmez (zarf 1,1–2,6 GB), yani eski 12 GB / 20 GB -eşikleri model çağından kalmaydı. Ölçtüğümüz 7 GB'lık geliştirme sunucusu -(6 466 MB boşta) bu kapıdan artık **geçer**. - -Kapıyı açmak için: repo secret'larına `SSH_PRIVATE_KEY`/`SSH_HOST`/`SSH_USER` +imaj + `release` artefaktı) → `Deploy`. Yeşil bir `main` push'u **bu koşunun** +artefaktını kendiliğinden alır: imajı yükle, deploy sahipli `stack.env`'in +`HEZARFEN_TAG`'ini o artefakta çevir, unit'i kur, `/health` ve `/ready` +kapılarını geçir, geçmezse önceki tag'e dön. Unit'in kendisi sürümle birlikte +iner: `deploy/hezarfen_rag_compose.service`. + +**Yeşil bir push servisi kendiliğinden günceller** (kullanıcı kararı +2026-09-23; 2026-09-15'teki "yalnız `workflow_dispatch`" kapısı kalktı). Kapıda +**kapasite ön kontrolü** durur ve değişmedi: eşikler `compose.yaml`'daki +`x-rag-envelope` bloğundan okunur — RAM ≥ `mem_limit_mb` (**3072 MB**) ve +disk ≥ **8 GB**; yetmezse nedeniyle birlikte reddeder, eşik gevşetilmez. +Gerekçe ölçülmüş: API gömme + API rerank ile yerel modeller hiç indirilmez +(zarf 1,1–2,6 GB), yani eski 12 GB / 20 GB eşikleri model çağından kalmaydı. +Ölçtüğümüz 7 GB'lık geliştirme sunucusu (6 466 MB boşta) bu kapıdan artık +**geçer**. + +Elle yeniden deploy (`workflow_dispatch`, `tests: auto`/`skip`) süiti tekrar +ödemeden en yeni yeşil build'in artefaktını alır. `tests: force` önce bu +ref'i derler ve test eder, sonra o taze artefaktı deploy eder. + +İlk kurulum: repo secret'larına `SSH_PRIVATE_KEY`/`SSH_HOST`/`SSH_USER` ekle, sunucuya `~/hezarfen_rag/hezarfen_rag.env` (0600, şablon: `deploy/hezarfen_rag.env.example`) ve `~/hezarfen_rag/data/` -(`/lise///kitap.pdf`, okul segmenti tireli uuid) korpusunu koy, sonra -`workflow_dispatch` ile koş. +(`/lise///kitap.pdf`, okul segmenti tireli uuid) +korpusunu koy. Sonraki `main` push'u deploy'u kendisi koşar. ### GPU için tek seferlik ana makine kurulumu diff --git a/scripts/gate-local.sh b/scripts/gate-local.sh index 2bc86bb..ef15956 100755 --- a/scripts/gate-local.sh +++ b/scripts/gate-local.sh @@ -8,7 +8,7 @@ # way). When you have run this script, commit the `Local-Gate:` trailer it # prints (`--amend` writes it for you) and the push carries proof: the # workflow's "Decide test gate" step verifies the trailer against HEAD^{tree} -# and then skips the runner suite, so CI only builds, packs and uploads. +# and then skips the runner suite, so CI only builds, packs, uploads and deploys this run's artifact. # # Default path (nothing here): push without a trailer and GitHub runs # everything, suite included. Nothing is mandatory; this is the fast lane.