From a3bb61b3c697a569a689df5464d77b8c9660a9ba Mon Sep 17 00:00:00 2001 From: Sumeet Jha <109774891+O1sumitkumar@users.noreply.github.com> Date: Thu, 5 Nov 2026 18:03:34 +0530 Subject: [PATCH 1/4] fix(manage): find the named instance's unit in logs --unit (#239) add_unit built relaysms-publisher-.service without the instance name, so on an install made with --instance-name every short name was an unknown unit. Build it with unit_name_for, as the other commands do. Closes #217 Signed-off-by: Sumeet Jha <109774891+O1sumitkumar@users.noreply.github.com> --- manage.sh | 2 +- tests/scripts/test_manage.py | 77 ++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 tests/scripts/test_manage.py diff --git a/manage.sh b/manage.sh index 39141a6..cc9981b 100755 --- a/manage.sh +++ b/manage.sh @@ -68,7 +68,7 @@ cmd_status() { # the subshell instead of stopping the script. add_unit() { local name="$1" full="$1" svc - [[ "$name" == *.service ]] || full="relaysms-publisher-${name}.service" + [[ "$name" == *.service ]] || full="$(unit_name_for "relaysms-publisher-${name}.service")" for svc in "${SERVICE_UNITS[@]}"; do if [ "$svc" = "$full" ]; then units+=("$full") diff --git a/tests/scripts/test_manage.py b/tests/scripts/test_manage.py new file mode 100644 index 0000000..15d2bcb --- /dev/null +++ b/tests/scripts/test_manage.py @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: GPL-3.0-only + +import os +import shutil +import subprocess + +import pytest + +from tests.scripts import REPO + + +@pytest.fixture +def logs(install, tmp_path): + """Run `manage.sh logs` in the install directory, with journalctl faked.""" + shutil.copy(REPO / "manage.sh", install) + bin_dir = tmp_path / "bin" + bin_dir.mkdir() + journalctl = bin_dir / "journalctl" + journalctl.write_text('#!/usr/bin/env bash\nprintf "%s\\n" "$@"\n') + journalctl.chmod(0o755) + + def run(*args: str, instance: str = "") -> subprocess.CompletedProcess[str]: + if instance: + (install / ".instance-name").write_text(instance) + return subprocess.run( + ["bash", "manage.sh", "logs", "--no-follow", *args], + cwd=install, + env={ + **os.environ, + "NO_COLOR": "1", + "PATH": f"{bin_dir}:{os.environ['PATH']}", + }, + capture_output=True, + text=True, + check=False, + ) + + return run + + +def journal_units(result: subprocess.CompletedProcess[str]) -> list[str]: + assert result.returncode == 0, result.stderr + args = result.stdout.splitlines() + return [args[i + 1] for i, arg in enumerate(args) if arg == "-u"] + + +class TestLogsUnit: + def test_short_name_selects_the_unit(self, logs): + assert journal_units(logs("--unit", "rest")) == [ + "relaysms-publisher-rest.service" + ] + + def test_short_name_selects_the_named_instance_unit(self, logs): + result = logs("--unit", "rest", "-u", "worker", "--unit=beat", instance="acme") + + assert journal_units(result) == [ + "relaysms-publisher-acme-rest.service", + "relaysms-publisher-acme-worker.service", + "relaysms-publisher-acme-beat.service", + ] + + def test_full_name_selects_the_named_instance_unit(self, logs): + result = logs("--unit=relaysms-publisher-acme-grpc.service", instance="acme") + + assert journal_units(result) == ["relaysms-publisher-acme-grpc.service"] + + def test_unknown_name_on_a_named_instance_fails(self, logs): + result = logs("--unit", "nope", instance="acme") + + assert result.returncode != 0 + assert "Unknown service unit: nope" in result.stderr + + def test_unit_of_another_instance_fails(self, logs): + result = logs("--unit", "relaysms-publisher-rest.service", instance="acme") + + assert result.returncode != 0 + assert "Unknown service unit: relaysms-publisher-rest.service" in result.stderr From 7e8e2c75961e1df2bdcf869238d6ffb14b3fcce7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 17:24:35 +0000 Subject: [PATCH 2/4] chore(deps): bump the python group with 17 updates Bumps the python group with 17 updates: | Package | From | To | | --- | --- | --- | | [cachetools](https://github.com/tkem/cachetools) | `7.2.5` | `7.2.8` | | [grpcio](https://github.com/grpc/grpc) | `1.85.0` | `1.85.1` | | [grpcio-health-checking](https://grpc.io) | `1.85.0` | `1.85.1` | | [grpcio-testing](https://grpc.io) | `1.85.0` | `1.85.1` | | [grpcio-tools](https://github.com/grpc/grpc) | `1.85.0` | `1.85.1` | | [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python) | `1.45.1` | `1.45.2` | | [phonenumbers](https://github.com/daviddrysdale/python-phonenumbers) | `9.0.41` | `9.0.42` | | [opentelemetry-distro](https://github.com/open-telemetry/opentelemetry-python-contrib) | `0.66b1` | `0.66b2` | | [opentelemetry-exporter-otlp-proto-grpc](https://github.com/open-telemetry/opentelemetry-python) | `1.45.1` | `1.45.2` | | [opentelemetry-instrumentation-celery](https://github.com/open-telemetry/opentelemetry-python-contrib) | `0.66b1` | `0.66b2` | | [opentelemetry-instrumentation-fastapi](https://github.com/open-telemetry/opentelemetry-python-contrib) | `0.66b1` | `0.66b2` | | [opentelemetry-instrumentation-grpc](https://github.com/open-telemetry/opentelemetry-python-contrib) | `0.66b1` | `0.66b2` | | [opentelemetry-instrumentation-logging](https://github.com/open-telemetry/opentelemetry-python-contrib) | `0.66b1` | `0.66b2` | | [opentelemetry-instrumentation-sqlalchemy](https://github.com/open-telemetry/opentelemetry-python-contrib) | `0.66b1` | `0.66b2` | | [opentelemetry-sdk](https://github.com/open-telemetry/opentelemetry-python) | `1.45.1` | `1.45.2` | | [pytest](https://github.com/pytest-dev/pytest) | `9.1.1` | `9.2.0` | | [ruff](https://github.com/astral-sh/ruff) | `0.17.2` | `0.17.3` | Updates `cachetools` from 7.2.5 to 7.2.8 - [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst) - [Commits](https://github.com/tkem/cachetools/compare/v7.2.5...v7.2.8) Updates `grpcio` from 1.85.0 to 1.85.1 - [Release notes](https://github.com/grpc/grpc/releases) - [Commits](https://github.com/grpc/grpc/compare/v1.85.0...v1.85.1) Updates `grpcio-health-checking` from 1.85.0 to 1.85.1 Updates `grpcio-testing` from 1.85.0 to 1.85.1 Updates `grpcio-tools` from 1.85.0 to 1.85.1 - [Release notes](https://github.com/grpc/grpc/releases) - [Commits](https://github.com/grpc/grpc/compare/v1.85.0...v1.85.1) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python/compare/v1.45.1...v1.45.2) Updates `phonenumbers` from 9.0.41 to 9.0.42 - [Commits](https://github.com/daviddrysdale/python-phonenumbers/compare/v9.0.41...v9.0.42) Updates `opentelemetry-distro` from 0.66b1 to 0.66b2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python-contrib/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python-contrib/commits) Updates `opentelemetry-exporter-otlp-proto-grpc` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python/compare/v1.45.1...v1.45.2) Updates `opentelemetry-instrumentation-celery` from 0.66b1 to 0.66b2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python-contrib/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python-contrib/commits) Updates `opentelemetry-instrumentation-fastapi` from 0.66b1 to 0.66b2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python-contrib/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python-contrib/commits) Updates `opentelemetry-instrumentation-grpc` from 0.66b1 to 0.66b2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python-contrib/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python-contrib/commits) Updates `opentelemetry-instrumentation-logging` from 0.66b1 to 0.66b2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python-contrib/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python-contrib/commits) Updates `opentelemetry-instrumentation-sqlalchemy` from 0.66b1 to 0.66b2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python-contrib/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python-contrib/commits) Updates `opentelemetry-sdk` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-python/compare/v1.45.1...v1.45.2) Updates `pytest` from 9.1.1 to 9.2.0 - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/9.1.1...9.2.0) Updates `ruff` from 0.17.2 to 0.17.3 - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.17.2...0.17.3) --- updated-dependencies: - dependency-name: cachetools dependency-version: 7.2.8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: grpcio dependency-version: 1.85.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: grpcio-health-checking dependency-version: 1.85.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: grpcio-testing dependency-version: 1.85.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: grpcio-tools dependency-version: 1.85.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: phonenumbers dependency-version: 9.0.42 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: opentelemetry-distro dependency-version: 0.66b2 dependency-type: direct:production dependency-group: python - dependency-name: opentelemetry-exporter-otlp-proto-grpc dependency-version: 1.45.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: opentelemetry-instrumentation-celery dependency-version: 0.66b2 dependency-type: direct:production dependency-group: python - dependency-name: opentelemetry-instrumentation-fastapi dependency-version: 0.66b2 dependency-type: direct:production dependency-group: python - dependency-name: opentelemetry-instrumentation-grpc dependency-version: 0.66b2 dependency-type: direct:production dependency-group: python - dependency-name: opentelemetry-instrumentation-logging dependency-version: 0.66b2 dependency-type: direct:production dependency-group: python - dependency-name: opentelemetry-instrumentation-sqlalchemy dependency-version: 0.66b2 dependency-type: direct:production dependency-group: python - dependency-name: opentelemetry-sdk dependency-version: 1.45.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python - dependency-name: pytest dependency-version: 9.2.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: python - dependency-name: ruff dependency-version: 0.17.3 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: python ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 4 ++-- requirements-observability.txt | 16 ++++++++-------- requirements.txt | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 36ee718..b741afd 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,6 +3,6 @@ httpx==0.28.1 import-linter==2.15 pre-commit==4.7.0 pyright==1.1.414 -pytest==9.1.1 +pytest==9.2.0 pytest-cov==7.1.0 -ruff==0.17.2 +ruff==0.17.3 diff --git a/requirements-observability.txt b/requirements-observability.txt index 27f8cca..08fe9d3 100644 --- a/requirements-observability.txt +++ b/requirements-observability.txt @@ -5,11 +5,11 @@ # Includes requirements.txt, since both pull in OTel packages that must # resolve to the same versions. -r requirements.txt -opentelemetry-distro==0.66b1 -opentelemetry-exporter-otlp-proto-grpc==1.45.1 -opentelemetry-instrumentation-celery==0.66b1 -opentelemetry-instrumentation-fastapi==0.66b1 -opentelemetry-instrumentation-grpc==0.66b1 -opentelemetry-instrumentation-logging==0.66b1 -opentelemetry-instrumentation-sqlalchemy==0.66b1 -opentelemetry-sdk==1.45.1 +opentelemetry-distro==0.66b2 +opentelemetry-exporter-otlp-proto-grpc==1.45.2 +opentelemetry-instrumentation-celery==0.66b2 +opentelemetry-instrumentation-fastapi==0.66b2 +opentelemetry-instrumentation-grpc==0.66b2 +opentelemetry-instrumentation-logging==0.66b2 +opentelemetry-instrumentation-sqlalchemy==0.66b2 +opentelemetry-sdk==1.45.2 diff --git a/requirements.txt b/requirements.txt index 5822b08..c0a4e4f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,21 +2,21 @@ alembic==1.20.1 argon2-cffi==25.1.0 authres==1.2.0 -cachetools==7.2.5 +cachetools==7.2.8 celery[sqlalchemy,redis]==5.6.3 cryptography==50.0.2 dkimpy==1.1.8 fastapi==0.162.0 GitPython==3.2.1 grpc-interceptor==0.15.4 -grpcio==1.85.0 -grpcio-health-checking==1.85.0 -grpcio-testing==1.85.0 -grpcio-tools==1.85.0 +grpcio==1.85.1 +grpcio-health-checking==1.85.1 +grpcio-testing==1.85.1 +grpcio-tools==1.85.1 imap-tools==1.16.0 msgspec==0.22.0 -opentelemetry-api==1.45.1 -phonenumbers==9.0.41 +opentelemetry-api==1.45.2 +phonenumbers==9.0.42 psycopg2-binary==2.9.13 pymysql==1.2.3 python-dotenv==1.2.4 From bce8e5fa9debef4a57520ec5c905a9e6166fa22c Mon Sep 17 00:00:00 2001 From: ShahadatTest Date: Tue, 10 Nov 2026 16:00:10 +0600 Subject: [PATCH 3/4] fix(config): reject unknown OFFLINE_PUBLISH_ALLOWED_PROTOCOLS entries (#231) Closes #220 --- docs/configuration/offline-publishing.md | 1 + publisher/config.py | 11 ++++++++- tests/test_config.py | 29 +++++++++++++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/docs/configuration/offline-publishing.md b/docs/configuration/offline-publishing.md index 277f23e..49cf80c 100644 --- a/docs/configuration/offline-publishing.md +++ b/docs/configuration/offline-publishing.md @@ -9,6 +9,7 @@ Each payload is tagged with the protocol it arrived on: ## Rules +- Listing anything other than the protocols above fails `manage.sh check`, and the services refuse to start. - An offline payload from a protocol not in `OFFLINE_PUBLISH_ALLOWED_PROTOCOLS` is discarded. An empty list allows every protocol. - An offline payload over `https` must carry `OFFLINE_PUBLISH_SHARED_SECRET` in the request's `tag` field, or it's discarded. - Leaving `OFFLINE_PUBLISH_ALLOWED_PROTOCOLS` empty, or listing `https`, without the secret fails `manage.sh check`, and the services refuse to start. diff --git a/publisher/config.py b/publisher/config.py index ea20c52..deb305e 100644 --- a/publisher/config.py +++ b/publisher/config.py @@ -21,6 +21,7 @@ ROOT = Path(__file__).resolve().parents[1] DATABASE_DIALECTS = ("sqlite", "mysql", "postgres") CELERY_BROKERS = ("sqlite", "redis", "rabbitmq") +OFFLINE_PUBLISH_PROTOCOLS = ("https", "smtp") GITHUB_ORG_PATTERN = re.compile(r"^[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$") # Fill unset variables from .env. Values already in the environment win. @@ -345,7 +346,15 @@ class OfflinePublishConfig(Section): @classmethod def load(cls, read: _Reader) -> Self: - allowed = read.get_list("OFFLINE_PUBLISH_ALLOWED_PROTOCOLS") + names = read.get_list("OFFLINE_PUBLISH_ALLOWED_PROTOCOLS") + allowed = list(dict.fromkeys(name.lower() for name in names)) + for protocol in allowed: + if protocol not in OFFLINE_PUBLISH_PROTOCOLS: + read.fail( + "OFFLINE_PUBLISH_ALLOWED_PROTOCOLS", + f"expected one of {', '.join(OFFLINE_PUBLISH_PROTOCOLS)}, " + f"got {protocol!r}", + ) https_allowed = not allowed or "https" in allowed return cls( allowed_protocols=allowed, diff --git a/tests/test_config.py b/tests/test_config.py index 2564798..6400f2b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -198,7 +198,7 @@ def test_offline_shared_secret_must_be_a_key(): assert offline.shared_secret == KEY -@pytest.mark.parametrize("protocols", ["https", "smtp,https", ""]) +@pytest.mark.parametrize("protocols", ["https", "HTTPS", "smtp,https", ""]) def test_offline_https_requires_shared_secret(protocols): allowed = {"OFFLINE_PUBLISH_ALLOWED_PROTOCOLS": protocols} @@ -206,6 +206,33 @@ def test_offline_https_requires_shared_secret(protocols): assert not errors(**allowed, OFFLINE_PUBLISH_SHARED_SECRET=KEY) +@pytest.mark.parametrize( + ("protocols", "expected"), + [ + ("smtp", ["smtp"]), + ("SMTP", ["smtp"]), + ("https,smtp", ["https", "smtp"]), + ("smtp,smtp", ["smtp"]), + ("smtp,SMTP", ["smtp"]), + ("", []), + ], +) +def test_offline_allowed_protocols_are_normalized(protocols, expected): + offline = load( + OfflinePublishConfig, + OFFLINE_PUBLISH_ALLOWED_PROTOCOLS=protocols, + OFFLINE_PUBLISH_SHARED_SECRET=KEY, + ) + assert offline.allowed_protocols == expected + + +@pytest.mark.parametrize("protocols", ["smpt", "SMTP,ftp", "http"]) +def test_offline_allowed_protocols_reject_unknown_entries(protocols): + problems = errors(OFFLINE_PUBLISH_ALLOWED_PROTOCOLS=protocols) + assert "OFFLINE_PUBLISH_ALLOWED_PROTOCOLS" in problems + assert "OFFLINE_PUBLISH_SHARED_SECRET" not in problems + + def test_template_env_paths_match_defaults(): # scripts/lib.sh falls back to template.env for paths unset in .env. template = dotenv_values(config.ROOT / "template.env") From 550aa4e326cb4c269914f59aeb8342f941cf6403 Mon Sep 17 00:00:00 2001 From: Promise Fru Date: Tue, 10 Nov 2026 11:39:01 +0100 Subject: [PATCH 4/4] ci: close issues named with any closing keyword in the PR or merge commit Signed-off-by: Promise Fru --- .github/workflows/close-issues.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/close-issues.yml b/.github/workflows/close-issues.yml index 58c7fa0..c44c3af 100644 --- a/.github/workflows/close-issues.yml +++ b/.github/workflows/close-issues.yml @@ -1,8 +1,8 @@ name: Close issues -# Closes the issues named with `Closes #` in a PR's description when the -# PR merges to staging. GitHub only acts on that keyword for PRs to the default -# branch. +# Closes the issues named with a closing keyword such as `Closes #` in a +# PR's description or its merged commit message when the PR merges to staging. +# GitHub only acts on these keywords for PRs to the default branch. on: push: branches: [staging] @@ -26,7 +26,9 @@ jobs: const pr = prs.find((p) => p.merged_at && p.base.ref === "staging"); if (!pr) return; - for (const [, issue_number] of (pr.body ?? "").matchAll(/\bcloses:? #(\d+)\b/gi)) { + const text = `${pr.body ?? ""}\n${context.payload.head_commit?.message ?? ""}`; + const pattern = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?):? #(\d+)\b/gi; + for (const [, issue_number] of text.matchAll(pattern)) { const { data: issue } = await github.rest.issues.get({ owner, repo, issue_number }); if (issue.pull_request || issue.state === "closed") continue;