[ADD] ci: Forgejo Actions CI and Claude bots ported from ecocentral
Same system as ecocentral-18 (see its docs/CI-CD.md): - ci.yml: lint (pre-commit), test (tools/ci/run_tests.py, OCA-style two-phase install) and review (PR bot, after lint and test). - issue-bot.yml: the issue bot answers issues or opens a PR on bot/issue-N. - pr-bot.yml: review when WIP is removed or the i18n label is added. - .gitea/issue-bot.md: context for the bots; this repo is shared by several clients. The bot scripts are copies of ecocentral's. Only the defaults differ (repo, token and state files, i18n languages es,eu,ca,gl) along with the [I18N] commit message and the references to the runner's sources.txt. The jobs run on a second forgejo-runner registration (CriptoMart org) on ecocentral's runner machine, sharing its image, mounts and cache. The runner files (Dockerfile, update.sh, sources.txt) live in ecocentral. Specific to this repo: - ODOO_SRC_SKIP: the runner's /odoo-src/18.0 holds a clone of addons-cm, so test skips it and checks the PR checkout instead. - BOT_BASE_BRANCH "18.0": the repo's default branch is 16.0. - test PostgreSQL on port 54330: ecocentral's runs on 54329 and a test job from each repo can run at the same time. The lint job fails until the repo is cleaned up with pre-commit run --all-files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fad510f69e
commit
d9d9e8be2d
13 changed files with 2154 additions and 0 deletions
91
.gitea/workflows/ci.yml
Normal file
91
.gitea/workflows/ci.yml
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
name: CI
|
||||
# Las comillas de "18.0" hacen falta: sin ellas YAML lo lee como un número y
|
||||
# Forgejo descarta el workflow entero, sin avisar.
|
||||
on:
|
||||
push:
|
||||
branches: ["18.0"]
|
||||
pull_request:
|
||||
branches: ["18.0"]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
# Misma imagen que el bot de incidencias: ya trae Python y pre-commit, y
|
||||
# el runner le monta la caché con los entornos de los hooks. Así el job no
|
||||
# depende de descargar Python de GitHub en cada ejecución.
|
||||
runs-on: issue-bot
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run pre-commit
|
||||
run: pre-commit run --all-files --show-diff-on-failure
|
||||
|
||||
test:
|
||||
# Misma imagen que el bot de incidencias: trae las dependencias de Odoo y
|
||||
# Chromium, y el runner le monta OCB y los repos OCA en /odoo-src. Ver
|
||||
# tools/issue_bot/README.md.
|
||||
runs-on: issue-bot
|
||||
# El runner lanza los contenedores en la red del host (hace falta para
|
||||
# llegar a Forgejo en localhost), y ahí los servicios no tienen nombre: se
|
||||
# llega a PostgreSQL por 127.0.0.1. Escucha solo en esa dirección y en un
|
||||
# puerto propio para no quedar expuesto ni chocar con otro PostgreSQL de
|
||||
# la máquina. El de ecocentral usa el 54329, y su runner y el de este
|
||||
# repo son registros distintos en la misma máquina: un job test de cada
|
||||
# uno puede correr a la vez.
|
||||
services:
|
||||
db:
|
||||
image: postgres:16
|
||||
env:
|
||||
POSTGRES_USER: odoo
|
||||
POSTGRES_PASSWORD: odoo
|
||||
POSTGRES_DB: postgres
|
||||
PGPORT: "54330"
|
||||
cmd: ["postgres", "-c", "listen_addresses=127.0.0.1"]
|
||||
env:
|
||||
PGHOST: 127.0.0.1
|
||||
PGPORT: "54330"
|
||||
PGUSER: odoo
|
||||
PGPASSWORD: odoo
|
||||
PGDATABASE: test
|
||||
ODOO_SRC: /odoo-src/18.0
|
||||
# El runner es el de ecocentral, y su /odoo-src/18.0 trae un clon de
|
||||
# este repo (ecocentral depende de él): se prueba el checkout del PR,
|
||||
# no ese clon.
|
||||
ODOO_SRC_SKIP: addons-cm
|
||||
# Si los tests pasan, deja aquí el .pot de cada addon para el job review.
|
||||
# Está en la caché que el runner monta en todos los jobs.
|
||||
BOT_POT_DIR: /root/.cache/eco-pr-bot/pot
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Tests de los addons
|
||||
run: python3 tools/ci/run_tests.py
|
||||
|
||||
review:
|
||||
# Revisión del PR por IA (seguridad, idiomas y flujos de Odoo): solo en los
|
||||
# PR que no están marcados como WIP, y después de pasar lint y test. El
|
||||
# resto de filtros (etiqueta no-bot, commit ya revisado) los aplica
|
||||
# review.py. Ver tools/pr_bot/README.md.
|
||||
needs: [lint, test]
|
||||
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
|
||||
runs-on: issue-bot
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# review.py pone las credenciales de la cuenta del bot al hacer push.
|
||||
persist-credentials: false
|
||||
- name: Run bot
|
||||
env:
|
||||
BOT_FORGEJO_URL: ${{ github.server_url }}
|
||||
BOT_FORGEJO_REPO: ${{ github.repository }}
|
||||
# La rama por defecto del repo es 16.0: sin esto el bot tomaría
|
||||
# esa como base.
|
||||
BOT_BASE_BRANCH: "18.0"
|
||||
BOT_FORGEJO_TOKEN: ${{ secrets.BOT_FORGEJO_TOKEN }}
|
||||
# Basta con uno de los dos.
|
||||
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
BOT_REPO_DIR: ${{ github.workspace }}
|
||||
BOT_ODOO_SRC: /odoo-src/18.0:/odoo-src/18.0-oca
|
||||
BOT_POT_DIR: /root/.cache/eco-pr-bot/pot
|
||||
run: >-
|
||||
python3 tools/pr_bot/review.py run
|
||||
"${{ github.event.pull_request.number }}" --ci-passed
|
||||
Loading…
Add table
Add a link
Reference in a new issue