diff --git a/.github/workflows/ci_ut_ext_base_workflow.yml b/.github/workflows/ci_ut_ext_base_workflow.yml index 96668a7..91d81f6 100644 --- a/.github/workflows/ci_ut_ext_base_workflow.yml +++ b/.github/workflows/ci_ut_ext_base_workflow.yml @@ -1,61 +1,84 @@ name: UT CI Run for Python Extension Base on: - push: - branches: [ dev, master, main, release/* ] - paths: - - 'azure-functions-extension-base/**' - pull_request: - branches: [ dev, master, main, release/* ] - paths: - - 'azure-functions-extension-base/**' + push: + branches: + - dev + - main + - release/* + paths: + - 'azure-functions-extension-base/**' + pull_request: + branches: + - dev + - main + - release/* + paths: + - 'azure-functions-extension-base/**' jobs: build: name: "Python Extension Base UT CI Run" runs-on: ubuntu-latest strategy: - fail-fast: false - matrix: - python-version: [ 3.8, 3.9, "3.10", "3.11" ] + fail-fast: false + matrix: + python-version: [ 3.8, 3.9, "3.10", "3.11" ] permissions: read-all steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - working-directory: azure-functions-extension-base - run: | - python -m pip install --upgrade pip - python -m pip install -U -e .[dev] - - - name: Run Unit Tests - working-directory: azure-functions-extension-base - env: - AzureWebJobsStorage: ${{ secrets.AzureWebJobsStorage }} - run: | - python -m pytest -q --instafail --cov=. --cov-report xml --cov-branch tests - - - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v3 - with: - file: ./azure-functions-extension-base/coverage.xml - flags: unittests - name: codecov - fail_ci_if_error: false - - - name: Notify dedicated teams channel - uses: jdcargile/ms-teams-notification@v1.4 - if: failure() - with: - github-token: ${{ github.token }} # this will use the runner's token. - ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - notification-summary: "Python Extension Base UT CI Failed for Python ${{ matrix.python-version }}" - notification-color: 17a2b8 - timezone: America/Denver - verbose-logging: false + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + working-directory: azure-functions-extension-base + run: | + python -m pip install --upgrade pip + python -m pip install -U -e .[dev] + + - name: Run Unit Tests + working-directory: azure-functions-extension-base + env: + AzureWebJobsStorage: ${{ secrets.AzureWebJobsStorage }} + run: | + python -m pytest -q --instafail --cov=. --cov-report xml --cov-branch tests + + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./azure-functions-extension-base/coverage.xml + flags: unittests + name: codecov + fail_ci_if_error: false + + send-notification: + runs-on: ubuntu-latest + needs: build + if: always() + steps: + - name: Notify dedicated teams channel on failure + if: ${{ always() && needs.build.result == 'failure' }} + uses: jdcargile/ms-teams-notification@v1.4 + with: + github-token: ${{ github.token }} + ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + notification-summary: "Python Extension Base UT CI Failed" + notification-color: FF0000 + timezone: America/Denver + verbose-logging: false + + - name: Notify dedicated teams channel on success + if: ${{ always() && needs.build.result == 'success' }} + uses: jdcargile/ms-teams-notification@v1.4 + with: + github-token: ${{ github.token }} + ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + notification-summary: "Python Extension Base UT CI Passed" + notification-color: 008000 + timezone: America/Denver + verbose-logging: false + \ No newline at end of file diff --git a/azure-functions-extension-base/azure/functions/extension/base/web.py b/azure-functions-extension-base/azure/functions/extension/base/web.py index 6ce87f2..d3b9ba3 100644 --- a/azure-functions-extension-base/azure/functions/extension/base/web.py +++ b/azure-functions-extension-base/azure/functions/extension/base/web.py @@ -1,5 +1,6 @@ from abc import abstractmethod from enum import Enum +import inspect from typing import Callable base_extension_module = __name__ @@ -53,7 +54,9 @@ def get_request_type(cls): @classmethod def check_type(cls, pytype: type) -> bool: - return cls._request_type is not None and issubclass(pytype, cls._request_type) + if pytype is not None and inspect.isclass(pytype): + return cls._request_type is not None and issubclass(pytype, cls._request_type) + return False class ResponseTrackerMeta(type): @@ -87,8 +90,10 @@ def get_response_type(cls, label): @classmethod def check_type(cls, pytype: type) -> bool: - return cls._response_types is not None and any(issubclass(pytype, response_type) - for response_type in cls._response_types.values()) + if pytype is not None and inspect.isclass(pytype): + return cls._response_types is not None and any(issubclass(pytype, response_type) + for response_type in cls._response_types.values()) + return False class WebApp(metaclass=ModuleTrackerMeta): @abstractmethod