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
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI

on:
push:
branches: [ main ]
tags-ignore: [ '**' ]
pull_request:
branches: [ main ]

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
py-checks:
uses: chatmail/workflows/.github/workflows/py-checks.yml@main
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release to PyPI

on:
push:
tags:
- "v*"

permissions:
contents: read

jobs:
# Lint and build via the shared reusable workflow, which uploads
# the built distributions as a "dist" artifact.
py-checks:
uses: chatmail/workflows/.github/workflows/py-checks.yml@main

# The publish job must stay here in the repo's own workflow: PyPI
# trusted publishing rejects publishes from reusable workflows.
# See https://github.com/pypi/warehouse/issues/11096
publish:
needs: py-checks
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/

- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

(in development)

- adopt shared CI from chatmail/workflows (ruff lint+format, build)
and release via PyPI trusted publishing on v* tags; release.py is
replaced by tagging vX.Y.Z

## 0.17.0

### Features
Expand Down
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

To install use:

pip install cmping
uv tool install cmping

To send and receive from a single chatmail relay:

Expand Down Expand Up @@ -61,23 +61,21 @@ Example output for two-domain ping:

## Developing / Releasing cmping

1. clone the git repository at https://github.com/chatmail/cmping
1. clone the git repository at https://github.com/chatmail/cmping

2. install 'cmping" in editing mode: `pip install -e .`
2. install 'cmping' in editing mode: `uv pip install -e .`

3. edit cmping.py and test, finally commit your changes

4. update CHANGELOG.md with the new version number and changes
CI checks (ruff lint/format, packaging) come from the shared
[chatmail/workflows](https://github.com/chatmail/workflows)
repository; run them locally with `uvx ruff check .` and
`uvx ruff format --check .`

5. install build/release tools: `pip install build twine`
To release, update CHANGELOG.md, then create and push a version tag:

6. run the release script:
git tag -a v0.18.0 -m "Release v0.18.0"
git push origin main v0.18.0

python release.py

The release script will:
- Validate the version in CHANGELOG.md is a proper version jump
- Create and push a git tag for the version
- Build the package and upload to PyPI
- Add a dev changelog entry and commit it
- Print which tag was uploaded to PyPI
The release.yml workflow then builds and publishes to PyPI via
trusted publishing (OIDC); no local twine or PyPI token is involved.
27 changes: 19 additions & 8 deletions cmping.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ def setup_accounts(args, sender_maker, receiver_maker):
try:
sender = sender_maker.get_relay_account(args.relay1)
profiles_created += 1
print_progress("Setting up profiles", profiles_created, total_profiles, profiles_created)
print_progress(
"Setting up profiles", profiles_created, total_profiles, profiles_created
)
except Exception as e:
print(f"\r✗ Failed to setup sender profile on {args.relay1}: {e}")
sys.exit(1)
Expand All @@ -311,9 +313,14 @@ def setup_accounts(args, sender_maker, receiver_maker):
receiver = receiver_maker.get_relay_account(args.relay2)
receivers.append(receiver)
profiles_created += 1
print_progress("Setting up profiles", profiles_created, total_profiles, profiles_created)
print_progress(
"Setting up profiles",
profiles_created,
total_profiles,
profiles_created,
)
except Exception as e:
print(f"\r✗ Failed to setup receiver profile {i+1} on {args.relay2}: {e}")
print(f"\r✗ Failed to setup receiver profile {i + 1} on {args.relay2}: {e}")
sys.exit(1)

# Profile setup complete
Expand Down Expand Up @@ -420,7 +427,9 @@ def wait_online_thread(maker):
t.join()

if online_errors:
print(f"\n✗ Timeout or error waiting for profiles to be online: {online_errors[0]}")
print(
f"\n✗ Timeout or error waiting for profiles to be online: {online_errors[0]}"
)
sys.exit(1)

print_progress("Waiting for profiles to be online", done=True)
Expand All @@ -437,19 +446,19 @@ def perform_ping(args):
Pinger: The pinger object with results
"""
base_accounts_dir = xdg_cache_home().joinpath("cmping")

# Determine unique relays being tested. Using a set to deduplicate when
# relay1 == relay2 (same relay testing), so we only create one RPC context.
relays = {args.relay1, args.relay2}

# Handle --reset option: remove account directories for tested relays
if args.reset:
for relay in relays:
relay_dir = base_accounts_dir.joinpath(relay)
if relay_dir.exists():
print(f"# Removing account directory for {relay}: {relay_dir}")
shutil.rmtree(relay_dir)

# Create per-relay account directories and RPC instances.
relay_contexts = {} # {relay: RelayContext}

Expand Down Expand Up @@ -633,7 +642,9 @@ def __init__(self, args, sender, group, receivers):
@property
def loss(self):
expected_total = self.sent * len(self.receivers)
return 0.0 if expected_total == 0 else (1 - self.received / expected_total) * 100
return (
0.0 if expected_total == 0 else (1 - self.received / expected_total) * 100
)

def send_pings(self):
"""Send ping messages to the group at regular intervals.
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build-backend = "setuptools.build_meta"
name = "cmping"
readme = "README.md"
description = "ping messages between chatmail relays"
requires-python = ">=3.11"
dependencies = [
"deltachat-rpc-server>=2.24.0",
"deltachat-rpc-client>=2.24.0",
Expand All @@ -23,17 +24,15 @@ py-modules = ["cmping"]

[project.urls]
Repository = "https://github.com/chatmail/cmping"
Changelog = "https://github.com/chatmail/cmping/blob/master/CHANGELOG.md"
Changelog = "https://github.com/chatmail/cmping/blob/main/CHANGELOG.md"

[project.scripts]
cmping = "cmping:main"

[tool.pytest.ini_options]
addopts = "-v -ra --strict-markers"

[tool.setuptools.packages.find]
where = ["."]

# The deltachat_rpc_client pytest plugin is not used and would need
# extra dependencies (execnet) to even load.
addopts = "-v -ra --strict-markers -p no:deltachat_rpc_client.pytestplugin"

[tool.ruff]
lint.select = [
Expand Down
Loading