Files
researchowl/.gitea/workflows/build.yml
T
ChemaVXandClaude Opus 5 6cbb7280fa
Build & Deploy ResearchOwl / build-and-push (push) Successful in 1m6s
ci: pinea anthropic y corre la suite DENTRO de la imagen
Tres piezas de un mismo agujero: ningún test de este repo había visto nunca las
librerías que ejecuta el bot.

1. **El pin.** `anthropic>=0.40.0` era el ÚNICO suelo del fichero — todo lo demás
   ya estaba pinneado exacto, y medido con `pip freeze` dentro del pod, todo lo
   pinneado cuadra. Ese suelo dejó entrar la 1.2.0, una versión MAYOR, sin un
   commit: quitó `temperature` de `messages.create` y rompió el reintento del SEO
   (32f0b2c). 1.2.0 es lo que ya corre, así que el pin no cambia producción:
   la escribe. Evidencia de compatibilidad del propio pod: convive con
   httpx 0.28.1, pydantic 2.13.4 y aiohttp 3.14.1.

2. **La suite en la CI, dentro de la imagen construida.** `Dockerfile.test` parte
   del tag recién publicado, así que los tests ven EXACTAMENTE lo que se
   despliega. Va antes de actualizar los manifiestos: si falla, no se despliega.
   `tests/` no hace falta copiarlo, el runtime ya hace `COPY . .`.
   `TELEGRAM_BOT_TOKEN` de mentira porque es obligatorio y en la imagen no hay
   `.env` — comprobado que la suite entera pasa sólo con eso.

3. **El barrido, que cierra la clase y no el caso.** `tests/test_sdk_contract.py`
   lee con `ast` TODAS las llamadas a `messages.create` del árbol y compara sus
   kwargs con la firma del SDK instalado. Comprobar sólo el sitio arreglado
   habría dejado los otros ocho a ciegas.

⚠️ Los dos guardianes nuevos NO pueden fallar en un portátil con anthropic
0.102.0: ahí `temperature` sigue en la firma. Verificados a mano dentro del pod
contra 1.2.0 — inyectando la avería en una copia aislada, el barrido la caza; con
el código real, las nueve llamadas pasan. Es el pin + la CI lo que los convierte
en pruebas y no en gestos.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EHakatofHeJAzdXL26Q5bq
2026-09-02 08:58:14 +00:00

161 lines
6.0 KiB
YAML

name: Build & Deploy ResearchOwl
on:
push:
branches:
- main
env:
REGISTRY: gitea.gitea.svc.cluster.local:3000
K8S_MANIFESTS_REPO: http://chemavx:${{ secrets.CI_TOKEN }}@gitea.gitea.svc.cluster.local:3000/chemavx/k8s-manifests.git
GIT_SSL_NO_VERIFY: "true"
TELEGRAM_CHAT_ID: "5138407666"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ssl-verify: false
- name: Verify vendored SEO engine
run: |
set -e
CANON_URL="http://gitea.gitea.svc.cluster.local:3000/chemavx/chemavx-seo-tools/raw/branch/main/seo_rules.py"
curl -fsS -u "chemavx:${{ secrets.CI_TOKEN }}" "$CANON_URL" -o /tmp/canonical_seo_rules.py
N=$(grep -n "BEGIN VENDORED seo_rules.py" src/seo/rules.py | head -1 | cut -d: -f1)
tail -n +$((N+1)) src/seo/rules.py > /tmp/vendored_body.py
if cmp -s /tmp/canonical_seo_rules.py /tmp/vendored_body.py; then
echo "OK: vendored SEO engine matches canonical chemavx-seo-tools/seo_rules.py"
else
echo "::error::SEO ENGINE DRIFT — src/seo/rules.py != canonical seo_rules.py. Run 'make sync-seo' and commit."
diff -u /tmp/canonical_seo_rules.py /tmp/vendored_body.py | head -40 || true
exit 1
fi
- name: Set image tag
id: tag
run: echo "TAG=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
- name: Log in to registry
run: echo "${{ secrets.CI_TOKEN }}" | docker login gitea.gitea.svc.cluster.local:3000 -u chemavx --password-stdin
- name: Clean previous buildx builder
run: docker buildx rm ci-builder 2>/dev/null || true
- name: Create buildx builder
run: |
cat > /tmp/buildkitd.toml << 'EOF'
[registry."registry-cache.registry-cache.svc.cluster.local:5000"]
http = true
insecure = true
[registry."gitea.gitea.svc.cluster.local:3000"]
http = true
insecure = true
[registry."docker.io"]
mirrors = ["registry-cache.registry-cache.svc.cluster.local:5000"]
EOF
docker buildx create \
--name ci-builder \
--driver docker-container \
--driver-opt network=host \
--config /tmp/buildkitd.toml \
--use
docker buildx inspect --bootstrap
- name: Build and push image
run: |
TAG=${{ steps.tag.outputs.TAG }}
docker buildx build \
--builder ci-builder \
--cache-from type=registry,ref=gitea.gitea.svc.cluster.local:3000/chemavx/researchowl:buildcache \
--cache-to type=registry,ref=gitea.gitea.svc.cluster.local:3000/chemavx/researchowl:buildcache,mode=max \
-t gitea.gitea.svc.cluster.local:3000/chemavx/researchowl:${TAG} \
--push \
-f Dockerfile .
- name: Verify image in registry
run: |
TAG=${{ steps.tag.outputs.TAG }}
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
-u "chemavx:${{ secrets.CI_TOKEN }}" \
-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
"http://gitea.gitea.svc.cluster.local:3000/v2/chemavx/researchowl/manifests/${TAG}")
if [ "$HTTP_CODE" != "200" ]; then
echo "ERROR: chemavx/researchowl:${TAG} not found in registry (HTTP $HTTP_CODE)"
exit 1
fi
echo "OK: chemavx/researchowl:${TAG} verified in registry"
- name: Run the suite inside the image
run: |
TAG=${{ steps.tag.outputs.TAG }}
BASE=gitea.gitea.svc.cluster.local:3000/chemavx/researchowl:${TAG}
# Contra la imagen recién construida, no contra el árbol de fuentes:
# la suite tiene que ver las librerías que se van a desplegar. Antes
# corría sólo en el portátil, con otro anthropic que el del pod, y por
# eso un kwarg que el SDK ya no aceptaba pasó meses sin que nada lo
# dijera.
docker buildx build \
--builder ci-builder \
--load \
--build-arg BASE=${BASE} \
-t researchowl-test:${TAG} \
-f Dockerfile.test .
docker run --rm researchowl-test:${TAG}
- name: Update k8s manifests
run: |
pip3 install pyyaml -q
TAG=${{ steps.tag.outputs.TAG }}
git config --global user.email "ci@git.chemavx.xyz"
git config --global user.name "Gitea CI"
git clone ${{ env.K8S_MANIFESTS_REPO }} /tmp/k8s-manifests
cd /tmp/k8s-manifests
sed -i "s|image: .*researchowl:.*|image: git.chemavx.xyz/chemavx/researchowl:${TAG}|g" \
researchowl/deployment.yaml
sed -i "s|imagePullPolicy: Never|imagePullPolicy: Always|g" \
researchowl/deployment.yaml
python3 -c "
import yaml, sys
f = 'researchowl/deployment.yaml'
try:
list(yaml.safe_load_all(open(f)))
print('OK: ' + f)
except yaml.YAMLError as e:
print('FAIL: ' + f + ': ' + str(e), file=sys.stderr)
sys.exit(1)
"
git add researchowl/deployment.yaml
git diff --cached --quiet || git commit -m "ci: update researchowl image to ${TAG} [skip ci]"
git push
- name: Notify Telegram
if: always()
env:
TAG: ${{ steps.tag.outputs.TAG }}
JOB_STATUS: ${{ job.status }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
run: |
TAG="${TAG:-${GITHUB_SHA:0:8}}"
if [ "$JOB_STATUS" = "success" ]; then
MSG="✅ Deploy researchowl:${TAG} completado"
else
MSG="❌ Deploy researchowl:${TAG} fallido (status: ${JOB_STATUS})"
fi
if [ -n "${TELEGRAM_TOKEN}" ]; then
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" \
-d "chat_id=${{ env.TELEGRAM_CHAT_ID }}" \
--data-urlencode "text=${MSG}"
fi