[ADD] Odoo tests workflow for 16.0 and 18.0
This commit is contained in:
89
README.md
89
README.md
@@ -21,22 +21,29 @@ odoo-elabore-ci/
|
||||
└── config/
|
||||
├── common/ # Shared files (all versions)
|
||||
│ ├── .editorconfig
|
||||
│ └── .gitea/workflows/
|
||||
│ └── pre-commit.yml # CI workflow deployed to each repo
|
||||
│ └── .gitea/
|
||||
│ ├── workflows/
|
||||
│ │ └── pre-commit.yml # Lint workflow deployed to each repo
|
||||
│ └── scripts/
|
||||
│ └── odoo-tests.sh # Odoo test runner used by test.yml
|
||||
├── 16.0/ # Odoo 16.0 configuration
|
||||
│ ├── .eslintrc.yml
|
||||
│ ├── .prettierrc.yml
|
||||
│ ├── .pre-commit-config.yaml
|
||||
│ ├── .pylintrc
|
||||
│ ├── .pylintrc-mandatory
|
||||
│ └── .ruff.toml
|
||||
│ ├── .ruff.toml
|
||||
│ └── .gitea/workflows/
|
||||
│ └── test.yml # Odoo tests workflow (deployed to 16.0 repos)
|
||||
└── 18.0/ # Odoo 18.0 configuration
|
||||
├── eslint.config.cjs
|
||||
├── prettier.config.cjs
|
||||
├── .pre-commit-config.yaml
|
||||
├── .pylintrc
|
||||
├── .pylintrc-mandatory
|
||||
└── .ruff.toml
|
||||
├── .ruff.toml
|
||||
└── .gitea/workflows/
|
||||
└── test.yml # Odoo tests workflow (deployed to 18.0 repos)
|
||||
```
|
||||
|
||||
## How It Works
|
||||
@@ -68,6 +75,19 @@ Deployed to each target repository, this workflow runs on every Pull Request:
|
||||
2. Installs and runs `pre-commit` with all configured hooks
|
||||
3. Verifies no untracked files were generated
|
||||
|
||||
### Test Workflow (`test.yml`)
|
||||
|
||||
Deployed to each target repository (per Odoo version), this workflow runs
|
||||
the Python tests of the modules changed in a Pull Request, on the
|
||||
self-hosted runner hosted at `ci.elabore.coop`:
|
||||
|
||||
1. Runs inside the Elabore doodba image for the repo's Odoo version
|
||||
2. Starts a PostgreSQL 17.2 service container
|
||||
3. Detects the installable modules touched by the PR
|
||||
4. Installs them and runs their tests (`odoo --test-enable`)
|
||||
|
||||
See [Odoo Tests (CI)](#odoo-tests-ci) for details.
|
||||
|
||||
## Linting Tools
|
||||
|
||||
| Tool | Purpose | Target Files |
|
||||
@@ -79,6 +99,66 @@ Deployed to each target repository, this workflow runs on every Pull Request:
|
||||
| **pre-commit-hooks** | Generic checks | Trailing whitespace, merge conflicts, etc. |
|
||||
| **OCA hooks** | Odoo community standards | Manifests, README, translations |
|
||||
|
||||
## Odoo Tests (CI)
|
||||
|
||||
Each target repository gets a `tests` workflow (`.gitea/workflows/test.yml`)
|
||||
that runs the Python tests of the modules changed in a Pull Request.
|
||||
|
||||
### How it works
|
||||
|
||||
| Aspect | Value |
|
||||
|--------|-------|
|
||||
| Runner | self-hosted Gitea runner on `ci.elabore.coop`, label `odoo-ci` |
|
||||
| Job image | `docker.0k.io/mirror/odoo:rc_<version>-ELABORE-LIGHT` (doodba) |
|
||||
| Database | `docker.0k.io/postgres:17.2.0-myc` service container |
|
||||
| Test runner | `.gitea/scripts/odoo-tests.sh` |
|
||||
|
||||
The workflow:
|
||||
|
||||
1. Checks out the PR head with full history.
|
||||
2. Computes the changed installable modules with
|
||||
`git diff origin/<base>...HEAD` (first-level directories containing
|
||||
`__manifest__.py`).
|
||||
3. Runs `odoo-tests.sh <modules>` inside the doodba image. The script
|
||||
generates `odoo.conf` from the environment (via the doodba
|
||||
entrypoint), then runs:
|
||||
```
|
||||
odoo --test-enable --stop-after-init -i <modules> \
|
||||
--addons-path="$PWD,/opt/odoo/auto/addons" --test-tags "/<modules>"
|
||||
```
|
||||
The checked-out repository is prepended to the addons path, so the
|
||||
PR's code takes precedence over the modules already baked in the
|
||||
image.
|
||||
|
||||
If no installable module is touched (e.g. docs-only PR), the test step
|
||||
is skipped.
|
||||
|
||||
### Runner (`gitea-runner`)
|
||||
|
||||
The runner is provided by the `gitea-runner` charm of the
|
||||
[`0k-charms`](https://git.myceliandre.fr/0k/0k-charms) collection. It
|
||||
registers against the Gitea instance with an organization-level token
|
||||
and exposes the `odoo-ci` label; the job image is chosen by each
|
||||
workflow through its `container:` key.
|
||||
|
||||
Required secrets (Gitea → organization **Elabore** → Settings → Actions
|
||||
→ Runners): a **registration token**, configured in the runner's
|
||||
deployment file on `ci.elabore.coop`. It is never stored in this
|
||||
repository.
|
||||
|
||||
### Adding a new Odoo version
|
||||
|
||||
1. Add `config/<version>/.gitea/workflows/test.yml` (copy the closest
|
||||
version, adjust the branch filter and the `container.image` tag).
|
||||
2. Deploy as usual.
|
||||
|
||||
### Limitations
|
||||
|
||||
- Modules are tested against the dependencies **already present in the
|
||||
Elabore image**. A dependency introduced in another Elabore repo and
|
||||
not yet baked in requires rebuilding that image.
|
||||
- One job runs at a time (`capacity: 1` on the runner).
|
||||
|
||||
## Usage Guide
|
||||
|
||||
### Deploying Configuration
|
||||
@@ -155,6 +235,7 @@ Deployment is done via the Gitea Actions interface:
|
||||
| `.pylintrc-mandatory` | `valid-odoo-versions=19.0` |
|
||||
| `.ruff.toml` | `target-version` if Python version changes |
|
||||
| `.pre-commit-config.yaml` | Hook versions if needed |
|
||||
| `.gitea/workflows/test.yml` | Branch filter and `container.image` tag |
|
||||
|
||||
4. **Commit and push**:
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user