Skip to content

Commit

Permalink
Feature: Transition to uv for dependency management (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpylog authored Oct 23, 2024
1 parent 18532c0 commit 82760e6
Show file tree
Hide file tree
Showing 11 changed files with 616 additions and 491 deletions.
8 changes: 6 additions & 2 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.6.0
rev: v5.0.0
hooks:
- id: check-docstring-first
- id: check-json
Expand Down Expand Up @@ -36,9 +36,13 @@ repos:
exclude: "(^Pipfile\\.lock$)"
# Python hooks
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.6.1'
rev: 'v0.7.0'
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.4.3"
hooks:
- id: pyproject-fmt
14 changes: 0 additions & 14 deletions .ruff.toml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Transition to `uv` for dependency and virtual environment management

### Changed

- Bump mypy from 1.11.0 to 1.11.1 (by @dependabot in [#102](https://github.com/stumpylog/image-cleaner-action/pull/102))
- Bump ruff from 0.5.5 to 0.6.1 (by @dependabot in [#105](https://github.com/stumpylog/image-cleaner-action/pull/105))
- Bump mypy from 1.11.1 to 1.13.0 (by @dependabot in [#120](https://github.com/stumpylog/image-cleaner-action/pull/120))
- Bump ruff from 0.6.1 to 0.7.0 (by @dependabot in [#118](https://github.com/stumpylog/image-cleaner-action/pull/118))
- Bump httpx from 0.27.0 to 0.27.2 (by @dependabot in [#109](https://github.com/stumpylog/image-cleaner-action/pull/109))

## [0.8.0] - 2024-07-30

Expand Down
16 changes: 0 additions & 16 deletions Pipfile

This file was deleted.

404 changes: 0 additions & 404 deletions Pipfile.lock

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This repository contains two actions for solving problems with the GitHub Container Registry.

These

## Ephemeral Image Removal

Many actions in a repository will end up creating a Docker image stored on the GitHub Container Registry
Expand Down
47 changes: 19 additions & 28 deletions ephemeral/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,29 @@ runs:
with:
python-version: '3.11'
-
name: Install pipenv
shell: bash
run: |
pip3 --quiet install --user pipenv==2023.12.1
-
name: Install dependencies
shell: bash
run: |
cd ${{ github.action_path }}/..
pipenv --quiet --python ${{ steps.setup-python.outputs.python-version }} sync
-
name: List installed dependencies
shell: bash
run: |
cd ${{ github.action_path }}/..
pipenv --quiet --python ${{ steps.setup-python.outputs.python-version }} run pip list
name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.x"
-
name: Clean the images
shell: bash
id: ephemeral-image-clean
run: |
cd ${{ github.action_path }}/..
pipenv --quiet \
uv run \
--frozen \
--quiet \
--no-python-downloads \
--no-dev \
--python ${{ steps.setup-python.outputs.python-version }} \
run \
${{ github.action_path }}/../main_ephemeral.py \
--token "${{ inputs.token }}" \
--owner "${{ inputs.owner }}" \
--scheme "${{ inputs.scheme }}" \
--match-regex "${{ inputs.match_regex }}" \
--is-org "${{ inputs.is_org }}" \
--name "${{ inputs.package_name }}" \
--delete "${{ inputs.do_delete }}" \
--loglevel "${{ inputs.log_level }}" \
--repo "${{ inputs.repo_name }}"
${{ github.action_path }}/../main_ephemeral.py \
--token "${{ inputs.token }}" \
--owner "${{ inputs.owner }}" \
--scheme "${{ inputs.scheme }}" \
--match-regex "${{ inputs.match_regex }}" \
--is-org "${{ inputs.is_org }}" \
--name "${{ inputs.package_name }}" \
--delete "${{ inputs.do_delete }}" \
--loglevel "${{ inputs.log_level }}" \
--repo "${{ inputs.repo_name }}"
53 changes: 53 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[project]
name = "image-cleaner-action"
version = "0.8.0"
description = "Tools to cleanup old ghcr.io images when the source is removed"
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"github-action-utils>=1.1",
"httpx[brotli,http2]>=0.27",
]

[tool.ruff]
target-version = "py311"
line-length = 110
respect-gitignore = true
# https://docs.astral.sh/ruff/settings/
fix = true
show-fixes = true

output-format = "grouped"
# https://docs.astral.sh/ruff/rules/
lint.extend-select = [
"COM",
"E",
"EXE",
"F",
"G201",
"I",
"ICN",
"INP",
"ISC",
"PIE",
"PLC",
"PLE",
"PTH",
"RSE",
"RUF",
"SIM",
"TID",
"UP",
"W",
]
# https://docs.astral.sh/ruff/settings/#lintisort
lint.isort.force-single-line = true

[tool.uv]
dev-dependencies = [ "ruff", "pre-commit", "pre-commit-uv", "mypy" ]
2 changes: 2 additions & 0 deletions src/image_cleaner_action/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def hello() -> str:
return "Hello from image-cleaner-action!"
41 changes: 16 additions & 25 deletions untagged/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,26 @@ runs:
with:
python-version: '3.11'
-
name: Install pipenv
shell: bash
run: |
pip3 --quiet install --user pipenv==2023.12.1
-
name: Install dependencies
shell: bash
run: |
cd ${{ github.action_path }}/..
pipenv --quiet --python ${{ steps.setup-python.outputs.python-version }} sync
-
name: List installed dependencies
shell: bash
run: |
cd ${{ github.action_path }}/..
pipenv --quiet --python ${{ steps.setup-python.outputs.python-version }} run pip list
name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.x"
-
name: Clean the images
shell: bash
id: untagged-image-clean
run: |
cd ${{ github.action_path }}/..
pipenv --quiet \
uv run \
--frozen \
--quiet \
--no-python-downloads \
--no-dev \
--python ${{ steps.setup-python.outputs.python-version }} \
run \
${{ github.action_path }}/../main_untagged.py \
--token "${{ inputs.token }}" \
--owner "${{ inputs.owner }}" \
--is-org "${{ inputs.is_org }}" \
--name "${{ inputs.package_name }}" \
--delete "${{ inputs.do_delete }}" \
--loglevel "${{ inputs.log_level }}"
${{ github.action_path }}/../main_untagged.py \
--token "${{ inputs.token }}" \
--owner "${{ inputs.owner }}" \
--is-org "${{ inputs.is_org }}" \
--name "${{ inputs.package_name }}" \
--delete "${{ inputs.do_delete }}" \
--loglevel "${{ inputs.log_level }}"
Loading

0 comments on commit 82760e6

Please sign in to comment.