diff --git a/.eslintrc.yml b/.eslintrc.yml index 0b81ecd..28cd197 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -149,6 +149,7 @@ rules: 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: diff --git a/.github/workflows/DINAR-PORT.yml b/.github/workflows/DINAR-PORT.yml new file mode 100644 index 0000000..8a0f9b7 --- /dev/null +++ b/.github/workflows/DINAR-PORT.yml @@ -0,0 +1,118 @@ +# 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 a message + 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@v2 + with: + python-version: "3.7.x" + - 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: 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: Analyze request + run: | + # sets environment variables that available in next steps via $ {{ env.PORT_... }} notation + python DINAR/workflow-files/analyze_port_trigger.py "${{ github.event.issue.title }}" + - 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 + + # 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 }}/ir_rule_protected + + > Made via .github/workflows/DINAR-PORT.yml" + fi + 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: | + 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 + 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 + 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 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6cf0839..1df1561 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: | (?x) # Files and folders generated by bots, to avoid loops - ^setup/|/static/description/index\.html$| + ^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) @@ -23,12 +23,13 @@ repos: rev: 20.8b1 hooks: - id: black - - repo: https://github.com/prettier/prettier - rev: 2.1.2 + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.1.2 hooks: - id: prettier name: prettier + plugin-xml additional_dependencies: + - "prettier@2.1.2" - "@prettier/plugin-xml@0.12.0" args: - --plugin=@prettier/plugin-xml @@ -41,14 +42,14 @@ repos: - --color - --fix - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + rev: v2.4.0 hooks: - id: trailing-whitespace # exclude autogenerated files - exclude: /README\.rst$|\.pot?$ + exclude: /README\.rst$ - id: end-of-file-fixer # exclude autogenerated files - exclude: /README\.rst$|\.pot?$ + exclude: /README\.rst$ - id: debug-statements - id: fix-encoding-pragma args: ["--remove"] @@ -56,28 +57,37 @@ repos: - id: check-docstring-first - id: check-executables-have-shebangs - id: check-merge-conflict - # exclude files where underlines are not distinguishable from merge conflicts - exclude: /README\.rst$|^docs/.*\.rst$ - id: check-symlinks - id: check-xml - id: mixed-line-ending args: ["--fix=lf"] + - repo: https://github.com/PyCQA/pylint + rev: pylint-2.5.3 + hooks: + - id: pylint + name: pylint with optional checks + args: ["--rcfile=.pylintrc", "--exit-zero"] + verbose: true + additional_dependencies: &pylint_deps + - pylint-odoo==3.5.0 + - id: pylint + name: pylint with mandatory checks + args: ["--rcfile=.pylintrc-mandatory"] + additional_dependencies: *pylint_deps - repo: https://github.com/asottile/pyupgrade - rev: v2.7.2 + rev: v1.26.2 hooks: - id: pyupgrade - - repo: https://github.com/PyCQA/isort - rev: 5.5.1 - hooks: - - id: isort - name: isort except __init__.py - args: - - --settings=. - exclude: /__init__\.py$ - repo: https://github.com/acsone/setuptools-odoo - rev: 2.5.10 + rev: 2.6.0 hooks: - id: setuptools-odoo-make-default + - id: setuptools-odoo-get-requirements + args: + - --output + - requirements.txt + - --header + - "# generated from manifests external_dependencies" - repo: https://gitlab.com/PyCQA/flake8 rev: 3.8.3 hooks: @@ -90,19 +100,11 @@ repos: args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py files: /__init__\.py$ additional_dependencies: ["flake8-bugbear==20.1.4"] - - repo: https://github.com/PyCQA/pylint - rev: pylint-2.5.3 + - repo: https://github.com/PyCQA/isort + rev: 5.5.1 hooks: - - id: pylint - name: pylint with optional checks - args: - - --rcfile=.pylintrc - - --exit-zero - verbose: true - additional_dependencies: &pylint_deps - - pylint-odoo==3.5.0 - - id: pylint - name: pylint with mandatory checks + - id: isort + name: isort except __init__.py args: - - --rcfile=.pylintrc-mandatory - additional_dependencies: *pylint_deps + - --settings=. + exclude: /__init__\.py$ diff --git a/.prettierrc.yml b/.prettierrc.yml index fc5f3a7..5b6d4b3 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -5,4 +5,4 @@ printWidth: 88 proseWrap: always semi: true trailingComma: "es5" -xmlWhitespaceSensitivity: "ignore" +xmlWhitespaceSensitivity: "strict"