diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..19a7c885 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: CI + +on: + push: + branches: + - '**' + tags-ignore: + - '**' + +jobs: + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Install shellcheck + run: sudo apt-get install -y shellcheck + - name: Run shellcheck + run: shellcheck -s bash -x -a --color -e "SC1090,SC1091,SC2034" ./bin/* ./lib/*.bash + + flake8: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Install flake8 + run: pip install flake8 + - name: Run flake8 + run: flake8 ./lib/pylib/ + + test-py2: + runs-on: ubuntu-22.04 + env: + CI_RUN: '1' + ODOO_HELPER_INSTALL_PATH: ${{ github.workspace }} + TEST_TMP_DIR: /tmp/odoo-helper-tests + DEBIAN_FRONTEND: noninteractive + ALWAYS_ANSWER_YES: '1' + LANG: C.UTF-8 + LC_ALL: C.UTF-8 + LANGUAGE: C.UTF-8 + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + - name: Setup locale and git + run: | + sudo apt-get update -qq && sudo apt-get install -yqq locales git + sudo update-locale LANG=C.UTF-8 LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 + git config --global user.email "test-oh@test.test" + git config --global user.name "test-oh" + - name: Install odoo-helper-scripts + run: sudo -E bash install-system.bash + - name: Run py2 tests (Odoo 8/9/10) + run: bash tests/test_py2.bash + + test-py3: + runs-on: ubuntu-${{ matrix.ubuntu }} + strategy: + fail-fast: false + matrix: + ubuntu: ['22.04', '24.04'] + env: + CI_RUN: '1' + ODOO_HELPER_INSTALL_PATH: ${{ github.workspace }} + TEST_TMP_DIR: /tmp/odoo-helper-tests + DEBIAN_FRONTEND: noninteractive + ALWAYS_ANSWER_YES: '1' + LANG: C.UTF-8 + LC_ALL: C.UTF-8 + LANGUAGE: C.UTF-8 + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + - name: Setup locale and git + run: | + sudo apt-get update -qq && sudo apt-get install -yqq locales git + sudo update-locale LANG=C.UTF-8 LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 + git config --global user.email "test-oh@test.test" + git config --global user.name "test-oh" + - name: Install odoo-helper-scripts + run: sudo -E bash install-system.bash + - name: Run py3 tests (Odoo 11–18) + run: bash tests/test_py3.bash diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 00000000..39923dc0 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,37 @@ +name: Deploy Docs to GitHub Pages + +on: + push: + branches: + - master + +permissions: + pages: write + id-token: write + +jobs: + deploy-docs: + runs-on: ubuntu-20.04 + environment: + name: github-pages + url: ${{ steps.deploy.outputs.page_url }} + env: + ODOO_HELPER_INSTALL_PATH: ${{ github.workspace }} + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + - name: Install system dependencies + run: sudo apt-get install -y python3-pip && sudo -E bash install-system.bash + - name: Install MkDocs + run: python3 -m pip install mkdocs mkdocs-cinder==0.14.0 + - name: Build docs + run: bash scripts/build_docs.bash + - name: Upload pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: public + - name: Deploy to GitHub Pages + id: deploy + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..fc288787 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + build-package: + runs-on: ubuntu-22.04 + env: + ODOO_HELPER_ROOT: ${{ github.workspace }} + ODOO_HELPER_BIN: ${{ github.workspace }}/bin + ODOO_HELPER_LIB: ${{ github.workspace }}/lib + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + - name: Install build dependencies + run: sudo apt-get install -qqy ruby ruby-dev make gcc curl + - name: Install fpm + run: sudo gem install fpm + - name: Build .deb package + run: bash scripts/build_packages.bash + - name: Upload .deb artifact + uses: actions/upload-artifact@v4 + with: + name: deb-package + path: build/odoo-helper-scripts.deb + + create-release: + runs-on: ubuntu-latest + needs: build-package + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v6 + - name: Download .deb artifact + uses: actions/download-artifact@v4 + with: + name: deb-package + path: build/ + - name: Extract release notes from CHANGELOG + run: | + sudo apt-get install -y coreutils + csplit --prefix=CHANGELOG. --suffix=%02d.md CHANGELOG.md '/---/' + - name: Create GitHub Release + run: | + gh release create "$GITHUB_REF_NAME" \ + --title "$GITHUB_REF_NAME" \ + --notes-file CHANGELOG.00.md \ + build/odoo-helper-scripts.deb diff --git a/.gitignore b/.gitignore index 6188ba2f..6577056c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ /docs/release-notes.md /docs/contributing.md /docs/command-reference.md +/CLAUDE.md diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 209082a1..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,174 +0,0 @@ -image: ubuntu:20.04 - -variables: - GIT_SUBMODULE_STRATEGY: recursive - CI_RUN: '1' - ODOO_HELPER_INSTALL_PATH: "$CI_PROJECT_DIR" - TEST_TMP_DIR: "/tmp/odoo-helper-tests" - DEBIAN_FRONTEND: 'noninteractive' - ALWAYS_ANSWER_YES: '1' - LANG: 'C.UTF-8' - LC_ALL: 'C.UTF-8' - LANGUAGE: 'C.UTF-8' - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache" - APT_DIR: "$CI_PROJECT_DIR/.apt-cache" - APT_STATE_LISTS: "$APT_DIR/lists" - APT_CACHE_ARCHIVES: "$APT_DIR/archives" - PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/odoo-helper-scripts" - -cache: - key: ${CI_JOB_NAME} - paths: - - .cache -stages: - - lint - - test - - build - - release - - deploy - -shellcheck: - image: koalaman/shellcheck-alpine:stable - stage: lint - before_script: - - shellcheck --version - script: - - shellcheck -s bash -x -a --color -e "SC1090,SC1091,SC2034" ./bin/* ./lib/*.bash - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS - when: never - - if: $CI_COMMIT_BRANCH - - if: $CI_COMMIT_TAG !~ /^v\d.*/ - -flake8: - image: python:3 - stage: lint - before_script: - - pip install flake8 - script: - - flake8 ./lib/pylib/ - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS - when: never - - if: $CI_COMMIT_BRANCH - - if: $CI_COMMIT_TAG !~ /^v\d.*/ - - -.test:definition: &tests-definition - stage: test - before_script: - # Setup PIP Cache - - mkdir -p .cache && chmod a+rwx -R .cache - - # Install deps - - apt-get update -qq && apt-get install -yqq adduser sudo locales ruby git - - update-locale LANG=C.UTF-8 && update-locale LC_ALL=C.UTF-8 && update-locale LANGUAGE=C.UTF-8 - - gem install bashcov -v 1.8.2 - - gem install codecov simplecov-console - - # Configure Odoo user - - adduser -q odoo - - echo ' odoo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - - sudo -u odoo -HE git config --global user.email "test-oh@test.test" - - sudo -u odoo -HE git config --global user.name "test-oh" - script: - - bash install-system.bash - - sudo -u odoo -HE bashcov tests/test.bash - coverage: '/COVERAGE:.*\s+(\d{1,3}\.\d{2}\%)/' - artifacts: - paths: - - coverage - expire_in: 3 day - when: always - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS - when: never - - if: $CI_COMMIT_BRANCH - - -tests:ubuntu:20.04: - image: ubuntu:20.04 - <<: *tests-definition - -tests:ubuntu:22.04: - image: ubuntu:22.04 - <<: *tests-definition - -.build:package:base:definition: &build-package-base-def - image: ubuntu:22.04 - stage: build - variables: - ODOO_HELPER_ROOT: $CI_PROJECT_DIR - ODOO_HELPER_BIN: $CI_PROJECT_DIR/bin - ODOO_HELPER_LIB: $CI_PROJECT_DIR/lib - before_script: - - apt-get update -qq && apt-get install -qqy ruby ruby-dev make gcc curl - - gem install fpm - -build:package:tag: - <<: *build-package-base-def - script: - - bash scripts/build_packages.bash - after_script: - - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_TAG#v}/odoo-helper-scripts_${CI_COMMIT_TAG#v}.deb"' - rules: - - if: $CI_COMMIT_TAG =~ /^v\d.*/ - -build:package:branch:dev: - <<: *build-package-base-def - script: - - bash scripts/build_packages.bash "${CI_COMMIT_REF_NAME}" - after_script: - - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_REF_NAME}/odoo-helper-scripts_${CI_COMMIT_REF_NAME}.deb"' - when: manual - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - -build:package:branch:master: - <<: *build-package-base-def - script: - - bash scripts/build_packages.bash "${CI_COMMIT_REF_NAME}" - after_script: - - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "build/odoo-helper-scripts.deb" "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_REF_NAME}/odoo-helper-scripts_${CI_COMMIT_REF_NAME}.deb"' - rules: - - if: $CI_COMMIT_BRANCH == "master" - -do_release:tag: - stage: release - image: registry.gitlab.com/gitlab-org/release-cli:latest - rules: - # Run this job when a tag is created manually - - if: $CI_COMMIT_TAG =~ /^v\d.*/ - before_script: - - apk add coreutils - script: - - echo "Preparing release $CI_COMMIT_TAG." - - csplit --prefix=CHANGELOG. --suffix=%02d.md CHANGELOG.md '/---/' - release: - tag_name: $CI_COMMIT_TAG - name: "${CI_COMMIT_TAG}" - description: "./CHANGELOG.00.md" - assets: - links: - - name: "odoo-helper-scripts_${CI_COMMIT_TAG}.deb" - url: "$PACKAGE_REGISTRY_URL/${CI_COMMIT_TAG#v}/odoo-helper-scripts_${CI_COMMIT_TAG#v}.deb" - link_type: "package" - -pages: - image: ubuntu:20.04 - stage: deploy - before_script: - - apt-get update - - apt-get install -y python3-pip - - bash install-system.bash - - python3 -m pip install mkdocs mkdocs-cinder==0.14.0 - script: - - bash scripts/build_docs.bash - artifacts: - paths: - - public - rules: - - if: $CI_COMMIT_BRANCH == "master" diff --git a/README.md b/README.md index 8efc486a..c2bb29b2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Odoo helper scripts collection -| Master | [![pipeline status](https://gitlab.com/katyukha/odoo-helper-scripts/badges/master/pipeline.svg)](https://gitlab.com/katyukha/odoo-helper-scripts/commits/master) | [![coverage report](https://gitlab.com/katyukha/odoo-helper-scripts/badges/master/coverage.svg)](https://gitlab.com/katyukha/odoo-helper-scripts/commits/master)| [![CHANGELOG](https://img.shields.io/badge/CHANGELOG-master-brightgreen.svg)](https://gitlab.com/katyukha/odoo-helper-scripts/blob/master/CHANGELOG.md) | -| ------------- |:---------------|:--------------|:------------| -| Dev | [![pipeline status](https://gitlab.com/katyukha/odoo-helper-scripts/badges/dev/pipeline.svg)](https://gitlab.com/katyukha/odoo-helper-scripts/commits/dev) | [![coverage report](https://gitlab.com/katyukha/odoo-helper-scripts/badges/dev/coverage.svg)](https://gitlab.com/katyukha/odoo-helper-scripts/commits/dev) | [![CHANGELOG](https://img.shields.io/badge/CHANGELOG-dev-yellow.svg)](https://gitlab.com/katyukha/odoo-helper-scripts/blob/dev/CHANGELOG.md) | +| Branch | CI Status | CHANGELOG | +| ------ |:----------|:----------| +| master | [![CI](https://github.com/katyukha/odoo-helper-scripts/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/katyukha/odoo-helper-scripts/actions/workflows/ci.yml?query=branch%3Amaster) | [![CHANGELOG](https://img.shields.io/badge/CHANGELOG-master-brightgreen.svg)](https://github.com/katyukha/odoo-helper-scripts/blob/master/CHANGELOG.md) | +| dev | [![CI](https://github.com/katyukha/odoo-helper-scripts/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/katyukha/odoo-helper-scripts/actions/workflows/ci.yml?query=branch%3Adev) | [![CHANGELOG](https://img.shields.io/badge/CHANGELOG-dev-yellow.svg)](https://github.com/katyukha/odoo-helper-scripts/blob/dev/CHANGELOG.md) | ## Overview diff --git a/lib/addons.bash b/lib/addons.bash index 3b46902d..f16f206d 100644 --- a/lib/addons.bash +++ b/lib/addons.bash @@ -715,7 +715,14 @@ function addons_install_update_internal { local todo_addons; todo_addons=$(join_by , "$@"); - local odoo_options=( "-d" "$db" "--max-cron-threads=0" "--stop-after-init" "--no-xmlrpc" "--pidfile=/dev/null" ); + local odoo_options=( "-d" "$db" "--max-cron-threads=0" "--stop-after-init" "--pidfile=/dev/null" ); + + if [ "$(odoo_get_major_version)" -lt 11 ]; then + odoo_options+=( "--no-xmlrpc" ); + else + odoo_options+=( "--no-http" ); + fi + if ! odoo_db_is_demo_enabled -q "$db"; then odoo_options+=( "--without-demo=all" ); fi diff --git a/lib/install.bash b/lib/install.bash index 4fec8291..a291bc6c 100644 --- a/lib/install.bash +++ b/lib/install.bash @@ -520,7 +520,9 @@ function install_odoo_py_requirements_for_version { elif exec_py -c "import sys; assert (3, 7) <= sys.version_info < (3, 9);" > /dev/null 2>&1; then echo "gevent==1.5.0"; elif exec_py -c "import sys; assert sys.version_info >= (3, 9);" > /dev/null 2>&1; then - echo "gevent>=20.6.0"; + # Use recent gevent that has prebuilt wheels and supports Python 3.9+ + # See: https://github.com/odoo/odoo/issues/187021 + echo "gevent>=24.11"; else echo "$dependency"; fi @@ -531,7 +533,9 @@ function install_odoo_py_requirements_for_version { if exec_py -c "import sys; assert (3, 5) <= sys.version_info < (3, 9);" > /dev/null 2>&1; then echo "greenlet==0.4.14"; elif exec_py -c "import sys; assert sys.version_info >= (3, 9);" > /dev/null 2>&1; then - echo "greenlet>=0.4.16"; + # Use recent greenlet compatible with gevent~=24.11 + # See: https://github.com/odoo/odoo/issues/187021 + echo "greenlet>=3.1"; else echo "$dependency"; fi @@ -559,6 +563,16 @@ function install_odoo_py_requirements_for_version { # Recent versions of setup tools do not support `use_2to3` flag,so, # we have to use another fork of suds to avoid errors during install echo "suds-py3"; + elif [[ "$dependency_stripped" =~ ^cbor2==5\.4\.2 ]] && exec_py -c "import sys; assert (3, 10) <= sys.version_info < (3, 12);" > /dev/null 2>&1; then + # cbor2==5.4.2 depends on pkg_resources that was removed from newer setuptools, + # breaking installation on Python 3.10–3.11. + # Odoo 18 specifies it as "cbor2==5.4.2 ; python_version < '3.12'" (with env + # marker), so we use regex match. We only apply this on Python 3.10–3.11: + # on Python 3.12+ the '< 3.12' marker already excludes this line, and the + # separate "cbor2==5.6.2 ; python_version >= '3.12'" line handles that range. + # Replacing without a marker on 3.12+ would conflict with that second line. + # See: https://github.com/odoo/odoo/issues/248315 + echo "cbor2==5.4.6"; else # Echo dependency line unchanged to rmp file echo "$dependency"; @@ -692,21 +706,23 @@ function install_build_python_guess_version { if [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -lt 11 ]; then echo "2.7.18"; elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 11 ]; then - echo "3.7.13"; + echo "3.7.17"; elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 12 ]; then - echo "3.7.13"; + echo "3.7.17"; elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 13 ]; then echo "3.8.20"; elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 14 ]; then echo "3.8.20"; elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 15 ]; then - echo "3.8.20"; + echo "3.10.19"; elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 16 ]; then - echo "3.8.20"; + echo "3.10.19"; elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 17 ]; then - echo "3.10.15"; + echo "3.11.14"; elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 18 ]; then - echo "3.10.15"; + echo "3.12.12"; + elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 19 ]; then + echo "3.12.12"; else echoe -e "${REDC}ERROR${NC}: Automatic detection of python version for odoo ${ODOO_VERSION} is not supported!"; return 1; @@ -828,9 +844,18 @@ function install_virtual_env { VIRTUALENV_PYTHON="$VIRTUALENV_PYTHON" python3 -m virtualenv "$VENV_DIR"; fi - if [ "$(odoo_get_major_version)" -gt 10 ]; then - # Ensure correct version of setup tools installed. + local odoo_major_ver; + odoo_major_ver=$(odoo_get_major_version); + if [ "$odoo_major_ver" -gt 10 ] && [ "$odoo_major_ver" -lt 16 ]; then + # Enforce setuptools between 45 and 58: some modules in older Odoo versions + # require python's 2to3 tool that is removed in later setuptools versions. exec_pip -q install "setuptools>=45,<58"; + elif [ "$odoo_major_ver" -ge 16 ] && [ "$odoo_major_ver" -lt 19 ]; then + # Fix for zope.index 5.1+ that breaks Odoo startup with recent setuptools. + # pkg_resources is deprecated but still used in this range. + exec_pip -q install "setuptools>=76,<81"; + elif [ "$odoo_major_ver" -ge 19 ]; then + exec_pip -q install "setuptools>=76"; fi echoe -e "${BLUEC}Enabling nodeenv to be able to run js utils...${NC}"; @@ -1208,6 +1233,23 @@ function odoo_run_setup_py { sed -i -E 's@([\t ]+)(self\.ws = websocket\.create_connection\(self\.ws_url\))@\1# Automatic odoo-helper fix for ability to run tours in Chrome 111\n\1# See: https://github.com/odoo/odoo/pull/114930\n\1# See: https://github.com/odoo/odoo/pull/115782\n\1# \2\n\1self.ws = websocket.create_connection(self.ws_url, suppress_origin=True)@gm' "$ODOO_PATH/odoo/tests/common.py"; fi + # Fix exec_pg_command in odoo/tools/misc.py for Odoo 10.0-14.0. + # The function uses open(os.devnull) which opens /dev/null read-only (O_RDONLY). + # On Linux, vfs_write() checks FMODE_WRITE and returns EBADF for read-only fds, + # so any write() by pg_dump to stdout/stderr (e.g. PostgreSQL NOTICE messages + # via libpq's notice processor) fails, causing pg_dump to exit with code 1. + # Fixed upstream in Odoo 15.0 by switching to subprocess.DEVNULL. + local misc_py="$ODOO_PATH/odoo/tools/misc.py"; + if [ "$(odoo_get_major_version)" -ge 10 ] \ + && [ "$(odoo_get_major_version)" -le 14 ] \ + && [ -f "$misc_py" ]; then + sed -i \ + "s/with open(os.devnull) as dn:/with open(os.devnull, 'w') as dn:/g" \ + "$misc_py"; + echoe -e "Applied fix for ${BLUEC}exec_pg_command${NC} in misc.py" \ + "(open(os.devnull, 'w') to avoid EBADF on pg_dump stderr writes)"; + fi + } diff --git a/lib/odoo.bash b/lib/odoo.bash index 6b37a4ad..ec743789 100644 --- a/lib/odoo.bash +++ b/lib/odoo.bash @@ -277,22 +277,26 @@ function odoo_ensure_python_version { return 2; # Python interpreter is not available fi - if [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 11 ]; then + local odoo_major_ver; + odoo_major_ver=$(odoo_get_major_version); + if [ "$odoo_major_ver" -le 10 ]; then + # Odoo 8-10: Python 2.7 only + ${python_interpreter} -c "import sys; assert (2, 7) <= sys.version_info < (3,);" > /dev/null 2>&1; + elif [ "$odoo_major_ver" -le 13 ]; then + # Odoo 11-13: Python 3.6–3.8 ${python_interpreter} -c "import sys; assert (3, 6) <= sys.version_info < (3, 9);" > /dev/null 2>&1; - elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 12 ]; then - ${python_interpreter} -c "import sys; assert (3, 6) <= sys.version_info < (3, 9);" > /dev/null 2>&1; - elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 13 ]; then - ${python_interpreter} -c "import sys; assert (3, 6) <= sys.version_info < (3, 10);" > /dev/null 2>&1; - elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 14 ]; then + elif [ "$odoo_major_ver" -eq 14 ]; then + # Odoo 14: Python 3.6–3.9 ${python_interpreter} -c "import sys; assert (3, 6) <= sys.version_info < (3, 10);" > /dev/null 2>&1; - elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 15 ]; then - ${python_interpreter} -c "import sys; assert (3, 7) <= sys.version_info < (3, 11);"; - elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 16 ]; then - ${python_interpreter} -c "import sys; assert (3, 7) <= sys.version_info < (3, 11);"; - elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 17 ]; then - ${python_interpreter} -c "import sys; assert sys.version_info > (3, 10);"; - elif [ -n "$ODOO_VERSION" ] && [ "$(odoo_get_major_version)" -eq 18 ]; then - ${python_interpreter} -c "import sys; assert sys.version_info > (3, 10);"; + elif [ "$odoo_major_ver" -le 16 ]; then + # Odoo 15-16: Python 3.7–3.10 + ${python_interpreter} -c "import sys; assert (3, 7) <= sys.version_info < (3, 11);" > /dev/null 2>&1; + elif [ "$odoo_major_ver" -eq 17 ]; then + # Odoo 17: Python 3.10–3.11 + ${python_interpreter} -c "import sys; assert (3, 10) <= sys.version_info < (3, 12);" > /dev/null 2>&1; + elif [ "$odoo_major_ver" -le 19 ]; then + # Odoo 18-19: Python 3.10–3.12 + ${python_interpreter} -c "import sys; assert (3, 10) <= sys.version_info < (3, 13);" > /dev/null 2>&1; else echoe -e "${REDC}ERROR${NC}: Automatic detection of python version for odoo ${ODOO_VERSION} is not supported!"; return 1; diff --git a/lib/utils.bash b/lib/utils.bash index a787fdae..347f44f2 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -135,7 +135,7 @@ function is_process_running { # random_string [length] # default length = 8 function random_string { - < /dev/urandom tr -dc A-Za-z0-9 | head -c"${1:-8}"; + < /dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c"${1:-8}"; } # search_file_up diff --git a/scripts/run_docker_test.bash b/scripts/run_docker_test.bash index 00b825b5..8ce521e6 100644 --- a/scripts/run_docker_test.bash +++ b/scripts/run_docker_test.bash @@ -45,7 +45,7 @@ CMD_CLEANUP="sudo rm -rf rm -rf $E_TEST_TMP_DIR"; #------------------------------------------------------ # Set up default values #------------------------------------------------------ -TEST_FILE=/opt/odoo-helper-scripts/tests/test.bash; +TEST_FILE=; # empty means run both py2 and py3 suites DOCKER_FILE=$PROJECT_DIR/tests/docker/; DOCKER_TEST_IMAGE=odoo-helper-test DOCKER_IMAGE="ubuntu:18.04" @@ -61,7 +61,7 @@ usage="Usage: Default: $DOCKER_IMAGE $SCRIPT_NAME --docker-ti - add '-ti' options to 'docker run' cmd $SCRIPT_NAME --with-coverage - run with code coverage - $SCRIPT_NAME --test-file - run test file. default: $TEST_FILE + $SCRIPT_NAME --test-file - run specific test file (default: run both test_py2.bash and test_py3.bash) $SCRIPT_NAME --help - show this help message "; @@ -108,7 +108,13 @@ do done #------------------------------------------------------ -D_CMD_TEST="cd /home/odoo && sudo -E -u odoo -H bash $TEST_FILE"; +if [ -z "$TEST_FILE" ]; then + D_CMD_TEST="cd /home/odoo && \ + sudo -E -u odoo -H bash /opt/odoo-helper-scripts/tests/test_py2.bash && \ + sudo -E -u odoo -H bash /opt/odoo-helper-scripts/tests/test_py3.bash" +else + D_CMD_TEST="cd /home/odoo && sudo -E -u odoo -H bash $TEST_FILE" +fi set -e; # fail on errors diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index 5f810c7f..e3bb697c 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:14.04 +FROM ubuntu:24.04 # Set corect locale-related environment variables ENV LANG="en_US.UTF-8" LANGUAGE="en_US:en" LC_ALL="en_US.UTF-8" diff --git a/tests/test_py2.bash b/tests/test_py2.bash new file mode 100644 index 00000000..ca17308f --- /dev/null +++ b/tests/test_py2.bash @@ -0,0 +1,439 @@ +#!/bin/bash + +# Copyright © 2016-2018 Dmytro Katyukha + +####################################################################### +# This Source Code Form is subject to the terms of the Mozilla Public # +# License, v. 2.0. If a copy of the MPL was not distributed with this # +# file, You can obtain one at http://mozilla.org/MPL/2.0/. # +####################################################################### + +# this script runs tests for Odoo 8.0, 9.0, 10.0 (Python 2) + +SCRIPT=$0; +SCRIPT_NAME=$(basename $SCRIPT); +PROJECT_DIR=$(readlink -f "$(dirname $SCRIPT)/.."); +TEST_TMP_DIR="${TEST_TMP_DIR:-$PROJECT_DIR/test-temp}"; +WORK_DIR=$(pwd); + +ERROR=; + +tempfiles=( ) + +# do cleanup on exit +cleanup() { + if [ -z $ERROR ]; then + if ! rm -rf "$TEST_TMP_DIR"; then + echo "Cannot remove $TEST_TMP_DIR"; + fi + fi +} +trap cleanup 0 + +# Handle errors +# Based on: http://stackoverflow.com/questions/64786/error-handling-in-bash#answer-185900 +error() { + local parent_lineno="$1" + local message="$2" + local code="${3:-1}" + ERROR=1; + if [[ -n "$message" ]] ; then + echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}" + else + echo "Error on or near line ${parent_lineno}; exiting with status ${code}" + fi + exit "${code}" +} +trap 'error ${LINENO}' ERR + +# Fail on any error +set -e; + +# Init test tmp dir +mkdir -p $TEST_TMP_DIR; +cd $TEST_TMP_DIR; + +# Prepare for test (if running on CI) +source "$PROJECT_DIR/tests/ci.bash"; + +# import odoo-helper common lib to allow colors in test output +source $(odoo-helper system lib-path common); +allow_colors; + +# +# Start test +# ========== +# +echo -e "${YELLOWC} +=================================================== +Show odoo-helper-scripts version +=================================================== +${NC}" +odoo-helper --version; + + +echo -e "${YELLOWC} +=================================================== +Install odoo-helper and odoo system prerequirements +=================================================== +${NC}" + +odoo-helper install pre-requirements -y; +odoo-helper install bin-tools -y; +odoo-helper install postgres; + +if [ ! -z $CI_RUN ] && ! odoo-helper exec postgres_test_connection; then + echo -e "${YELLOWC}WARNING${NC}: Cannot connect to postgres instance. Seems that postgres not started, trying to start it now..." + sudo /etc/init.d/postgresql start; +fi + + +echo -e "${YELLOWC} +=================================================== +Run odoo-helper postgres speedify +=================================================== +${NC}" +odoo-helper postgres speedify + + +echo -e "${YELLOWC} +======================================================================== +Install odoo 8.0, fetch and run tests for OCA addon 'project_sla' +Also install python package 'suds' in virtual env of this odoo instance +======================================================================== +${NC}" +# Let's install odoo of version 8.0 too here. +odoo-helper install sys-deps -y 8.0; +odoo-helper postgres user-create odoo8 odoo +odoo-install --install-dir odoo-8.0 --odoo-version 8.0 \ + --conf-opt-xmlrpc_port 8369 --conf-opt-xmlrpcs_port 8371 --conf-opt-longpolling_port 8372 \ + --db-user odoo8 --db-pass odoo + +cd odoo-8.0 + +echo ""; +echo "Generated odoo config:" +echo "$(cat ./conf/odoo.conf)" +echo ""; + +# and install there for example addon 'project_sla' for 'project-service' Odoo Comutinty repository +# Note that odoo-helper script will automaticaly fetch branch named as server version in current install, +# if another branch was not specified +odoo-helper fetch --oca project -m project_sla + +# create test database +odoo-helper db create --demo odoo8-odoo-test + +# Check if db has demo-data +odoo-helper db is-demo odoo8-odoo-test + +# Check if db has demo-data, but database does not exists +odoo-helper db is-demo unexisting-database || true + +# and run tests for it +odoo-helper test -m project_sla + +# Install py-tools to get coverage reports +odoo-helper install py-tools + +# or run tests with test-coverage enabled +(cd ./repositories/oca/project; odoo-helper test --recreate-db --coverage-report project_sla || true); + +# Also it is possible to fail if test coverage less than specified value +(cd ./repositories/oca/project; odoo-helper test --recreate-db --coverage-fail-under 50 project_sla || true); + +# Also we may generate html coverage report too +(cd ./repositories/oca/project; odoo-helper test --create-test-db --coverage-html --dir . --skip project_sla || true); + +# Skip all addons that starts with project +(cd ./repositories/oca/project; odoo-helper test --create-test-db --coverage-html --dir . --skip-re "^project_" || true); + +# Show addons status for this project +odoo-helper --use-unbuffer addons status + +# Or check for updates of addons +odoo-helper --use-unbuffer addons check-updates + + +echo -e "${YELLOWC} +========================== +Install and check Odoo 9.0 +========================== +${NC}" + +# got back to test root and install odoo version 9.0 (clonning it) +cd ../; +odoo-helper install sys-deps -y 9.0; +odoo-helper postgres user-create odoo9 odoo; +odoo-install --install-dir odoo-9.0 --odoo-version 9.0 \ + --conf-opt-xmlrpc_port 8369 --conf-opt-xmlrpcs_port 8371 --conf-opt-longpolling_port 8372 \ + --db-user odoo9 --db-pass odoo + +cd odoo-9.0; + +echo ""; +echo "Generated odoo config:" +echo "$(cat ./conf/odoo.conf)" +echo ""; + +odoo-helper server --stop-after-init; # test that it runs + +# Create odoo 9 database +odoo-helper db create test-9-db; + +# Ensure database does not have demo-data installed +! odoo-helper db is-demo test-9-db; +! odoo-helper db is-demo -q test-9-db; + +odoo-helper addons list ./custom_addons; # list addons available to odoo +odoo-helper addons list --help; +odoo-helper addons list --recursive ./custom_addons; +odoo-helper addons list --installable ./custom_addons; +odoo-helper addons list --color --recursive ./repositories; +odoo-helper --no-colors addons list --color --recursive ./repositories; +odoo-helper addons list --not-linked --recursive ./repositories; +odoo-helper addons list --linked --recursive ./repositories; +odoo-helper addons list --by-path ./repositories; +(cd repositories && odoo-helper addons list --recursive); +odoo-helper addons update-list --help; +odoo-helper addons update-list; +odoo-helper start; +odoo-helper stop; + +# uninstall addon that is not installed +odoo-helper addons uninstall account; + +# uninstall all addons (error) +odoo-helper addons uninstall all || true; + +# List addon repositories +odoo-helper addons list-repos; + +# List addons without repositories +odoo-helper addons list-no-repo; + +# Generate requirements +odoo-helper addons generate-requirements; + +# Generate requirements (shortcut) +odoo-helper generate-requirements; + +# Update odoo sources +odoo-helper update-odoo + +# Reinstall odoo downloading archive +odoo-helper install reinstall-odoo download; + +# Remove created backup of previous odoo code +rm -rf ./odoo-backup-*; + +# Reinstall python dependencies for Odoo +odoo-helper install py-deps + +# Drop created database +odoo-helper db drop test-9-db; + +# Show project status +odoo-helper status + +# Show complete odoo-helper status +odoo-helper status --tools-versions --ci-tools-versions + +# Install dev tools +odoo-helper install dev-tools + +# Install unoconv +odoo-helper install unoconv + +# Install openupgradelib +odoo-helper install openupgradelib + +# And show odoo-helper status after tools installed +odoo-helper status --tools-versions --ci-tools-versions + + +echo -e "${YELLOWC} +================================= +Test database management features +(create, list, and drop database) +================================= +${NC}" + +# create test database if it does not exists yet +if ! odoo-helper db exists my-test-odoo-database; then + odoo-helper db create my-test-odoo-database; +fi + +# list all odoo databases available for this odoo instance +odoo-helper db list + +# backup database +backup_file=$(odoo-helper db backup --format zip my-test-odoo-database); + +# Also it is possible to backup SQL only (without filesystem) +backup_file_sql=$(odoo-helper db backup --format sql my-test-odoo-database); + +# drop test database if it exists +if odoo-helper db exists my-test-odoo-database; then + odoo-helper db drop my-test-odoo-database; +fi + +# restore dropped database +odoo-helper db restore my-test-odoo-database "$backup_file"; + +# ensure that database exists +odoo-helper db exists my-test-odoo-database + +# rename database to my-test-db-renamed +odoo-helper db rename my-test-odoo-database my-test-db-renamed + +# Run psql and list all databases visible for odoo user +# This command will automaticaly pass connection params from odoo config +odoo-helper postgres psql -c "\l" + +# Run psql and list all databases visible for odoo user (shortcut) +odoo-helper psql -c "\l" + +# Show running queries +odoo-helper pg stat-activity + +# Show active locks +odoo-helper pg locks-info + +# Show connections info +odoo-helper pg stat-connections + +# recompute parent-store for ir.ui.menu +odoo-helper odoo recompute --dbname my-test-db-renamed -m ir.ui.menu --parent-store + +# recompute menus (parent-store values) +odoo-helper odoo recompute-menu --dbname my-test-db-renamed + +# recompute 'web_icon_data' field on ir.ui.menu +odoo-helper odoo recompute --dbname my-test-db-renamed -m ir.ui.menu -f web_icon_data + + +# drop database egain +odoo-helper db drop my-test-db-renamed; + + +echo -e "${YELLOWC} +=========================== +Install and check Odoo 10.0 +=========================== +${NC}" + +# got back to test root and install odoo version 9.0 +cd ../; +odoo-helper install sys-deps -y 10.0; +odoo-helper postgres user-create odoo10 odoo; +odoo-install --install-dir odoo-10.0 --odoo-version 10.0 \ + --conf-opt-xmlrpc_port 8369 --conf-opt-xmlrpcs_port 8371 --conf-opt-longpolling_port 8372 \ + --db-user odoo10 --db-pass odoo + +# Remove odoo 8 and odoo 9, +# this is needed to bypass gitlab.com limitation of disk space for CI jobs +rm -rf ./odoo-8.0 +rm -rf ./odoo-9.0 + +cd odoo-10.0; + +echo ""; +echo "Generated odoo config:" +echo "$(cat ./conf/odoo.conf)" +echo ""; + +odoo-helper server --stop-after-init; # test that it runs + +# Also in odoo 10 it is possible to install addons via pip. +# For example there are some OCA addons available for such install +# Let's install for example mis-builder. +# odoo-helper will automaticaly set correct pypi indexx or findlinks option +# for pip, if it is called with this command. +odoo-helper pip install odoo10-addon-mis-builder; + +# Also there is odoo-helper npm command +odoo-helper npm help + +# Install extra js tools +odoo-helper install js-tools; + + +# Install oca/partner-contact addons +odoo-helper fetch --git-single-branch --oca partner-contact; + +# Regenerate Ukrainian translations for partner_firstname addons +odoo-helper tr regenerate --lang uk_UA --file uk_UA partner_firstname; +odoo-helper tr rate --lang uk_UA partner_firstname; + +# Check partner_first_name addon with pylint and flake8 +odoo-helper install py-tools +odoo-helper pylint ./repositories/oca/partner-contact/partner_firstname || true; +odoo-helper flake8 ./repositories/oca/partner-contact/partner_firstname || true; +odoo-helper addons list --filter "first" ./repositories/oca/partner-contact +odoo-helper addons list --except-filter "first" ./repositories/oca/partner-contact + +# Show project status +odoo-helper status + +# Update odoo-sources +odoo-helper update-odoo + +# Clean up odoo backups dir +rm -rf ./backups/*; + +# Show complete odoo-helper status +odoo-helper status --tools-versions --ci-tools-versions + +# Print odoo helper configuration +odoo-helper print-config + +# Pull odoo addons update +(cd ./repositories/oca/partner-contact && git reset --hard HEAD^^^1) +odoo-helper addons pull-updates + +# Update odoo base addon +odoo-helper-addons-update base + +# Fetch OCA account-financial-reporting, which seems to have +# complicated enough dependencies for this test +odoo-helper fetch --git-single-branch --oca account-financial-reporting + +# Clone repository explicitly and link it +(cd repositories && \ + git clone -b 10.0 https://github.com/OCA/contract && \ + odoo-helper addons list --color contract && \ + odoo-helper link --ual contract && \ + odoo-helper addons list --color contract) + +# Update addons list +odoo-helper addons update-list + + +# Generate requirements and fetch them again +odoo-helper addons generate-requirements > /tmp/odoo-requirements.txt +odoo-helper fetch --git-single-branch --requirements /tmp/odoo-requirements.txt + +# Try to reinstall virtualenv and run server +odoo-helper install reinstall-venv; +odoo-helper server status +odoo-helper start +odoo-helper status +odoo-helper server status +odoo-helper stop + +# Update python dependencies of addons +odoo-helper addons update-py-deps + +# Test doc-utils. List all addons available in *contract* addon +odoo-helper doc-utils addons-list --sys-name -f name -f version -f summary -f application --git-repo ./repositories/contract + +# Same but in CSV format and with list of dependencies +odoo-helper doc-utils addons-list --sys-name -f name -f version --dependencies -f summary -f application --git-repo --format csv ./repositories/contract + + +echo -e "${GREENC} +========================================== +Tests finished (py2: Odoo 8/9/10) +========================================== +${NC}" diff --git a/tests/test.bash b/tests/test_py3.bash old mode 100755 new mode 100644 similarity index 66% rename from tests/test.bash rename to tests/test_py3.bash index ae4b16a9..4bfa436a --- a/tests/test.bash +++ b/tests/test_py3.bash @@ -8,7 +8,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # ####################################################################### -# this script run's basic tests +# this script runs tests for Odoo 11.0–18.0 (Python 3) SCRIPT=$0; SCRIPT_NAME=$(basename $SCRIPT); @@ -96,349 +96,13 @@ ${NC}" odoo-helper postgres speedify -echo -e "${YELLOWC} -======================================================================== -Install odoo 8.0, fetch and run tests for OCA addon 'project_sla' -Also install python package 'suds' in virtual env of this odoo instance -======================================================================== -${NC}" -# Let's install odoo of version 8.0 too here. -odoo-helper install sys-deps -y 8.0; -odoo-helper postgres user-create odoo8 odoo -odoo-install --install-dir odoo-8.0 --odoo-version 8.0 \ - --conf-opt-xmlrpc_port 8369 --conf-opt-xmlrpcs_port 8371 --conf-opt-longpolling_port 8372 \ - --db-user odoo8 --db-pass odoo - -cd odoo-8.0 - -echo ""; -echo "Generated odoo config:" -echo "$(cat ./conf/odoo.conf)" -echo ""; - -# and install there for example addon 'project_sla' for 'project-service' Odoo Comutinty repository -# Note that odoo-helper script will automaticaly fetch branch named as server version in current install, -# if another branch was not specified -odoo-helper fetch --oca project -m project_sla - -# create test database -odoo-helper db create --demo odoo8-odoo-test - -# Check if db has demo-data -odoo-helper db is-demo odoo8-odoo-test - -# Check if db has demo-data, but database does not exists -odoo-helper db is-demo unexisting-database || true - -# and run tests for it -odoo-helper test -m project_sla - -# Install py-tools to get coverage reports -odoo-helper install py-tools - -# or run tests with test-coverage enabled -(cd ./repositories/oca/project; odoo-helper test --recreate-db --coverage-report project_sla || true); - -# Also it is possible to fail if test coverage less than specified value -(cd ./repositories/oca/project; odoo-helper test --recreate-db --coverage-fail-under 50 project_sla || true); - -# Also we may generate html coverage report too -(cd ./repositories/oca/project; odoo-helper test --create-test-db --coverage-html --dir . --skip project_sla || true); - -# Skip all addons that starts with project -(cd ./repositories/oca/project; odoo-helper test --create-test-db --coverage-html --dir . --skip-re "^project_" || true); - -# Show addons status for this project -odoo-helper --use-unbuffer addons status - -# Or check for updates of addons -odoo-helper --use-unbuffer addons check-updates - - -echo -e "${YELLOWC} -========================== -Install and check Odoo 9.0 -========================== -${NC}" - -# got back to test root and install odoo version 9.0 (clonning it) -cd ../; -odoo-helper install sys-deps -y 9.0; -odoo-helper postgres user-create odoo9 odoo; -odoo-install --install-dir odoo-9.0 --odoo-version 9.0 \ - --conf-opt-xmlrpc_port 8369 --conf-opt-xmlrpcs_port 8371 --conf-opt-longpolling_port 8372 \ - --db-user odoo9 --db-pass odoo - -cd odoo-9.0; - -echo ""; -echo "Generated odoo config:" -echo "$(cat ./conf/odoo.conf)" -echo ""; - -odoo-helper server --stop-after-init; # test that it runs - -# Create odoo 9 database -odoo-helper db create test-9-db; - -# Ensure database does not have demo-data installed -! odoo-helper db is-demo test-9-db; -! odoo-helper db is-demo -q test-9-db; - -odoo-helper addons list ./custom_addons; # list addons available to odoo -odoo-helper addons list --help; -odoo-helper addons list --recursive ./custom_addons; -odoo-helper addons list --installable ./custom_addons; -odoo-helper addons list --color --recursive ./repositories; -odoo-helper --no-colors addons list --color --recursive ./repositories; -odoo-helper addons list --not-linked --recursive ./repositories; -odoo-helper addons list --linked --recursive ./repositories; -odoo-helper addons list --by-path ./repositories; -(cd repositories && odoo-helper addons list --recursive); -odoo-helper addons update-list --help; -odoo-helper addons update-list; -odoo-helper start; -odoo-helper stop; - -# uninstall addon that is not installed -odoo-helper addons uninstall account; - -# uninstall all addons (error) -odoo-helper addons uninstall all || true; - -# List addon repositories -odoo-helper addons list-repos; - -# List addons without repositories -odoo-helper addons list-no-repo; - -# Generate requirements -odoo-helper addons generate-requirements; - -# Generate requirements (shortcut) -odoo-helper generate-requirements; - -# Update odoo sources -odoo-helper update-odoo - -# Reinstall odoo downloading archive -odoo-helper install reinstall-odoo download; - -# Remove created backup of previous odoo code -rm -rf ./odoo-backup-*; - -# Reinstall python dependencies for Odoo -odoo-helper install py-deps - -# Drop created database -odoo-helper db drop test-9-db; - -# Show project status -odoo-helper status - -# Show complete odoo-helper status -odoo-helper status --tools-versions --ci-tools-versions - -# Install dev tools -odoo-helper install dev-tools - -# Install unoconv -odoo-helper install unoconv - -# Install openupgradelib -odoo-helper install openupgradelib - -# And show odoo-helper status after tools installed -odoo-helper status --tools-versions --ci-tools-versions - - -echo -e "${YELLOWC} -================================= -Test database management features -(create, list, and drop database) -================================= -${NC}" - -# create test database if it does not exists yet -if ! odoo-helper db exists my-test-odoo-database; then - odoo-helper db create my-test-odoo-database; -fi - -# list all odoo databases available for this odoo instance -odoo-helper db list - -# backup database -backup_file=$(odoo-helper db backup --format zip my-test-odoo-database); - -# Also it is possible to backup SQL only (without filesystem) -backup_file_sql=$(odoo-helper db backup --format sql my-test-odoo-database); - -# drop test database if it exists -if odoo-helper db exists my-test-odoo-database; then - odoo-helper db drop my-test-odoo-database; -fi - -# restore dropped database -odoo-helper db restore my-test-odoo-database "$backup_file"; - -# ensure that database exists -odoo-helper db exists my-test-odoo-database - -# rename database to my-test-db-renamed -odoo-helper db rename my-test-odoo-database my-test-db-renamed - -# Run psql and list all databases visible for odoo user -# This command will automaticaly pass connection params from odoo config -odoo-helper postgres psql -c "\l" - -# Run psql and list all databases visible for odoo user (shortcut) -odoo-helper psql -c "\l" - -# Show running queries -odoo-helper pg stat-activity - -# Show active locks -odoo-helper pg locks-info - -# Show connections info -odoo-helper pg stat-connections - -# recompute parent-store for ir.ui.menu -odoo-helper odoo recompute --dbname my-test-db-renamed -m ir.ui.menu --parent-store - -# recompute menus (parent-store values) -odoo-helper odoo recompute-menu --dbname my-test-db-renamed - -# recompute 'web_icon_data' field on ir.ui.menu -odoo-helper odoo recompute --dbname my-test-db-renamed -m ir.ui.menu -f web_icon_data - - -# drop database egain -odoo-helper db drop my-test-db-renamed; - - -echo -e "${YELLOWC} -=========================== -Install and check Odoo 10.0 -=========================== -${NC}" - -# got back to test root and install odoo version 9.0 -cd ../; -odoo-helper install sys-deps -y 10.0; -odoo-helper postgres user-create odoo10 odoo; -odoo-install --install-dir odoo-10.0 --odoo-version 10.0 \ - --conf-opt-xmlrpc_port 8369 --conf-opt-xmlrpcs_port 8371 --conf-opt-longpolling_port 8372 \ - --db-user odoo10 --db-pass odoo - -# Remove odoo 8 and odoo 9, -# this is needed to bypass gitlab.com limitation of disk space for CI jobs -rm -rf ./odoo-8.0 -rm -rf ./odoo-9.0 - -cd odoo-10.0; - -echo ""; -echo "Generated odoo config:" -echo "$(cat ./conf/odoo.conf)" -echo ""; - -odoo-helper server --stop-after-init; # test that it runs - -# Also in odoo 10 it is possible to install addons via pip. -# For example there are some OCA addons available for such install -# Let's install for example mis-builder. -# odoo-helper will automaticaly set correct pypi indexx or findlinks option -# for pip, if it is called with this command. -odoo-helper pip install odoo10-addon-mis-builder; - -# Also there is odoo-helper npm command -odoo-helper npm help - -# Install extra js tools -odoo-helper install js-tools; - - -# Install oca/partner-contact addons -odoo-helper fetch --git-single-branch --oca partner-contact; - -# Regenerate Ukrainian translations for partner_firstname addons -odoo-helper tr regenerate --lang uk_UA --file uk_UA partner_firstname; -odoo-helper tr rate --lang uk_UA partner_firstname; - -# Check partner_first_name addon with pylint and flake8 -odoo-helper install py-tools -odoo-helper pylint ./repositories/oca/partner-contact/partner_firstname || true; -odoo-helper flake8 ./repositories/oca/partner-contact/partner_firstname || true; -odoo-helper addons list --filter "first" ./repositories/oca/partner-contact -odoo-helper addons list --except-filter "first" ./repositories/oca/partner-contact - -# Show project status -odoo-helper status - -# Update odoo-sources -odoo-helper update-odoo - -# Clean up odoo backups dir -rm -rf ./backups/*; - -# Show complete odoo-helper status -odoo-helper status --tools-versions --ci-tools-versions - -# Print odoo helper configuration -odoo-helper print-config - -# Pull odoo addons update -(cd ./repositories/oca/partner-contact && git reset --hard HEAD^^^1) -odoo-helper addons pull-updates - -# Update odoo base addon -odoo-helper-addons-update base - -# Fetch OCA account-financial-reporting, which seems to have -# complicated enough dependencies for this test -odoo-helper fetch --git-single-branch --oca account-financial-reporting - -# Clone repository explicitly and link it -(cd repositories && \ - git clone -b 10.0 https://github.com/OCA/contract && \ - odoo-helper addons list --color contract && \ - odoo-helper link --ual contract && \ - odoo-helper addons list --color contract) - -# Update addons list -odoo-helper addons update-list - - -# Generate requirements and fetch them again -odoo-helper addons generate-requirements > /tmp/odoo-requirements.txt -odoo-helper fetch --git-single-branch --requirements /tmp/odoo-requirements.txt - -# Try to reinstall virtualenv and run server -odoo-helper install reinstall-venv; -odoo-helper server status -odoo-helper start -odoo-helper status -odoo-helper server status -odoo-helper stop - -# Update python dependencies of addons -odoo-helper addons update-py-deps - -# Test doc-utils. List all addons available in *contract* addon -odoo-helper doc-utils addons-list --sys-name -f name -f version -f summary -f application --git-repo ./repositories/contract - -# Same but in CSV format and with list of dependencies -odoo-helper doc-utils addons-list --sys-name -f name -f version --dependencies -f summary -f application --git-repo --format csv ./repositories/contract - - echo -e "${YELLOWC} ================================= Install and check Odoo 11.0 (Py3) ================================= ${NC}" -cd ../; +# Already in $TEST_TMP_DIR from init block above odoo-helper install sys-deps -y 11.0; odoo-helper postgres user-create odoo11 odoo; @@ -601,8 +265,8 @@ odoo-helper system is-project ./repositories; echo -e "${YELLOWC}Print path to virtualenv directory of current odoo-helper project:${NC}"; odoo-helper system get-venv-dir; -echo -e "${YELLOWC}Print path to virtualenv directory of odoo 10.0 project:${NC}"; -odoo-helper system get-venv-dir ../odoo-10.0; +echo -e "${YELLOWC}Print path to virtualenv directory of odoo 11.0 project:${NC}"; +odoo-helper system get-venv-dir ../odoo-11.0; echo -e "${YELLOWC} ========================================== @@ -1100,7 +764,6 @@ bash "$PROJECT_DIR/scripts/prepare_docs.bash"; echo -e "${GREENC} ========================================== -Tests finished +Tests finished (py3: Odoo 11–18) ========================================== ${NC}" -