From 68ddd597f25fa17fab49873e642bba7297c3549d Mon Sep 17 00:00:00 2001 From: AAriam <80158628+AAriam@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:53:39 +0100 Subject: [PATCH] Release version 0.0.0.dev340 --- pyproject.toml | 23 ++--- requirements.txt | 21 +++-- .../schema/def/cache-retention-hours.yaml | 53 +++++++++++ src/controlman/_data/schema/local.yaml | 17 ++-- src/controlman/_data/schema/main.yaml | 92 ++++++------------- src/controlman/center_manager.py | 21 ++++- src/controlman/const.py | 4 +- 7 files changed, 130 insertions(+), 101 deletions(-) create mode 100644 src/controlman/_data/schema/def/cache-retention-hours.yaml diff --git a/pyproject.toml b/pyproject.toml index e77401a9..93eb5573 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ namespaces = true # ----------------------------------------- Project Metadata ------------------------------------- # [project] -version = "0.0.0.dev339" +version = "0.0.0.dev340" name = "ControlMan" dependencies = [ "packaging >= 23.2, < 24", @@ -26,18 +26,19 @@ dependencies = [ "referencing == 0.35.1", "jsonpath-ng == 1.6.1", "ruamel.yaml == 0.17.40", - "PyLinks == 0.0.0.dev41", - "LoggerMan == 0.0.0.dev57", - "PySerials == 0.0.0.dev31", - "GitTidy == 0.0.0.dev54", + "Jinja2 == 3.0.2", + "PyLinks == 0.0.0.dev42", + "LoggerMan == 0.0.0.dev58", + "PySerials == 0.0.0.dev32", + "GitTidy == 0.0.0.dev55", "PkgData == 0.0.0.dev5", - "PyShellMan == 0.0.0.dev18", - "PySyntax == 0.0.0.dev3", - "ExceptionMan == 0.0.0.dev28", - "MDit == 0.0.0.dev28", - "JSONSchemata == 0.0.0.dev27", + "PyShellMan == 0.0.0.dev19", + "PySyntax == 0.0.0.dev4", + "ExceptionMan == 0.0.0.dev29", + "MDit == 0.0.0.dev29", + "JSONSchemata == 0.0.0.dev28", "VersionMan == 0.0.0.dev248", "HTMP == 0.0.0.dev5", - "LicenseMan == 0.0.0.dev14", + "LicenseMan == 0.0.0.dev15", ] requires-python = ">=3.10" diff --git a/requirements.txt b/requirements.txt index aa676f7c..738c765e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,16 +4,17 @@ jsonschema >= 4.23, < 5 referencing == 0.35.1 jsonpath-ng == 1.6.1 ruamel.yaml == 0.17.40 -PyLinks == 0.0.0.dev41 -LoggerMan == 0.0.0.dev57 -PySerials == 0.0.0.dev31 -GitTidy == 0.0.0.dev54 +Jinja2 == 3.0.2 +PyLinks == 0.0.0.dev42 +LoggerMan == 0.0.0.dev58 +PySerials == 0.0.0.dev32 +GitTidy == 0.0.0.dev55 PkgData == 0.0.0.dev5 -PyShellMan == 0.0.0.dev18 -PySyntax == 0.0.0.dev3 -ExceptionMan == 0.0.0.dev28 -MDit == 0.0.0.dev28 -JSONSchemata == 0.0.0.dev27 +PyShellMan == 0.0.0.dev19 +PySyntax == 0.0.0.dev4 +ExceptionMan == 0.0.0.dev29 +MDit == 0.0.0.dev29 +JSONSchemata == 0.0.0.dev28 VersionMan == 0.0.0.dev248 HTMP == 0.0.0.dev5 -LicenseMan == 0.0.0.dev14 \ No newline at end of file +LicenseMan == 0.0.0.dev15 \ No newline at end of file diff --git a/src/controlman/_data/schema/def/cache-retention-hours.yaml b/src/controlman/_data/schema/def/cache-retention-hours.yaml new file mode 100644 index 00000000..e72f861a --- /dev/null +++ b/src/controlman/_data/schema/def/cache-retention-hours.yaml @@ -0,0 +1,53 @@ +$id: https://controlman.repodynamics.com/schema/cache-retention-hours +$schema: https://json-schema.org/draft/2020-12/schema +title: Number of hours to keep different cached data. +description: | + After the specified duration, + the cached data is considered stale + and will be automatically synced with the source. +type: object +additionalProperties: false +default: { } +required: [ extension, repo, user, orcid, doi, python ] +properties: + extension: + title: Configuration extensions retrieved from external URLs. + description: | + These are extended data in control center configuration files + defined with the `!ext` tag. + default: 0 + $ref: https://jsonschemata.repodynamics.com/number/non-negative + repo: + title: Repository data retrieved from GitHub API. + description: | + This includes general repository settings, + as well as details about discussion categories, + which are used for the website's blog. + default: 1 + $ref: https://jsonschemata.repodynamics.com/number/non-negative + user: + title: Team member data retrieved from GitHub API. + description: | + This includes GitHub user data such as + name, email, avatar, bio, and other profile information. + default: 24 + $ref: https://jsonschemata.repodynamics.com/number/non-negative + orcid: + title: Publications data retrieved from ORCID API. + description: | + This includes a list of all publication DOIs associated with an ORCID ID. + default: 240 + $ref: https://jsonschemata.repodynamics.com/number/non-negative + doi: + title: Publication data retrieved from DOI API. + description: | + This corresponds to citation details associated with a specific DOI. + default: 1000 + $ref: https://jsonschemata.repodynamics.com/number/non-negative + python: + title: Python version data retrieved from the Python GitHub repository. + description: | + This is a list of currently available Python versions, + used to update workflow configurations such as CI/CD/CT pipelines. + default: 500 + $ref: https://jsonschemata.repodynamics.com/number/non-negative \ No newline at end of file diff --git a/src/controlman/_data/schema/local.yaml b/src/controlman/_data/schema/local.yaml index 4bfbbca3..fc76ab83 100644 --- a/src/controlman/_data/schema/local.yaml +++ b/src/controlman/_data/schema/local.yaml @@ -18,16 +18,13 @@ description: | This allows you to easily maintain your own local configurations without affecting the remote repository. ::: -examples: - - control: - cache: - retention_hours: - api: 1 - extensions: 1 type: object additionalProperties: false properties: - control: - title: Control Center - description: Configurations for the project's control center. - $ref: user/ci.yaml#/properties/control + retention_hours: + title: Number of hours to keep different cached data. + description: | + After the specified duration, + the cached data is considered stale + and will be automatically synced with the source. + $ref: https://controlman.repodynamics.com/schema/cache-retention-hours diff --git a/src/controlman/_data/schema/main.yaml b/src/controlman/_data/schema/main.yaml index dbfb8e71..fba626d1 100644 --- a/src/controlman/_data/schema/main.yaml +++ b/src/controlman/_data/schema/main.yaml @@ -1817,7 +1817,7 @@ properties: Initialize new changelog entry. body: | Issue #{{ issue.number }} - Pull #{{ pull.number }} + Pull #{{ pull_request.number }} $ref: https://controlman.repodynamics.com/schema/commit-auto config_sync: title: Configuration Synchronization @@ -1837,7 +1837,7 @@ properties: type: refactor scope: auto description: >- - Refactor code. + Apply automatic formatting and refactoring. $ref: https://controlman.repodynamics.com/schema/commit-auto primary: title: Primary Commits @@ -2444,6 +2444,7 @@ properties: Project's changelog templates and paths. Configurations and templates for your project's changelogs and release notes. type: object + default: { } properties: path: title: Path @@ -2550,10 +2551,10 @@ properties: type: string default: | {%- macro make_user(user) -%} - {%- if user.name -%} - {{ user.name }} (@{{ user.login }}) + {%- if user.name.full != user.github.id -%} + {{ user.name.full }} (@{{ user.github.id }}) {%- else -%} - @{{ user.login }} + @{{ user.github.id }} {%- endif -%} {%- endmacro -%} @@ -2638,30 +2639,38 @@ properties: {%- endmacro -%} {%- macro make_user(user) -%} - {%- if user.name -%} - {{ user.name }} (@{{ user.login }}) + {%- if user.name.full != user.github.id -%} + {{ user.name.full }} (@{{ user.github.id }}) {%- else -%} - @{{ user.login }} + @{{ user.github.id }} {%- endif -%} {%- endmacro -%} {%- macro make_description() -%} {%- if action == "assigned" -%} - Assigned to {{ make_user(assignee) }}. + {%- if event == "issues" -%} + Issue assigned to {{ make_user(assignee) }}. + {%- elif event == "pull_request" -%} + Pull request assigned to {{ make_user(assignee) }}. + {%- endif -%} {%- elif action == "unassigned" -%} - Unassigned from {{ make_user(assignee) }}. + {%- if event == "issues" -%} + Issue unassigned from {{ make_user(assignee) }}. + {%- elif event == "pull_request" -%} + Pull request unassigned from {{ make_user(assignee) }}. + {%- endif -%} {%- elif action == "review_requested" -%} - Assigned to {{ make_user(requested_reviewer) }} for review. + Review assigned to {{ make_user(requested_reviewer) }}. {%- elif action == "review_request_removed" -%} - Unassigned from {{ make_user(requested_reviewer) }} for review. + Review unassigned from {{ make_user(requested_reviewer) }}. {%- elif action == "synchronize" -%} New commits pushed to [{{ head.name }}]({{ head.url }}) (CI [{{ context.run_id }}]({{ workflow_url }})). {%- elif action == "labeled" -%} {%- set category = label.category -%} {%- if category == "type" -%} Type set to `{{ label.suffix }}`. - {%- elif category == "subtype" -%} - Subtype set to `{{ label.suffix }}`. + {%- elif category == "scope" -%} + Scope set to `{{ label.suffix }}`. {%- elif category == "version" -%} Target version set to `{{ label.suffix }}`. {%- elif category == "branch" -%} @@ -2700,13 +2709,13 @@ properties: {%- endif -%} {%- elif action == "opened" -%} {%- if event == "issues" -%} - Issue ticket #{{ payload.issue.number }} submitted by {{ make_user(creator) }}. + Issue ticket #{{ issue.number }} submitted by {{ make_user(issue.user) }}. {%- elif event == "pull_request" -%} - Pull request #{{ payload.pull_request.number }} opened by {{ make_user(creator) }}. + Pull request #{{ pull_request.number }} opened from branch {{ by {{ make_user(pull_request.user) }}. {%- endif -%} {%- endif -%} {%- endmacro %} - {{ make_entry(make_user(payload.sender), make_description()) -}} + {{ make_entry(make_user(sender), make_description()) -}} references: $ref: https://controlman.repodynamics.com/schema/doc-protocol-dynamic-data default: @@ -3593,55 +3602,10 @@ properties: After the specified duration, the cached data is considered stale and will be automatically synced with the source. - type: object - additionalProperties: false - default: { } - required: [ extension, repo, user, orcid, doi, python ] - properties: - extension: - title: Configuration extensions retrieved from external URLs. - description: | - These are extended data in control center configuration files - defined with the `!ext` tag. - default: 0 - $ref: https://jsonschemata.repodynamics.com/number/non-negative - repo: - title: Repository data retrieved from GitHub API. - description: | - This includes general repository settings, - as well as details about discussion categories, - which are used for the website's blog. - default: 1 - $ref: https://jsonschemata.repodynamics.com/number/non-negative - user: - title: Team member data retrieved from GitHub API. - description: | - This includes GitHub user data such as - name, email, avatar, bio, and other profile information. - default: 24 - $ref: https://jsonschemata.repodynamics.com/number/non-negative - orcid: - title: Publications data retrieved from ORCID API. - description: | - This includes a list of all publication DOIs associated with an ORCID ID. - default: 240 - $ref: https://jsonschemata.repodynamics.com/number/non-negative - doi: - title: Publication data retrieved from DOI API. - description: | - This corresponds to citation details associated with a specific DOI. - default: 1000 - $ref: https://jsonschemata.repodynamics.com/number/non-negative - python: - title: Python version data retrieved from the Python GitHub repository. - description: | - This is a list of currently available Python versions, - used to update workflow configurations such as CI/CD/CT pipelines. - default: 500 - $ref: https://jsonschemata.repodynamics.com/number/non-negative + $ref: https://controlman.repodynamics.com/schema/cache-retention-hours url: title: URL of the project's configuration file. - default: ${{ repo.url.raw }}$/.github/.control/.metadata.json + default: ${{ repo.url.raw }}$/.github/.repodynamics/metadata.json $ref: https://jsonschemata.repodynamics.com/url/https workflow: type: object diff --git a/src/controlman/center_manager.py b/src/controlman/center_manager.py index 8aa43014..c899705b 100644 --- a/src/controlman/center_manager.py +++ b/src/controlman/center_manager.py @@ -17,6 +17,7 @@ DynamicDir as _DynamicDir, ) from controlman import const +from controlman.exception import load as _load_exception from controlman.cache_manager import CacheManager from controlman import file_gen as _file_gen from controlman import data_loader as _data_loader @@ -45,12 +46,24 @@ def __init__( self._path_root = self._git.repo_path self._hook_manager = _HookManager(dir_path=self._path_cc / const.DIRNAME_CC_HOOK) - local_cache_path = self._data_before.get("local.cache.path") + relpath_local_cache = self._data_before.get("local.cache.path") + path_local_cache = None + retention_hours = self._data_before.get("control.cache.retention_hours", {}) + if relpath_local_cache: + path_local_cache = self._path_root / relpath_local_cache + path_local_config = path_local_cache / const.FILENAME_LOCAL_CONFIG + if path_local_config.is_file(): + with _logger.sectioning("Local Cache Configuration"): + try: + local_config = _ps.read.yaml_from_file(path=path_local_config, safe=True) + except _ps.exception.read.PySerialsInvalidDataError as e: + raise _load_exception.ControlManInvalidConfigFileDataError(cause=e) from None + _data_validator.validate(data=local_config, schema="local") + retention_hours = local_config.get("retention_hours", {}) self._cache_manager: CacheManager = CacheManager( - path_local_cache=self._path_root / local_cache_path if local_cache_path else None, - retention_hours=self._data_before.get("control.cache.retention_hours", {}), + path_local_cache=path_local_cache, + retention_hours=retention_hours, ) - self._data_raw: _ps.NestedDict | None = None self._data: _ps.NestedDict | None = None self._files: list[_GeneratedFile] = [] diff --git a/src/controlman/const.py b/src/controlman/const.py index c00ddf65..3b54eef3 100644 --- a/src/controlman/const.py +++ b/src/controlman/const.py @@ -10,9 +10,9 @@ DIRNAME_LOCAL_REPORT = "reports" DIRNAME_LOCAL_REPODYNAMICS = "RepoDynamics" -FILEPATH_METADATA = ".github/.control/.metadata.json" +FILEPATH_METADATA = ".github/.repodynamics/metadata.json" FILENAME_METADATA_CACHE = ".metadata_cache.yaml" -FILEPATH_LOCAL_CONFIG = ".github/.control/local_config.yaml" +FILENAME_LOCAL_CONFIG = "config.yaml" DIRNAME_CC_HOOK = "hook"