From 60589274eb54a24b6308b7c1e27cee9fdd070461 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Wed, 13 Dec 2023 12:14:49 +0000 Subject: [PATCH] :construction_worker_man: sync DINAR Pushed from https://github.com/itpp-labs/DINAR/.github/workflows/fork2repos.yml --- .DINAR/config.yaml | 11 ++ .DINAR/image/README.md | 4 + .DINAR/image/dependencies/pip.txt | 1 + .DINAR/image/src/addons.yaml | 1 + .DINAR/image/src/repos.yaml | 12 ++ .editorconfig | 20 +++ .eslintrc.yml | 185 ++++++++++++++++++++ .flake8 | 13 ++ .github/workflows/DINAR-PORT.yml | 146 ++++++++++++++++ .github/workflows/DINAR-pr.yml | 264 +++++++++++++++++++++++++++++ .github/workflows/DINAR-readme.yml | 64 +++++++ .github/workflows/DINAR.yml | 116 +++++++++++++ .github/workflows/repo2store.yml | 34 ++++ .isort.cfg | 13 ++ .pre-commit-config.yaml | 104 ++++++++++++ .prettierrc.yml | 8 + .pylintrc | 86 ++++++++++ .pylintrc-mandatory | 65 +++++++ 18 files changed, 1147 insertions(+) create mode 100644 .DINAR/config.yaml create mode 100644 .DINAR/image/README.md create mode 100644 .DINAR/image/dependencies/pip.txt create mode 100644 .DINAR/image/src/addons.yaml create mode 100644 .DINAR/image/src/repos.yaml create mode 100644 .editorconfig create mode 100644 .eslintrc.yml create mode 100644 .flake8 create mode 100644 .github/workflows/DINAR-PORT.yml create mode 100644 .github/workflows/DINAR-pr.yml create mode 100644 .github/workflows/DINAR-readme.yml create mode 100644 .github/workflows/DINAR.yml create mode 100644 .github/workflows/repo2store.yml create mode 100644 .isort.cfg create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierrc.yml create mode 100644 .pylintrc create mode 100644 .pylintrc-mandatory diff --git a/.DINAR/config.yaml b/.DINAR/config.yaml new file mode 100644 index 00000000..24e4c0f3 --- /dev/null +++ b/.DINAR/config.yaml @@ -0,0 +1,11 @@ +addons: + # modules to install before running tests + include: + - contacts + + # modules to exclude from installation/testing + exclude: + - hw_proxy + + server_wide_modules: + - web diff --git a/.DINAR/image/README.md b/.DINAR/image/README.md new file mode 100644 index 00000000..e6e2e05b --- /dev/null +++ b/.DINAR/image/README.md @@ -0,0 +1,4 @@ +This folder is attached on image building as `custom/` folder in +[doobba](https://github.com/Tecnativa/doodba#image-usage). Few additional +[files](https://github.com/itpp-labs/DINAR/tree/master/embedded-files/.DINAR/image) are +attached temporary on image building. diff --git a/.DINAR/image/dependencies/pip.txt b/.DINAR/image/dependencies/pip.txt new file mode 100644 index 00000000..08ccfb7f --- /dev/null +++ b/.DINAR/image/dependencies/pip.txt @@ -0,0 +1 @@ +# Python dependencies diff --git a/.DINAR/image/src/addons.yaml b/.DINAR/image/src/addons.yaml new file mode 100644 index 00000000..906aaf57 --- /dev/null +++ b/.DINAR/image/src/addons.yaml @@ -0,0 +1 @@ +# see https://github.com/Tecnativa/doodba#optodoocustomsrcaddonsyaml diff --git a/.DINAR/image/src/repos.yaml b/.DINAR/image/src/repos.yaml new file mode 100644 index 00000000..f376033b --- /dev/null +++ b/.DINAR/image/src/repos.yaml @@ -0,0 +1,12 @@ +# Documentation: https://github.com/Tecnativa/doodba#optodoocustomsrcreposyaml + +# Odoo source. +# Update this section to switch to OCA/OCB or apply custom patches +odoo: + defaults: + depth: 1 + remotes: + origin: https://github.com/odoo/odoo.git + target: origin $ODOO_VERSION + merges: + - origin $ODOO_VERSION diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..bfd7ac53 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# Configuration for known file extensions +[*.{css,js,json,less,md,py,rst,sass,scss,xml,yaml,yml}] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{json,yml,yaml,rst,md}] +indent_size = 2 + +# Do not configure editor for libs and autogenerated content +[{*/static/{lib,src/lib}/**,*/static/description/index.html,*/readme/../README.rst}] +charset = unset +end_of_line = unset +indent_size = unset +indent_style = unset +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 00000000..69cc2097 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,185 @@ +env: + browser: true + +# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 +parserOptions: + ecmaVersion: 2017 + sourceType: module + +# Globals available in Odoo that shouldn't produce errorings +globals: + _: readonly + $: readonly + fuzzy: readonly + jQuery: readonly + moment: readonly + odoo: readonly + openerp: readonly + Promise: readonly + owl: readonly + +# Styling is handled by Prettier, so we only need to enable AST rules; +# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890 +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: off + 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 + - args: none + 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] + space-before-function-paren: ["warn", { "anonymous": "always", "named": "never" }] + strict: [error, function] + use-isnan: error + valid-jsdoc: + - warn + - prefer: + arg: param + argument: param + augments: extends + constructor: class + exception: throws + func: function + method: function + prop: property + return: returns + virtual: abstract + yield: yields + preferType: + array: Array + bool: Boolean + boolean: Boolean + number: Number + object: Object + str: String + string: String + requireParamDescription: false + requireReturn: false + requireReturnDescription: false + requireReturnType: false + valid-typeof: warn + yoda: warn diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..486bc7ed --- /dev/null +++ b/.flake8 @@ -0,0 +1,13 @@ +[flake8] +max-line-length = 80 +max-complexity = 16 +# B = bugbear +# B9 = bugbear opinionated (incl line length) +select = C,E,F,W,B,B9 +# E203: whitespace before ':' (black behaviour) +# E501: flake8 line length (covered by bugbear B950) +# W503: line break before binary operator (black behaviour) +# C901: "method is too complex" -- it's too complex to fix existing modules. Disable for now +ignore = E203,E501,W503,B950,C901 +per-file-ignores= + __init__.py:F401 diff --git a/.github/workflows/DINAR-PORT.yml b/.github/workflows/DINAR-PORT.yml new file mode 100644 index 00000000..ae93f66d --- /dev/null +++ b/.github/workflows/DINAR-PORT.yml @@ -0,0 +1,146 @@ +# Copyright 2020 IT Projects Labs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: "Port module" + +on: + issues: + types: + - opened + - reopened + +jobs: + port: + runs-on: ubuntu-latest + if: "startsWith(github.event.issue.title, 'DINAR-PORT ')" + steps: + - name: Post link + uses: KeisukeYamashita/create-comment@v1 + with: + comment: + "Porting is started. Check logs: https://github.com/${{ github.repository + }}/actions/runs/${{ github.run_id }}" + - name: Checkout DINAR + uses: actions/checkout@v2 + with: + path: DINAR + repository: itpp-labs/DINAR-fork + ref: master + - uses: actions/setup-python@v4 + with: + python-version: "3.8" + - name: Install python tools + run: | + pip install plumbum pre-commit git-aggregator + - name: Check Python Version + run: + echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> + $GITHUB_ENV + - name: Analyze request + env: + TITLE: ${{ github.event.issue.title }} + run: | + # sets environment variables that available in next steps via $ {{ env.PORT_... }} notation + python DINAR/workflow-files/analyze_port_trigger.py "$TITLE" + - name: Checkout Repo + uses: actions/checkout@v2 + with: + path: REPO + fetch-depth: 0 + ref: ${{ env.PORT_TO_BRANCH }} + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('REPO/.pre-commit-config.yaml') }} + - name: Copy module to new branch + run: | + git config --global user.email "itpp-bot@users.noreply.github.com" + git config --global user.name "Mitchell Admin" + cd REPO + if [ ! -d ${{ env.PORT_MODULE }} ] + then + # apply original commit history + if ! git format-patch --keep-subject --stdout origin/${{ env.PORT_TO_BRANCH }}..origin/${{ env.PORT_FROM_BRANCH }} -- ${{ env.PORT_MODULE }} | git am -3 --keep + then + # git am failed + git am --abort + fi + fi + if [ ! -d ${{ env.PORT_MODULE }} ] + then + # just copy source + git checkout origin/${{ env.PORT_FROM_BRANCH }} -- ${{ env.PORT_MODULE }} + git commit -m ":tada:${{ env.PORT_FROM_BRANCH_TAGS }} ${{ env.PORT_MODULE }} + previous commits history: https://github.com/${{ github.repository }}/commits/${{ env.PORT_FROM_BRANCH }}/${{ env.PORT_MODULE }} + > Made via .github/workflows/DINAR-PORT.yml" + fi + - name: make OCA/odoo-module-migrator + run: | + gitaggregate -c DINAR/workflow-files/odoo-module-migrator-mix.yml + pip install -e ./odoo-module-migrator + - name: apply OCA/odoo-module-migrator + run: | + LOG_FILE=../odoo-module-migrator.logs + cd REPO + odoo-module-migrate \ + --modules ${{ env.PORT_MODULE }} \ + --init-version-name ${{ env.PORT_FROM_BRANCH }} \ + --target-version-name ${{ env.PORT_TO_BRANCH }} \ + --no-commit \ + --no-pre-commit \ + 2> $LOG_FILE || true + cat $LOG_FILE + + # remove colors + sed -r -i "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" $LOG_FILE + # escape character + # TODO: update KeisukeYamashita/create-comment to support reading comment's body from file + echo 'MIGRATOR_LOGS<> $GITHUB_ENV + cat $LOG_FILE >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + + git add -A + git commit -m ":arrow_up:${{ env.PORT_TO_BRANCH_TAGS }} OCA/odoo-module-migrator + + close #${{ github.event.issue.number }} + + > Made via .github/workflows/DINAR-PORT.yml" + - name: pre-commit + run: | + cd REPO + pre-commit run --files $(find ${{ env.PORT_MODULE }} -type f) || true + git add -A + git commit -m ":rainbow: pre-commit + > Made via .github/workflows/DINAR-PORT.yml" || echo "pre-commit: no changes" + - name: PR + uses: peter-evans/create-pull-request@v3 + id: cpr + with: + path: REPO + # GITHUB_TOKEN would not trigger PR checks + token: ${{ secrets.DINAR_TOKEN }} + branch: ${{ env.PORT_TO_BRANCH }}-${{ env.PORT_MODULE }} + title: "[${{ env.PORT_TO_BRANCH }}] ${{ env.PORT_MODULE }}" + body: | + Made by [DINAR](https://github.com/itpp-labs/DINAR#readme) by request in #${{ github.event.issue.number }} + - name: Post logs + uses: KeisukeYamashita/create-comment@v1 + with: + number: ${{ steps.cpr.outputs.pull-request-number }} + comment: | + [Migrator](https://github.com/OCA/odoo-module-migrator/)'s [logs](https://github.com/${{ github.repository + }}/actions/runs/${{ github.run_id }}): + + ``` + ${{ env.MIGRATOR_LOGS }} + ``` diff --git a/.github/workflows/DINAR-pr.yml b/.github/workflows/DINAR-pr.yml new file mode 100644 index 00000000..fbc0a36a --- /dev/null +++ b/.github/workflows/DINAR-pr.yml @@ -0,0 +1,264 @@ +# Copyright 2020 IT Projects Labs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: "DINAR" + +on: + pull_request: + +jobs: + pre-commit: + name: "pre-commit" + # Let Quick Review/Tests run first + needs: + - review + - tests + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - uses: actions/setup-python@v4 + with: + python-version: "3.8" + - name: Check Python Version + run: + echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> + $GITHUB_ENV + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - uses: pre-commit/action@v1.0.1 + + review: + name: "Quick Review" + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + path: REPO + - name: Checkout DINAR + uses: actions/checkout@v2 + with: + path: DINAR + repository: itpp-labs/DINAR-fork + ref: master + - uses: actions/setup-python@v4 + with: + python-version: "3.8" + - name: Install python tools + run: | + pip install plumbum PyGithub pyyaml + - name: Analyze PR + run: | + # sets environment variables that available in next steps via $ {{ env.PR_... }} notation + cd REPO + python ../DINAR/workflow-files/analyze-modules.py updated ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.number }} + - name: Configure docker + run: | + bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN || secrets.GITHUB_TOKEN }} + echo "PR_FILES=../../REPO" >> $GITHUB_ENV + - name: HOW TO RUN ODOO LOCALLY + if: always() + run: | + export MODULES=${{ env.PR_MODULES }} + export LOAD_MODULES=${{ env.PR_MODULES_LOAD }} + export PR_NUM=${{ github.event.number }} + export VERSION=${{ github.event.pull_request.base.ref }} + export REVISION_PR=${{ github.event.pull_request.head.sha}} + export DINAR_REPO="itpp-labs/DINAR-fork" + bash DINAR/workflow-files/how-to-run-locally.sh + - name: Check Python Version + run: + echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> + $GITHUB_ENV + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('REPO/.pre-commit-config.yaml') }} + - name: Install pre-commit + run: | + pip install pre-commit + - name: PRE-COMMIT against updated files only + run: | + cd REPO + git fetch origin ${{ github.event.pull_request.base.ref }} + echo "CHANGED FILES:" + git diff --name-only --no-ext-diff FETCH_HEAD..HEAD -- . + echo "RUN PRE-COMMIT:" + pre-commit run --show-diff-on-failure --color=always --show-diff-on-failure --files $(git diff --name-only --no-ext-diff FETCH_HEAD..HEAD -- .) + + tests: + name: "Quick Tests" + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + path: REPO + - name: Checkout DINAR + uses: actions/checkout@v2 + with: + path: DINAR + repository: itpp-labs/DINAR-fork + ref: master + - name: Configure docker + run: | + bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN || secrets.GITHUB_TOKEN }} + echo "PR_FILES=../../REPO" >> $GITHUB_ENV + - name: Install python tools + run: | + pip install plumbum PyGithub pyyaml + - name: Download Docker images with preinstalled modules + run: | + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml pull + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --no-start + - name: Analyze PR + run: | + # Get list of installed modules + ODOO_BASE_MODULES=$(docker inspect \ + --format '{{ index .Config.Labels "dinar.odoo.modules"}}' \ + dinar_odoo_1) + echo "ODOO_BASE_MODULES=$ODOO_BASE_MODULES" + + # sets environment variables that available in next steps via $ {{ env.PR_... }} notation + cd REPO + python ../DINAR/workflow-files/analyze-modules.py updated ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.number }} $ODOO_BASE_MODULES + - name: Install json parser + run: | + sudo apt-get install jq + - name: Install Additional Dependencies (Modules) + if: env.PR_MODULES_DEPS != '' + run: | + # Install new dependencies without tests + export MODULES="${{ env.PR_MODULES_DEPS }}" + export LOAD_MODULES="${{ env.PR_MODULES_LOAD }}" + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit + - name: Install Additional Dependencies (Packages) + if: env.PR_DEPS != '' + run: | + # TODO https://github.com/itpp-labs/DINAR/issues/42 + exit 1 + - name: Prepare Artifact Folder + run: | + mkdir new-deps/ + # create dummy file to be sure that Artifact will be uploaded + echo ok > new-deps/.empty + echo "ARTIFACT=empty" >> $GITHUB_ENV + - name: Prepare DINAR with additional dependencies + if: env.PR_MODULES_DEPS != '' || env.PR_DEPS != '' + run: | + # Save artifacts for local run and for integrations Tests + bash DINAR/workflow-files/save-docker-layers.sh new-deps/ + echo "${{ env.PR_MODULES_DEPS }}" > new-deps/modules.txt + echo "ARTIFACT=yes" >> $GITHUB_ENV + - name: Save DINAR with dependencies + uses: actions/upload-artifact@v1 + with: + name: new-deps + path: new-deps/ + - name: HOW TO RUN QUICK TESTS LOCALLY + if: always() + run: | + export MODULES=${{ env.PR_MODULES }} + export LOAD_MODULES=${{ env.PR_MODULES_LOAD }} + export PR_NUM=${{ github.event.number }} + export VERSION=${{ github.event.pull_request.base.ref }} + export REVISION_PR=${{ github.event.pull_request.head.sha}} + export DINAR_REPO="itpp-labs/DINAR-fork" + export ODOO_EXTRA_ARG=--test-enable + bash DINAR/workflow-files/how-to-run-locally.sh ${{ secrets.GITHUB_TOKEN }} + - name: Test updated modules + if: env.PR_MODULES != '' + run: | + export MODULES="${{ env.PR_MODULES }}" + export LOAD_MODULES="${{ env.PR_MODULES_LOAD }}" + export ODOO_EXTRA_ARG=--test-enable + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit + + tests-all: + name: Integration Tests + # Let Quick Review/Tests run first + # This job uses artifacts from "Quick Tests" + needs: + - tests + - review + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + path: REPO + - name: Checkout DINAR + uses: actions/checkout@v2 + with: + path: DINAR + repository: itpp-labs/DINAR-fork + ref: master + - name: Install python tools + run: | + pip install plumbum pyyaml + - name: Download Additional Dependencies artifact + uses: actions/download-artifact@v1 + with: + name: new-deps + path: new-deps/ + - name: Check artifact + run: | + if [ ! -f new-deps/modules.txt ]; then + echo "ARTIFACT=empty" >> $GITHUB_ENV + fi + - name: Configure Docker + run: | + bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN || secrets.GITHUB_TOKEN }} + echo "PR_FILES=../../REPO" >> $GITHUB_ENV + - name: Analyze PR + run: | + # sets environment variables that available in next steps via $ {{ env.PR_... }} notation + DEPS_MODULES=$(cat new-deps/modules.txt || true) + cd REPO + python ../DINAR/workflow-files/analyze-modules.py all "$DEPS_MODULES" + - name: Install json parser + run: | + sudo apt-get install jq + - name: HOW TO RUN TESTS LOCALLY + if: always() + run: | + export MODULES=${{ env.ALL_MODULES }} + export LOAD_MODULES=${{ env.ALL_MODULES_LOAD }} + export PR_NUM=${{ github.event.number }} + export VERSION=${{ github.event.pull_request.base.ref }} + export REVISION_PR=${{ github.event.pull_request.head.sha}} + export DINAR_REPO="itpp-labs/DINAR-fork" + export ODOO_EXTRA_ARG=--test-enable + bash DINAR/workflow-files/how-to-run-locally.sh ${{ secrets.GITHUB_TOKEN }} + - name: Download base images + run: | + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml pull + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --no-start + - name: Apply new-deps artifact + if: env.ARTIFACT != 'empty' + run: | + bash DINAR/workflow-files/load-docker-layers.sh new-deps/ + - name: Test all modules + run: | + export MODULES="${{ env.ALL_MODULES }}" + export LOAD_MODULES="${{ env.ALL_MODULES_LOAD }}" + export ODOO_EXTRA_ARG=--test-enable + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config + docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit diff --git a/.github/workflows/DINAR-readme.yml b/.github/workflows/DINAR-readme.yml new file mode 100644 index 00000000..268d786e --- /dev/null +++ b/.github/workflows/DINAR-readme.yml @@ -0,0 +1,64 @@ +# Copyright 2020 IT Projects Labs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: "DINAR: update repo's readme" + +on: + push: + paths: + - ".DINAR/build-date.txt" + - ".DINAR/config.yaml" + - ".github/workflows/DINAR-readme.yml" + - "*/__manifest__.py" +jobs: + repo_readme: + runs-on: ubuntu-latest + if: + "! endsWith(github.repository, '-store') && startsWith(github.repository, + 'itpp-labs/')" + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + path: REPO + # token is required to bypass pushing without checks/reviews + token: ${{ secrets.DINAR_TOKEN }} + - name: Checkout DINAR + uses: actions/checkout@v2 + with: + path: DINAR + repository: itpp-labs/DINAR-fork + ref: master + - uses: actions/setup-python@v1 + with: + python-version: "3.7.x" + - name: Install python tools + run: | + pip install plumbum pyyaml PyGithub + - name: Generate readme + run: | + REF=${GITHUB_BASE_REF:-${GITHUB_REF}} + BRANCH=${REF##*/} + cd REPO + python ../DINAR/workflow-files/generate-repo-readme.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} $BRANCH + - name: Commit updates + uses: stefanzweifel/git-auto-commit-action@v4 + with: + repository: REPO + commit_user_name: Mitchell Admin + commit_user_email: itpp-bot@users.noreply.github.com + # Commit may contain other updates, but in usual flow it's only module list. + commit_message: | + :construction_worker_man: Update module list + + Sent from Github Actions (see .github/workflows/DINAR-readme.yml ) diff --git a/.github/workflows/DINAR.yml b/.github/workflows/DINAR.yml new file mode 100644 index 00000000..197e46c3 --- /dev/null +++ b/.github/workflows/DINAR.yml @@ -0,0 +1,116 @@ +# Copyright 2020 IT Projects Labs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: "DINAR: Docker Image Building" + +on: + push: + paths: + - ".DINAR/**" + - ".github/workflows/DINAR.yml" + + # Cron works only for defaul branch. See https://github.com/itpp-labs/DINAR/issues/48 + schedule: + - cron: "5 5 * * 0" + +jobs: + check-secret: + runs-on: ubuntu-latest + steps: + - name: Check that DINAR_TOKEN is set + run: | + if [ -z "${{ secrets.DINAR_TOKEN }}" ] + then + echo "DINAR_TOKEN is not set" + exit 1 + fi + + check-branch: + runs-on: ubuntu-latest + steps: + - name: Check that this branch needs docker images + run: | + REF=${GITHUB_BASE_REF:-${GITHUB_REF}} + BRANCH=${REF##*/} + CHECK=$( echo "$BRANCH" | grep -E "^(master|[0-9]+\.[0-9]+)(-dev-.+)?$" || true) + if [ -z "$CHECK" ] + then + echo "This branch is not supposed to be a target of pull requests, so docker image is not needed." + echo "For information check https://github.com/itpp-labs/DINAR/issues/60" + exit 1 + fi + + rebuild-images: + runs-on: ubuntu-latest + needs: + - check-secret + - check-branch + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + path: REPO + - name: Checkout DINAR + uses: actions/checkout@v2 + with: + path: DINAR + repository: itpp-labs/DINAR-fork + ref: master + - uses: actions/setup-python@v1 + with: + python-version: "3.7.x" + - name: Prepare build folder + run: | + cp -rnT DINAR/embedded-files/ REPO/ + + - name: Configure Docker + run: | + bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN }} + + cat <<- EOF > REPO/.DINAR/image/.netrc + machine github.com + login $GITHUB_ACTOR + password ${{ secrets.DINAR_TOKEN }} + EOF + - name: Build ${{ env.IMAGE_ODOO_BASE }} + uses: elgohr/Publish-Docker-Github-Action@v4 + env: + LOCAL_CUSTOM_DIR: ./image + AGGREGATE: true + PIP_INSTALL_ODOO: false + CLEAN: false + COMPILE: false + with: + name: ${{ env.IMAGE_ODOO_BASE }} + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + buildargs: ODOO_VERSION,AGGREGATE,PIP_INSTALL_ODOO,CLEAN,COMPILE,LOCAL_CUSTOM_DIR + workdir: REPO/.DINAR/ + - name: Install python tools + run: | + pip install plumbum pyyaml + - name: Compute Modules Dependencies + run: | + # sets environment variables that available in next steps via $ {{ env.VAR_NAME }} notation + cd REPO + python ../DINAR/workflow-files/analyze-modules.py all + - name: Install Base Addons + run: | + export MODULES=$ALL_MODULES_DEPENDENCIES + + export DOODBA_WITHOUT_DEMO=all + bash DINAR/workflow-files/images-with-preinstalled-modules.sh $IMAGE_DB-nodemo $IMAGE_ODOO-nodemo + + export DOODBA_WITHOUT_DEMO=false + bash DINAR/workflow-files/images-with-preinstalled-modules.sh $IMAGE_DB $IMAGE_ODOO diff --git a/.github/workflows/repo2store.yml b/.github/workflows/repo2store.yml new file mode 100644 index 00000000..b5b39aab --- /dev/null +++ b/.github/workflows/repo2store.yml @@ -0,0 +1,34 @@ +name: "Push Updates to REPO-store" + +on: + push: + +jobs: + repo2store: + runs-on: ubuntu-latest + if: + "! endsWith(github.repository, '-store') && startsWith(github.repository, + 'itpp-labs/')" + steps: + - name: Checkout REPO + uses: actions/checkout@v2-beta + with: + fetch-depth: 0 + # custom token is not needed for fetching REPO, + # but the action makes some magic with authentication headers + # which are used on pushing to REPO-store + token: ${{ secrets.DINAR_TOKEN }} + - name: Fetch REPO-store + run: | + git remote add store https://x-access-token:${{ secrets.DINAR_TOKEN }}@github.com/${GITHUB_REPOSITORY}-store.git + git fetch store + - name: Merge and Push + run: | + set -x + git config --global user.email "itpp-bot@users.noreply.github.com" + git config --global user.name "Mitchell Admin" + BRANCH=${GITHUB_REF##*/} + REF=$(git rev-parse HEAD) + git checkout -b $BRANCH-store store/$BRANCH + git merge origin/$BRANCH $REF + git push store $BRANCH-store:$BRANCH diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 00000000..77a8749a --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,13 @@ +[settings] +; see https://github.com/psf/black +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +combine_as_imports=True +use_parentheses=True +line_length=88 +known_odoo=odoo +known_odoo_addons=odoo.addons +sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER +default_section=THIRDPARTY +known_third_party= diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..aa8c3eb3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,104 @@ +exclude: | + (?x) + # Files and folders generated by bots, to avoid loops + ^setup/|/static/description/index\.html$|/i18n/.*\.pot?$| + # 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$| + # You don't usually want a bot to modify your legal texts + (LICENSE.*|COPYING.*) +default_language_version: + python: python3 + node: "14.13.0" +repos: + - repo: https://github.com/myint/autoflake + rev: v1.6.1 + hooks: + - id: autoflake + args: ["-i", "--ignore-init-module-imports"] + - repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.4.1 + hooks: + - id: prettier + name: prettier + plugin-xml + additional_dependencies: + - "prettier@2.1.2" + - "@prettier/plugin-xml@0.12.0" + args: + - --plugin=@prettier/plugin-xml + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v7.32.0 + hooks: + - id: eslint + verbose: true + args: + - --color + - --fix + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + # exclude autogenerated files + exclude: /README\.rst$ + - id: end-of-file-fixer + # exclude autogenerated files + exclude: /README\.rst$ + - 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 + - id: check-symlinks + - id: check-xml + - id: mixed-line-ending + args: ["--fix=lf"] + - repo: https://github.com/OCA/pylint-odoo + rev: 7.0.2 + hooks: + - id: pylint_odoo + name: pylint with optional checks + args: + - --rcfile=.pylintrc + - --exit-zero + verbose: true + - id: pylint_odoo + args: + - --rcfile=.pylintrc-mandatory + - repo: https://github.com/asottile/pyupgrade + rev: v2.29.0 + hooks: + - id: pyupgrade + args: ["--keep-percent-format"] + - repo: https://github.com/acsone/setuptools-odoo + rev: 3.1.5 + hooks: + - id: setuptools-odoo-make-default + - id: setuptools-odoo-get-requirements + args: + - --output + - requirements.txt + - --header + - "# generated from manifests external_dependencies" + - repo: https://github.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + name: flake8 + additional_dependencies: ["flake8-bugbear==21.9.2"] + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + name: isort except __init__.py + args: + - --settings=. + exclude: /__init__\.py$ diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 00000000..d0e3a949 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,8 @@ +# Defaults for all prettier-supported languages. +# Prettier will complete this with settings from .editorconfig file. +bracketSpacing: true +printWidth: 88 +proseWrap: always +semi: true +trailingComma: "es5" +xmlWhitespaceSensitivity: "ignore" diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 00000000..742f0a76 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,86 @@ +[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=IT Projects Labs +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,MIT,Other OSI approved licence,OPL-1 +valid_odoo_versions=17.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, + assignment-from-none, + attribute-deprecated, + class-camelcase, + dangerous-default-value, + dangerous-view-replace-wo-priority, + duplicate-id-csv, + duplicate-key, + duplicate-xml-fields, + duplicate-xml-record-id, + eval-referenced, + eval-used, + incoherent-interpreter-exec-perm, + 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, + missing-manifest-dependency, + openerp-exception-warning, + pointless-statement, + pointless-string-statement, + print-used, + redundant-keyword-arg, + redundant-modulename-xml, + reimported, + relative-import, + return-in-init, + rst-syntax-error, + sql-injection, + too-few-format-args, + translation-field, + translation-required, + unreachable, + use-vim-comment, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + # messages that do not cause the lint step to fail + consider-merging-classes-inherited, + create-user-wo-reset-password, + dangerous-filter-wo-user, + deprecated-module, + file-not-used, + invalid-commit, + missing-newline-extrafiles, + missing-readme, + no-utf8-coding-comment, + odoo-addons-relative-import, + old-api7-method-defined, + redefined-builtin, + too-complex, + unnecessary-utf8-coding-comment + +[REPORTS] +msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} +output-format=colorized +reports=no diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory new file mode 100644 index 00000000..073ffd65 --- /dev/null +++ b/.pylintrc-mandatory @@ -0,0 +1,65 @@ +[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=IT Projects Labs +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,MIT,Other OSI approved licence,OPL-1 +valid_odoo_versions=17.0 + +[MESSAGES CONTROL] +disable=all + +enable=anomalous-backslash-in-string, + api-one-deprecated, + api-one-multi-together, + assignment-from-none, + attribute-deprecated, + class-camelcase, + dangerous-default-value, + dangerous-view-replace-wo-priority, + duplicate-id-csv, + duplicate-key, + duplicate-xml-fields, + duplicate-xml-record-id, + eval-referenced, + eval-used, + incoherent-interpreter-exec-perm, + 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, + missing-import-error, + missing-manifest-dependency, + openerp-exception-warning, + pointless-statement, + pointless-string-statement, + print-used, + redundant-keyword-arg, + redundant-modulename-xml, + reimported, + relative-import, + return-in-init, + rst-syntax-error, + sql-injection, + too-few-format-args, + translation-field, + translation-required, + unreachable, + use-vim-comment, + wrong-tabs-instead-of-spaces, + xml-syntax-error + +[REPORTS] +msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} +output-format=colorized +reports=no