Skip to content

Commit

Permalink
Merge pull request #633 from camptocamp/renovate/ci-dependencies
Browse files Browse the repository at this point in the history
Update CI dependencies (minor)
  • Loading branch information
sbrunner authored Feb 28, 2025
2 parents 8054e0f + 291da83 commit ea594f3
Show file tree
Hide file tree
Showing 34 changed files with 846 additions and 897 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
- run: c2cciutils-docker-logs
if: always()

- run: git reset --hard
if: failure()
- name: Publish
run: tag-publish
env:
Expand Down
46 changes: 28 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# https://pre-commit.com/hooks.html

exclude: |-
(?x)^(
github_app_geo_project/project_configuration\.py
|github_app_geo_project/application_configuration\.py
|github_app_geo_project/module/standard/changelog_configuration\.py
|github_app_geo_project/module/standard/auto_configuration\.py
|github_app_geo_project/module/audit/configuration\.py
|github_app_geo_project/module/pull_request/checks_configuration\.py
|github_app_geo_project/module/pull_request/links_configuration\.py
|github_app_geo_project/module/delete_old_workflow_runs/configuration\.py
|github_app_geo_project/module/versions/configuration\.py
|github_app_geo_project/module/clean/configuration\.py
|github_app_geo_project/module/backport/configuration\.py
)$
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
additional_dependencies:
- prettier@3.3.3 # npm
- prettier@3.5.2 # npm
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand All @@ -28,9 +43,9 @@ repos:
hooks:
- id: poetry2-lock
additional_dependencies:
- poetry==2.0.1 # pypi
- poetry==2.1.1 # pypi
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
exclude: |-
Expand All @@ -42,12 +57,8 @@ repos:
rev: v0.10.0.1
hooks:
- id: shellcheck
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: git-check
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
rev: 0.31.2
hooks:
- id: check-github-workflows
- id: check-jsonschema
Expand All @@ -66,20 +77,19 @@ repos:
hooks:
- id: ripsecrets
- repo: https://github.com/PyCQA/prospector
rev: v1.13.3
rev: v1.15.2
hooks:
- id: prospector
args:
- --tool=ruff
- --die-on-tool-error
- --output-format=pylint
- --profile=.prospector-fix.yaml
- --profile=utils:pre-commit
- --profile=.prospector.yaml
additional_dependencies:
- prospector-profile-duplicated==1.8.1 # pypi
- prospector-profile-utils==1.11.1 # pypi
- ruff==0.7.4 # pypi
- prospector-profile-duplicated==1.10.4 # pypi
- prospector-profile-utils==1.21.6 # pypi
- repo: https://github.com/camptocamp/jsonschema-gentypes
rev: 2.8.1
rev: 2.10.0
hooks:
- id: jsonschema-gentypes
files: |-
Expand Down Expand Up @@ -185,14 +195,14 @@ repos:
- --ignore-acronyms
- --en-us
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 39.31.4
rev: 39.182.3
hooks:
- id: renovate-config-validator
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.9.8
hooks:
- id: ruff-format
- repo: https://github.com/sbrunner/python-versions-hook
rev: 0.7.0
rev: 0.8.0
hooks:
- id: python-versions
4 changes: 0 additions & 4 deletions .prospector-fix.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ ignore-paths:
- github_app_geo_project/module/standard/changelog_configuration.py
- github_app_geo_project/module/audit/configuration.py
- github_app_geo_project/module/clean/configuration.py
- github_app_geo_project/module/versions/configuration.py
- github_app_geo_project/module/backport/configuration.py
- github_app_geo_project/module/delete_old_workflow_runs/configuration.py
- github_app_geo_project/module/pull_request/checks_configuration.py
- github_app_geo_project/module/pull_request/links_configuration.py
- github_app_geo_project/module/standard/auto_configuration.py

mypy:
options:
Expand Down
12 changes: 6 additions & 6 deletions ci/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
c2cciutils[checks,publish]==1.7.3
importlib-metadata<8.5.1 # issue with twine, see: https://github.com/python/importlib_metadata/issues/492
poetry==2.0.1
pre-commit==4.0.1
importlib-metadata<8.6.2 # issue with twine, see: https://github.com/python/importlib_metadata/issues/492
poetry==2.1.1
pre-commit==4.1.0
poetry-plugin-drop-python-upper-constraint==0.1.0
poetry-plugin-export==1.8.0
poetry-plugin-export==1.9.0
poetry-plugin-tweak-dependencies-version==1.5.2
poetry-dynamic-versioning==1.4.1
poetry-dynamic-versioning==1.7.1
certifi>=2024.7.4 # not directly required, pinned by Snyk to avoid a vulnerability
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
jinja2>=3.1.3 # not directly required, pinned by Snyk to avoid a vulnerability
cryptography>=42.0.8 # not directly required, pinned by Snyk to avoid a vulnerability
zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability
tag-publish==0.9.2
tag-publish==0.13.3
62 changes: 31 additions & 31 deletions github_app_geo_project/application_configuration.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
"""Automatically generated file from a JSON schema."""
"""
Automatically generated file from a JSON schema.
"""


from typing import Any, TypedDict


# | GitHub application project configuration.
GithubApplicationProjectConfiguration = TypedDict(
"GithubApplicationProjectConfiguration",
{
# | Title.
# |
# | The title of the project
"title": str,
# | Description.
# |
# | The description of the project
"description": str,
# | Documentation URL.
# |
# | The URL of the documentation
"documentation-url": str,
# | Start URL.
# |
# | The URL of the start page
"start-url": str,
# | Default profile.
# |
# | The profile name used by default
"default-profile": str,
# | Profiles.
# |
# | The profiles configuration
"profiles": dict[str, dict[str, Any]],
},
total=False,
)
GithubApplicationProjectConfiguration = TypedDict('GithubApplicationProjectConfiguration', {
# | Title.
# |
# | The title of the project
'title': str,
# | Description.
# |
# | The description of the project
'description': str,
# | Documentation URL.
# |
# | The URL of the documentation
'documentation-url': str,
# | Start URL.
# |
# | The URL of the start page
'start-url': str,
# | Default profile.
# |
# | The profile name used by default
'default-profile': str,
# | Profiles.
# |
# | The profiles configuration
'profiles': dict[str, dict[str, Any]],
}, total=False)
12 changes: 6 additions & 6 deletions github_app_geo_project/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
import os
from pathlib import Path
from typing import Any, NamedTuple, cast

import github
Expand All @@ -15,7 +16,7 @@

APPLICATION_CONFIGURATION: application_configuration.GithubApplicationProjectConfiguration = {}
if "GHCI_CONFIGURATION" in os.environ:
with open(os.environ["GHCI_CONFIGURATION"], encoding="utf-8") as configuration_file:
with Path(os.environ["GHCI_CONFIGURATION"]).open(encoding="utf-8") as configuration_file:
APPLICATION_CONFIGURATION = yaml.load(configuration_file, Loader=yaml.SafeLoader)


Expand Down Expand Up @@ -76,9 +77,10 @@ def get_github_application(config: dict[str, Any], application_name: str) -> Git
"""Get the Github Application objects by name."""
applications = config.get("applications", "").split()
if application_name not in applications:
raise ValueError(
f"Application {application_name} not found, available applications: {', '.join(applications)}",
message = (
f"Application {application_name} not found, available applications: {', '.join(applications)}"
)
raise ValueError(message)
if application_name not in GITHUB_APPLICATIONS: # pylint: disable=undefined-variable
private_key = "\n".join(
[
Expand All @@ -94,9 +96,7 @@ def get_github_application(config: dict[str, Any], application_name: str) -> Git

GITHUB_APPLICATIONS[application_name] = objects

objects = GITHUB_APPLICATIONS[application_name]

return objects
return GITHUB_APPLICATIONS[application_name]


def get_github_project(
Expand Down
6 changes: 3 additions & 3 deletions github_app_geo_project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Queue(Base):
"""SQLAlchemy model for the queue."""

__tablename__ = "queue"
__table_args__ = {"schema": _SCHEMA}
__table_args__ = {"schema": _SCHEMA} # noqa: RUF012

id: Mapped[int] = mapped_column(Integer, primary_key=True, nullable=False, autoincrement=True)
status: Mapped[JobStatus] = mapped_column(
Expand Down Expand Up @@ -98,7 +98,7 @@ class Output(Base):
"""SQLAlchemy model for the output entries."""

__tablename__ = "output"
__table_args__ = {"schema": _SCHEMA}
__table_args__ = {"schema": _SCHEMA} # noqa: RUF012

id: Mapped[int] = mapped_column(Integer, primary_key=True, nullable=False, autoincrement=True)
created_at: Mapped[datetime] = mapped_column(
Expand Down Expand Up @@ -126,7 +126,7 @@ class ModuleStatus(Base):
"""SQLAlchemy model for the output entries."""

__tablename__ = "module_status"
__table_args__ = {"schema": _SCHEMA}
__table_args__ = {"schema": _SCHEMA} # noqa: RUF012

id: Mapped[int] = mapped_column(Integer, primary_key=True, nullable=False, autoincrement=True)
module: Mapped[str] = mapped_column(Unicode, nullable=False, unique=True, index=True)
Expand Down
14 changes: 7 additions & 7 deletions github_app_geo_project/module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def cleanup(self, context: CleanupContext[_EVENT_DATA]) -> None:
@abstractmethod
async def get_json_schema(self) -> dict[str, Any]:
"""Get the JSON schema of the module configuration."""
super_ = [c for c in self.__class__.__orig_bases__ if c.__origin__ == Module][0] # type: ignore[attr-defined] # pylint: disable=no-member
super_ = next(c for c in self.__class__.__orig_bases__ if c.__origin__ == Module) # type: ignore[attr-defined] # pylint: disable=no-member
generic_element = super_.__args__[0]
# Is Pydantic BaseModel
if not isinstance(generic_element, GenericAlias) and issubclass(generic_element, BaseModel):
Expand All @@ -374,28 +374,28 @@ async def get_json_schema(self) -> dict[str, Any]:

def configuration_from_json(self, data: dict[str, Any]) -> _CONFIGURATION:
"""Create the configuration from the JSON data."""
super_ = [c for c in self.__class__.__orig_bases__ if c.__origin__ == Module][0] # type: ignore[attr-defined] # pylint: disable=no-member
super_ = next(c for c in self.__class__.__orig_bases__ if c.__origin__ == Module) # type: ignore[attr-defined] # pylint: disable=no-member
generic_element = super_.__args__[0]
# Is Pydantic BaseModel
if not isinstance(generic_element, GenericAlias) and issubclass(generic_element, BaseModel):
try:
return generic_element(**data) # type: ignore[no-any-return]
except ValidationError:
_LOGGER.error("Invalid configuration, try with empty configuration: %s", data)
_LOGGER.error("Invalid configuration, try with empty configuration: %s", data) # noqa: TRY400
return generic_element() # type: ignore[no-any-return]

return data # type: ignore[return-value]

def event_data_from_json(self, data: dict[str, Any]) -> _EVENT_DATA:
"""Create the module event data from the JSON data."""
super_ = [c for c in self.__class__.__orig_bases__ if c.__origin__ == Module][0] # type: ignore[attr-defined] # pylint: disable=no-member
super_ = next(c for c in self.__class__.__orig_bases__ if c.__origin__ == Module) # type: ignore[attr-defined] # pylint: disable=no-member
generic_element = super_.__args__[1]
# Is Pydantic BaseModel
if (not isinstance(generic_element, GenericAlias)) and issubclass(generic_element, BaseModel):
try:
return generic_element(**data) # type: ignore[no-any-return]
except ValidationError:
_LOGGER.error("Invalid event data, try with empty event data: %s", data)
_LOGGER.error("Invalid event data, try with empty event data: %s", data) # noqa: TRY400
return generic_element() # type: ignore[no-any-return]
return data # type: ignore[return-value]

Expand All @@ -410,14 +410,14 @@ def event_data_to_json(self, data: _EVENT_DATA) -> dict[str, Any]:
def transversal_status_from_json(self, data: dict[str, Any] | None) -> _TRANSVERSAL_STATUS:
"""Create the transversal status from the JSON data."""
data = data or {}
super_ = [c for c in self.__class__.__orig_bases__ if c.__origin__ == Module][0] # type: ignore[attr-defined] # pylint: disable=no-member
super_ = next(c for c in self.__class__.__orig_bases__ if c.__origin__ == Module) # type: ignore[attr-defined] # pylint: disable=no-member
generic_element = super_.__args__[2]
# Is Pydantic BaseModel
if not isinstance(generic_element, GenericAlias) and issubclass(generic_element, BaseModel):
try:
return generic_element(**data) # type: ignore[no-any-return]
except ValidationError:
_LOGGER.error("Invalid transversal status, try with empty transversal status: %s", data)
_LOGGER.error("Invalid transversal status, try with empty transversal status: %s", data) # noqa: TRY400
return generic_element() # type: ignore[no-any-return]
return data # type: ignore[return-value]

Expand Down
16 changes: 8 additions & 8 deletions github_app_geo_project/module/audit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pathlib import Path
from typing import Any, cast

import aiofiles
import github
import security_md
import yaml
Expand Down Expand Up @@ -153,16 +154,16 @@ async def _process_snyk_dpkg(

ghci_config_path = Path(".github/ghci.yaml")
if context.module_event_data.type in ("snyk", "dpkg") and ghci_config_path.exists():
with ghci_config_path.open(encoding="utf-8") as file:
local_config = yaml.load(file, Loader=yaml.SafeLoader).get("audit", {})
async with aiofiles.open(ghci_config_path, encoding="utf-8") as file:
local_config = yaml.load(await file.read(), Loader=yaml.SafeLoader).get("audit", {})

logs_url = urllib.parse.urljoin(context.service_url, f"logs/{context.job_id}")
if context.module_event_data.type == "snyk":
python_version = ""
tool_versions = Path(".tool-versions")
if tool_versions.exists():
with tool_versions.open(encoding="utf-8") as file:
for line in file:
async with aiofiles.open(tool_versions, encoding="utf-8") as file:
async for line in file:
if line.startswith("python "):
python_version = ".".join(line.split(" ")[1].split(".")[0:2]).strip()
break
Expand Down Expand Up @@ -347,7 +348,7 @@ async def _use_python_version(python_version: str) -> dict[str, str]:
env = os.environ.copy()
bin_paths = list(Path("/pyenv/versions/").glob(f"{python_version}.*/bin"))
if bin_paths:
env["PATH"] = f'{bin_paths[0]}:{env["PATH"]}'
env["PATH"] = f"{bin_paths[0]}:{env['PATH']}"

message = module_utils.AnsiProcessMessage.from_async_artifacts(command, proc, stdout, stderr)
message.title = "Python version"
Expand Down Expand Up @@ -523,8 +524,7 @@ async def process(
if key == _OUTDATED:
all_key_starts.append(_OUTDATED)
else:
for version in versions:
all_key_starts.append(f"{key}{version}")
all_key_starts.extend([f"{key}{version}" for version in versions])

full_repository = f"{context.github_project.owner}/{context.github_project.repository}"
if full_repository in context.transversal_status.repositories:
Expand All @@ -540,7 +540,7 @@ async def process(
)
actions = []
for version in versions:
version = context.module_config.get("version-mapping", {}).get(version, version)
version = context.module_config.get("version-mapping", {}).get(version, version) # noqa: PLW2901
if context.module_event_data.snyk and context.module_config.get("snyk", {}).get(
"enabled",
configuration.ENABLE_SNYK_DEFAULT,
Expand Down
Loading

0 comments on commit ea594f3

Please sign in to comment.