diff --git a/.copier-answers.yml b/.copier-answers.yml index 45147ba..b2a07b4 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,7 +1,9 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v8.0.1 +_commit: v9.2.1 _src_path: git@github.com:Noviat-CI/addons-repo-template.git -ci_disable_autoinstall_modules: '' +ci_disable_autoinstall_modules: account_asset +ci_postgis: false +community_excluded_modules: account_zbics_batch_payment,account_ebics_oe odoo_test_flavor: Both odoo_version: 20.0 org_slug: Noviat diff --git a/.github/workflows/check-version-bump.yml b/.github/workflows/check-version-bump.yml index 6f9ce42..bb16fd7 100644 --- a/.github/workflows/check-version-bump.yml +++ b/.github/workflows/check-version-bump.yml @@ -14,9 +14,16 @@ jobs: with: # HEAD is the PR merge commit, HEAD^1 the tip of the base branch fetch-depth: 2 + persist-credentials: false + - name: Configure git authentication + # Header instead of URL credentials, see test.yml + env: + TOKEN: ${{ secrets.PRIVATE_TOKEN }} + run: | + git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" - name: Add Noviat CI Tools to PATH run: | - git clone https://${{ secrets.PRIVATE_TOKEN }}@github.com/Noviat-CI/noviat-ci-tools.git /opt/noviat-ci-tools - echo "/opt/noviat-ci-tools" >> $GITHUB_PATH + git clone https://github.com/Noviat-CI/noviat-ci-tools.git /opt/noviat-ci-tools + echo "/opt/noviat-ci-tools" >> "$GITHUB_PATH" - name: Check module version bump run: check_module_version_bump diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index e9fd3a5..58f6046 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -23,7 +23,7 @@ jobs: cache: 'pip' cache-dependency-path: '.pre-commit-config.yaml' - name: Get python version - run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV" - uses: actions/cache@v6 with: path: ~/.cache/pre-commit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b11347c..1ac87fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,11 +20,11 @@ jobs: - uses: actions/checkout@v7 - run: | for reqfile in requirements.txt test-requirements.txt ; do - if [ -f ${reqfile} ] ; then + if [ -f "${reqfile}" ] ; then result=0 # reject non-comment lines that contain a / (i.e. URLs, relative paths) # unless they have a "# SKIP TEST" comment - grep "^[^#].*/" ${reqfile} | grep -v "# SKIP TEST" || result=$? + grep "^[^#].*/" "${reqfile}" | grep -v "# SKIP TEST" || result=$? if [ $result -eq 0 ] ; then echo "Unreleased dependencies found in ${reqfile}." exit 1 @@ -33,7 +33,11 @@ jobs: done test: runs-on: ubuntu-latest - container: ${{ matrix.container }} + container: + image: ${{ matrix.container }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.PRIVATE_TOKEN }} name: ${{ matrix.name }} permissions: pull-requests: write @@ -42,14 +46,15 @@ jobs: fail-fast: false matrix: include: - - container: ghcr.io/oca/oca-ci/py3.12-odoo20.0:latest + - container: ghcr.io/noviat-ci/odoo-ci:20.0-stable name: test with Odoo Community odoo_enterprise : 0 - exclude_modules : "" - - container: ghcr.io/oca/oca-ci/py3.12-odoo20.0:latest + exclude_modules : "account_asset" + skip: "account_zbics_batch_payment,account_ebics_oe" + - container: ghcr.io/noviat-ci/odoo-ci:20.0-stable name: test with Odoo Enterprise odoo_enterprise : 1 - exclude_modules : "" + exclude_modules : "account_asset" makepot: "true" services: postgres: @@ -67,42 +72,43 @@ jobs: - uses: actions/checkout@v7 with: persist-credentials: false - - name: Upgrade pip in container - run: python -m pip install --upgrade pip - - name: Install Odoo upgrade util - run: python -m pip install git+https://github.com/odoo/upgrade-util@master - - name: Add Noviat CI Tools to PATH - run: | - git clone https://${{ secrets.PRIVATE_TOKEN }}@github.com/Noviat-CI/noviat-ci-tools.git /opt/noviat-ci-tools - echo "/opt/noviat-ci-tools" >> $GITHUB_PATH - - name: Clone Odoo Enterprise - if: ${{ matrix.odoo_enterprise == 1 }} - run : | - git clone https://${{ secrets.PRIVATE_TOKEN }}@github.com/odoo/enterprise.git --depth 1 -b 20.0 /opt/enterprise - - name: Clone Noviat Dependencies + - name: Configure git authentication env: - PRIVATE_TOKEN: ${{ secrets.PRIVATE_TOKEN }} + TOKEN: ${{ secrets.PRIVATE_TOKEN }} + run: | + git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" + - name: Show the CI image age + run: | + age=$(( ( $(date -u +%s) - $(date -u -d "$NOVIAT_CI_IMAGE_BUILD_DATE" +%s) ) / 86400 )) + echo "Image $NOVIAT_CI_ODOO_VERSION built $NOVIAT_CI_IMAGE_BUILD_DATE ($age days old)" | tee -a "$GITHUB_STEP_SUMMARY" + - name: Clone Noviat Dependencies run: clone_oca_dependencies_by_noviat - name: Create addons path run: | - mkdir -p ${{ env.INSTALL_ADDONS_DIR }}/setup - find $(realpath $ADDONS_DIR) $(realpath ${{ env.ADDITIONAL_ADDONS_DIR }}) -name __manifest__.py -exec sh -c 'ln -s "$(dirname "$0")" "${{ env.INSTALL_ADDONS_DIR }}"' {} \; - find $(realpath $ADDONS_DIR) $(realpath ${{ env.ADDITIONAL_ADDONS_DIR }}) -iwholename '*/setup/*/setup.py' -exec sh -c 'ln -s "$(dirname "$0")" "${{ env.INSTALL_ADDONS_DIR }}/setup"' {} \; - if [ -n ${{ matrix.exclude}} ] + mkdir -p "$INSTALL_ADDONS_DIR/setup" + find "$(realpath "$ADDONS_DIR")" "$(realpath "$ADDITIONAL_ADDONS_DIR")" -name __manifest__.py -exec sh -c 'ln -s "$(dirname "$0")" "$1"' {} "$INSTALL_ADDONS_DIR" \; + find "$(realpath "$ADDONS_DIR")" "$(realpath "$ADDITIONAL_ADDONS_DIR")" -iwholename '*/setup/*/setup.py' -exec sh -c 'ln -s "$(dirname "$0")" "$1/setup"' {} "$INSTALL_ADDONS_DIR" \; + # EXCLUDE (from matrix.exclude) only exists with rebel module groups + if [ -n "${EXCLUDE:-}" ] then - remove_excluded_modules ${{ env.INSTALL_ADDONS_DIR }} ${{ matrix.exclude }} + remove_excluded_modules "$INSTALL_ADDONS_DIR" "$EXCLUDE" fi + - name: Skip addons + if: ${{ matrix.skip }} + env: + SKIPPED: ${{ matrix.skip }} + run: | + remove_excluded_modules "$INSTALL_ADDONS_DIR" "$SKIPPED" + echo "EXCLUDE=${EXCLUDE:+$EXCLUDE,}$SKIPPED" >> "$GITHUB_ENV" + echo "Not installed nor tested with Odoo Community: $SKIPPED" | tee -a "$GITHUB_STEP_SUMMARY" - name: Update addons path with enterprise if: ${{ matrix.odoo_enterprise == 1 }} run: | - echo "ADDONS_PATH=/opt/odoo/addons,/opt/enterprise,${{ env.INSTALL_ADDONS_DIR }}" >> $GITHUB_ENV + echo "ADDONS_PATH=/opt/odoo/addons,/opt/enterprise,${{ env.INSTALL_ADDONS_DIR }}" >> "$GITHUB_ENV" - name: Update addons path without enterprise if: ${{ matrix.odoo_enterprise == 0 }} run: | - echo "ADDONS_PATH=/opt/odoo/addons,${{ env.INSTALL_ADDONS_DIR }}" >> $GITHUB_ENV - - name: Inject GitHub token for Noviat orgs in test-requirements.txt - run: | - sed -i -E "s#https://github.com/(Noviat-(Projects|Generic|ARP|Internal))#https://${{ secrets.PRIVATE_TOKEN }}@github.com/\1#g" test-requirements.txt + echo "ADDONS_PATH=/opt/odoo/addons,${{ env.INSTALL_ADDONS_DIR }}" >> "$GITHUB_ENV" - name: Install addons and dependencies run: | (ADDONS_PATH=${ADDONS_PATH} ADDONS_DIR=${INSTALL_ADDONS_DIR} oca_install_addons) @@ -114,10 +120,19 @@ jobs: - name: Run tests run: oca_run_tests - name: Generate coverage files + id: coverage run: | + # oca_run_tests exits early without coverage data when there is no + # addon to test (e.g. a freshly scaffolded version branch). + if [ -z "$(oca_list_addons_to_test)" ]; then + echo "No addon to test, skipping coverage report." + exit 0 + fi coverage report -m coverage xml -o coverage.xml + echo "report=true" >> "$GITHUB_OUTPUT" - name: Code Coverage Summary Report + if: steps.coverage.outputs.report == 'true' uses: irongut/CodeCoverageSummary@v1.3.0 with: filename: 'coverage.xml' @@ -126,7 +141,8 @@ jobs: output: 'both' hide_complexity: true - name: Write to Job Summary - run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY + if: steps.coverage.outputs.report == 'true' + run: cat code-coverage-results.md >> "$GITHUB_STEP_SUMMARY" - name: Update .pot files - run: noviat_export_and_push_pot https://x-access-token:${{ secrets.PRIVATE_TOKEN }}@github.com/${{ github.repository }} + run: noviat_export_and_push_pot https://github.com/${{ github.repository }} if: ${{ matrix.makepot == 'true' && github.event_name == 'push' }} diff --git a/.github/workflows/update-addons-table.yml b/.github/workflows/update-addons-table.yml index 95c814a..4cac9a3 100644 --- a/.github/workflows/update-addons-table.yml +++ b/.github/workflows/update-addons-table.yml @@ -28,14 +28,15 @@ jobs: continue-on-error: true - name: Commit & push if changed env: - PUSH_URL: https://x-access-token:${{ secrets.PRIVATE_TOKEN }}@github.com/${{ github.repository }}.git + TOKEN: ${{ secrets.PRIVATE_TOKEN }} run: | if ! git diff --quiet; then git config user.name "noviat-ci-bot" git config user.email "bot+ci@noviat.com" git add -A git commit -m "update addons table" - git remote set-url origin "$PUSH_URL" + # Header instead of URL credentials, see test.yml + git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" git config --global --add safe.directory "$GITHUB_WORKSPACE" git push origin HEAD:20.0 fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 841b664..6e2beba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,12 +6,14 @@ exclude: | ^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 holds the generated addons table ^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$| + # Sphinx translation catalogs are not Odoo translations + ^docs/.*\.pot?$| # Don't bother non-technical authors with formatting issues in docs readme/.*\.(rst|md)$| # Ignore build and dist directories in addons @@ -121,10 +123,6 @@ repos: - id: check-xml - id: mixed-line-ending args: ["--fix=lf"] - - repo: https://github.com/asottile/pyupgrade - rev: v3.21.2 - hooks: - - id: pyupgrade - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.16.9 hooks: @@ -137,13 +135,7 @@ repos: rev: v10.0.11 hooks: - id: pylint_odoo - name: pylint (optional, core only) - args: - - --rcfile=.pylintrc - - --exit-zero - verbose: true - - id: pylint_odoo - name: pylint-odoo (mandatory, blocking) + name: pylint-odoo args: - --disable=missing-readme - --rcfile=.pylintrc-mandatory diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index f0378d1..0000000 --- a/.pylintrc +++ /dev/null @@ -1,119 +0,0 @@ -[MASTER] -ignore-patterns=["^.*/TODO/.*$"] -load-plugins=pylint_odoo -score=n - -[IMPORTS] -# pytz is no longer an Odoo requirement since 20.0 (use zoneinfo) -deprecated-modules=pdb,pudb,ipdb,bs4,pytz - -[ODOOLINT] -#readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" -manifest-required-authors=Noviat -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=20.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, - assignment-from-none, - attribute-deprecated, - dangerous-default-value, - deprecated-module, - 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, - # >= 15 - attribute-string-redundant, - consider-merging-classes-inherited, - context-overridden, - except-pass, - invalid-commit, - manifest-external-assets, - manifest-maintainers-list, - missing-readme, - missing-return, - odoo-addons-relative-import, - odoo-exception-warning, - renamed-field-parameter, - resource-not-exist, - test-folder-imported, - translation-contains-variable, - translation-positional-used, - website-manifest-key-not-valid-uri, - # >= 16 - external-request-timeout, - # >= 19 - bad-builtin-groupby, - category-allowed, - deprecated-name-get, - deprecated-odoo-model-method, - deprecated-self-cr, - inheritable-method-lambda, - inheritable-method-string, - invalid-email, - manifest-behind-migrations, - manifest-data-duplicated, - missing-odoo-file, - no-raise-unlink, - no-search-all, - no-wizard-in-models, - prohibited-method-override, - prefer-env-translation, - translation-format-interpolation, - translation-format-truncated, - translation-injection, - translation-fstring-interpolation, - translation-not-lazy, - translation-too-few-args, - translation-too-many-args, - translation-unsupported-format, - no-write-in-compute, - odoolint, - # >= 20 - manifest-summary-multiline, - # messages that do not cause the lint step to fail - consider-merging-classes-inherited, - invalid-commit, - missing-readme, - odoo-addons-relative-import, - redefined-builtin - - -[REPORTS] -msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} -output-format=colorized -reports=no diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 212a0c8..79a3593 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -12,12 +12,11 @@ deprecated-modules=pdb,pudb,ipdb,bs4,pytz manifest-required-authors=Noviat 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 +license-allowed=AGPL-3,LGPL-3,Other proprietary valid-odoo-versions=20.0 [MESSAGES CONTROL] disable=all - enable = anomalous-backslash-in-string, assignment-from-none, diff --git a/.ruff.toml b/.ruff.toml index 30ac7f4..5bce83b 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -16,6 +16,40 @@ select = [ "E501", # line too long (default 88) "I", # isort "UP", # pyupgrade + # Autofixed + "RET501", + "RET502", + "RET505", + "RET506", + "RET507", + "RET508", + "PLR1711", + "PLR5501", + "RUF019", + "RUF021", + "RUF100", + "SIM114", + "ISC001", + "C4", + "PIE", + "FLY", + "FURB", + # Few and real: logging format, performance, security + "G", + "PERF", + "S102", + "S105", + "S106", + "S107", + "S108", + "S301", + "S603", + "S607", + "S704", + # Commented-out code, blind except, unused unpacked variables + "ERA001", + "BLE001", + "RUF059", ] extend-safe-fixes = ["UP008"] exclude = ["setup/*"] diff --git a/test-requirements.txt b/test-requirements.txt index 771d7f3..11c9dc2 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1 @@ openupgradelib -lxml_html_clean