From 590ef72e997633ddcf5b0afc3a878d34e7b1940f Mon Sep 17 00:00:00 2001 From: Santiago Hernandez Date: Mon, 23 Nov 2026 20:55:45 -0500 Subject: [PATCH] [SCRUM-1724] Prueba de contrato de Rules contra rules.yaml en el CI (QAS-23) --- .github/workflows/quality-gate.yml | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml index 85dd22b..67bfd6f 100644 --- a/.github/workflows/quality-gate.yml +++ b/.github/workflows/quality-gate.yml @@ -80,6 +80,45 @@ jobs: if-no-files-found: error retention-days: 3 + # Prueba de contrato (QAS-23, SCRUM-1724): Rules contra + # docs/openapi/rules.yaml del Gateway. + # Solo hacia develop: en release y main el contrato de develop puede ir + # delante del código que se promueve, que ya pasó por aquí. + - name: Contrato y verificador (MANI-APIGateway) + if: github.event_name == 'push' || github.base_ref == 'develop' + uses: actions/checkout@v4 + with: + repository: Trama-AS/MANI-APIGateway + ref: develop + path: .mani-contrato + + - name: Configurar Node.js (verificador de contrato) + if: github.event_name == 'push' || github.base_ref == 'develop' + uses: actions/setup-node@v4 + with: + node-version: '22' + + # El secreto de prueba se genera en cada corrida: firma los JWT de las sondas. + - name: Preparar el verificador de contrato + if: github.event_name == 'push' || github.base_ref == 'develop' + run: | + npm ci --prefix .mani-contrato --ignore-scripts + echo "SUPABASE_JWT_SECRET=$(openssl rand -hex 32)" >> "$GITHUB_ENV" + + - name: Contrato de Rules + if: github.event_name == 'push' || github.base_ref == 'develop' + run: | + esperar() { + curl -sf --retry 60 --retry-delay 1 --retry-all-errors "$1" > /dev/null + } + java -jar target/mani-rules-java-*.jar > rules.log 2>&1 & + esperar http://localhost:8080/api/v1/rules/health + node .mani-contrato/scripts/verificar_contrato.js --contrato rules --url http://localhost:8080/api/v1/rules + + - name: Logs de los servicios (si algo falló) + if: failure() + run: tail -n 50 rules.log || true + sonar_quality_gate: name: Sonar Quality Gate needs: pruebas_cobertura