From 7fc8520f5802ba6ec0e371577fdb4158f86fe317 Mon Sep 17 00:00:00 2001 From: Omar Aljarrah <50204418+OmarAlJarrah@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:23:00 +0300 Subject: [PATCH] feat(github): add `contrib-lint.yaml` workflow (#299) PR: https://github.com/ExpediaGroup/expediagroup-python-sdk/pull/299 --- .../{quality.yaml => code-quality.yaml} | 2 +- .github/workflows/contribution-lint.yaml | 41 +++++++++++++++++++ .github/workflows/validate-test-coverage.yaml | 1 + commitlint.config.js | 1 + expediagroup/sdk/core/constant/log.py | 12 ++---- expediagroup/sdk/docsgen/render.py | 1 + .../sdk/generator/client/visitors/models.py | 1 + release/fraudPreventionV2/src/client.py | 16 ++------ release/fraudPreventionV2/src/model.py | 15 +++++++ validate_test_coverage.py | 12 ++---- 10 files changed, 73 insertions(+), 29 deletions(-) rename .github/workflows/{quality.yaml => code-quality.yaml} (97%) create mode 100644 .github/workflows/contribution-lint.yaml create mode 100644 commitlint.config.js diff --git a/.github/workflows/quality.yaml b/.github/workflows/code-quality.yaml similarity index 97% rename from .github/workflows/quality.yaml rename to .github/workflows/code-quality.yaml index b96953dc..4bd8ef92 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/code-quality.yaml @@ -11,7 +11,7 @@ # 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: Quality Checks +name: Code Quality Checks on: push jobs: flake8-lint: diff --git a/.github/workflows/contribution-lint.yaml b/.github/workflows/contribution-lint.yaml new file mode 100644 index 00000000..a12b1c4a --- /dev/null +++ b/.github/workflows/contribution-lint.yaml @@ -0,0 +1,41 @@ +# Copyright 2022 Expedia, Inc. +# +# 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: Contribution Quality Checks +on: + pull_request: + types: + - opened + - edited + - reopened + - synchronize + - ready_for_review + - review_requested + - auto_merge_enabled + push: + branches: '*' +jobs: + contribution-lint: + name: Contribution Details Validation + runs-on: ubuntu-latest + steps: + - name: Check out source repository + uses: actions/checkout@v4 + - name: Install Dependencies + run: npm install @commitlint/config-conventional + - name: Run Pull Request Title Validation + uses: JulienKode/pull-request-name-linter-action@v0.5.0 + - name: Run Latest Commit Message Validation + uses: wagoid/commitlint-github-action@v5 + with: + commitDepth: 1 diff --git a/.github/workflows/validate-test-coverage.yaml b/.github/workflows/validate-test-coverage.yaml index 67a15837..6f2bb61c 100644 --- a/.github/workflows/validate-test-coverage.yaml +++ b/.github/workflows/validate-test-coverage.yaml @@ -16,6 +16,7 @@ name: Test Coverage Validation on: push jobs: validate-coverage: + name: Test Coverage Validation runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 00000000..3347cb96 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1 @@ +module.exports = {extends: ['@commitlint/config-conventional']}; diff --git a/expediagroup/sdk/core/constant/log.py b/expediagroup/sdk/core/constant/log.py index 968ef765..6677accd 100644 --- a/expediagroup/sdk/core/constant/log.py +++ b/expediagroup/sdk/core/constant/log.py @@ -25,19 +25,15 @@ NEW_TOKEN_EXPIRATION_TEMPLATE: str = "New token expires in {0} seconds" -HTTP_HEADERS_LOG_MESSAGE_TEMPLATE: str = dedent( - """\tHeaders: +HTTP_HEADERS_LOG_MESSAGE_TEMPLATE: str = dedent("""\tHeaders: \t--- BEGIN --- {0} \t--- END --- - """ -) + """) -HTTP_BODY_LOG_MESSAGE_TEMPLATE: str = dedent( - """ +HTTP_BODY_LOG_MESSAGE_TEMPLATE: str = dedent(""" \tBody: \t--- BEGIN --- {0} \t--- END --- - """ -) + """) diff --git a/expediagroup/sdk/docsgen/render.py b/expediagroup/sdk/docsgen/render.py index 0e550be5..be6b5dcb 100644 --- a/expediagroup/sdk/docsgen/render.py +++ b/expediagroup/sdk/docsgen/render.py @@ -36,6 +36,7 @@ class MarkdownRenderer: resolvers (dict[str, Any]): A dictionary of resolver functions to assist in rendering. master_filename (str): The filename for the master documentation file. """ + master: Master modules: list[Module] environment: Environment diff --git a/expediagroup/sdk/generator/client/visitors/models.py b/expediagroup/sdk/generator/client/visitors/models.py index 419aead3..15dbf9e9 100644 --- a/expediagroup/sdk/generator/client/visitors/models.py +++ b/expediagroup/sdk/generator/client/visitors/models.py @@ -45,6 +45,7 @@ class Alias: order(int): A value used in sorting alias position among other aliases, depending on its position in the inheritance hierarchy. """ + parent_classname: str children_classnames: list[str] order: int = 1 diff --git a/release/fraudPreventionV2/src/client.py b/release/fraudPreventionV2/src/client.py index 80aefd12..6d5fe2b2 100644 --- a/release/fraudPreventionV2/src/client.py +++ b/release/fraudPreventionV2/src/client.py @@ -84,9 +84,7 @@ def __init__(self, client_config: ClientConfig): self.__user_agent = f"{sdk_metadata} (Python {python_version}; {os_name} {os_version})" - def screen_account( - self, transaction_id: UUID = uuid4(), body: AccountScreenRequest = None - ) -> Union[ + def screen_account(self, transaction_id: UUID = uuid4(), body: AccountScreenRequest = None) -> Union[ AccountScreenResponse, AccountTakeoverBadRequestError, AccountTakeoverUnauthorizedError, @@ -149,9 +147,7 @@ def screen_account( error_responses=error_responses, ) - def notify_with_account_update( - self, transaction_id: UUID = uuid4(), body: AccountUpdateRequest = None - ) -> Union[ + def notify_with_account_update(self, transaction_id: UUID = uuid4(), body: AccountUpdateRequest = None) -> Union[ AccountUpdateResponse, AccountTakeoverBadRequestError, AccountTakeoverUnauthorizedError, @@ -215,9 +211,7 @@ def notify_with_account_update( error_responses=error_responses, ) - def screen_order( - self, transaction_id: UUID = uuid4(), body: OrderPurchaseScreenRequest = None - ) -> Union[ + def screen_order(self, transaction_id: UUID = uuid4(), body: OrderPurchaseScreenRequest = None) -> Union[ OrderPurchaseScreenResponse, BadRequestError, UnauthorizedError, @@ -279,9 +273,7 @@ def screen_order( error_responses=error_responses, ) - def notify_with_order_update( - self, transaction_id: UUID = uuid4(), body: OrderPurchaseUpdateRequest = None - ) -> Union[ + def notify_with_order_update(self, transaction_id: UUID = uuid4(), body: OrderPurchaseUpdateRequest = None) -> Union[ OrderPurchaseUpdateResponse, BadRequestError, UnauthorizedError, diff --git a/release/fraudPreventionV2/src/model.py b/release/fraudPreventionV2/src/model.py index 2c4025b1..881e1df0 100644 --- a/release/fraudPreventionV2/src/model.py +++ b/release/fraudPreventionV2/src/model.py @@ -2793,76 +2793,91 @@ class OrderPurchaseScreenRequest( class ExpediaGroupForbiddenErrorException(ExpediaGroupApiException): r"""Exception wrapping a ForbiddenError object.""" + pass class ExpediaGroupOrderPurchaseUpdateNotFoundErrorException(ExpediaGroupApiException): r"""Exception wrapping a OrderPurchaseUpdateNotFoundError object.""" + pass class ExpediaGroupGatewayTimeoutErrorException(ExpediaGroupApiException): r"""Exception wrapping a GatewayTimeoutError object.""" + pass class ExpediaGroupBadRequestErrorException(ExpediaGroupApiException): r"""Exception wrapping a BadRequestError object.""" + pass class ExpediaGroupAccountTakeoverUnauthorizedErrorException(ExpediaGroupApiException): r"""Exception wrapping a AccountTakeoverUnauthorizedError object.""" + pass class ExpediaGroupAccountUpdateNotFoundErrorException(ExpediaGroupApiException): r"""Exception wrapping a AccountUpdateNotFoundError object.""" + pass class ExpediaGroupTooManyRequestsErrorException(ExpediaGroupApiException): r"""Exception wrapping a TooManyRequestsError object.""" + pass class ExpediaGroupServiceUnavailableErrorException(ExpediaGroupApiException): r"""Exception wrapping a ServiceUnavailableError object.""" + pass class ExpediaGroupUnauthorizedErrorException(ExpediaGroupApiException): r"""Exception wrapping a UnauthorizedError object.""" + pass class ExpediaGroupAccountTakeoverBadRequestErrorException(ExpediaGroupApiException): r"""Exception wrapping a AccountTakeoverBadRequestError object.""" + pass class ExpediaGroupNotFoundErrorException(ExpediaGroupApiException): r"""Exception wrapping a NotFoundError object.""" + pass class ExpediaGroupRetryableOrderPurchaseScreenFailureException(ExpediaGroupApiException): r"""Exception wrapping a RetryableOrderPurchaseScreenFailure object.""" + pass class ExpediaGroupRetryableOrderPurchaseUpdateFailureException(ExpediaGroupApiException): r"""Exception wrapping a RetryableOrderPurchaseUpdateFailure object.""" + pass class ExpediaGroupBadGatewayErrorException(ExpediaGroupApiException): r"""Exception wrapping a BadGatewayError object.""" + pass class ExpediaGroupInternalServerErrorException(ExpediaGroupApiException): r"""Exception wrapping a InternalServerError object.""" + pass diff --git a/validate_test_coverage.py b/validate_test_coverage.py index 991b704f..faa646ae 100644 --- a/validate_test_coverage.py +++ b/validate_test_coverage.py @@ -19,23 +19,19 @@ from prettytable import PrettyTable MINIMUM_REQUIRED_COVERAGE_PERCENTAGE: int = 90 -FAILURE_MESSAGE_TEMPLATE: str = dedent( - """ +FAILURE_MESSAGE_TEMPLATE: str = dedent(""" > Coverage Validation Failed! >> Minimum Required Total Coverage Percentage: {0}% >> Current Total Coverage Percentage: {1}% >>> Full Coverage Report: {2} - """ -) -SUCCESS_MESSAGE_TEMPLATE: str = dedent( - """ + """) +SUCCESS_MESSAGE_TEMPLATE: str = dedent(""" > Coverage Validation Succeed! >> Current Total Coverage Percentage: {0}% >>> Full Coverage Report: {1} - """ -) + """) def validate_test_coverage(report: dict):