gha-utils 4.5.2__tar.gz → 4.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of gha-utils might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gha-utils
3
- Version: 4.5.2
3
+ Version: 4.5.3
4
4
  Summary: ⚙️ CLI helpers for GitHub Actions + reuseable workflows
5
5
  Author-email: Kevin Deldycke <kevin@deldycke.com>
6
6
  Project-URL: Homepage, https://github.com/kdeldycke/workflows
@@ -54,6 +54,13 @@ Requires-Dist: PyDriller~=2.6
54
54
  Requires-Dist: pyproject-metadata~=0.8.0
55
55
  Requires-Dist: tomli~=2.0.1; python_version < "3.11"
56
56
  Requires-Dist: wcmatch>=8.5
57
+ Provides-Extra: test
58
+ Requires-Dist: coverage[toml]~=7.6.0; extra == "test"
59
+ Requires-Dist: pytest~=8.3.1; extra == "test"
60
+ Requires-Dist: pytest-cases~=3.8.3; extra == "test"
61
+ Requires-Dist: pytest-cov~=5.0.0; extra == "test"
62
+ Requires-Dist: pytest-github-actions-annotate-failures~=0.2.0; extra == "test"
63
+ Requires-Dist: pytest-randomly~=3.15.0; extra == "test"
57
64
 
58
65
  # `gha-utils` CLI + reusable workflows
59
66
 
@@ -61,6 +68,7 @@ Requires-Dist: wcmatch>=8.5
61
68
  [![Python versions](https://img.shields.io/pypi/pyversions/gha-utils.svg)](https://pypi.python.org/pypi/gha-utils)
62
69
  [![Type checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
63
70
  [![Unittests status](https://github.com/kdeldycke/workflows/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/kdeldycke/workflows/actions/workflows/tests.yaml?query=branch%3Amain)
71
+ [![Coverage status](https://codecov.io/gh/kdeldycke/workflows/branch/main/graph/badge.svg)](https://app.codecov.io/gh/kdeldycke/workflows)
64
72
 
65
73
  Thanks to this project, I am able to **release Python packages multiple times a day with only 2-clicks**.
66
74
 
@@ -17,4 +17,4 @@
17
17
 
18
18
  from __future__ import annotations
19
19
 
20
- __version__ = "4.5.2"
20
+ __version__ = "4.5.3"
@@ -19,6 +19,7 @@ from __future__ import annotations
19
19
  import logging
20
20
  import re
21
21
  import sys
22
+ from functools import cached_property
22
23
  from pathlib import Path
23
24
  from textwrap import indent
24
25
 
@@ -38,10 +39,20 @@ class Changelog:
38
39
  self.content = initial_changelog
39
40
  logging.debug(f"Initial content set to:\n{self.content}")
40
41
 
41
- def update(self) -> str | None:
42
+ @cached_property
43
+ def current_version(self) -> str | None:
44
+ # Extract current version as defined by bump-my-version.
45
+ config_file = Path("./pyproject.toml").resolve()
46
+ logging.info(f"Open {config_file}")
47
+ config = tomllib.loads(config_file.read_text(encoding="UTF-8"))
48
+ current_version = config["tool"]["bumpversion"]["current_version"]
49
+ logging.info(f"Current version: {current_version}")
50
+ return current_version if current_version else None
51
+
52
+ def update(self) -> str:
42
53
  r"""Adds a new empty entry at the top of the changelog.
43
54
 
44
- Returns ``None`` if initial changelog content has already been updated.
55
+ Will return the same content as the current changelog if it has already been updated.
45
56
 
46
57
  This is designed to be used just after a new release has been tagged. And before a
47
58
  post-release version increment is applied with a call to:
@@ -98,16 +109,6 @@ class Changelog:
98
109
  Would not tag since we are not committing
99
110
  ```
100
111
  """
101
- # Extract current version as defined by bump-my-version.
102
- config_file = Path("./pyproject.toml").resolve()
103
- logging.info(f"Open {config_file}")
104
- config = tomllib.loads(config_file.read_text(encoding="UTF-8"))
105
- current_version = config["tool"]["bumpversion"]["current_version"]
106
- logging.info(f"Current version: {current_version}")
107
- assert current_version
108
-
109
- assert current_version in self.content
110
-
111
112
  # Extract parts of the changelog or set default values.
112
113
  SECTION_START = "##"
113
114
  sections = self.content.split(SECTION_START, 2)
@@ -125,7 +126,7 @@ class Changelog:
125
126
  # Update GitHub's comparison URL to target the main branch.
126
127
  new_entry = re.sub(
127
128
  rf"v{VERSION_REGEX}\.\.\.v{VERSION_REGEX}",
128
- f"v{current_version}...main",
129
+ f"v{self.current_version}...main",
129
130
  new_entry,
130
131
  count=1,
131
132
  )
@@ -143,9 +144,7 @@ class Changelog:
143
144
  )
144
145
  logging.info("New generated section:\n" + indent(new_entry, " " * 2))
145
146
 
146
- # No need to update.
147
- history = f"{current_entry}{past_entries}"
148
- if new_entry in history:
149
- return None
150
- # Recompose full changelog with new top entry.
151
- return f"{changelog_header}{new_entry}{history}"
147
+ history = current_entry + past_entries
148
+ if new_entry not in history:
149
+ history = new_entry + history
150
+ return (changelog_header + history).rstrip()
@@ -187,7 +187,7 @@ def changelog(ctx, source, changelog_path):
187
187
 
188
188
  changelog = Changelog(initial_content)
189
189
  content = changelog.update()
190
- if not content:
190
+ if content == initial_content:
191
191
  logging.warning("Changelog already up to date. Do nothing.")
192
192
  ctx.exit()
193
193
 
@@ -398,11 +398,13 @@ class Metadata:
398
398
  current_version = Metadata.get_current_version()
399
399
 
400
400
  sha_list.append(commit.hash)
401
- include_list.append({
402
- "commit": commit.hash,
403
- "short_sha": commit.hash[:SHORT_SHA_LENGTH],
404
- "current_version": current_version,
405
- })
401
+ include_list.append(
402
+ {
403
+ "commit": commit.hash,
404
+ "short_sha": commit.hash[:SHORT_SHA_LENGTH],
405
+ "current_version": current_version,
406
+ }
407
+ )
406
408
 
407
409
  # Restore the repository to its initial state.
408
410
  if past_commit_lookup:
@@ -412,10 +414,12 @@ class Metadata:
412
414
  logging.debug("Unstash local changes that were previously saved.")
413
415
  git.repo.git.stash("pop")
414
416
 
415
- return Matrix({
416
- "commit": sha_list,
417
- "include": include_list,
418
- })
417
+ return Matrix(
418
+ {
419
+ "commit": sha_list,
420
+ "include": include_list,
421
+ }
422
+ )
419
423
 
420
424
  @cached_property
421
425
  def event_type(self) -> WorkflowEvent | None: # type: ignore[valid-type]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gha-utils
3
- Version: 4.5.2
3
+ Version: 4.5.3
4
4
  Summary: ⚙️ CLI helpers for GitHub Actions + reuseable workflows
5
5
  Author-email: Kevin Deldycke <kevin@deldycke.com>
6
6
  Project-URL: Homepage, https://github.com/kdeldycke/workflows
@@ -54,6 +54,13 @@ Requires-Dist: PyDriller~=2.6
54
54
  Requires-Dist: pyproject-metadata~=0.8.0
55
55
  Requires-Dist: tomli~=2.0.1; python_version < "3.11"
56
56
  Requires-Dist: wcmatch>=8.5
57
+ Provides-Extra: test
58
+ Requires-Dist: coverage[toml]~=7.6.0; extra == "test"
59
+ Requires-Dist: pytest~=8.3.1; extra == "test"
60
+ Requires-Dist: pytest-cases~=3.8.3; extra == "test"
61
+ Requires-Dist: pytest-cov~=5.0.0; extra == "test"
62
+ Requires-Dist: pytest-github-actions-annotate-failures~=0.2.0; extra == "test"
63
+ Requires-Dist: pytest-randomly~=3.15.0; extra == "test"
57
64
 
58
65
  # `gha-utils` CLI + reusable workflows
59
66
 
@@ -61,6 +68,7 @@ Requires-Dist: wcmatch>=8.5
61
68
  [![Python versions](https://img.shields.io/pypi/pyversions/gha-utils.svg)](https://pypi.python.org/pypi/gha-utils)
62
69
  [![Type checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
63
70
  [![Unittests status](https://github.com/kdeldycke/workflows/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/kdeldycke/workflows/actions/workflows/tests.yaml?query=branch%3Amain)
71
+ [![Coverage status](https://codecov.io/gh/kdeldycke/workflows/branch/main/graph/badge.svg)](https://app.codecov.io/gh/kdeldycke/workflows)
64
72
 
65
73
  Thanks to this project, I am able to **release Python packages multiple times a day with only 2-clicks**.
66
74
 
@@ -12,4 +12,5 @@ gha_utils.egg-info/SOURCES.txt
12
12
  gha_utils.egg-info/dependency_links.txt
13
13
  gha_utils.egg-info/entry_points.txt
14
14
  gha_utils.egg-info/requires.txt
15
- gha_utils.egg-info/top_level.txt
15
+ gha_utils.egg-info/top_level.txt
16
+ tests/test_changelog.py
@@ -9,3 +9,11 @@ wcmatch>=8.5
9
9
  [:python_version < "3.11"]
10
10
  backports.strenum~=1.3.1
11
11
  tomli~=2.0.1
12
+
13
+ [test]
14
+ coverage[toml]~=7.6.0
15
+ pytest~=8.3.1
16
+ pytest-cases~=3.8.3
17
+ pytest-cov~=5.0.0
18
+ pytest-github-actions-annotate-failures~=0.2.0
19
+ pytest-randomly~=3.15.0
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  # Docs: https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
3
3
  name = "gha-utils"
4
- version = "4.5.2"
4
+ version = "4.5.3"
5
5
  # Python versions and their status: https://devguide.python.org/versions/
6
6
  requires-python = ">= 3.9"
7
7
  description = "⚙️ CLI helpers for GitHub Actions + reuseable workflows"
@@ -84,6 +84,17 @@ dependencies = [
84
84
  "wcmatch >= 8.5",
85
85
  ]
86
86
 
87
+ [project.optional-dependencies]
88
+ test = [
89
+ "coverage [toml] ~= 7.6.0",
90
+ "pytest ~= 8.3.1",
91
+ # More pytest plugins at: https://docs.pytest.org/en/latest/reference/plugin_list.html
92
+ "pytest-cases ~= 3.8.3",
93
+ "pytest-cov ~= 5.0.0",
94
+ "pytest-github-actions-annotate-failures ~= 0.2.0",
95
+ "pytest-randomly ~= 3.15.0",
96
+ ]
97
+
87
98
  [project.urls]
88
99
  "Homepage" = 'https://github.com/kdeldycke/workflows'
89
100
  "Repository" = 'https://github.com/kdeldycke/workflows'
@@ -94,6 +105,9 @@ dependencies = [
94
105
  [project.scripts]
95
106
  gha-utils = "gha_utils.__main__:main"
96
107
 
108
+ [tool.uv]
109
+ package = true
110
+
97
111
  [tool.setuptools.packages.find]
98
112
  include = ["gha_utils"]
99
113
 
@@ -106,7 +120,7 @@ warn_unreachable = true
106
120
  pretty = true
107
121
 
108
122
  [tool.bumpversion]
109
- current_version = "4.5.2"
123
+ current_version = "4.5.3"
110
124
  allow_dirty = true
111
125
  ignore_missing_files = true
112
126
 
@@ -4,6 +4,7 @@
4
4
  [![Python versions](https://img.shields.io/pypi/pyversions/gha-utils.svg)](https://pypi.python.org/pypi/gha-utils)
5
5
  [![Type checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
6
6
  [![Unittests status](https://github.com/kdeldycke/workflows/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/kdeldycke/workflows/actions/workflows/tests.yaml?query=branch%3Amain)
7
+ [![Coverage status](https://codecov.io/gh/kdeldycke/workflows/branch/main/graph/badge.svg)](https://app.codecov.io/gh/kdeldycke/workflows)
7
8
 
8
9
  Thanks to this project, I am able to **release Python packages multiple times a day with only 2-clicks**.
9
10
 
@@ -0,0 +1,90 @@
1
+ # Copyright Kevin Deldycke <kevin@deldycke.com> and contributors.
2
+ #
3
+ # This program is Free Software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU General Public License
5
+ # as published by the Free Software Foundation; either version 2
6
+ # of the License, or (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
+
17
+ from __future__ import annotations
18
+
19
+ from textwrap import dedent
20
+
21
+ import pytest
22
+
23
+ from gha_utils.changelog import Changelog
24
+
25
+
26
+ @pytest.mark.parametrize(
27
+ ("version", "initial", "updated"),
28
+ [
29
+ ("1.1.1", None, "# Changelog"),
30
+ ("1.1.1", "", "# Changelog"),
31
+ (
32
+ "1.2.1",
33
+ dedent(
34
+ """\
35
+ # Changelog
36
+
37
+ ## [1.2.1 (unreleased)](https://github.com/kdeldycke/extra-platforms/compare/v1.2.0...main)
38
+
39
+ > [!IMPORTANT]
40
+ > This version is not released yet and is under active development.
41
+
42
+ - Fix changelog indention.
43
+
44
+
45
+ """
46
+ ),
47
+ dedent(
48
+ """\
49
+ # Changelog
50
+
51
+ ## [1.2.1 (unreleased)](https://github.com/kdeldycke/extra-platforms/compare/v1.2.0...main)
52
+
53
+ > [!IMPORTANT]
54
+ > This version is not released yet and is under active development.
55
+
56
+ - Fix changelog indention."""
57
+ ),
58
+ ),
59
+ (
60
+ "1.0.0",
61
+ dedent(
62
+ """\
63
+ # Changelog
64
+
65
+ ## [1.0.0 (2024-08-20)](https://github.com/kdeldycke/extra-platforms/compare/v0.0.1...v1.0.0)
66
+
67
+ - Add documentation.
68
+ """
69
+ ),
70
+ dedent(
71
+ """\
72
+ # Changelog
73
+
74
+ ## [1.0.0 (unreleased)](https://github.com/kdeldycke/extra-platforms/compare/v1.0.0...main)
75
+
76
+ > [!IMPORTANT]
77
+ > This version is not released yet and is under active development.
78
+
79
+ ## [1.0.0 (2024-08-20)](https://github.com/kdeldycke/extra-platforms/compare/v0.0.1...v1.0.0)
80
+
81
+ - Add documentation."""
82
+ ),
83
+ ),
84
+ ],
85
+ )
86
+ def test_changelog_update(version, initial, updated):
87
+ changelog = Changelog(initial)
88
+ # Force current version to match the one in the test data.
89
+ changelog.current_version = version
90
+ assert changelog.update() == updated
File without changes
File without changes