Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable github workflows for main branch #17

Merged
merged 8 commits into from
Nov 8, 2023
Merged
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
4 changes: 2 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
volumes:
- app-db-data:/var/lib/postgresql/data/pgdata
env_file:
- .env
- ../.env
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
deploy:
Expand All @@ -74,7 +74,7 @@ services:
depends_on:
- db
env_file:
- .env
- ../.env
environment:
- SERVER_NAME=${DOMAIN?Variable not set}
- SERVER_HOST=https://${DOMAIN?Variable not set}
Expand Down
File renamed without changes.
10 changes: 4 additions & 6 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Python Linting

on:
pull_request:
branches:
- develop
- "release/**"
pull_request_target:
types: [opened, synchronize, reopened]
push:
branches:
- develop
- main
- "release/**"

jobs:
Expand Down Expand Up @@ -40,9 +39,8 @@ jobs:
types-pyyaml==6.0.12.10
types-retry==0.9.9.4
- name: Run linters
uses: wearerequired/lint-action@v1
uses: wearerequired/lint-action@v2
with:
github_token: ${{ secrets.github_token }}
# Enable linters
black: true
flake8: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/spell-check.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: "Check spelling"
on: # rebuild any PRs and main branch changes
pull_request:
branches:
- develop
pull_request_target:
types: [opened, synchronize, reopened]
push:
branches:
- develop
- main
jobs:
spellcheck: # run the action
runs-on: ubuntu-latest
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Unit Tests

on:
pull_request:
branches:
- develop
pull_request_target:
types: [opened, synchronize, reopened]
push:
branches:
- develop
- main

jobs:
backend-tests:
Expand Down Expand Up @@ -39,15 +39,15 @@ jobs:
- name: Load .env file to job environent
uses: cardinalby/export-env-action@v2
with:
envFile: '.env'
envFile: ".env"

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: "3.10"
cache: poetry
cache-dependency-path: poetry.lock
- name: Set Poetry environment
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Fetch yaml tests and runner
run: |
source $(poetry env info --path)/bin/activate
./scripts/fetch_sdk_yaml_tests_and_runner.sh
./test_collections/sdk_tests/fetch_sdk_tests_and_runner.sh
env:
SERVER_NAME: localhost
SERVER_HOST: http://localhost
Expand All @@ -76,4 +76,4 @@ jobs:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
SERVER_NAME: localhost
SERVER_HOST: http://localhost
SERVER_HOST: http://localhost
4 changes: 3 additions & 1 deletion app/chip_tool/chip_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@

# Websocket runner
BACKEND_ROOT = Path(__file__).parents[2]
TEST_COLLECTION_SDK_CHECKOUT_PATH = BACKEND_ROOT / Path("test_collections/sdk_tests/sdk_checkout/")
TEST_COLLECTION_SDK_CHECKOUT_PATH = BACKEND_ROOT / Path(
"test_collections/sdk_tests/sdk_checkout/"
)
YAML_TESTS_PATH_BASE = TEST_COLLECTION_SDK_CHECKOUT_PATH / Path("yaml_tests/")
YAML_TESTS_PATH = YAML_TESTS_PATH_BASE / Path("yaml/sdk")
XML_SPEC_DEFINITION_PATH = TEST_COLLECTION_SDK_CHECKOUT_PATH / Path(
Expand Down
7 changes: 5 additions & 2 deletions app/test_engine/models/manual_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ def handle_uploaded_file(self, file: UploadFile) -> None:
try:
logger.info(line.decode("utf-8").strip())
except UnicodeDecodeError:
logger.warning("WARNING: The following line contained invalid UTF-8. Some content was replaced with: �")
logger.info(line.decode("utf-8", errors='replace').strip())
logger.warning(
"WARNING: The following line contained invalid UTF-8."
" Some content was replaced with: �"
)
logger.info(line.decode("utf-8", errors="replace").strip())
logger.info("---- End of Manual Log ----")


Expand Down
1 change: 1 addition & 0 deletions app/tests/yaml_tests/test_sdk_yaml_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
VERSION_FILE_FILENAME = ".version"
VERSION_FILE_PATH = Path("/app/backend/test_collections/sdk_tests/sdk_checkout/")


@pytest.fixture
def yaml_collection() -> YamlCollectionDeclaration:
test_sdk_yaml_path = Path(__file__).parent / "test_yamls"
Expand Down
6 changes: 4 additions & 2 deletions app/tests/yaml_tests/test_test_declarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def test_yaml_suite_declaration() -> None:
version = "SomeVersionStr"

with mock.patch(
"test_collections.sdk_tests.support.yaml_tests.models.test_suite.YamlTestSuite.class_factory"
"test_collections.sdk_tests.support.yaml_tests.models."
"test_suite.YamlTestSuite.class_factory"
) as class_factory, mock.patch(
"app.test_engine.models.test_declarations.TestSuiteDeclaration.__init__"
) as declaration_init:
Expand All @@ -46,7 +47,8 @@ def test_yaml_case_declaration() -> None:
test = YamlTest(name="TestTest", config={}, tests=[])
version = "SomeVersionStr"
with mock.patch(
"test_collections.sdk_tests.support.yaml_tests.models.test_case.YamlTestCase.class_factory"
"test_collections.sdk_tests.support.yaml_tests.models."
"test_case.YamlTestCase.class_factory"
) as class_factory, mock.patch(
"app.test_engine.models.test_declarations.TestCaseDeclaration.__init__"
) as declaration_init:
Expand Down
9 changes: 6 additions & 3 deletions app/tests/yaml_tests/test_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ async def test_manual_suite_setup_cleanup() -> None:
with mock.patch.object(
target=test_engine_logger, attribute="info"
) as logger_info, mock.patch(
"test_collections.sdk_tests.support.yaml_tests.models.test_suite.YamlTestSuite.setup"
"test_collections.sdk_tests.support.yaml_tests.models."
"test_suite.YamlTestSuite.setup"
) as _, mock.patch(
"test_collections.sdk_tests.support.yaml_tests.models.test_suite.YamlTestSuite.cleanup"
"test_collections.sdk_tests.support.yaml_tests.models."
"test_suite.YamlTestSuite.cleanup"
) as _:
await suite_instance.setup()
logger_info.assert_called_once()
Expand All @@ -154,7 +156,8 @@ async def test_chip_tool_suite_setup() -> None:
suite_instance = suite_class(TestSuiteExecution())

with mock.patch(
"test_collections.sdk_tests.support.yaml_tests.models.test_suite.YamlTestSuite.setup"
"test_collections.sdk_tests.support.yaml_tests.models."
"test_suite.YamlTestSuite.setup"
) as yaml_suite_setup, mock.patch(
"app.chip_tool.test_suite.ChipToolSuite.setup"
) as chip_tool_suite_setup:
Expand Down
8 changes: 2 additions & 6 deletions app/tests/yaml_tests/test_yaml_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,15 @@ def test_yaml_folder_version() -> None:
with mock.patch(
"test_collections.sdk_tests.support.yaml_tests.models.yaml_test_folder.open",
new=mock.mock_open(read_data=version_file_content),
), mock.patch.object(
target=Path, attribute="exists", return_value=True
) as _:
), mock.patch.object(target=Path, attribute="exists", return_value=True) as _:
yaml_folder = YamlTestFolder(test_yaml_path)

assert yaml_folder.version == version_file_content


def test_yaml_folder_version_missing() -> None:
expected_version = "Unknown"
with mock.patch.object(
target=Path, attribute="exists", return_value=False
) as _:
with mock.patch.object(target=Path, attribute="exists", return_value=False) as _:
yaml_folder = YamlTestFolder(test_yaml_path)
assert yaml_folder.version == expected_version

Expand Down
5 changes: 3 additions & 2 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@
"*.ini",
"*.toml",
"docker-compose*",
"*.dockerfile",
"Dockerfile",
"*.pyc",
".vscode/*",
"test_collections/sdk_tests/sdk_checkout",
"sdk_patch"
"sdk_patch",
".devcontainer"
],
"enableFiletypes": [
"shellscript"
Expand Down
3 changes: 2 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ exclude = (?x)(
^test_collections\/sdk_tests\/sdk_checkout\/
(
sdk_runner |
yaml_tests\/yaml\/sdk
yaml_tests\/yaml\/sdk |
python_testing
)
\/.*\.py$
)
2 changes: 1 addition & 1 deletion test_collections/sdk_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .support.yaml_tests import sdk_collection, custom_collection
from .support.yaml_tests import custom_collection, sdk_collection
6 changes: 4 additions & 2 deletions test_collections/sdk_tests/support/yaml_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from typing import Optional

from app.test_engine.models.test_declarations import TestCollectionDeclaration

from .sdk_yaml_tests import sdk_yaml_test_collection, custom_yaml_test_collection
from .sdk_yaml_tests import custom_yaml_test_collection, sdk_yaml_test_collection

# Test engine will auto load TestCollectionDeclarations declared inside the package
# initializer
sdk_collection: TestCollectionDeclaration = sdk_yaml_test_collection()

custom_collection: TestCollectionDeclaration = custom_yaml_test_collection()
custom_collection: Optional[TestCollectionDeclaration] = custom_yaml_test_collection()
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
VERSION_FILE_FILENAME = ".version"



class YamlTestFolder:
"""Representing a folder with Test YAML files.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#
from pathlib import Path
from typing import Optional

from loguru import logger

Expand Down Expand Up @@ -128,14 +129,14 @@ def sdk_yaml_test_collection(

def custom_yaml_test_collection(
yaml_test_folder: YamlTestFolder = CUSTOM_YAML_TEST_FOLDER,
) -> YamlCollectionDeclaration:
) -> Optional[YamlCollectionDeclaration]:
"""Declare a new collection of test suites."""
collection = YamlCollectionDeclaration(
name="Custom YAML Tests", folder=yaml_test_folder
)

files = yaml_test_folder.yaml_file_paths()
suites = _parse_all_yaml(yaml_files=files, yaml_version=None)
suites = _parse_all_yaml(yaml_files=files, yaml_version="custom")

for suite in suites:
if not suite.test_cases:
Expand Down