Skip to content

Commit 5281510

Browse files
authored
Merge pull request #51 from sadsfae/development
fix: black, syntax, deprecated GHA, rpm vers, sync-back [publish]
2 parents 6c763ca + 4661341 commit 5281510

8 files changed

Lines changed: 318 additions & 67 deletions

File tree

.github/workflows/publish.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ jobs:
1515
pull-requests: write
1616

1717
steps:
18-
- name: Check out code
19-
uses: actions/checkout@v2
20-
with:
21-
fetch-depth: 0
22-
23-
- name: Set up Python
24-
uses: actions/setup-python@v2
25-
with:
26-
python-version: '3.12'
27-
28-
- name: Install dependencies
29-
run: |
30-
python -m pip install --upgrade pip
31-
pip install setuptools wheel twine
32-
33-
- name: Build package
34-
run: python setup.py sdist bdist_wheel
35-
36-
- name: Publish package
37-
env:
38-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
39-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
40-
run: twine upload dist/*
18+
- name: Check out code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install setuptools wheel twine
32+
33+
- name: Build package
34+
run: python setup.py sdist bdist_wheel
35+
36+
- name: Publish package
37+
env:
38+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
39+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
40+
run: twine upload dist/*
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Update RPM Spec and Sync
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Publish Python Package"] # Listens for your existing publish action
6+
types:
7+
- completed
8+
9+
jobs:
10+
update-and-sync:
11+
runs-on: ubuntu-latest
12+
# Only run if the PyPI publish actually succeeded
13+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Configure Git
24+
run: |
25+
git config --global user.name 'github-actions[bot]'
26+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
27+
git fetch origin
28+
29+
- name: Update RPM spec version on latest
30+
run: |
31+
git checkout latest
32+
33+
# Extract version from your __init__.py file
34+
VERSION=$(grep -oP "^__version__ = ['\"]([^'\"]+)['\"]" src/quads_lib/__init__.py | grep -oP "[0-9]+\.[0-9]+\.[0-9]+")
35+
echo "Extracted version: $VERSION"
36+
37+
# Update the spec file
38+
sed -i "s/^%define version.*/%define version $VERSION/" rpm/quads-lib.spec
39+
40+
# Commit and push if there are changes
41+
git add rpm/quads-lib.spec
42+
if ! git diff --staged --quiet; then
43+
# Added [skip ci] so this commit doesn't accidentally trigger other tests
44+
git commit -m "chore: update RPM spec version to $VERSION [skip ci]"
45+
git push origin latest
46+
echo "Updated RPM spec to version $VERSION on latest"
47+
else
48+
echo "No version changes to commit"
49+
fi
50+
51+
- name: Sync back to development
52+
run: |
53+
git checkout development
54+
# Merge the updated latest branch into development
55+
git merge origin/latest --no-edit
56+
git push origin development

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ You can also install the in-development version with::
5858

5959
pip install https://github.com/quadsproject/python-quads-lib/archive/development.zip
6060

61+
RPM Installation
62+
----------------
63+
64+
For Fedora Linux::
65+
66+
dnf copr enable quadsdev/python3-quads -y
67+
dnf install quads-lib
68+
6169

6270
Documentation
6371
=============

ci/bootstrap.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,21 @@ def main():
5959
# This uses sys.executable the same way that the call in
6060
# cookiecutter-pylibrary/hooks/post_gen_project.py
6161
# invokes this bootstrap.py itself.
62-
for line in subprocess.check_output([sys.executable, "-m", "tox", "--listenvs"], universal_newlines=True).splitlines()
62+
for line in subprocess.check_output(
63+
[sys.executable, "-m", "tox", "--listenvs"], universal_newlines=True
64+
).splitlines()
6365
]
6466
tox_environments = [line for line in tox_environments if line.startswith("py")]
6567
for template in templates_path.rglob("*"):
6668
if template.is_file():
6769
template_path = template.relative_to(templates_path).as_posix()
6870
destination = base_path / template_path
6971
destination.parent.mkdir(parents=True, exist_ok=True)
70-
destination.write_text(jinja.get_template(template_path).render(tox_environments=tox_environments))
72+
destination.write_text(
73+
jinja.get_template(template_path).render(
74+
tox_environments=tox_environments
75+
)
76+
)
7177
print(f"Wrote {template_path}")
7278
print("DONE.")
7379

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ignore = [
2222
"E501", # pycodestyle line-too-long
2323
"S105", # Possible hardcoded password
2424
"S106", # Hardcoded password
25+
"COM812", # conflicts with black
26+
"ISC001", # conflicts with black
2527
]
2628
select = [
2729
"B", # flake8-bugbear

src/quads_lib/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ def __exit__(self, exc_type, exc_value, traceback):
5757
self.session.close()
5858

5959
def _make_request(self, method: str, endpoint: str, data: Optional[dict] = None) -> dict:
60+
full_url = urljoin(self.base_url, endpoint)
6061
_response = self.session.request(
6162
method,
62-
urljoin(self.base_url, endpoint),
63+
full_url,
6364
json=data,
6465
verify=self.verify,
6566
)

src/quads_lib/quads.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def remove_host(self, hostname: str) -> dict:
9090
def is_available(self, hostname: str, data: dict) -> bool:
9191
url_params = urlencode(data)
9292
endpoint = Path("available") / hostname
93-
json_response = self.get(f"{endpoint}?{url_params}")
93+
full_url = f"{endpoint}?{url_params}"
94+
json_response = self.get(full_url)
9495
# Server returns {hostname: "True"} or {hostname: "False"}
9596
return json_response.get(hostname) == "True"
9697

0 commit comments

Comments
 (0)