Skip to content

Commit

Permalink
Merge branch 'release/0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpylog committed Jul 30, 2024
2 parents f39c67c + 8e79040 commit 0924047
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 180 deletions.
15 changes: 7 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
repos:
# General hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-docstring-first
- id: check-json
Expand All @@ -25,8 +25,8 @@ repos:
- svg
- id: check-case-conflict
- id: detect-private-key
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.3.3"
hooks:
- id: prettier
types_or:
Expand All @@ -36,10 +36,9 @@ repos:
exclude: "(^Pipfile\\.lock$)"
# Python hooks
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.5'
rev: 'v0.5.5'
hooks:
# Run the linter.
- id: ruff
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.0
hooks:
- id: black
# Run the formatter.
- id: ruff-format
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.0] - 2024-07-30

### Fixed

- Resolved various reported issues from mypy

### Changed

- Bulk update of pre-commit hooks
- Bump certifi from 2024.2.2 to 2024.7.4 (by @dependabot in [#94](https://github.com/stumpylog/image-cleaner-action/pull/94))
- Bump ruff from 0.5.0 to 0.5.2 (by @dependabot in [#96](https://github.com/stumpylog/image-cleaner-action/pull/96))
- Bump setuptools from 69.5.1 to 70.0.0 (by @dependabot in [#97](https://github.com/stumpylog/image-cleaner-action/pull/97))
- Bump mypy from 1.10.1 to 1.11.0 (by @dependabot in [#99](https://github.com/stumpylog/image-cleaner-action/pull/99))
- Bump ruff from 0.5.2 to 0.5.5 (by @dependabot in [#100](https://github.com/stumpylog/image-cleaner-action/pull/100))
- Bump pre-commit from 3.7.1 to 3.8.0 (by @dependabot in [#101](https://github.com/stumpylog/image-cleaner-action/pull/101))

## [0.7.0] - 2024-06-03

### Changed
Expand Down
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ github-action-utils = "*"

[dev-packages]
ruff = "*"
black = "*"
pre-commit = "*"
mypy = "*"

Expand Down
210 changes: 75 additions & 135 deletions Pipfile.lock

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions github/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ def _read_all_pages(self, endpoint: str, query_params: dict | None = None):
logger.error(msg)

# If forbidden, check if it is rate limiting
if (
resp.status_code == HTTPStatus.FORBIDDEN
and "X-RateLimit-Remaining" in resp.headers
):
if resp.status_code == HTTPStatus.FORBIDDEN and "X-RateLimit-Remaining" in resp.headers:
remaining = int(resp.headers["X-RateLimit-Remaining"])
if remaining <= 0:
raise RateLimitError
Expand Down
26 changes: 12 additions & 14 deletions github/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def versions(
)

# Always request the max allowed per page
query_params = {"per_page": 100}
query_params: dict[str, str | int] = {"per_page": 100}

# Filter to the requested state, if any
if active is not None:
Expand Down Expand Up @@ -127,10 +127,7 @@ def delete(self, package_data: ContainerPackage):
resp = self._client.delete(package_data.url)
if resp.status_code != HTTPStatus.NO_CONTENT:
# If forbidden, check if it is rate limiting
if (
resp.status_code == HTTPStatus.FORBIDDEN
and "X-RateLimit-Remaining" in resp.headers
):
if resp.status_code == HTTPStatus.FORBIDDEN and "X-RateLimit-Remaining" in resp.headers:
remaining = int(resp.headers["X-RateLimit-Remaining"])
if remaining <= 0:
raise RateLimitError
Expand Down Expand Up @@ -158,10 +155,7 @@ def restore(
resp = self._client.post(endpoint)
if resp.status_code != HTTPStatus.NO_CONTENT:
# If forbidden, check if it is rate limiting
if (
resp.status_code == HTTPStatus.FORBIDDEN
and "X-RateLimit-Remaining" in resp.headers
):
if resp.status_code == HTTPStatus.FORBIDDEN and "X-RateLimit-Remaining" in resp.headers:
remaining = int(resp.headers["X-RateLimit-Remaining"])
if remaining <= 0:
raise RateLimitError
Expand All @@ -181,11 +175,13 @@ class GithubContainerRegistryOrgApi(_GithubContainerRegistryApiBase):
This class is for organizations
"""

PACKAGE_VERSIONS_ENDPOINT = (
"/orgs/{ORG}/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions"
PACKAGE_VERSIONS_ENDPOINT = "/orgs/{ORG}/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions"
PACKAGE_VERSION_DELETE_ENDPOINT = (
"/orgs/{ORG}/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions/{PACKAGE_VERSION_ID}"
)
PACKAGE_VERSION_RESTORE_ENDPOINT = (
"/orgs/{ORG}/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions/{PACKAGE_VERSION_ID}/restore"
)
PACKAGE_VERSION_DELETE_ENDPOINT = "/orgs/{ORG}/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions/{PACKAGE_VERSION_ID}" # noqa: E501
PACKAGE_VERSION_RESTORE_ENDPOINT = "/orgs/{ORG}/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions/{PACKAGE_VERSION_ID}/restore" # noqa: E501


class GithubContainerRegistryUserApi(_GithubContainerRegistryApiBase):
Expand All @@ -199,4 +195,6 @@ class GithubContainerRegistryUserApi(_GithubContainerRegistryApiBase):
PACKAGE_VERSION_DELETE_ENDPOINT = (
"/user/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions/{PACKAGE_VERSION_ID}"
)
PACKAGE_VERSION_RESTORE_ENDPOINT = "/user/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions/{PACKAGE_VERSION_ID}/restore" # noqa: E501
PACKAGE_VERSION_RESTORE_ENDPOINT = (
"/user/packages/{PACKAGE_TYPE}/{PACKAGE_NAME}/versions/{PACKAGE_VERSION_ID}/restore"
)
6 changes: 1 addition & 5 deletions main_ephemeral.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ def _main() -> None:
#
# Step 1 - gather the active package information
#
container_reg_class = (
GithubContainerRegistryOrgApi
if config.is_org
else GithubContainerRegistryUserApi
)
container_reg_class = GithubContainerRegistryOrgApi if config.is_org else GithubContainerRegistryUserApi
with container_reg_class(
config.token,
config.owner_or_org,
Expand Down
9 changes: 2 additions & 7 deletions main_untagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def __init__(self, args) -> None:

def _main() -> None:
parser = common_args(
"Using the GitHub API locate and optionally delete container"
"images which are untagged",
"Using the GitHub API locate and optionally delete container images which are untagged",
)

config = Config(parser.parse_args())
Expand Down Expand Up @@ -63,11 +62,7 @@ def _main() -> None:
#
# Step 1 - gather the active package information
#
container_reg_class = (
GithubContainerRegistryOrgApi
if config.is_org
else GithubContainerRegistryUserApi
)
container_reg_class = GithubContainerRegistryOrgApi if config.is_org else GithubContainerRegistryUserApi
with container_reg_class(
config.token,
config.owner_or_org,
Expand Down
9 changes: 5 additions & 4 deletions regtools/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ def _handle_docker_inspect_with_timeout(name: str) -> dict:
max_retries = 4
wait_time_s = 5.0
data = None
if shutil.which("docker") is None:
docker_exe = shutil.which("docker")
if docker_exe is None:
raise OSError("docker executable not found")

while (retry_count < max_retries) and data is None:
try:
proc = subprocess.run(
[
shutil.which("docker"),
docker_exe,
"buildx",
"imagetools",
"inspect",
Expand Down Expand Up @@ -113,8 +115,7 @@ def is_multi_arch(self) -> bool:
"application/vnd.oci.image.index.v1+json",
"application/vnd.docker.distribution.manifest.list.v2+json",
}
and "application/vnd.oci.image.layer"
not in self._data["manifests"][0]["mediaType"]
and "application/vnd.oci.image.layer" not in self._data["manifests"][0]["mediaType"]
)

@property
Expand Down
4 changes: 2 additions & 2 deletions version/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Final

_version: Final[tuple[int, int, int]] = (0, 7, 0)
_version: Final[tuple[int, int, int]] = (0, 8, 0)

version = ".".join(_version)
version = ".".join(map(str, _version))

0 comments on commit 0924047

Please sign in to comment.