Skip to content

Commit 661267b

Browse files
authored
Merge pull request #164 from mdellweg/cookiecutter
Update cookiecutter
2 parents 0b3a9b1 + d030ff1 commit 661267b

File tree

4 files changed

+97
-3
lines changed

4 files changed

+97
-3
lines changed
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-deb"
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)

.github/workflows/cookiecutter.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
name: "Update CI from cookiecutter"
3+
on:
4+
workflow_dispatch:
5+
6+
defaults:
7+
run:
8+
working-directory: "pulp-cli-deb"
9+
10+
jobs:
11+
update-ci:
12+
runs-on: "ubuntu-latest"
13+
steps:
14+
- uses: "actions/checkout@v4"
15+
with:
16+
repository: "pulp/pulp-cli"
17+
path: "pulp-cli"
18+
- uses: "actions/checkout@v4"
19+
with:
20+
token: "${{ secrets.RELEASE_TOKEN }}"
21+
path: "pulp-cli-deb"
22+
- name: "Set up Python"
23+
uses: "actions/setup-python@v5"
24+
with:
25+
python-version: "3.11"
26+
- name: "Setup git"
27+
run: |
28+
git config user.name pulpbot
29+
git config user.email [email protected]
30+
- name: "Install python dependencies"
31+
run: |
32+
pip install cookiecutter tomlkit
33+
- name: "Apply cookiecutter templates"
34+
run: |
35+
../pulp-cli/cookiecutter/apply_templates.py
36+
if [ "$(git status --porcelain)" ]
37+
then
38+
git add .
39+
git commit -m "Update cookiecutter"
40+
fi
41+
- name: "Create Pull Request"
42+
uses: "peter-evans/create-pull-request@v7"
43+
id: "create_pr"
44+
with:
45+
token: "${{ secrets.RELEASE_TOKEN }}"
46+
title: "Update cookiecutter"
47+
body: ""
48+
branch: "update_cookiecutter"
49+
delete-branch: true
50+
path: "pulp-cli-deb"
51+
- name: "Mark PR automerge"
52+
run: |
53+
gh pr merge --rebase --auto "${{ steps.create_pr.outputs.pull-request-number }}"
54+
if: "steps.create_pr.outputs.pull-request-number"
55+
env:
56+
GH_TOKEN: "${{ secrets.RELEASE_TOKEN }}"
57+
continue-on-error: true
58+
...

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ lint:
2626
cd pulp-glue-deb; isort -c --diff .
2727
black --diff --check .
2828
flake8
29+
.ci/scripts/check_cli_dependencies.py
2930
.ci/scripts/check_click_for_mypy.py
3031
MYPYPATH=pulp-glue-deb mypy
3132
cd pulp-glue-deb; mypy

0 commit comments

Comments
 (0)