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

Update all minor versions (master) (minor) #2037

Merged
merged 2 commits into from
Dec 2, 2024
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
6 changes: 0 additions & 6 deletions .bandit.yaml

This file was deleted.

26 changes: 8 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,35 +100,25 @@ repos:
rev: v0.1.8
hooks:
- id: ripsecrets
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: pyupgrade
- id: ruff-format
args:
- --py39-plus
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- --line-length=110
- repo: https://github.com/PyCQA/prospector
rev: v1.13.3
hooks:
- id: prospector
args:
- --tool=pydocstyle
- --tool=ruff
- --die-on-tool-error
- --output-format=pylint
additional_dependencies:
- prospector-profile-duplicated==1.8.0 # pypi
- prospector-profile-utils==1.12.2 # pypi
- prospector-profile-utils==1.13.0 # pypi
- ruff==0.8.1 # pypi
- repo: https://github.com/mheap/json-schema-spell-checker
rev: main
hooks:
Expand Down
15 changes: 2 additions & 13 deletions .prospector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@ inherits:
- utils:base
- utils:no-design-checks
- utils:fix
- utils:unsafe
- duplicated

doc-warnings: true

ignore-paths:
- c2cciutils/configuration.py

pylint:
disable:
- missing-module-docstring

bandit:
options:
config: .bandit.yaml

pycodestyle:
disable:
# Buggy checks that don't detect strings
- W604 # backticks are deprecated, use 'repr()'
- E221 # multiple spaces before operator
- B113 # Call to requests without timeout (didn't work)
25 changes: 15 additions & 10 deletions c2cciutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
c2cciutils shared utils function.
"""
"""c2cciutils shared utils function."""

import glob
import json
Expand All @@ -18,9 +16,7 @@


def get_repository() -> str:
"""
Get the current GitHub repository like `organization/project`.
"""
"""Get the current GitHub repository like `organization/project`."""
if "GITHUB_REPOSITORY" in os.environ:
return os.environ["GITHUB_REPOSITORY"]

Expand All @@ -44,11 +40,12 @@ def merge(default_config: Any, config: Any) -> Any:
Arguments:
default_config: The default config that will be applied
config: The base config, will be modified

"""
if not isinstance(default_config, dict) or not isinstance(config, dict):
return config

for key in default_config.keys():
for key in default_config:
if key not in config:
config[key] = default_config[key]
else:
Expand All @@ -73,9 +70,7 @@ def get_master_branch(repo: list[str]) -> tuple[str, bool]:


def get_config() -> c2cciutils.configuration.Configuration:
"""
Get the configuration, with project and auto detections.
"""
"""Get the configuration, with project and auto detections."""
config: c2cciutils.configuration.Configuration = {}
if os.path.exists("ci/config.yaml"):
with open("ci/config.yaml", encoding="utf-8") as open_file:
Expand Down Expand Up @@ -155,6 +150,7 @@ def error(
line: The line number of the error
col: The column number of the error
error_type: The kind of error (error or warning)

"""
result = ""
on_ci = os.environ.get("CI", "false").lower() == "true"
Expand Down Expand Up @@ -197,6 +193,7 @@ def compile_re(config: c2cciutils.configuration.VersionTransform, prefix: str =
prefix: The version prefix

Return the compiled transform config.

"""
result = []
for conf in config:
Expand Down Expand Up @@ -226,6 +223,7 @@ def match(

Returns the re match object, the matched config and the value as a tuple
On no match it returns None, value

"""
for conf in config:
matched = conf["from"].match(value)
Expand All @@ -243,6 +241,7 @@ def does_match(value: str, config: list[VersionTransform]) -> bool:
config: The result of `compile`

Returns True it it does match else False

"""
matched, _, _ = match(value, config)
return matched is not None
Expand All @@ -262,6 +261,7 @@ def get_value(matched: Optional[Match[str]], config: Optional[VersionTransform],
value: The default value on returned no match

Return the value

"""
return matched.expand(config.get("to", r"\1")) if matched is not None and config is not None else value

Expand All @@ -272,6 +272,7 @@ def print_versions(config: c2cciutils.configuration.PrintVersions) -> bool:

Arguments:
config: The print configuration

"""
for version in config.get("versions", c2cciutils.configuration.PRINT_VERSIONS_VERSIONS_DEFAULT):
try:
Expand Down Expand Up @@ -310,6 +311,7 @@ def gopass(key: str, default: Optional[str] = None) -> Optional[str]:
default: the value to return if gopass is not found

Return the value

"""
try:
return subprocess.check_output(["gopass", "show", key]).strip().decode()
Expand All @@ -326,6 +328,7 @@ def gopass_put(secret: str, key: str) -> None:
Arguments:
secret: The secret value
key: The key

"""
subprocess.check_output(["gopass", "insert", "--force", key], input=secret.encode())

Expand All @@ -338,6 +341,7 @@ def add_authorization_header(headers: dict[str, str]) -> dict[str, str]:
headers: The headers

Return the headers (to be chained)

"""
try:
token = (
Expand Down Expand Up @@ -375,6 +379,7 @@ def graphql(query_file: str, variables: dict[str, Any], default: Any = None) ->

Return the data result
In case of error it throw an exception

"""
with open(os.path.join(os.path.dirname(__file__), query_file), encoding="utf-8") as query_open:
query = query_open.read()
Expand Down
2 changes: 1 addition & 1 deletion c2cciutils/applications-versions.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://docs.renovatebot.com/modules/datasource/#github-releases-datasource
k3d-io/k3d: v5.7.5 # github-releases
postgresql: 16.1.2 # helm - https://charts.bitnami.com/bitnami
postgresql: 16.2.3 # helm - https://charts.bitnami.com/bitnami
helm/chart-releaser: v1.6.1 # github-releases
4 changes: 1 addition & 3 deletions c2cciutils/applications_definition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Automatically generated file from a JSON schema.
"""
"""Automatically generated file from a JSON schema."""

from typing import Literal, TypedDict, Union

Expand Down
6 changes: 2 additions & 4 deletions c2cciutils/configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Automatically generated file from a JSON schema.
"""
"""Automatically generated file from a JSON schema."""

from typing import Any, Literal, TypedDict, Union

Expand Down Expand Up @@ -721,7 +719,7 @@ class _PrintVersionsVersionsItem(TypedDict, total=False):


class _PublishDockerConfigSnyk(TypedDict, total=False):
"""Checks the published images with Snyk"""
"""Checks the published images with Snyk."""

monitor_args: Union["_PublishDockerSnykMonitorArgsOneof0", "_PublishDockerSnykMonitorArgsOneof1"]
"""
Expand Down
32 changes: 8 additions & 24 deletions c2cciutils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@


class PrintVersions:
"""
Print some tools versions.
"""
"""Print some tools versions."""

def __init__(self, config: c2cciutils.configuration.PrintVersions) -> None:
"""Construct."""
Expand All @@ -24,9 +22,7 @@ def __call__(self) -> None:


class PrintConfig:
"""
Print the configuration.
"""
"""Print the configuration."""

def __init__(self, config: c2cciutils.configuration.Configuration) -> None:
"""Construct."""
Expand All @@ -40,49 +36,37 @@ def __call__(self) -> None:


def print_environment_variables() -> None:
"""
Print the environment variables.
"""
"""Print the environment variables."""
for name, value in sorted(os.environ.items()):
if name != "GITHUB_EVENT":
print(f"{name}: {value}")


def print_github_event_file() -> None:
"""
Print the GitHub event file.
"""
"""Print the GitHub event file."""
if "GITHUB_EVENT_PATH" in os.environ:
with open(os.environ["GITHUB_EVENT_PATH"], encoding="utf-8") as event:
print(event.read())


def print_github_event_object() -> None:
"""
Print the GitHub event object.
"""
"""Print the GitHub event object."""
github_event = json.loads(os.environ["GITHUB_EVENT"])
print(yaml.dump(github_event, indent=2))


def print_python_package_version() -> None:
"""
Print the version of the Python packages.
"""
"""Print the version of the Python packages."""
subprocess.run(["python3", "-m", "pip", "freeze", "--all"]) # pylint: disable=subprocess-run-check


def print_node_package_version() -> None:
"""
Print the version of the Python packages.
"""
"""Print the version of the Python packages."""
subprocess.run(["npm", "list", "--global"]) # pylint: disable=subprocess-run-check


def print_debian_package_version() -> None:
"""
Print the version of the Python packages.
"""
"""Print the version of the Python packages."""
subprocess.run(["dpkg", "--list"]) # pylint: disable=subprocess-run-check


Expand Down
8 changes: 2 additions & 6 deletions c2cciutils/lib/docker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Some utility functions for Docker images.
"""
"""Some utility functions for Docker images."""

import os
import subprocess # nosec: B404
Expand Down Expand Up @@ -102,9 +100,7 @@ def get_dpkg_packages_versions(


def get_versions_config() -> tuple[dict[str, dict[str, str]], bool]:
"""
Get the versions from the config file.
"""
"""Get the versions from the config file."""
if os.path.exists("ci/dpkg-versions.yaml"):
with open("ci/dpkg-versions.yaml", encoding="utf-8") as versions_file:
return (
Expand Down
2 changes: 2 additions & 0 deletions c2cciutils/lib/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ def pypi_login() -> None:
Connect to PyPI using OpenID Connect and mint a token for the user.

See Also
--------
- https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect
- https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-pypi

"""
pypirc_filename = os.path.expanduser("~/.pypirc")

Expand Down
Loading
Loading