Change CI to GitHub actions

Use copier template from oca/oca-addons-repo-template

Apply linting
This commit is contained in:
Yannick Payot
2023-05-24 19:44:34 +02:00
parent 1731912ba4
commit 5d2779d03b
77 changed files with 1698 additions and 865 deletions
@@ -1,50 +1,51 @@
# Copyright 2016-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import re
import os
import re
from odoo import models, api
from odoo.addons.cloud_platform.models.cloud_platform import FilestoreKind
from odoo.addons.cloud_platform.models.cloud_platform import PlatformConfig
from odoo import api, models
from odoo.addons.cloud_platform.models.cloud_platform import (
FilestoreKind,
PlatformConfig,
)
S3_STORE_KIND = FilestoreKind('s3', 'remote')
S3_STORE_KIND = FilestoreKind("s3", "remote")
class CloudPlatform(models.AbstractModel):
_inherit = 'cloud.platform'
_inherit = "cloud.platform"
@api.model
def _filestore_kinds(self):
kinds = super(CloudPlatform, self)._filestore_kinds()
kinds['s3'] = S3_STORE_KIND
kinds["s3"] = S3_STORE_KIND
return kinds
@api.model
def _platform_kinds(self):
kinds = super(CloudPlatform, self)._platform_kinds()
kinds.append('exoscale')
kinds.append("exoscale")
return kinds
@api.model
def _config_by_server_env_for_exoscale(self):
fs_kinds = self._filestore_kinds()
configs = {
'prod': PlatformConfig(filestore=fs_kinds['s3']),
'integration': PlatformConfig(filestore=fs_kinds['s3']),
'labs': PlatformConfig(filestore=fs_kinds['s3']),
'test': PlatformConfig(filestore=fs_kinds['db']),
'dev': PlatformConfig(filestore=fs_kinds['db']),
"prod": PlatformConfig(filestore=fs_kinds["s3"]),
"integration": PlatformConfig(filestore=fs_kinds["s3"]),
"labs": PlatformConfig(filestore=fs_kinds["s3"]),
"test": PlatformConfig(filestore=fs_kinds["db"]),
"dev": PlatformConfig(filestore=fs_kinds["db"]),
}
return configs
@api.model
def _check_filestore(self, environment_name):
params = self.env['ir.config_parameter'].sudo()
use_s3 = (params.get_param('ir_attachment.location') ==
S3_STORE_KIND.name)
if environment_name in ('prod', 'integration'):
params = self.env["ir.config_parameter"].sudo()
use_s3 = params.get_param("ir_attachment.location") == S3_STORE_KIND.name
if environment_name in ("prod", "integration"):
# Labs instances use s3 by default, but we don't want
# to enforce it in case we want to test something with a different
# storage. At your own risks!
@@ -55,16 +56,16 @@ class CloudPlatform(models.AbstractModel):
"automatically."
)
if use_s3:
assert os.environ.get('AWS_ACCESS_KEY_ID'), (
assert os.environ.get("AWS_ACCESS_KEY_ID"), (
"AWS_ACCESS_KEY_ID environment variable is required when "
"ir_attachment.location is 's3'."
)
assert os.environ.get('AWS_SECRET_ACCESS_KEY'), (
assert os.environ.get("AWS_SECRET_ACCESS_KEY"), (
"AWS_SECRET_ACCESS_KEY environment variable is required when "
"ir_attachment.location is 's3'."
)
bucket_name = os.environ.get('AWS_BUCKETNAME', '')
if environment_name in ('prod', 'integration', 'labs'):
bucket_name = os.environ.get("AWS_BUCKETNAME", "")
if environment_name in ("prod", "integration", "labs"):
assert bucket_name, (
"AWS_BUCKETNAME environment variable is required when "
"ir_attachment.location is 's3'.\n"
@@ -80,10 +81,10 @@ class CloudPlatform(models.AbstractModel):
#
# Use AWS_BUCKETNAME_UNSTRUCTURED to by-pass check on bucket name
# structure
if os.environ.get('AWS_BUCKETNAME_UNSTRUCTURED'):
if os.environ.get("AWS_BUCKETNAME_UNSTRUCTURED"):
return
prod_bucket = bool(re.match(r'[a-z-0-9]+-odoo-prod', bucket_name))
if environment_name == 'prod':
prod_bucket = bool(re.match(r"[a-z-0-9]+-odoo-prod", bucket_name))
if environment_name == "prod":
assert prod_bucket, (
"AWS_BUCKETNAME should match '<client>-odoo-prod', "
"we got: '%s'" % (bucket_name,)
@@ -96,9 +97,9 @@ class CloudPlatform(models.AbstractModel):
"we got: '%s'" % (bucket_name,)
)
elif environment_name == 'test':
elif environment_name == "test":
# store in DB so we don't have files local to the host
assert params.get_param('ir_attachment.location') == 'db', (
assert params.get_param("ir_attachment.location") == "db", (
"In test instances, files must be stored in the database with "
"'ir_attachment.location' set to 'db'. This is "
"automatically set by the function 'install()'."
@@ -106,4 +107,4 @@ class CloudPlatform(models.AbstractModel):
@api.model
def install(self):
self._install('exoscale')
self._install("exoscale")