Github Actions 4 years ago
parent
commit
73605014e1
  1. 1
      .eslintrc.yml
  2. 118
      .github/workflows/DINAR-PORT.yml
  3. 74
      .pre-commit-config.yaml
  4. 2
      .prettierrc.yml

1
.eslintrc.yml

@ -149,6 +149,7 @@ rules:
require-yield: warn require-yield: warn
sort-imports: warn sort-imports: warn
spaced-comment: [error, always] spaced-comment: [error, always]
space-before-function-paren: ["warn", {"anonymous": "always", "named": "never"}]
strict: [error, function] strict: [error, function]
use-isnan: error use-isnan: error
valid-jsdoc: valid-jsdoc:

118
.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 }}

74
.pre-commit-config.yaml

@ -13,39 +13,27 @@ exclude: |
default_language_version: default_language_version:
python: python3 python: python3
repos: repos:
- repo: https://github.com/humitos/mirrors-autoflake
rev: v1.3
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks: hooks:
- id: autoflake - id: autoflake
args:
[
"--exclude",
"__init__.py",
"--in-place",
"--remove-all-unused-imports",
"--remove-unused-variable",
]
args: ["-i", "--ignore-init-module-imports"]
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 19.10b0
rev: 20.8b1
hooks: hooks:
- id: black - id: black
- repo: https://github.com/prettier/prettier
rev: "1.19.1"
hooks:
- id: prettier
# TODO Avoid awebdeveloper/pre-commit-prettier if possible
# HACK https://github.com/prettier/prettier/issues/7407
- repo: https://github.com/awebdeveloper/pre-commit-prettier
rev: v0.0.1
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2
hooks: hooks:
- id: prettier - id: prettier
name: prettier xml plugin
name: prettier + plugin-xml
additional_dependencies: additional_dependencies:
- "prettier@1.19.1"
- "@prettier/plugin-xml@0.7.2"
files: \.xml$
- "prettier@2.1.2"
- "@prettier/plugin-xml@0.12.0"
args:
- --plugin=@prettier/plugin-xml
- repo: https://github.com/pre-commit/mirrors-eslint - repo: https://github.com/pre-commit/mirrors-eslint
rev: v6.8.0
rev: v7.8.1
hooks: hooks:
- id: eslint - id: eslint
verbose: true verbose: true
@ -62,15 +50,6 @@ repos:
# exclude autogenerated files # exclude autogenerated files
exclude: /README\.rst$ exclude: /README\.rst$
- id: debug-statements - id: debug-statements
- id: flake8
name: flake8 except __init__.py
exclude: /__init__\.py$
additional_dependencies: ["flake8-bugbear==19.8.0"]
- id: flake8
name: flake8 only __init__.py
args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py
files: /__init__\.py$
additional_dependencies: ["flake8-bugbear==19.8.0"]
- id: fix-encoding-pragma - id: fix-encoding-pragma
args: ["--remove"] args: ["--remove"]
- id: check-case-conflict - id: check-case-conflict
@ -81,29 +60,40 @@ repos:
- id: check-xml - id: check-xml
- id: mixed-line-ending - id: mixed-line-ending
args: ["--fix=lf"] args: ["--fix=lf"]
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.3.1
- repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.3
hooks: hooks:
- id: pylint - id: pylint
name: pylint with optional checks name: pylint with optional checks
args: ["--rcfile=.pylintrc", "--exit-zero"] args: ["--rcfile=.pylintrc", "--exit-zero"]
verbose: true verbose: true
additional_dependencies: ["pylint-odoo==3.1.0"]
additional_dependencies: &pylint_deps
- pylint-odoo==3.5.0
- id: pylint - id: pylint
name: pylint with mandatory checks name: pylint with mandatory checks
args: ["--rcfile=.pylintrc-mandatory"] args: ["--rcfile=.pylintrc-mandatory"]
additional_dependencies: ["pylint-odoo==3.1.0"]
additional_dependencies: *pylint_deps
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v1.26.2 rev: v1.26.2
hooks: hooks:
- id: pyupgrade - id: pyupgrade
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.4
- repo: https://gitlab.com/PyCQA/flake8
rev: 3.8.3
hooks: hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
- id: flake8
name: flake8 except __init__.py
exclude: /__init__\.py$
additional_dependencies: ["flake8-bugbear==20.1.4"]
- id: flake8
name: flake8 only __init__.py
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/isort
rev: 5.5.1
hooks: hooks:
- id: isort - id: isort
name: isort except __init__.py name: isort except __init__.py
args:
- --settings=.
exclude: /__init__\.py$ exclude: /__init__\.py$

2
.prettierrc.yml

@ -5,4 +5,4 @@ printWidth: 88
proseWrap: always proseWrap: always
semi: true semi: true
trailingComma: "es5" trailingComma: "es5"
xmlWhitespaceSensitivity: "ignore"
xmlWhitespaceSensitivity: "strict"
Loading…
Cancel
Save