Skip to content

Commit

Permalink
Clear release notes and the migration script
Browse files Browse the repository at this point in the history
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
  • Loading branch information
llucax committed Nov 22, 2024
1 parent fea7837 commit 04845f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 143 deletions.
30 changes: 13 additions & 17 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,28 @@

## Summary

This version accumulates a few improvements, and bumps the dependency of setuptools to use v75, which is compatible with PEP625, which is necessary to be able to keep uploading to PyPI, so you should upgrade to this version as soon as possible.

The migration script was also rewritten in Python, so it should be more compatible with different OSes.
<!-- Here goes a general summary of what this release is about -->

## Upgrading

- The `frequenz.repo.config.github.abort()` function now takes most arguments as keyword-only arguments.
- The *Queue PRs for v0.x.x* GitHub ruleset was renamed to *Queue PRs for the default branch* and now targets the default branch. It also only have the merge queue restriction, all other restrictions were removed as they are already present in the *Protect version branches* ruleset. You might want to re-import this ruleset to your repositories.
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->

### Cookiecutter template

<!-- Here upgrade steps for cookiecutter specifically -->

## New Features

* Added a new GitHub branch ruleset for Rust projects.
<!-- Here goes the main new features and examples or instructions on how to use them -->

### Cookiecutter template

* Group GitHub Actions dependabot updates.
* API projects don't include the `google-common-protos` dependency by default.
* API projects updated the `grpcio` dependency to `1.66.1`.
* API projects updated the `frequenz-api-common` dependency to `0.6`.
* Bump most of the dependencies.
* Change `edit_uri` default branch to v0.x.x in mkdocs.yml.
* Added a new default option `asyncio_default_fixture_loop_scope = "function"` for `pytest-asyncio` as not providing a value is deprecated.
* The migration script is now written in Python, so it should be (hopefully) more compatible with different OSes.
* Disable more `pylint` checks that are also checked by `mypy` to avoid false positives.
* Remove the redundant `--platform` from the testing dockerfile.
<!-- Here new features for cookiecutter specifically -->

## Bug Fixes

* Sybil now parses the `__init__.py` file as well. Previously it was disabled due to an upstream bug.
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->

### Cookiecutter template

<!-- Here bug fixes for cookiecutter specifically -->
132 changes: 6 additions & 126 deletions cookiecutter/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
from typing import SupportsIndex


def main() -> None:
"""Run the migration steps."""
# Add a separation line like this one after each migration step.
print("=" * 72)


def apply_patch(patch_content: str) -> None:
"""Apply a patch using the patch utility."""
subprocess.run(["patch", "-p1"], input=patch_content.encode(), check=True)
Expand Down Expand Up @@ -92,132 +98,6 @@ def replace_file_contents_atomically( # noqa; DOC501
raise


def add_pylint_checks() -> None:
"""Add new pylint checks to the project."""
pyproject_toml = Path("pyproject.toml")
print(
f"{pyproject_toml}: Skip some flaky pylint checks that are checked better by mypy."
)
marker = ' "no-member",\n'
pyproject_toml_content = pyproject_toml.read_text(encoding="utf-8")
if pyproject_toml_content.find(marker) == -1:
manual_step(
f"""\
{pyproject_toml}: We couldn't find the marker {marker!r} in the file.
Please add the following lines to the file manually in the
`[tool.pylint.messages_control]` section, under the `disable` key (ideally below other
checks that are disabled because `mypy` already checks them) if they are missing:
"no-name-in-module",
"possibly-used-before-assignment",
"""
)
return

replacement = ""
if pyproject_toml_content.find("possibly-used-before-assignment") == -1:
replacement += ' "possibly-used-before-assignment",\n'
if pyproject_toml_content.find("no-name-in-module") == -1:
replacement += ' "no-name-in-module",\n'

if not replacement:
print(f"{pyproject_toml}: seems to be already up-to-date.")
return

replace_file_contents_atomically(
pyproject_toml, marker, marker + replacement, content=pyproject_toml_content
)


def fix_default_fixture_scope() -> None:
"""Fix the default scope of fixtures to 'function'."""
pyproject_toml = Path("pyproject.toml")
print(f"{pyproject_toml}: Fix the default scope of fixtures to 'function'.")
marker = 'asyncio_mode = "auto"\n'
pyproject_toml_content = pyproject_toml.read_text(encoding="utf-8")
if pyproject_toml_content.find(marker) == -1:
manual_step(
f"""\
{pyproject_toml}: We couldn't find the marker {marker!r} in the file.
Please add the following line to the file manually in the
`[tool.pytest.ini_options]` section if it is missing:
asyncio_default_fixture_loop_scope = "function"
"""
)
return

replacement = 'asyncio_default_fixture_loop_scope = "function"\n'
if pyproject_toml_content.find(replacement) >= 0:
print(f"{pyproject_toml}: seems to be already up-to-date.")
return
replace_file_contents_atomically(
pyproject_toml, marker, marker + replacement, content=pyproject_toml_content
)


def main() -> None:
"""Run the migration steps."""
# Dependabot patch
dependabot_yaml = Path(".github/dependabot.yml")
print(f"{dependabot_yaml}: Add new grouping for actions/*-artifact updates.")
if dependabot_yaml.read_text(encoding="utf-8").find("actions/*-artifact") == -1:
apply_patch(
"""\
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -39,3 +39,11 @@ updates:
labels:
- "part:tooling"
- "type:tech-debt"
+ groups:
+ compatible:
+ update-types:
+ - "minor"
+ - "patch"
+ artifacts:
+ patterns:
+ - "actions/*-artifact"
"""
)
else:
print(f"{dependabot_yaml}: seems to be already up-to-date.")
print("=" * 72)

# Fix labeler configuration
labeler_yml = ".github/labeler.yml"
print(f"{labeler_yml}: Fix the labeler configuration example.")
replace_file_contents_atomically(
labeler_yml, "all-glob-to-all-file", "all-globs-to-all-files"
)
print("=" * 72)

# Add new pylint checks
add_pylint_checks()
print("=" * 72)

# Remove redundant --platform from the dockerfile
dockerfile = Path(".github/containers/test-installation/Dockerfile")
print(f"{dockerfile}: Removing redundant --platform.")
if dockerfile.is_file():
replace_file_contents_atomically(
dockerfile, "--platform=${TARGETPLATFORM} ", ""
)
else:
print(f"{dockerfile}: Not found.")
print("=" * 72)

# Make sure `edit_uri` points to the default branch
manual_step(
"Make sure that the `edit_uri` in the `mkdocs.yml` file points to the default branch."
)
print("=" * 72)

# Fix the default scope of fixtures to 'function'
fix_default_fixture_scope()

# Add a separation line like this one after each migration step.
print("=" * 72)


def manual_step(message: str) -> None:
"""Print a manual step message in yellow."""
print(f"\033[0;33m>>> {message}\033[0m")
Expand Down

0 comments on commit 04845f4

Please sign in to comment.