Compare commits

..

6 Commits

Author SHA1 Message Date
Stéphan Sainléger
f86c403ab2 [IMP] push directly to branches instead of creating PRs
CI config changes are low-risk and don't affect business code.
Direct push eliminates the need to manually validate 50+ PRs.

Changes:
- Push commits directly to target branches (no AGit PR flow)
- Simplified commit message: '[CI] sync config from odoo-elabore-ci'
- Update README to reflect direct push behavior
2026-03-10 17:11:03 +01:00
Stéphan Sainléger
61a9e10b17 [IMP] manual deployment workflow with dry-run and filters
Replace automatic deployment (on push) with manual workflow_dispatch:
- Version filter: deploy to all versions or specific one (16.0, 18.0)
- Repo filter: deploy to all repos or comma-separated list
- Dry-run mode: preview changes without creating PRs
- Detailed summary with emoji indicators and statistics

Benefits:
- Full control over deployment scope and timing
- Safe preview before creating 50+ PRs
- Targeted deployments for testing

Update README with new deployment guide and examples.
2026-03-10 16:59:45 +01:00
Stéphan Sainléger
3eadd1f0c4 [ADD] comprehensive README documentation
Document repository purpose, architecture, workflows, and usage:
- CI deployment workflow explanation
- Linting tools overview
- How to modify CI configuration
- How to add new Odoo version support
- Configuration files explanation
- Secrets setup
- Version differences (16.0 vs 18.0)
2026-03-07 17:00:16 +01:00
Stéphan Sainléger
25e9370cc0 [ADD] support for Odoo 18.0 configuration
Add config/18.0/ with configuration files based on OCA standards:
- .pylintrc and .pylintrc-mandatory (valid-odoo-versions=18.0)
- .ruff.toml (Python linting)
- .pre-commit-config.yaml with updated hooks:
  - whool-init (new in 18.0)
  - oca-gen-external-dependencies (new in 18.0)
  - Updated prettier 3.x and eslint 9.x
- eslint.config.cjs and prettier.config.cjs (new flat config format)

Also move .eslintrc.yml and .prettierrc.yml to config/16.0/ since
18.0 uses the new CJS flat config format instead of YAML.
2026-03-07 16:54:39 +01:00
Stéphan Sainléger
20b9ce48d0 [REF] use single main branch with per-version config directories
Replace per-branch versioning (16.0, 18.0...) with a single main branch
containing version-specific subdirectories under config/.

Structure:
- config/common/: shared files deployed to all versions
- config/16.0/: Odoo 16.0 specific configs (pylintrc, ruff, pre-commit)

The deploy workflow now:
- Triggers on push to main
- Auto-detects available versions from config/*/
- For each target repo, deploys common + version-specific files

Also enables Gitea native cache in pre-commit workflow.
2026-03-07 16:48:28 +01:00
Stéphan Sainléger
bc57d359d0 [IMP] activate the use of gitea cache for environment build 2026-03-07 16:19:45 +01:00
16 changed files with 1024 additions and 90 deletions

View File

@@ -1,126 +1,230 @@
name: Sync Config to All Odoo Repositories
run-name: ${{ gitea.actor }} is deploying new pre-commit config 🚀
name: Deploy CI Config
run-name: "${{ gitea.actor }} deploying config [${{ inputs.version }}] to [${{ inputs.repos || 'all repos' }}]${{ inputs.dry_run && ' (DRY-RUN)' || '' }}"
on:
push:
branches:
- 16.0
workflow_dispatch:
inputs:
version:
description: 'Odoo version to deploy'
required: true
type: choice
options:
- all
- '16.0'
- '18.0'
default: 'all'
repos:
description: 'Target repos (comma-separated, empty = all *-addons/*-tools)'
required: false
type: string
default: ''
dry_run:
description: 'Dry run (preview changes without creating PRs)'
required: true
type: boolean
default: true
jobs:
sync:
deploy:
runs-on: ubuntu-latest
steps:
- name: Show deployment parameters
run: |
echo "============================================"
echo " DEPLOYMENT PARAMETERS"
echo "============================================"
echo "Version: ${{ inputs.version }}"
echo "Repos: ${{ inputs.repos || '(all)' }}"
echo "Dry-run: ${{ inputs.dry_run }}"
echo "============================================"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq git rsync
- name: Determine source branch
id: branch_vars
run: |
# Set SOURCE_BRANCH to the branch/tag that triggered this workflow
echo "SOURCE_BRANCH=${GITEA_REF_NAME}" >> $GITEA_ENV
env:
GITEA_REF_NAME: ${{ gitea.ref_name }}
- name: Checkout config repository
env:
GITEA_SERVER: "https://git.elabore.coop" # Base URL of Gitea instance, e.g. https://gitea.example.com
ORG_NAME: "Elabore"
CONFIG_REPO: "odoo-elabore-ci"
SOURCE_BRANCH: ${{ env.SOURCE_BRANCH }}
run: |
# Clone the config repo to local directory
git clone --single-branch --branch "$SOURCE_BRANCH" "${GITEA_SERVER}/${ORG_NAME}/${CONFIG_REPO}.git" config-repo
# Path where configs are stored in config repo
CONFIG_PATH="config"
- name: Get list of all repos in organization
env:
GITEA_SERVER: "https://git.elabore.coop"
ORG_NAME: "Elabore"
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }} # token must have read + write permissions on all repos
CONFIG_REPO: "odoo-elabore-ci"
run: |
git clone --single-branch --branch main "${GITEA_SERVER}/${ORG_NAME}/${CONFIG_REPO}.git" config-repo
- name: Determine versions to deploy
run: |
# List all available versions
ALL_VERSIONS=$(ls -d config-repo/config/*/ | xargs -n1 basename | grep -v common | tr '\n' ' ')
echo "Available versions: $ALL_VERSIONS"
# Filter based on input
if [ "${{ inputs.version }}" = "all" ]; then
VERSIONS="$ALL_VERSIONS"
else
VERSIONS="${{ inputs.version }}"
fi
echo "Versions to deploy: $VERSIONS"
echo "VERSIONS=$VERSIONS" >> $GITEA_ENV
- name: Build target repos list
env:
GITEA_SERVER: "https://git.elabore.coop"
ORG_NAME: "Elabore"
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }}
INPUT_REPOS: ${{ inputs.repos }}
run: |
page=1
per_page=50
REPO_LIST="repos.txt"
> $REPO_LIST
while true; do
echo "Fetching page $page"
response=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"${GITEA_SERVER}/api/v1/orgs/${ORG_NAME}/repos?page=${page}&limit=${per_page}")
count=$(echo "$response" | jq 'length')
if [ "$count" -eq 0 ]; then
break
fi
# Append each repo name to file
echo "response=$response"
echo "$response" | jq .
echo "$response" | jq -r '.[].name' >> $REPO_LIST
page=$((page + 1))
done
echo "Repositories found:"
cat $REPO_LIST
- name: Sync config to each repo
if [ -n "$INPUT_REPOS" ]; then
# User specified repos - use them directly
echo "Using user-specified repos: $INPUT_REPOS"
echo "$INPUT_REPOS" | tr ',' '\n' | sed 's/^ *//;s/ *$//' > $REPO_LIST
else
# Fetch all repos from organization
page=1
per_page=50
while true; do
echo "Fetching page $page"
response=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"${GITEA_SERVER}/api/v1/orgs/${ORG_NAME}/repos?page=${page}&limit=${per_page}")
count=$(echo "$response" | jq 'length')
if [ "$count" -eq 0 ]; then
break
fi
# Filter for *-addons and *-tools repos only
echo "$response" | jq -r '.[].name | select(endswith("-addons") or endswith("-tools"))' >> $REPO_LIST
page=$((page + 1))
done
fi
echo ""
echo "Target repositories:"
cat $REPO_LIST
echo ""
echo "Total: $(wc -l < $REPO_LIST) repos"
- name: Deploy config to repos
env:
GITEA_SERVER: "git.elabore.coop"
ORG_NAME: "Elabore"
SOURCE_BRANCH: ${{ env.SOURCE_BRANCH }}
CONFIG_REPO: "odoo-elabore-ci"
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }}
CONFIG_PATH: "config"
VERSIONS: ${{ env.VERSIONS }}
DRY_RUN: ${{ inputs.dry_run }}
run: |
REPO_LIST="repos.txt"
SUMMARY_FILE="deployment_summary.txt"
> $SUMMARY_FILE
pr_created=0
pr_skipped_no_changes=0
pr_skipped_no_branch=0
errors=0
while read repo; do
# Skip empty lines
[ -z "$repo" ] && continue
# Skip the config repo itself
if [ "$repo" = "$CONFIG_REPO" ]; then
echo "Skipping config repo: $repo"
echo "⏭️ Skipping config repo: $repo"
continue
fi
# Skip repos not matching suffixes -addons and -tools
if ! [[ "$repo" == *-addons ]] && ! [[ "$repo" == *-tools ]]; then
echo "Skipping $repo (does not end with -addons or -tools)"
continue
fi
echo ""
echo "=========================================="
echo "📦 Processing: $repo"
echo "=========================================="
echo "Processing repo: $repo"
for VERSION in $VERSIONS; do
echo ""
echo "--- Version $VERSION ---"
# Clone the target repo
echo "${GITEA_TOKEN}"
git clone --quiet --single-branch --branch "$SOURCE_BRANCH" "https://elabore_bot:${GITEA_TOKEN}@${GITEA_SERVER}/${ORG_NAME}/${repo}.git" target-$repo || { echo "Failed to clone branch $SOURCE_BRANCH from $repo"; continue; }
cd target-$repo || { echo "Failed to enter target-$repo"; exit 1; }
# Try to clone the target repo at this version branch
if ! git clone --quiet --single-branch --branch "$VERSION" "https://elabore_bot:${GITEA_TOKEN}@${GITEA_SERVER}/${ORG_NAME}/${repo}.git" "target-${repo}-${VERSION}" 2>/dev/null; then
echo "⚠️ Branch $VERSION does not exist in $repo"
pr_skipped_no_branch=$((pr_skipped_no_branch + 1))
continue
fi
# Copy files from config repo
echo "Copy config to target repo $repo"
rsync -av ../config-repo/$CONFIG_PATH/ .
git add -N .
cd "target-${repo}-${VERSION}" || { echo "❌ Failed to enter directory"; errors=$((errors + 1)); continue; }
# If there are no changes, skip
if git diff --quiet; then
echo "No changes for $repo"
else
echo "Changes detected for $repo committing & pushing"
# Set user identity for commit
git config user.name "elabore_bot"
git config user.email "gitea.bot@elabore.coop"
git checkout -b "$SOURCE_BRANCH-config_deployment"
git add .
git commit -m "Sync config from ${CONFIG_REPO}:${SOURCE_BRANCH}"
# Copy common files first
rsync -a ../config-repo/config/common/ .
echo "Attempts to push to $repo on branch $SOURCE_BRANCH"
git push --quiet origin "$SOURCE_BRANCH-config_deployment":refs/for/"$SOURCE_BRANCH" -o topic="$SOURCE_BRANCH-config_deployment" -o title="Sync config from ${CONFIG_REPO}:${SOURCE_BRANCH}" -o force-push || { echo "Push failed for $repo"; exit 1; }
echo "Push done for $repo"
fi
# Copy version-specific files (overwrites common if conflict)
rsync -a ../config-repo/config/${VERSION}/ .
cd .. # go back to workflow root
# Clean up clone
echo "Cleaning up $repo"
rm -rf target-$repo
echo "Cleanup done for $repo"
git add -N .
echo "Moving to next repo"
# Check for changes
if git diff --quiet; then
echo "✅ No changes needed for $repo:$VERSION"
pr_skipped_no_changes=$((pr_skipped_no_changes + 1))
else
echo "📝 Changes detected for $repo:$VERSION"
echo ""
echo "Changed files:"
git diff --stat
echo ""
if [ "$DRY_RUN" = "true" ]; then
echo "🔍 DRY-RUN: Would push to $repo:$VERSION"
echo "[DRY-RUN] $repo:$VERSION - would be updated" >> ../$SUMMARY_FILE
else
echo "🚀 Pushing to $repo:$VERSION"
git config user.name "elabore_bot"
git config user.email "gitea.bot@elabore.coop"
git add .
git commit -m "[CI] sync config from ${CONFIG_REPO}"
if git push --quiet origin HEAD:"${VERSION}"; then
echo "✅ Pushed to $repo:$VERSION"
echo "[PUSHED] $repo:$VERSION" >> ../$SUMMARY_FILE
pr_created=$((pr_created + 1))
else
echo "❌ Push failed for $repo:$VERSION"
echo "[ERROR] $repo:$VERSION - Push failed" >> ../$SUMMARY_FILE
errors=$((errors + 1))
fi
fi
fi
cd ..
rm -rf "target-${repo}-${VERSION}"
done
done < $REPO_LIST
echo ""
echo "============================================"
echo " DEPLOYMENT SUMMARY"
echo "============================================"
if [ "$DRY_RUN" = "true" ]; then
echo "Mode: DRY-RUN (no changes pushed)"
else
echo "Mode: LIVE (direct push to branches)"
fi
echo ""
echo "Branches updated: $pr_created"
echo "Skipped (no changes): $pr_skipped_no_changes"
echo "Skipped (branch missing): $pr_skipped_no_branch"
echo "Errors: $errors"
echo ""
if [ -s $SUMMARY_FILE ]; then
echo "Details:"
cat $SUMMARY_FILE
fi
echo "============================================"
# Exit with error if there were failures
if [ $errors -gt 0 ]; then
exit 1
fi

218
README.md
View File

@@ -1,2 +1,220 @@
# odoo-elabore-ci
Centralized CI/CD configuration for Elabore's Odoo repositories.
## Purpose
This repository manages linting and CI configuration centrally for all Odoo repositories (`*-addons` and `*-tools`) in the Elabore organization on Gitea.
**Benefits:**
- Single, consistent configuration across all repos
- Automatic updates via deployment workflow
- Multi-version Odoo support (16.0, 18.0, etc.)
- Based on OCA (Odoo Community Association) standards
## Architecture
```
odoo-elabore-ci/
├── .gitea/workflows/
│ └── deploy-config.yml # Manual deployment workflow (with dry-run)
└── config/
├── common/ # Shared files (all versions)
│ ├── .editorconfig
│ └── .gitea/workflows/
│ └── pre-commit.yml # CI workflow deployed to each repo
├── 16.0/ # Odoo 16.0 configuration
│ ├── .eslintrc.yml
│ ├── .prettierrc.yml
│ ├── .pre-commit-config.yaml
│ ├── .pylintrc
│ ├── .pylintrc-mandatory
│ └── .ruff.toml
└── 18.0/ # Odoo 18.0 configuration
├── eslint.config.cjs
├── prettier.config.cjs
├── .pre-commit-config.yaml
├── .pylintrc
├── .pylintrc-mandatory
└── .ruff.toml
```
## How It Works
### Deployment Workflow (`deploy-config.yml`)
The deployment is **manually triggered** via Gitea Actions interface, giving you full control over what gets deployed and where.
**Features:**
- **Version filter**: Deploy to all versions or a specific one (16.0, 18.0)
- **Repo filter**: Deploy to all repos or specific ones (comma-separated)
- **Dry-run mode**: Preview changes without pushing anything
- **Direct push**: Commits are pushed directly to target branches (no PR)
**Process:**
1. Detects available versions (folders in `config/` other than `common/`)
2. For each target repository:
- For each selected Odoo version:
- Attempts to clone the corresponding branch
- Copies `config/common/` then `config/{version}/`
- In dry-run: shows what would change
- In live mode: commits and pushes directly to the branch
### CI Workflow (`pre-commit.yml`)
Deployed to each target repository, this workflow runs on every Pull Request:
1. Sets up Python 3.11 environment
2. Installs and runs `pre-commit` with all configured hooks
3. Verifies no untracked files were generated
## Linting Tools
| Tool | Purpose | Target Files |
|------|---------|--------------|
| **Ruff** | Python linter + formatter | `.py` |
| **Pylint-Odoo** | Odoo-specific rules | `.py`, `__manifest__.py`, XML |
| **ESLint** | JavaScript linter | `.js` |
| **Prettier** | Multi-language formatter | JS, CSS, XML, JSON, YAML, MD |
| **pre-commit-hooks** | Generic checks | Trailing whitespace, merge conflicts, etc. |
| **OCA hooks** | Odoo community standards | Manifests, README, translations |
## Usage Guide
### Deploying Configuration
Deployment is done via the Gitea Actions interface:
1. Go to **Gitea**`odoo-elabore-ci`**Actions**
2. Select **"Deploy CI Config"** workflow
3. Click **"Run workflow"**
4. Fill in the parameters:
| Parameter | Description | Examples |
|-----------|-------------|----------|
| **Version** | Odoo version to deploy | `all`, `16.0`, `18.0` |
| **Repos** | Target repos (empty = all) | `crm-addons, hr-addons` |
| **Dry-run** | Preview without pushing | `true` (recommended first) |
#### Deployment Examples
| I want to... | Version | Repos | Dry-run |
|--------------|---------|-------|---------|
| Preview all changes | `all` | *(empty)* | ✅ |
| Deploy 16.0 to one repo | `16.0` | `crm-addons` | ❌ |
| Deploy 18.0 to multiple repos | `18.0` | `crm-addons, hr-addons` | ❌ |
| Deploy all versions everywhere | `all` | *(empty)* | ❌ |
#### Recommended Workflow
```
1. Make changes in config/
2. git commit && git push origin main
→ Nothing happens (no auto-deploy)
3. Run workflow with DRY-RUN enabled
→ Review the logs to see what would change
4. If satisfied, run again WITHOUT dry-run
→ Changes are pushed directly to target branches
```
### Modifying CI Configuration
1. **Edit files in `config/`**:
- `config/common/`: changes applied to all versions
- `config/{version}/`: version-specific changes
2. **Commit and push to `main`**:
```bash
git add .
git commit -m "[IMP] description of change"
git push origin main
```
3. **Trigger deployment manually** (see above)
### Adding a New Odoo Version
1. **Create the configuration directory**:
```bash
mkdir config/{new_version}
```
2. **Copy and adapt files** from the closest version or from an OCA repo:
```bash
# Example for Odoo 19.0 based on 18.0
cp config/18.0/* config/19.0/
```
3. **Adapt the copied files**:
| File | Required Changes |
|------|------------------|
| `.pylintrc` | `valid-odoo-versions=19.0` |
| `.pylintrc-mandatory` | `valid-odoo-versions=19.0` |
| `.ruff.toml` | `target-version` if Python version changes |
| `.pre-commit-config.yaml` | Hook versions if needed |
4. **Commit and push**:
```bash
git add config/19.0/
git commit -m "[ADD] support for Odoo 19.0 configuration"
git push origin main
```
5. **Deploy** via Gitea Actions:
- The new version will appear in the "Version" dropdown
- Use dry-run first to verify which repos have a `19.0` branch
## Secrets Configuration
The workflow requires a Gitea token with the following permissions:
- Read access to all organization repos
- Write access (to create PRs)
Configure the `ELABORE_BOT_TOKEN` secret in the repository settings.
## Version Differences
### 16.0 vs 18.0
| Aspect | 16.0 | 18.0 |
|--------|------|------|
| ESLint config | `.eslintrc.yml` | `eslint.config.cjs` (flat config) |
| Prettier config | `.prettierrc.yml` | `prettier.config.cjs` |
| Node.js | 16.17.0 | 22.9.0 |
| Prettier | 2.7.1 | 3.3.3 |
| ESLint | 8.x | 9.x |
| Additional hooks | - | `whool-init`, `oca-gen-external-dependencies` |
## Configuration Files
### `.pylintrc` vs `.pylintrc-mandatory`
- **`.pylintrc`**: All rules (optional + mandatory), non-blocking mode (`--exit-zero`). Useful for IDEs.
- **`.pylintrc-mandatory`**: Critical rules only, blocking mode. Used by CI.
### Elabore-Specific Rules
Files are customized for Elabore:
- `manifest-required-authors=Elabore`
- URLs pointing to `https://git.elabore.coop/elabore/`
## Contributing
1. Test changes locally with `pre-commit run --all-files`
2. Follow commit conventions (tags `[IMP]`, `[FIX]`, `[ADD]`, etc.)
3. Auto-generated PRs should be reviewed before merging
## Resources
- [OCA Maintainer Tools](https://github.com/OCA/maintainer-tools)
- [OCA Pre-commit Hooks](https://github.com/OCA/odoo-pre-commit-hooks)
- [Pylint-Odoo](https://github.com/OCA/pylint-odoo)
- [Ruff](https://docs.astral.sh/ruff/)
- [Pre-commit](https://pre-commit.com/)
## License
AGPL-3.0

View File

@@ -0,0 +1,142 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying
^docs/_templates/.*\.html$|
# Don't bother non-technical authors with formatting issues in docs
readme/.*\.(rst|md)$|
# Ignore build and dist directories in addons
/build/|/dist/|
# Ignore test files in addons
/tests/samples/.*|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
python: python3
node: "22.9.0"
repos:
- repo: local
hooks:
# These files are most likely copier diff rejection junks; if found,
# review them manually, fix the problem (if needed) and remove them
- id: forbidden-files
name: forbidden files
entry: found forbidden files; remove them
language: fail
files: "\\.rej$"
- id: en-po-files
name: en.po files cannot exist
entry: found a en.po file
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/sbidoul/whool
rev: v1.3
hooks:
- id: whool-init
- repo: https://github.com/oca/maintainer-tools
rev: b89f767503be6ab2b11e4f50a7557cb20066e667
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
entry:
bash -c 'oca-fix-manifest-website "https://git.elabore.coop/elabore/$(basename
$(git rev-parse --show-toplevel))"'
- id: oca-gen-addon-readme
entry:
bash -c 'oca-gen-addon-readme
--addons-dir=.
--branch=$(git symbolic-ref
refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")
--repo-name=$(basename $(git rev-parse --show-toplevel))
--org-name="Elabore"
--if-source-changed
--keep-source-digest
--convert-fragments-to-markdown'
- id: oca-gen-external-dependencies
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.33
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
args:
- --disable=po-pretty-format
- repo: local
hooks:
- id: prettier
name: prettier (with plugin-xml)
entry: prettier
args:
- --write
- --list-different
- --ignore-unknown
types: [text]
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
language: node
additional_dependencies:
- "prettier@3.3.3"
- "@prettier/plugin-xml@3.4.1"
- repo: local
hooks:
- id: eslint
name: eslint
entry: eslint
args:
- --color
- --fix
verbose: true
types: [javascript]
language: node
additional_dependencies:
- "eslint@9.12.0"
- "eslint-plugin-jsdoc@50.3.1"
- "globals@16.0.0"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
- id: end-of-file-fixer
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
- id: debug-statements
- id: fix-encoding-pragma
args: ["--remove"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
# exclude files where underlines are not distinguishable from merge conflicts
exclude: /README\.rst$|^docs/.*\.rst$
- id: check-symlinks
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/OCA/pylint-odoo
rev: v9.1.3
hooks:
- id: pylint_odoo
name: pylint with optional checks
args:
- --rcfile=.pylintrc
- --exit-zero
verbose: true
- id: pylint_odoo
args:
- --rcfile=.pylintrc-mandatory

124
config/18.0/.pylintrc Normal file
View File

@@ -0,0 +1,124 @@
[MASTER]
load-plugins=pylint_odoo
score=n
[ODOOLINT]
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest-required-authors=Elabore
manifest-required-keys=license
manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid-odoo-versions=18.0
[MESSAGES CONTROL]
disable=all
# This .pylintrc contains optional AND mandatory checks and is meant to be
# loaded in an IDE to have it check everything, in the hope this will make
# optional checks more visible to contributors who otherwise never look at a
# green travis to see optional checks that failed.
# .pylintrc-mandatory containing only mandatory checks is used the pre-commit
# config as a blocking check.
enable=anomalous-backslash-in-string,
api-one-deprecated,
api-one-multi-together,
class-camelcase,
dangerous-view-replace-wo-priority,
duplicate-id-csv,
duplicate-xml-fields,
duplicate-xml-record-id,
eval-referenced,
incoherent-interpreter-exec-perm,
openerp-exception-warning,
redundant-modulename-xml,
relative-import,
rst-syntax-error,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
assignment-from-none,
attribute-deprecated,
dangerous-default-value,
development-status-allowed,
duplicate-key,
eval-used,
license-allowed,
manifest-author-string,
manifest-deprecated-key,
manifest-required-author,
manifest-required-key,
manifest-version-format,
method-compute,
method-inverse,
method-required-super,
method-search,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
reimported,
return-in-init,
sql-injection,
too-few-format-args,
translation-field,
translation-required,
unreachable,
use-vim-comment,
character-not-valid-in-resource-link,
create-user-wo-reset-password,
dangerous-filter-wo-user,
dangerous-qweb-replace-wo-priority,
deprecated-data-xml-node,
deprecated-openerp-xml-node,
duplicate-po-message-definition,
file-not-used,
missing-newline-extrafiles,
old-api7-method-defined,
po-msgstr-variables,
po-syntax-error,
str-format-used,
unnecessary-utf8-coding-comment,
xml-attribute-translatable,
xml-deprecated-qweb-directive,
xml-deprecated-tree-attribute,
attribute-string-redundant,
consider-merging-classes-inherited,
context-overridden,
except-pass,
invalid-commit,
manifest-maintainers-list,
missing-readme,
missing-return,
odoo-addons-relative-import,
renamed-field-parameter,
resource-not-exist,
test-folder-imported,
translation-contains-variable,
translation-positional-used,
website-manifest-key-not-valid-uri,
external-request-timeout,
missing-manifest-dependency,
too-complex,,
create-user-wo-reset-password,
dangerous-filter-wo-user,
file-not-used,
missing-newline-extrafiles,
no-utf8-coding-comment,
old-api7-method-defined,
unnecessary-utf8-coding-comment,
# messages that do not cause the lint step to fail
consider-merging-classes-inherited,
deprecated-module,
invalid-commit,
missing-readme,
odoo-addons-relative-import,
redefined-builtin,
manifest-external-assets
[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no

View File

@@ -0,0 +1,98 @@
[MASTER]
load-plugins=pylint_odoo
score=n
[ODOOLINT]
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest-required-authors=Elabore
manifest-required-keys=license
manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid-odoo-versions=18.0
[MESSAGES CONTROL]
disable=all
enable=anomalous-backslash-in-string,
api-one-deprecated,
api-one-multi-together,
class-camelcase,
dangerous-view-replace-wo-priority,
duplicate-id-csv,
duplicate-xml-fields,
duplicate-xml-record-id,
eval-referenced,
incoherent-interpreter-exec-perm,
openerp-exception-warning,
redundant-modulename-xml,
relative-import,
rst-syntax-error,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
assignment-from-none,
attribute-deprecated,
dangerous-default-value,
development-status-allowed,
duplicate-key,
eval-used,
license-allowed,
manifest-author-string,
manifest-deprecated-key,
manifest-required-author,
manifest-required-key,
manifest-version-format,
method-compute,
method-inverse,
method-required-super,
method-search,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
reimported,
return-in-init,
sql-injection,
too-few-format-args,
translation-field,
translation-required,
unreachable,
use-vim-comment,
character-not-valid-in-resource-link,
create-user-wo-reset-password,
dangerous-filter-wo-user,
dangerous-qweb-replace-wo-priority,
deprecated-data-xml-node,
deprecated-openerp-xml-node,
duplicate-po-message-definition,
file-not-used,
missing-newline-extrafiles,
old-api7-method-defined,
po-msgstr-variables,
po-syntax-error,
str-format-used,
unnecessary-utf8-coding-comment,
xml-attribute-translatable,
xml-deprecated-qweb-directive,
xml-deprecated-tree-attribute,
attribute-string-redundant,
consider-merging-classes-inherited,
context-overridden,
except-pass,
invalid-commit,
manifest-maintainers-list,
missing-readme,
missing-return,
odoo-addons-relative-import,
renamed-field-parameter,
resource-not-exist,
test-folder-imported,
translation-contains-variable,
translation-positional-used,
website-manifest-key-not-valid-uri,
external-request-timeout
[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no

31
config/18.0/.ruff.toml Normal file
View File

@@ -0,0 +1,31 @@
target-version = "py310"
fix = true
[lint]
extend-select = [
"B",
"C90",
"E501", # line too long (default 88)
"I", # isort
"UP", # pyupgrade
]
extend-safe-fixes = ["UP008"]
exclude = ["setup/*"]
[format]
exclude = ["setup/*"]
[lint.per-file-ignores]
"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py
"__manifest__.py" = ["B018"] # useless expression
[lint.isort]
section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"]
[lint.isort.sections]
"odoo" = ["odoo"]
"odoo-addons" = ["odoo.addons"]
[lint.mccabe]
max-complexity = 16

View File

@@ -0,0 +1,205 @@
var globals = require('globals');
jsdoc = require("eslint-plugin-jsdoc");
const config = [{
plugins: {
jsdoc,
},
languageOptions: {
globals: {
_: "readonly",
$: "readonly",
fuzzy: "readonly",
jQuery: "readonly",
moment: "readonly",
odoo: "readonly",
openerp: "readonly",
owl: "readonly",
luxon: "readonly",
QUnit: "readonly",
...globals.browser,
},
ecmaVersion: 2024,
sourceType: "script",
},
rules: {
"accessor-pairs": "warn",
"array-callback-return": "warn",
"callback-return": "warn",
"capitalized-comments": ["warn", "always", {
ignoreConsecutiveComments: true,
ignoreInlineComments: true,
}],
complexity: ["warn", 15],
"constructor-super": "warn",
"dot-notation": "warn",
eqeqeq: "warn",
"global-require": "warn",
"handle-callback-err": "warn",
"id-blacklist": "warn",
"id-match": "warn",
"init-declarations": "error",
"max-depth": "warn",
"max-nested-callbacks": "warn",
"max-statements-per-line": "warn",
"no-alert": "warn",
"no-array-constructor": "warn",
"no-caller": "warn",
"no-case-declarations": "warn",
"no-class-assign": "warn",
"no-cond-assign": "error",
"no-const-assign": "error",
"no-constant-condition": "warn",
"no-control-regex": "warn",
"no-debugger": "error",
"no-delete-var": "warn",
"no-div-regex": "warn",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-else-return": "warn",
"no-empty-character-class": "warn",
"no-empty-function": "error",
"no-empty-pattern": "error",
"no-empty": "warn",
"no-eq-null": "error",
"no-eval": "error",
"no-ex-assign": "error",
"no-extend-native": "warn",
"no-extra-bind": "warn",
"no-extra-boolean-cast": "warn",
"no-extra-label": "warn",
"no-fallthrough": "warn",
"no-func-assign": "error",
"no-global-assign": "error",
"no-implicit-coercion": ["warn", {
allow: ["~"],
}],
"no-implicit-globals": "warn",
"no-implied-eval": "warn",
"no-inline-comments": "warn",
"no-inner-declarations": "warn",
"no-invalid-regexp": "warn",
"no-irregular-whitespace": "warn",
"no-iterator": "warn",
"no-label-var": "warn",
"no-labels": "warn",
"no-lone-blocks": "warn",
"no-lonely-if": "error",
"no-mixed-requires": "error",
"no-multi-str": "warn",
"no-native-reassign": "error",
"no-negated-condition": "warn",
"no-negated-in-lhs": "error",
"no-new-func": "warn",
"no-new-object": "warn",
"no-new-require": "warn",
"no-new-symbol": "warn",
"no-new-wrappers": "warn",
"no-new": "warn",
"no-obj-calls": "warn",
"no-octal-escape": "warn",
"no-octal": "warn",
"no-param-reassign": "warn",
"no-path-concat": "warn",
"no-process-env": "warn",
"no-process-exit": "warn",
"no-proto": "warn",
"no-prototype-builtins": "warn",
"no-redeclare": "warn",
"no-regex-spaces": "warn",
"no-restricted-globals": "warn",
"no-restricted-imports": "warn",
"no-restricted-modules": "warn",
"no-restricted-syntax": "warn",
"no-return-assign": "error",
"no-script-url": "warn",
"no-self-assign": "warn",
"no-self-compare": "warn",
"no-sequences": "warn",
"no-shadow-restricted-names": "warn",
"no-shadow": "warn",
"no-sparse-arrays": "warn",
"no-sync": "warn",
"no-this-before-super": "warn",
"no-throw-literal": "warn",
"no-undef-init": "warn",
"no-undef": "error",
"no-unmodified-loop-condition": "warn",
"no-unneeded-ternary": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-unused-vars": "error",
"no-use-before-define": "error",
"no-useless-call": "warn",
"no-useless-computed-key": "warn",
"no-useless-concat": "warn",
"no-useless-constructor": "warn",
"no-useless-escape": "warn",
"no-useless-rename": "warn",
"no-void": "warn",
"no-with": "warn",
"operator-assignment": ["error", "always"],
"prefer-const": "warn",
radix: "warn",
"require-yield": "warn",
"sort-imports": "warn",
"spaced-comment": ["error", "always"],
strict: ["error", "function"],
"use-isnan": "error",
"jsdoc/check-tag-names": "warn",
"jsdoc/check-types": "warn",
"jsdoc/require-param-description": "off",
"jsdoc/require-return": "off",
"jsdoc/require-return-description": "off",
"jsdoc/require-return-type": "off",
"valid-typeof": "warn",
yoda: "warn",
},
settings: {
jsdoc: {
tagNamePreference: {
arg: "param",
argument: "param",
augments: "extends",
constructor: "class",
exception: "throws",
func: "function",
method: "function",
prop: "property",
return: "returns",
virtual: "abstract",
yield: "yields",
},
preferredTypes: {
array: "Array",
bool: "Boolean",
boolean: "Boolean",
number: "Number",
object: "Object",
str: "String",
string: "String",
},
},
},
}, {
files: ["**/*.esm.js", "**/*test.js"],
languageOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
}];
module.exports = config

View File

@@ -0,0 +1,14 @@
/** @type {import('prettier').Config} */
const config = {
// https://github.com/prettier/prettier/issues/15388#issuecomment-1717746872
plugins: [require.resolve("@prettier/plugin-xml")],
bracketSpacing: false,
printWidth: 88,
proseWrap: "always",
semi: true,
trailingComma: "es5",
xmlWhitespaceSensitivity: "preserve",
};
module.exports = config;

View File

@@ -2,8 +2,6 @@ name: pre-commit
on:
pull_request:
branches:
- "16.0*"
jobs:
pre-commit:
@@ -15,10 +13,10 @@ jobs:
python-version: "3.11"
- name: Get python version
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
# - uses: actions/cache@v4
# with:
# path: ~/.cache/pre-commit
# key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: https://gitea.com/actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit