Skip to content
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: 3 additions & 3 deletions .ci/bootstrap_catdog.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -euv
set -eu

GITHUB_EVENT_NAME="${GITHUB_EVENT_NAME:-not_pull_request}"
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]
Expand All @@ -23,8 +23,8 @@ sed -i "s/disabled_redis_runners: \[\]/disabled_redis_runners: [s3]/g" ../pulp_c
cd ../pulp_catdog

# ignore unused imports
flake8 .ci || exit 1 # check ci files before ignoring imports
sed -i -e '/^ignore/s/$/,F401/' .flake8
ruff check .ci || exit 1 # check ci files before ignoring imports
echo $'[tool.ruff.lint]\nignore = [ "F401" ]' >> pyproject.toml

# include post_before_script to generate migrations
cp ../plugin_template/.ci/post_before_script.sh .github/workflows/scripts
Expand Down
2 changes: 1 addition & 1 deletion .ci/post_before_script.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

set -euv
set -eu

cmd_prefix pulpcore-manager makemigrations
cmd_user_prefix pulpcore-manager migrate
25 changes: 0 additions & 25 deletions .flake8

This file was deleted.

18 changes: 7 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ jobs:
- name: "Lint plugin_template"
working-directory: "plugin_template"
run: |
pip3 install black~=26.3 flake8
black --version
black --check --diff plugin-template utils.py
flake8 plugin-template utils.py
pip3 install ruff
ruff format --check --diff plugin-template utils.py
ruff check --diff plugin-template utils.py
- name: "Bootstrap catdog plugin"
working-directory: "plugin_template"
run: |
Expand All @@ -49,16 +48,13 @@ jobs:
run: |
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows

# run black separately from flake8 to get a diff
- name: "Run black"
- name: "Check formatting"
run: |
black --version
black --check --diff .
ruff format --check --diff

# Lint code.
- name: "Run flake8"
- name: "Lint code"
run: |
flake8
ruff check --diff

- name: "Check for common gettext problems"
run: |
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ You can edit them according to your needs to control subsequent calls to `plugin
The following settings are stored in `template_config.yml`.

```bash
black Boolean, whether to use black to format python source files.

flake8 Boolean, whether to use flake8 to lint python source files.

check_commit_message Include inspection of commit message for a reference to an issue in
pulp.plan.io.

Expand Down Expand Up @@ -118,9 +114,6 @@ The following settings are stored in `template_config.yml`.
layers in Containerfile configuring the base Pulp image. `<scenario>` is one
of "azure", "s3", "gcp".

pydocstyle Boolean, whether to have flake8 use pydocstyle to check for compliance with
Python docstring conventions.

release_user The GitHub user that is associated with the RELEASE_TOKEN secret on GitHub.
The username and token are used to push the Changelog and version bump commits
created by the release workflow. The default is 'pulpbot'.
Expand Down
43 changes: 25 additions & 18 deletions plugin-template
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "black~=26.3",
# "jamldump>=1.2.0,<1.3.0",
# "jinja2>=3.1.6,<3.2.0",
# "jamldump>=1.2.0,<1.3",
# "jinja2>=3.1.6,<3.2",
# "packaging>=26.0,<27",
# "pyyaml>=6.0.3,<6.1.0",
# "pyyaml>=6.0.3,<6.1",
# "requests~=2.32.3",
# "requests-cache>=1.3.0,<1.4.0",
# "tomlkit>=0.14.0,<0.14.1",
# "requests-cache>=1.3.0,<1.4",
# "ruff>=0.15.11,<0.16",
# "tomlkit>=0.14.0,<0.15",
# ]
# ///

Expand All @@ -29,7 +29,6 @@ from jinja2 import Environment, FileSystemLoader
import utils

DEFAULT_SETTINGS = {
"black": True,
"check_commit_message": True,
"check_gettext": True,
"check_manifest": True,
Expand All @@ -46,10 +45,9 @@ DEFAULT_SETTINGS = {
"disabled_redis_runners": [],
"docker_fixtures": False,
"extra_files": [],
"flake8_ignore": [],
"flake8": True,
"github_org": "pulp",
"latest_release_branch": None,
"lint_ignore": [],
"lint_requirements": True,
"os_required_packages": [],
"parallel_test_workers": 8,
Expand Down Expand Up @@ -130,7 +128,6 @@ DEFAULT_SETTINGS = {
},
},
},
"pydocstyle": True,
"release_email": "pulp-infra@redhat.com",
"release_user": "pulpbot",
"stalebot_days_until_close": 30,
Expand Down Expand Up @@ -170,6 +167,7 @@ DEPRECATED_FILES = {
".ci/scripts/update_github.sh",
".ci/scripts/update_redmine.sh",
".ci/scripts/upper_bound.py",
".flake8",
".github/template_gitref",
".github/workflows/kanban.yml",
".github/workflows/changelog.yml",
Expand All @@ -188,6 +186,7 @@ DEPRECATED_FILES = {
".github/workflows/scripts/publish_plugin_pypi.sh",
".travis",
".travis.yml",
"dev_requirements.txt",
"flake8.cfg",
"CHANGES/.TEMPLATE.rst",
],
Expand Down Expand Up @@ -321,10 +320,20 @@ def load_config(plugin_config_path: Path, verbose: bool) -> tuple[dict[str, t.An
# Migrate api_root to (scenario) setting
if config["pulp_settings"] is None:
config["pulp_settings"] = {}
config["pulp_settings"].setdefault("api_root", config.get("api_root", "/pulp/"))
write_new_config = True
if "api_root" not in config["pulp_settings"]:
config["pulp_settings"]["api_root"] = "/pulp/"
write_new_config = True
if config["pulp_settings_s3"] is None:
config["pulp_settings_s3"] = {}
config["pulp_settings_s3"].setdefault("api_root", "/rerouted/djnd/")
write_new_config = True
if "api_root" not in config["pulp_settings_s3"]:
config["pulp_settings_s3"]["api_root"] = "/rerouted/djnd/"
write_new_config = True
# Migrate flake8_ignore
if "flake8_ignore" in config:
config["lint_ignore"] = config.pop("flake8_ignore")
write_new_config = True
# remove deprecated options
for key in set(config.keys()) - set(DEFAULT_SETTINGS.keys()):
config.pop(key)
Expand Down Expand Up @@ -385,7 +394,6 @@ def write_template_section(
"current_version": utils.current_version(plugin_root_dir),
"pulpdocs_branch": PULPDOCS_BRANCH,
"is_pulpdocs_member": config["plugin_name"] in utils.get_pulpdocs_members(PULPDOCS_BRANCH),
"black_requirement": utils.black_requirement(),
"config": config,
**config,
}
Expand Down Expand Up @@ -501,11 +509,10 @@ def remove_deprecated_files(plugin_root_dir: Path, sections: list[str]) -> None:


def reformat_files(plugin_root_dir: Path, config: dict[str, t.Any]) -> None:
if config["black"]:
try:
subprocess.run(["black", "--quiet", "."], cwd=plugin_root_dir)
except FileNotFoundError:
pass
try:
subprocess.run(["ruff", "format"], cwd=plugin_root_dir)
except FileNotFoundError:
pass


if __name__ == "__main__":
Expand Down
16 changes: 2 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ title_format = "{version} ({project_date})"
template = "CHANGES/.TEMPLATE.rst"
issue_format = "`#{issue} <https://github.com/pulp/plugin_template/issues/{issue}>`__"

[tool.black]
[tool.ruff]
line-length = 100
target-version = ["py36", "py37", "py38"]
exclude = '''
/(
\.eggs
| \.git
| \.venv
| _build
| build
| dist
| migrations
| docs
)/
'''
extend-exclude = ["templates"]
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# This (black) is copied into templates/github/lint_requirement.txt.j2
black~=26.3 # Pin style to the year. https://black.readthedocs.io/en/stable/faq.html#how-stable-is-black-s-style
jamldump>=1.2.0,<1.3.0
jinja2
packaging>=26.0,<27
pyyaml
requests~=2.32.3
requests_cache
ruff
tomlkit
1 change: 0 additions & 1 deletion scripts/update_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fi

PLUGIN_NAME="$(python ../plugin_template/scripts/get_template_config_value.py plugin_name)"
CI_UPDATE_DOCS="$(python ../plugin_template/scripts/get_template_config_value.py ci_update_docs)"
USE_BLACK="$(python ../plugin_template/scripts/get_template_config_value.py black)"

if [[ "${CI_UPDATE_DOCS}" == "True" ]]; then
DOCS=("--docs")
Expand Down
21 changes: 0 additions & 21 deletions templates/bootstrap/pyproject.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -82,37 +82,16 @@ underlines = ["", "", ""]
name = "Misc"
showcontent = false

{% if black %}
[tool.black]
line-length = 100
target-version = ["py39", "py310", "py311", "py312"]
exclude = '''
/(
\.eggs
| \.git
| \.venv
| _build
| build
| dist
| migrations
| docs
| protobuf
)/
'''
{% endif %}

{% if check_manifest %}
[tool.check-manifest]
ignore = [
".git-blame-ignore-revs",
"AGENTS.md",
"CHANGES/**",
"CLAUDE.md",
"dev_requirements.txt",
"doc_requirements.txt",
"lint_requirements.txt",
"docs/**",
".flake8",
"template_config.yml",
".coveragerc",
".dependabot/config.yml",
Expand Down
14 changes: 3 additions & 11 deletions templates/ci/Makefile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@

.PHONY: format
format:
{%- if black %}
black .
{%- else %}
@echo "No formating configured in this repository."
{%- endif %}
ruff format

.PHONY: lint
lint:
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows
bump-my-version bump --dry-run release
{%- if black %}
black --check --diff .
{%- endif %}
{%- if flake8 %}
flake8
{%- endif %}
ruff format --check --diff
ruff check --diff
{%- if check_manifest %}
check-manifest
{%- endif %}
Expand Down
4 changes: 2 additions & 2 deletions templates/github/.ci/scripts/check_gettext.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# make sure this script runs at the repo root
cd "$(dirname "$(realpath -e "$0")")"/../..

set -uv
set -u

MATCHES=$(grep -n -r --include \*.py "_(f")
MATCHES="$(grep -n -r --include \*.py "_(f" {% for plugin in plugins -%}{{plugin.name | snake }} {% endfor -%})"

if [ $? -ne 1 ]; then
printf "\nERROR: Detected mix of f-strings and gettext:\n"
Expand Down
4 changes: 2 additions & 2 deletions templates/github/.ci/scripts/check_pulpcore_imports.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# make sure this script runs at the repo root
cd "$(dirname "$(realpath -e "$0")")"/../..

set -uv
set -u

# check for imports not from pulpcore.plugin. exclude tests
MATCHES=$(grep -n -r --include \*.py "from pulpcore.*import" . | grep -v "tests\|plugin" {%- for allow in core_import_allowed -%}| grep -v "{{allow}}" {%- endfor -%})
MATCHES="$(grep -n -r --include \*.py "from pulpcore.*import" {% for plugin in plugins -%}{{plugin.name | snake }} {% endfor -%} | grep -v "tests\|plugin" {%- for allow in core_import_allowed -%} | grep -v "{{allow}}" {%- endfor -%})"

if [ $? -ne 1 ]; then
printf "\nERROR: Detected bad imports from pulpcore:\n"
Expand Down
6 changes: 3 additions & 3 deletions templates/github/.ci/scripts/check_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ def main(options: argparse.Namespace, template_config: dict[str, t.Any]) -> int:

if reasons:
curr_version = Version(last_tag)
assert curr_version.base_version.startswith(
branch
), "Current-version has to belong to the current branch!"
assert curr_version.base_version.startswith(branch), (
"Current-version has to belong to the current branch!"
)
next_version = Version(f"{branch}.{curr_version.micro + 1}")
print(
f"A Z-release is needed for {branch}, "
Expand Down
1 change: 0 additions & 1 deletion templates/github/.ci/scripts/check_requirements.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ from packaging.requirements import Requirement
CHECK_MATRIX = [
("pyproject.toml", True, True, True),
("requirements.txt", True, True, True),
("dev_requirements.txt", False, True, False),
("ci_requirements.txt", False, True, True),
("doc_requirements.txt", False, True, False),
("lint_requirements.txt", False, True, True),
Expand Down
Loading