Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ jobs:
name: Run Test
command: docker-compose run --rm odoo run_pytest.sh

- run:
name: Codacy Coverage
command: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l python -r .log/coverage.xml

- store_test_results:
path: .log

Expand All @@ -46,9 +42,9 @@ jobs:
curl -L $NWS_BIN_LOCATION > ./nws
chmod +x ./nws
- run:
name: Set tag
name: Set tag on isidor-odoo
command: |
./nws circleci create-tag -t odoo-base
./nws circleci create-tag -t isidor-odoo

workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion .docker_files/main/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# © 2023 - today Numigi
# © 2024 - today Numigi
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
29 changes: 14 additions & 15 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# © 2019 - today Numigi
# © 2024 - today Numigi
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
'name': 'Main Module',
'version': '1.0.0',
'author': 'Numigi',
'maintainer': 'Numigi',
'website': 'https://www.numigi.com',
'license': 'LGPL-3',
'category': 'Other',
'summary': 'Install all addons required for testing.',
'depends': [
'github_event',
'github_event_webhook',
'github_pull_request',
'github_pull_request_project',
"name": "Main Module",
"version": "1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://www.numigi.com",
"license": "LGPL-3",
"category": "Other",
"summary": "Install all addons required for testing.",
"depends": [
"base",
"github_event",
"github_pull_request",
],
'installable': True,
"installable": True,
}
2 changes: 1 addition & 1 deletion .docker_files/odoo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test_report_directory = False
translate_modules = ['all']
unaccent = False
without_demo = False
workers = 2
workers = 0
xmlrpc = True
xmlrpc_interface =
xmlrpc_port = 8069
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
max-line-length = 88
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)
ignore = E203,E501,W503,F821
per-file-ignores=
__init__.py:F401
36 changes: 36 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: pre-commit

on:
pull_request:
branches:
- "16.0"
push:
branches:
- "16.0"

jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Get python version
run: echo "PY=$(python -VV | 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') }}
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always
- name: Check that all files generated by pre-commit are in git
run: |
newfiles="$(git ls-files --others --exclude-from=.gitignore)"
if [ "$newfiles" != "" ] ; then
echo "Please check-in the following files:"
echo "$newfiles"
exit 1
fi
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
.log
/.idea/
venv
log
/.idea
__pycache__
__pycache__/
*.pyc
.venv
Pipfile
docker-compose.override.yml
.DS_STORE
.pytest_cache
.vscode/
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
# 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$|
# Don't bother non-technical authors with formatting issues in docs
readme/.*\.(rst|md)$|
# Ignore build and dist directories in addons
/build/|/dist/|
# 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/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"]
17 changes: 6 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM quay.io/numigi/odoo-public:14.latest
MAINTAINER numigi <contact@numigi.com>
FROM quay.io/numigi/odoo-public:16.latest
LABEL maintainer="contact@numigi.com"

USER root

COPY .docker_files/requirements.txt .
RUN pip3 install -r requirements.txt

# Variable used for fetching private git repositories.
ARG GIT_TOKEN
COPY .docker_files/test-requirements.txt .
RUN pip3 install -r test-requirements.txt

ENV THIRD_PARTY_ADDONS /mnt/third-party-addons
RUN mkdir -p "${THIRD_PARTY_ADDONS}" && chown -R odoo "${THIRD_PARTY_ADDONS}"
Expand All @@ -16,10 +13,8 @@ RUN gitoo install-all --conf_file /gitoo.yml --destination "${THIRD_PARTY_ADDONS

USER odoo

COPY ./github_event /mnt/extra-addons/github_event
COPY ./github_event_webhook /mnt/extra-addons/github_event_webhook
COPY ./github_pull_request /mnt/extra-addons/github_pull_request
COPY ./github_pull_request_project /mnt/extra-addons/github_pull_request_project
COPY github_event /mnt/extra-addons/github_event
COPY github_pull_request /mnt/extra-addons/github_pull_request

COPY .docker_files/main /mnt/extra-addons/main
COPY .docker_files/odoo.conf /etc/odoo
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# odoo-git-addons

git and github related odoo modules
12 changes: 5 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ services:
build:
context: .
dockerfile: Dockerfile
args:
- GIT_TOKEN=${GIT_TOKEN}
volumes:
- odoo-web-data:/var/lib/odoo
- odoo16-web-data:/var/lib/odoo
- ./.log:/var/log/odoo
ports:
- "8069:8069"
Expand All @@ -18,16 +16,16 @@ services:
environment:
- LOG_ODOO=/var/log/odoo
db:
image: quay.io/numigi/postgres-odoo:13.1.6
image: postgres:16.0
environment:
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata
- odoo16-db-data:/var/lib/postgresql/data/pgdata
expose:
- 5432

volumes:
odoo-web-data:
odoo-db-data:
odoo16-web-data:
odoo16-db-data:
2 changes: 1 addition & 1 deletion github_event/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# © 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import models
32 changes: 16 additions & 16 deletions github_event/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# © 2023 - Today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# Copyright 2023 - Today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
'name': 'Github Events',
'version': "14.0.1.0.0",
'author': 'Numigi',
'maintainer': 'Numigi',
'website': 'https://bit.ly/numigi-com',
'license': 'LGPL-3',
'category': 'Connector',
'summary': 'Define what is a github event as an odoo object',
'depends': [
'base_sparse_field',
"name": "Github Events",
"version": "16.0.1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "LGPL-3",
"category": "Connector",
"summary": "Define what is a github event as an odoo object",
"depends": [
"base_sparse_field",
],
'data': [
'security/ir.model.access.csv',
'views/github_event.xml',
'views/menu.xml',
"data": [
"security/ir.model.access.csv",
"views/github_event.xml",
"views/menu.xml",
],
'installable': True,
"installable": True,
}
2 changes: 1 addition & 1 deletion github_event/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-04 19:28+0000\n"
"PO-Revision-Date: 2019-12-04 14:30-0500\n"
Expand Down
2 changes: 1 addition & 1 deletion github_event/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# © 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import (
Expand Down
25 changes: 12 additions & 13 deletions github_event/models/github_event.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# © 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import json
Expand All @@ -11,35 +11,34 @@ class GithubEvent(models.Model):

_name = "github.event"
_description = "Github Event"
_order = 'id desc'
_order = "id desc"

action = fields.Char()
payload = fields.Text()
payload_serialized = Serialized(
compute='_compute_payload_serialized'
)
payload_serialized = Serialized(compute="_compute_payload_serialized")

@api.depends('payload')
@api.depends("payload")
def _compute_payload_serialized(self):
events_with_payloads = self.filtered(lambda e: e.payload)
for event in events_with_payloads:
event.payload_serialized = json.loads(event.payload)

action = fields.Char()

def _get_value_from_payload(self, path):
"""Get a value from the payload.

:param path: a doted notation of the path to access the value.
:return: the value contained at the given path.
"""
section = self.payload_serialized
keys = path.split('.')
keys = path.split(".")

for key in keys[:-1]:
if not isinstance(section, dict) or key not in section:
raise ValidationError(_(
"The payload does not contain a value at the path {}."
).format(path))
raise ValidationError(
_("The payload does not contain a value at the path {}.").format(
path
)
)

section = section[key]

Expand All @@ -51,4 +50,4 @@ def process(self):
This method is intended to be inherited by other modules
to add extra behavior when processing a github event.
"""
self.action = self._get_value_from_payload('action')
self.action = self._get_value_from_payload("action")
Binary file modified github_event/static/description/event_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified github_event/static/description/event_form_process_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified github_event/static/description/event_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified github_event/static/description/menu_technical_events.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion github_event/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# © 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
11 changes: 5 additions & 6 deletions github_event/tests/common.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# © 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import os
from odoo.tests import common


class GithubEventCase(common.SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.event_1 = cls.env['github.event'].create({})
cls.event_2 = cls.env['github.event'].create({})
cls.event_1 = cls.env["github.event"].create({})
cls.event_2 = cls.env["github.event"].create({})

def _read_payload(self, filename):
test_folder = os.path.dirname(os.path.realpath(__file__))
payload_file_path = os.path.join(test_folder, 'data', filename)
with open(payload_file_path, 'r') as file:
payload_file_path = os.path.join(test_folder, "data", filename)
with open(payload_file_path, "r") as file:
return file.read()
Loading