Skip to content

Commit daa51ca

Browse files
committed
Add check for cli and glue dependencies
Plugins need to update these tied together.
1 parent da21dce commit daa51ca

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/bin/env python3
22

3-
import sys
4-
53
import click
64
from packaging.version import parse
75

86
if parse(click.__version__) < parse("8.1.1") or parse(click.__version__) >= parse("8.2"):
97
print("🚧 Linting with mypy is currently only supported with click~=8.1.1. 🚧")
108
print("🔧 Please run `pip install click~=8.1.1` first. 🔨")
11-
sys.exit(1)
9+
exit(1)

cookiecutter/ci/hooks/post_gen_project.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"pulp-glue{{ cookiecutter.__app_label_suffix }}",
3131
"CHANGES/pulp-glue{{ cookiecutter.__app_label_suffix }}",
3232
{%- endif %}
33+
{% if not cookiecutter.app_label -%}
34+
".ci/scripts/check_cli_dependencies.py",
35+
{%- endif %}
3336
]
3437

3538
for path in REMOVE_PATHS:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/env python3
2+
3+
import tomllib
4+
from pathlib import Path
5+
6+
from packaging.requirements import Requirement
7+
8+
if __name__ == "__main__":
9+
base_path = Path(__file__).parent.parent.parent
10+
glue_path = "pulp-glue{{ cookiecutter.__app_label_suffix }}"
11+
with (base_path / "pyproject.toml").open("rb") as fp:
12+
cli_pyproject = tomllib.load(fp)
13+
14+
cli_dependency = next(
15+
(
16+
Requirement(r)
17+
for r in cli_pyproject["project"]["dependencies"]
18+
if r.startswith("pulp-cli")
19+
)
20+
)
21+
22+
with (base_path / glue_path / "pyproject.toml").open("rb") as fp:
23+
glue_pyproject = tomllib.load(fp)
24+
25+
glue_dependency = next(
26+
(
27+
Requirement(r)
28+
for r in glue_pyproject["project"]["dependencies"]
29+
if r.startswith("pulp-glue")
30+
)
31+
)
32+
33+
if cli_dependency.specifier != glue_dependency.specifier:
34+
print("🪢 CLI and GLUE dependencies mismatch:")
35+
print(" ", cli_dependency)
36+
print(" ", glue_dependency)
37+
exit(1)
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/bin/env python3
22

3-
import sys
4-
53
import click
64
from packaging.version import parse
75

86
if parse(click.__version__) < parse("8.1.1") or parse(click.__version__) >= parse("8.2"):
97
print("🚧 Linting with mypy is currently only supported with click~=8.1.1. 🚧")
108
print("🔧 Please run `pip install click~=8.1.1` first. 🔨")
11-
sys.exit(1)
9+
exit(1)

cookiecutter/ci/{{ cookiecutter.__project_name }}/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ lint:
3737
{%- endif %}
3838
black --diff --check .
3939
flake8
40+
{%- if cookiecutter.glue and cookiecutter.app_label %}
41+
.ci/scripts/check_cli_dependencies.py
42+
{%- endif %}
4043
.ci/scripts/check_click_for_mypy.py
4144
{%- if cookiecutter.glue %}
4245
MYPYPATH=pulp-glue{{ cookiecutter.__app_label_suffix }} mypy

0 commit comments

Comments
 (0)