From d8b4254f020f3dc41ecc6523c739bdb307b593a7 Mon Sep 17 00:00:00 2001 From: Swetha Swaminathan Date: Tue, 10 Dec 2024 16:21:40 +0530 Subject: [PATCH] remove python folder --- .github/workflows/allure_report.yaml | 4 +- .github/workflows/integration_test_run.yaml | 2 +- python/cli/README.md | 3 - .../__init__.py | 2 - .../allure_add_default_for_missing_results.py | 51 -------- python/cli/pyproject.toml | 20 --- .../allure_pytest_collection_report/README.md | 1 - .../__init__.py | 2 - .../_plugin.py | 122 ------------------ .../pyproject.toml | 22 ---- .../integration/test-upload-charm/tox.ini | 4 +- 11 files changed, 5 insertions(+), 228 deletions(-) delete mode 100644 python/cli/README.md delete mode 100644 python/cli/allure_add_default_for_missing_results/__init__.py delete mode 100644 python/cli/allure_add_default_for_missing_results/allure_add_default_for_missing_results.py delete mode 100644 python/cli/pyproject.toml delete mode 100644 python/pytest_plugins/allure_pytest_collection_report/README.md delete mode 100644 python/pytest_plugins/allure_pytest_collection_report/allure_pytest_collection_report/__init__.py delete mode 100644 python/pytest_plugins/allure_pytest_collection_report/allure_pytest_collection_report/_plugin.py delete mode 100644 python/pytest_plugins/allure_pytest_collection_report/pyproject.toml diff --git a/.github/workflows/allure_report.yaml b/.github/workflows/allure_report.yaml index 999fa1d43..06c6f85f3 100644 --- a/.github/workflows/allure_report.yaml +++ b/.github/workflows/allure_report.yaml @@ -39,7 +39,7 @@ jobs: pattern: allure-results* merge-multiple: true - name: Install CLI - run: pipx install git+https://github.com/canonical/operator-workflows@ISD-2620-allure#subdirectory=python/cli + run: pipx install git+https://github.com/canonical/data-platform-workflows@v24.0.0#subdirectory=python/cli - name: Combine Allure default results & actual results # For every test: if actual result available, use that. Otherwise, use default result # So that, if actual result not available, Allure report will show "unknown"/"failed" test result @@ -93,4 +93,4 @@ jobs: git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git commit -m "Allure report ${{ github.run_number }}" # Uses token set in checkout step - git push origin gh-pages \ No newline at end of file + git push origin gh-pages diff --git a/.github/workflows/integration_test_run.yaml b/.github/workflows/integration_test_run.yaml index 24d733922..432083aa4 100644 --- a/.github/workflows/integration_test_run.yaml +++ b/.github/workflows/integration_test_run.yaml @@ -190,7 +190,7 @@ jobs: echo "ALLURE_ARTIFACT_SUFFIX=$allure_artifact_suffix" >> $GITHUB_ENV - name: Install tox run: | - pipx install tox + pip install tox - name: Collect tests for Allure working-directory: ${{ inputs.working-directory }} run: | diff --git a/python/cli/README.md b/python/cli/README.md deleted file mode 100644 index 5b6554569..000000000 --- a/python/cli/README.md +++ /dev/null @@ -1,3 +0,0 @@ -The `allure_add_default_for_missing_results` cli combines the Allure default results & actual results before generating the report. - -Currently, if the result of a test is not available (for reasons such as setup failure), allure omits the test. This CLI ensures that for every test, if actual result is available, it will use that. Otherwise, it uses the default result `unknown`. \ No newline at end of file diff --git a/python/cli/allure_add_default_for_missing_results/__init__.py b/python/cli/allure_add_default_for_missing_results/__init__.py deleted file mode 100644 index e3979c0f6..000000000 --- a/python/cli/allure_add_default_for_missing_results/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright 2024 Canonical Ltd. -# See LICENSE file for licensing details. diff --git a/python/cli/allure_add_default_for_missing_results/allure_add_default_for_missing_results.py b/python/cli/allure_add_default_for_missing_results/allure_add_default_for_missing_results.py deleted file mode 100644 index 14d2b6bad..000000000 --- a/python/cli/allure_add_default_for_missing_results/allure_add_default_for_missing_results.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2024 Canonical Ltd. -# See LICENSE file for licensing details. -import argparse -import dataclasses -import json -import pathlib - - -@dataclasses.dataclass(frozen=True) -class Result: - test_case_id: str - path: pathlib.Path - - def __eq__(self, other): - if not isinstance(other, type(self)): - return False - return self.test_case_id == other.test_case_id - - -def main(): - """Combine Allure default results & actual results - - For every test: if actual result available, use that. Otherwise, use default result - - So that, if actual result not available, Allure report will show "unknown"/"failed" test result - instead of omitting the test - """ - parser = argparse.ArgumentParser() - parser.add_argument("--allure-results-dir", required=True) - parser.add_argument("--allure-collection-default-results-dir", required=True) - args = parser.parse_args() - - actual_results = pathlib.Path(args.allure_results_dir) - default_results = pathlib.Path(args.allure_collection_default_results_dir) - - results: dict[pathlib.Path, set[Result]] = { - actual_results: set(), - default_results: set(), - } - for directory, results_ in results.items(): - for path in directory.glob("*-result.json"): - with path.open("r") as file: - id_ = json.load(file)["testCaseId"] - results_.add(Result(id_, path)) - - actual_results.mkdir(exist_ok=True) - - missing_results = results[default_results] - results[actual_results] - for default_result in missing_results: - # Move to `actual_results` directory - default_result.path.rename(actual_results / default_result.path.name) diff --git a/python/cli/pyproject.toml b/python/cli/pyproject.toml deleted file mode 100644 index ad7ef259b..000000000 --- a/python/cli/pyproject.toml +++ /dev/null @@ -1,20 +0,0 @@ -[tool.poetry] -name = "allure_add_default_for_missing_results" -version = "0.1.0" -description = "" -license = "Apache-2.0" -authors = ["Carl Csaposs "] -readme = "README.md" - -[tool.poetry.scripts] -allure-add-default-for-missing-results = "allure_add_default_for_missing_results.allure_add_default_for_missing_results:main" - -[tool.poetry.dependencies] -python = "^3.10" -pyyaml = "^6.0.1" -requests = "^2.31.0" - - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" \ No newline at end of file diff --git a/python/pytest_plugins/allure_pytest_collection_report/README.md b/python/pytest_plugins/allure_pytest_collection_report/README.md deleted file mode 100644 index e3a5e1b8b..000000000 --- a/python/pytest_plugins/allure_pytest_collection_report/README.md +++ /dev/null @@ -1 +0,0 @@ -The `allure-pytest` plugin marks all the test statuses as unknown during collection time. \ No newline at end of file diff --git a/python/pytest_plugins/allure_pytest_collection_report/allure_pytest_collection_report/__init__.py b/python/pytest_plugins/allure_pytest_collection_report/allure_pytest_collection_report/__init__.py deleted file mode 100644 index e3979c0f6..000000000 --- a/python/pytest_plugins/allure_pytest_collection_report/allure_pytest_collection_report/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright 2024 Canonical Ltd. -# See LICENSE file for licensing details. diff --git a/python/pytest_plugins/allure_pytest_collection_report/allure_pytest_collection_report/_plugin.py b/python/pytest_plugins/allure_pytest_collection_report/allure_pytest_collection_report/_plugin.py deleted file mode 100644 index 1832d0575..000000000 --- a/python/pytest_plugins/allure_pytest_collection_report/allure_pytest_collection_report/_plugin.py +++ /dev/null @@ -1,122 +0,0 @@ -# Copyright 2024 Canonical Ltd. -# See LICENSE file for licensing details. -# Upstream feature request to replace this plugin: -# https://github.com/allure-framework/allure-python/issues/821 - -import allure_commons.logger -import allure_commons.model2 -import allure_commons.types -import allure_commons.utils -import allure_pytest.listener -import allure_pytest.utils - - -def pytest_addoption(parser): - parser.addoption( - "--allure-collection-dir", - help="Generate default Allure results (used by GitHub Actions) in \ - this directory for tests that are missing Allure results", - ) - - -def pytest_configure(config): - if config.option.allure_collection_dir: - config.option.collectonly = True - - -def pytest_collection_finish(session): - report_dir = session.config.option.allure_collection_dir - if not report_dir: - return - - # Copied from `allure_pytest.listener.AllureListener._cache` - _cache = allure_pytest.listener.ItemCache() - # Modified from `allure_pytest.plugin.pytest_configure` - file_logger = allure_commons.logger.AllureFileLogger(report_dir) - - for item in session.items: - # Modified from - # `allure_pytest.listener.AllureListener.pytest_runtest_protocol` - uuid = _cache.push(item.nodeid) - test_result = allure_commons.model2.TestResult(name=item.name, uuid=uuid) - - # Copied from `allure_pytest.listener.AllureListener.pytest_runtest_setup` - params = ( - allure_pytest.listener.AllureListener._AllureListener__get_pytest_params( - item - ) - ) - test_result.name = allure_pytest.utils.allure_name(item, params) - full_name = allure_pytest.utils.allure_full_name(item) - test_result.fullName = full_name - test_result.testCaseId = allure_commons.utils.md5(full_name) - test_result.description = allure_pytest.utils.allure_description(item) - test_result.descriptionHtml = allure_pytest.utils.allure_description_html(item) - current_param_names = [param.name for param in test_result.parameters] - test_result.parameters.extend( - [ - allure_commons.model2.Parameter( - name=name, value=allure_commons.utils.represent(value) - ) - for name, value in params.items() - if name not in current_param_names - ] - ) - - # Copied from `allure_pytest.listener.AllureListener.pytest_runtest_teardown` - listener = allure_pytest.listener.AllureListener - test_result.historyId = allure_pytest.utils.get_history_id( - test_result.fullName, - test_result.parameters, - original_values=listener._AllureListener__get_pytest_params(item), - ) - test_result.labels.extend( - [ - allure_commons.model2.Label(name=name, value=value) - for name, value in allure_pytest.utils.allure_labels(item) - ] - ) - test_result.labels.extend( - [ - allure_commons.model2.Label( - name=allure_commons.types.LabelType.TAG, value=value - ) - for value in allure_pytest.utils.pytest_markers(item) - ] - ) - allure_pytest.listener.AllureListener._AllureListener__apply_default_suites( - None, item, test_result - ) - test_result.labels.append( - allure_commons.model2.Label( - name=allure_commons.types.LabelType.HOST, - value=allure_commons.utils.host_tag(), - ) - ) - test_result.labels.append( - allure_commons.model2.Label( - name=allure_commons.types.LabelType.FRAMEWORK, value="pytest" - ) - ) - test_result.labels.append( - allure_commons.model2.Label( - name=allure_commons.types.LabelType.LANGUAGE, - value=allure_commons.utils.platform_label(), - ) - ) - test_result.labels.append( - allure_commons.model2.Label( - name="package", value=allure_pytest.utils.allure_package(item) - ) - ) - test_result.links.extend( - [ - allure_commons.model2.Link(link_type, url, name) - for link_type, url, name in allure_pytest.utils.allure_links(item) - ] - ) - - # Modified from `allure_pytest.listener.AllureListener.pytest_runtest_protocol` - test_result.status = allure_commons.model2.Status.UNKNOWN - # Modified from `allure_commons.reporter.AllureReporter.close_test` - file_logger.report_result(test_result) diff --git a/python/pytest_plugins/allure_pytest_collection_report/pyproject.toml b/python/pytest_plugins/allure_pytest_collection_report/pyproject.toml deleted file mode 100644 index 7c721432c..000000000 --- a/python/pytest_plugins/allure_pytest_collection_report/pyproject.toml +++ /dev/null @@ -1,22 +0,0 @@ -[tool.poetry] -name = "allure_pytest_collection_report" -version = "0.1.0" -description = "" -authors = ["Carl Csaposs "] -readme = "README.md" -classifiers = [ - "Framework :: Pytest", -] - -[tool.poetry.plugins."pytest11"] -allure_collection_report = "allure_pytest_collection_report._plugin" - -[tool.poetry.dependencies] -python = "^3.8" -pytest = "*" -allure-pytest = ">=2.13.5" - - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" \ No newline at end of file diff --git a/tests/workflows/integration/test-upload-charm/tox.ini b/tests/workflows/integration/test-upload-charm/tox.ini index b6353b92e..04a96ee43 100644 --- a/tests/workflows/integration/test-upload-charm/tox.ini +++ b/tests/workflows/integration/test-upload-charm/tox.ini @@ -112,7 +112,7 @@ deps = macaroonbakery==1.3.2 websockets<14.0 # https://github.com/juju/python-libjuju/issues/1184 -r{toxinidir}/requirements.txt - git+https://github.com/canonical/operator-workflows@ISD-2620-allure\#subdirectory=python/pytest_plugins/allure_pytest_collection_report + git+https://github.com/canonical/data-platform-workflows@v24.0.0\#subdirectory=python/pytest_plugins/allure_pytest_collection_report commands = pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} @@ -127,6 +127,6 @@ deps = macaroonbakery==1.3.2 websockets<14.0 # https://github.com/juju/python-libjuju/issues/1184 -r{toxinidir}/requirements.txt - git+https://github.com/canonical/operator-workflows@ISD-2620-allure\#subdirectory=python/pytest_plugins/allure_pytest_collection_report + git+https://github.com/canonical/data-platform-workflows@v24.0.0\#subdirectory=python/pytest_plugins/allure_pytest_collection_report commands = pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs}