106 Commits
Author SHA1 Message Date
poli0981 598fe1b825 Merge pull request 'Chore/gitea migration' (#1) from chore/gitea-migration into main
ci / lint (push) Successful in 43s
ci / test (push) Successful in 35s
ci / security (push) Successful in 33s
ci / qodana (push) Successful in 2m46s
Reusable / Security / Secrets (gitleaks) (push) Successful in 10s
Reusable / Security / Rust (cargo-deny) (push) Skipped
Reusable / Security / .NET (NuGetAudit) (push) Skipped
Reusable / Security / SAST (Opengrep) (push) Successful in 23s
Reusable / Security / Dependencies (osv-scanner) (push) Successful in 13s
Security / security (push) Successful in 46s
ci / ci (push) Successful in 2s
Release / release (push) Successful in 36s
Reusable — Announce Release to Discord / announce (push) Successful in 7s
Release / announce (push) Successful in 7s
Reviewed-on: #1
2026-11-23 14:31:01 +00:00
poli0981andClaude Opus 5.5 db5774bc98 ci(security): accept gitleaks' finding on the Mastodon curl example
ci / lint (pull_request) Successful in 1m6s
ci / test (pull_request) Successful in 34s
ci / security (pull_request) Successful in 32s
ci / qodana (pull_request) Successful in 2m48s
ci / ci (pull_request) Successful in 2s
Reusable / Security / Rust (cargo-deny) (pull_request) Skipped
Reusable / Security / .NET (NuGetAudit) (pull_request) Skipped
Reusable / Security / Secrets (gitleaks) (pull_request) Successful in 8s
Reusable / Security / SAST (Opengrep) (pull_request) Successful in 21s
Reusable / Security / Dependencies (osv-scanner) (pull_request) Successful in 12s
Security / security (pull_request) Successful in 42s
The ops security.yml scans the whole history with gitleaks, which flags
`Authorization: Bearer YOUR_TOKEN` in SETUP_NEW_PLATFORMS.md (rule
curl-auth-header, added in 779499c). It is a placeholder for the
reader's own token. .gitleaksignore accepts that one fingerprint, with
the reason, as zizmor.yml does for its findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:21:01 +07:00
poli0981andClaude Opus 5.5 f307010c1c docs(changelog): 1.5.0, the move to Gitea
Reusable / Security / Rust (cargo-deny) (pull_request) Skipped
Reusable / Security / .NET (NuGetAudit) (pull_request) Skipped
ci / lint (pull_request) Successful in 37s
ci / test (pull_request) Successful in 28s
ci / security (pull_request) Successful in 30s
ci / qodana (pull_request) Successful in 2m51s
Reusable / Security / Secrets (gitleaks) (pull_request) Failing after 10s
Reusable / Security / SAST (Opengrep) (pull_request) Successful in 23s
Reusable / Security / Dependencies (osv-scanner) (pull_request) Successful in 13s
Security / security (pull_request) Failing after 46s
ci / ci (pull_request) Successful in 2s
The once-a-day schedule, the 72 h lookback, the new source, issue and
security addresses, Gitea releases, and SonarQube Cloud's removal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:08:54 +07:00
poli0981andClaude Opus 5.5 309cf83cb7 docs: README and setup notes after the move to Gitea
README: where the source, the issue mirror and the contacts are; the
daily 14:47 UTC schedule on the maintainer's runner and the 72 h
lookback; .gitea/workflows and security.yml in the layout; the CI and
notifier secrets; Qodana through the CLI with its report artifact; the
local zizmor/actionlint commands; Gitea branch and tag protection;
Renovate instead of Dependabot. SonarQube Cloud goes from the text and
the badges, the ci badge points at Gitea.

SETUP_NEW_PLATFORMS.md says where secrets go on Gitea, and the
changelog conventions name the Gitea release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:08:40 +07:00
poli0981andClaude Opus 5.5 d0e70f2a59 docs(security): report by e-mail only
GitHub's private vulnerability reporting went with the account, and the
GitLab mirror's issues are public. SECURITY.md sends reports to
security@poli0981.dev and asks for no public issue (runbook §3.4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:08:39 +07:00
poli0981andClaude Opus 5.5 1407f0ef61 fix(links): the project URL in the User-Agent points at Gitea
The bot's User-Agent named the GitHub repository, which went with the
account. It now names the canonical source on git.poli0981.dev
(runbook §3.4). The release-notes script's docstring says Gitea.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:05:44 +07:00
poli0981andClaude Opus 5.5 aaa877f272 ci: the ops repo's security checks, weekly and on every change
A caller of the ops security.yml with `python: true`: gitleaks over the
whole history, Opengrep with the workflow, shell and Python rules, and
osv-scanner over the lock (runbook §3.5 item 2). On pushes to main, pull
requests, and weekly on Thursday 15:47 UTC (22:47 Vietnam), this repo's
slot in the ops registry. Pinned to the same ops commit as the notifiers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:05:33 +07:00
poli0981andClaude Opus 5.5 4c222b1fe1 ci: the bot posts once a day, inside the 13:00-16:00 UTC window
The runner is the maintainer's PC, so scheduled jobs run only in the
13:00-16:00 UTC window, daily at most (runbook §3.2 item 9). notify.yml
moves from three runs a day (06:30, 14:30, 22:30 UTC) to 14:47 UTC
(21:47 Vietnam), the slot the ops registry gives this repo (YA1).

A run waits while the PC is off and is cancelled after 24 h, so the gap
between two runs can now pass 48 h: LOOKBACK_HOURS goes to 72 (workflow
and default), enough for a late start plus one missed day. The state
commit is authored by Gitea's Actions user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:05:16 +07:00
poli0981andClaude Opus 5.5 db15605518 ci(release): a Gitea release instead of gh release create
`gh` only talks to github.com. The release job now creates the release
with gitea-release-action (SHA-pinned, job token), notes from the
changelog as before, pre-release for a suffixed tag, no files (runbook
§1). `releases: write` sits next to `contents: write` until the pilot
shows which one Gitea enforces.

The announce job calls the pinned ops reusable with the secrets by name:
a release made with the job token still fires no `release` event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:05:00 +07:00
poli0981andClaude Opus 5.5 8091671363 ci: ops callers pinned by SHA, secrets passed by name
The notifier callers point at poli0981/.github/.gitea/workflows on Gitea,
pinned to the ops main commit 8e6582a with `ops_ref` at the same SHA, so
the Discord script matches the workflow. That commit carries the notifier
fix for Gitea's workflow_run payload, which tag v2026.11.1 predates; move
the pin when the ops repo is next tagged (Renovate does not bump it).

Secrets are passed by name instead of `secrets: inherit` (runbook §3.2
item 3), so zizmor's secrets-inherit ignore and the ref-pin policy for
poli0981/* go: every `uses:` is now hash-pinned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:05:00 +07:00
poli0981andClaude Opus 5.5 c88a54b376 ci: zizmor and actionlint without Docker
zizmor-action and `docker run rhysd/actionlint` both need a Docker daemon
inside the job, which the Gitea runner's job containers are not given.
zizmor 1.32.0 joins the hash-locked dev tools (a wheel per platform,
lock recompiled on Python 3.14); actionlint 1.7.12 and shellcheck 0.11.0
are release binaries at the ops repo's pinned versions, SHA-256 verified.

Both get the .gitea/workflows files by name, since each only finds
.github/workflows by itself. zizmor runs offline (its online audits ask
GitHub's API). .github/actionlint.yaml ignores only the Gitea features
actionlint does not know, as the ops repo's does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:03:58 +07:00
poli0981andClaude Opus 5.5 25d694ee22 ci(qodana): the Qodana CLI instead of the action
JetBrains/qodana-action needs GitHub's APIs (annotations, PR comment,
reactions). The job now downloads the Qodana CLI at the ops repo's pinned
version, checks its SHA-256 and scans in native mode with the job's
Python 3.15, as before. Findings stay in Qodana Cloud and in a
`qodana-report` artifact (Gitea artifact action); `checks` and
`pull-requests` permissions go.

A local job, not the ops reusable-qodana.yml: the scan needs setup-python
first for QODANA_PYTHON_PATH (runbook §3.5 item 5). Runs by renovate-bot
skip the scan, since Gitea hands same-repo PRs the repo's secrets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:02:29 +07:00
poli0981andClaude Opus 5.5 04e7b181af ci: remove SonarQube Cloud
Dropped in every repo with the move to Gitea (ops decision D1): the
`sonar` job, sonar-project.properties, the coverage.xml hand-off and the
SONAR_TOKEN secret. Qodana stays the code-quality check; pytest-cov keeps
the 95 % coverage floor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:01:52 +07:00
poli0981andClaude Opus 5.5 89a0f8f7d8 chore: Renovate replaces Dependabot
Gitea has no Dependabot (runbook §1). renovate.json extends the shared
preset (poli0981/renovate-config), which pins action digests, groups
non-major updates and holds PyPI releases for 3 days.

requirements-dev.txt goes through Renovate's pip-compile manager, which
re-runs the lock's own header command on the header's Python, so the
hashes stay valid. pip_requirements is off: it would match the same lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:01:07 +07:00
poli0981andClaude Opus 5.5 2a6f0a1027 ci: move the workflows to .gitea/workflows
Gitea Actions reads .gitea/workflows (runbook §3.2 item 1). Same file
names; the contents change in the commits that follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:00:50 +07:00
dependabot[bot] 40083c9812 chore: bump the dev group with 2 updates (#13)
Bumps the dev group: ruff 0.17.3 -> 0.17.4, coverage 7.17.0 -> 7.17.2
(requirements-dev.in and its hash-locked requirements-dev.txt).
2026-11-16 17:04:53 +07:00
poli0981andClaude Opus 5.5 44ea47985b 1.4.2: Qodana Cloud analysis, maintenance mode (#14)
Qodana Cloud analysis in CI (`qodana` job in the `ci` gate: Ultimate
linter qodana-python, native mode with the job's Python 3.15,
qodana.recommended profile, failThreshold 0; settings in qodana.yaml) and
the one problem its first run found (PEP 8 naming: ElementTree imported
as ET in scripts/youtube.py).

The project enters maintenance mode: README badges, notice and section 9
with the policy (no new features, except periodic dependency updates,
High+ CVEs or serious runtime vulnerabilities, features judged truly
necessary, new Python versions). Changelog entry 1.4.2. zizmor 1.32.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 16:59:45 +07:00
dependabot[bot] e086a377e0 ci: bump SonarSource/sonarqube-scan-action from 8.4.0 to 8.4.1 in the actions group (#12)
Bumps the actions group with 1 update:
[SonarSource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action).

Updates `SonarSource/sonarqube-scan-action` from 8.4.0 to 8.4.1
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/sonarsource/sonarqube-scan-action/releases">SonarSource/sonarqube-scan-action's
releases</a>.</em></p>
<blockquote>
<h2>v8.4.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Update dependency node to v26 by <a
href="https://github.com/renovate"><code>@​renovate</code></a>[bot] in
<a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/294">SonarSource/sonarqube-scan-action#294</a></li>
<li>SQSCANGHA-184 Bump undici from 6.28.1 to 6.29.1 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/289">SonarSource/sonarqube-scan-action#289</a></li>
<li>SQSCANGHA-191 Bump scanner-cli version to 8.3.1.16491 by <a
href="https://github.com/jerome-chetelat-sonarsource"><code>@​jerome-chetelat-sonarsource</code></a>
in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/298">SonarSource/sonarqube-scan-action#298</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/jerome-chetelat-sonarsource"><code>@​jerome-chetelat-sonarsource</code></a>
made their first contribution in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/298">SonarSource/sonarqube-scan-action#298</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/SonarSource/sonarqube-scan-action/compare/v8.4.0...v8.4.1">https://github.com/SonarSource/sonarqube-scan-action/compare/v8.4.0...v8.4.1</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/e805d875275f728fac1885b413934be6d7c63f65"><code>e805d87</code></a>
SQSCANGHA-191 Bump scanner-cli version to 8.3.1.16491 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/298">#298</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/5e62cf21accac0b6d7948a329fddbc9e257f4d46"><code>5e62cf2</code></a>
SQSCANGHA-189 docs: remove duplicate README logo (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/295">#295</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/afe7ea15c200170268c076c3e60bd122cb44efc1"><code>afe7ea1</code></a>
SQSCANGHA-184 Bump undici from 6.28.1 to 6.29.1 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/289">#289</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/d86a3b3b8720c2f09b41769717d35b91a9badb7f"><code>d86a3b3</code></a>
Update dependency node to v26 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/294">#294</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/8a538b99a59beddc1c3054a50f9020d988635b96"><code>8a538b9</code></a>
Run build and build-wrapper compatibility checks every weekday (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/292">#292</a>)</li>
<li>See full diff in <a
href="https://github.com/sonarsource/sonarqube-scan-action/compare/4d1dc0c91ee400dcf8a6dddf2f705ac36542e304...e805d875275f728fac1885b413934be6d7c63f65">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=SonarSource/sonarqube-scan-action&package-manager=github_actions&previous-version=8.4.0&new-version=8.4.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-16 16:41:22 +07:00
dependabot[bot] 46187ade32 chore: bump the dev group across 1 directory with 3 updates (#11)
Bumps the dev group with 3 updates in the / directory:
[coverage](https://github.com/coveragepy/coveragepy),
[pytest](https://github.com/pytest-dev/pytest) and
[ruff](https://github.com/astral-sh/ruff).

Updates `coverage` from 7.16.2 to 7.17.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/coveragepy/coveragepy/releases">coverage's
releases</a>.</em></p>
<blockquote>
<h2>7.17.0</h2>
<h2>Version 7.17.0 — 2026-10-22</h2>
<ul>
<li>Dropped support for Python 3.10.</li>
<li>Binary wheels are now provided for iOS and Android. This allows the
use of the optimized C tracer on mobile platforms.</li>
<li>Fix: three or more levels of nested <code>with</code> statements
could make a <code>with</code> line look like a branch with an exit that
can never happen. Using the sys.monitoring core, these phantom branches
were reported as partial. Other cores hid the problem but still counted
the phantom branches in the total. Closes <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/1987">issue
1987</a>.</li>
<li>Fix: a comment or string that merely mentioned <code>if True:</code>
or <code>while True:</code> could mark its line as a branch that is
known to be partial, so a branch that never ran was reported as taken.
These built-in patterns now only match at the start of the statement.
Closes <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2314">issue
2314</a>.</li>
<li>Fix: region detection missed functions defined in unusual places,
such as <code>else</code> and <code>except</code> clauses. This is now
fixed.</li>
<li>Fix: recent versions of the lcov tool complain if the same function
name appears more than once in a report. Python can have multiple
same-named functions in a few ways, for example, getters/setters or
conditionally defined functions. These are now disambiguated by adding a
<code>@&lt;line number&gt;</code> suffix to the function name. Fixes
<em>issue 2335</em>.</li>
<li>Fix: The “Can’t combine statement coverage data with branch data”
error now names the two data files it couldn’t combine. The <a
href="https://coverage.readthedocs.io/en/latest/messages.html#error-cant-combine">error
description</a> in the docs now lists common causes and how to find the
process that wrote the file.</li>
<li>Fix: at coverage totals close to 0 or 100, the XML report could get
incorrect <code>line-rate</code> values like <code>8.333e-05</code> or
<code>1</code>. This is now fixed, closing <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2293">issue
2293</a> and <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2294">issue
2294</a>.</li>
<li>Fix: a parallel data file saved more than once kept the hash of its
first save in its file name. Combining could then skip it as a duplicate
of another file that had the same data at that point, and delete it,
losing the data recorded after the first save. Each save now updates the
hash. This had been a problem since 7.13.1. Fixes <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2338">issue
2338</a>.</li>
<li>Fixes for obscure but legal file names:
<ul>
<li>File names (and plugin names) can contain control characters, which
are legal in POSIX paths but unsafe in reports: in XML 1.0 they make the
document non-well-formed, and in a terminal they act as escape sequences
(colors, title/clipboard sequences, cursor moves that forge output). Now
the XML report, the text and Markdown summary reports, and
<code>coverage debug data</code> replace non-printable characters in
names. Printable names are unchanged.</li>
<li>A file pattern (from <code>include</code>, <code>omit</code>, or a
<code>[paths]</code> alias) containing a newline sent the glob-to-regex
translation into an infinite loop, hanging the process. Newlines in
patterns are now handled like any other character.</li>
</ul>
</li>
<li>Fixes in the implementation of the C tracer:
<ul>
<li>If a plugin’s <code>dynamic_source_filename</code> method raised an
exception, lines in that function could be recorded as belonging to a
different file. Also fixed some minor memory leaks in the C tracer.</li>
<li>The refcount of <code>None</code> was mismanaged during function
calls, including comprehensions. This was unlikely to cause an actual
problem, but is now fixed. Thanks, Andrew Dalke.</li>
<li>The C tracer held borrowed references to dictionary values, which
was unsafe on free-threaded Python. Now it takes its own
references.</li>
<li>An internal error while recording a new file could be reported as a
confusing <code>SystemError</code> instead of the actual exception.</li>
</ul>
</li>
<li>Performance: the text summary report (<code>coverage report</code>)
held on to every file’s parsed source until it finished, so its memory
use grew with the size of the project: ten times or more what 7.14 used
on large projects. Now it keeps only what it needs to print. Fixes <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2277">issue
2277</a>.</li>
<li>Performance: HTML reports should be about 5% faster to produce.</li>
<li>Kept the political banner in the README. Closes <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2344">issue
2344</a>.</li>
</ul>
<p>:arrow_right:  PyPI page: <a
href="https://pypi.org/project/coverage/7.17.0">coverage 7.17.0</a>.
:arrow_right:  To install: <code>python3 -m pip install
coverage==7.17.0</code></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/coveragepy/coveragepy/blob/main/CHANGES.rst">coverage's
changelog</a>.</em></p>
<blockquote>
<h2>Version 7.17.0 — 2026-10-22</h2>
<ul>
<li>
<p>Dropped support for Python 3.10.</p>
</li>
<li>
<p>Binary wheels are now provided for iOS and Android. This allows the
use of
the optimized C tracer on mobile platforms.</p>
</li>
<li>
<p>Fix: three or more levels of nested <code>with</code> statements
could make a <code>with</code>
line look like a branch with an exit that can never happen. Using the
sys.monitoring core, these phantom branches were reported as partial.
Other
cores hid the problem but still counted the phantom branches in the
total.
Closes <code>issue 1987</code>_.</p>
</li>
<li>
<p>Fix: a comment or string that merely mentioned <code>if True:</code>
or
<code>while True:</code> could mark its line as a branch that is known
to be partial,
so a branch that never ran was reported as taken. These built-in
patterns
now only match at the start of the statement. Closes <code>issue
2314</code>_.</p>
</li>
<li>
<p>Fix: region detection missed functions defined in unusual places,
such as
<code>else</code> and <code>except</code> clauses. This is now
fixed.</p>
</li>
<li>
<p>Fix: recent versions of the lcov tool complain if the same function
name
appears more than once in a report. Python can have multiple same-named
functions in a few ways, for example, getters/setters or conditionally
defined functions. These are now disambiguated by adding a
<code>@&lt;line number&gt;</code>
suffix to the function name. Fixes <code>issue 2335</code>.</p>
</li>
<li>
<p>Fix: The &quot;Can't combine statement coverage data with branch
data&quot; error now
names the two data files it couldn't combine. The :ref:<code>error
description &lt;error_cant_combine&gt;</code> in the docs now lists
common causes and how to find the
process that wrote the file.</p>
</li>
<li>
<p>Fix: at coverage totals close to 0 or 100, the XML report could get
incorrect
<code>line-rate</code> values like <code>8.333e-05</code> or
<code>1</code>. This is now fixed, closing
<code>issue 2293</code>_ and <code>issue 2294</code>_.</p>
</li>
<li>
<p>Fix: a parallel data file saved more than once kept the hash of its
first
save in its file name. Combining could then skip it as a duplicate of
another
file that had the same data at that point, and delete it, losing the
data
recorded after the first save. Each save now updates the hash. This had
been
a problem since 7.13.1. Fixes <code>issue 2338</code>_.</p>
</li>
<li>
<p>Fixes for obscure but legal file names:</p>
<ul>
<li>File names (and plugin names) can contain control characters, which
are
legal in POSIX paths but unsafe in reports: in XML 1.0 they make the
document non-well-formed, and in a terminal they act as escape sequences
(colors, title/clipboard sequences, cursor moves that forge output). Now
the XML report, the text and Markdown summary reports, and ``coverage
debug</li>
</ul>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/393ac715ddae841a85452d97edeedd8be8f0cda8"><code>393ac71</code></a>
docs: prep for 7.17.0</li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/14257d31dd4071fdcb9c2c19d7d0a0015556af55"><code>14257d3</code></a>
test: check that 100% files haven't lost coverage</li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/db056ac3f4d380e40d81b97caf227a67d4b46034"><code>db056ac</code></a>
docs: keep the ukraine banner <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2344">#2344</a></li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/6033660c69a6ca6ed19817c8450d3c0c7ac03080"><code>6033660</code></a>
fix: update the data file hash when a parallel data file is saved again
(<a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2339">#2339</a>)</li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/99024b5f8594039b0234c843f54f10bc2ba8513e"><code>99024b5</code></a>
fix: clamp rate in XML report to prevent false 1.0/0.0 rounding and
scientifi...</li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/ff62a027dde688c31943d66aa20542f687218e35"><code>ff62a02</code></a>
refactor: remove unused caching branches</li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/24d0b677d51337484b7db479f7c98f5f34ac32bd"><code>24d0b67</code></a>
fix: KeyError for a with statement at the end of a finally clause (<a
href="https://redirect.github.com/coveragepy/coveragepy/issues/2336">#2336</a>)</li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/934f5b87067e188a7a7cdf23739d874be2b181a8"><code>934f5b8</code></a>
chore: upgrade pip==26.2.2 certifi==2026.10.19</li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/f95c980d8b1c63d8fc698027c2129e5bee25f2fe"><code>f95c980</code></a>
fix: triply nested <code>with</code> statements don't cause false branch
misses <a
href="https://redirect.github.com/coveragepy/coveragepy/issues/1987">#1987</a></li>
<li><a
href="https://github.com/coveragepy/coveragepy/commit/6aaa858dd8fd1fce40af313d1dab1d94fd0176ac"><code>6aaa858</code></a>
docs: more changelog gardening</li>
<li>Additional commits viewable in <a
href="https://github.com/coveragepy/coveragepy/compare/7.16.2...7.17.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `pytest` from 9.1.1 to 9.2.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pytest-dev/pytest/releases">pytest's
releases</a>.</em></p>
<blockquote>
<h2>9.2.0</h2>
<h1>pytest 9.2.0 (2026-10-27)</h1>
<h2>Removals and backward incompatible breaking changes</h2>
<ul>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14716">#14716</a>:
<code>-c</code> now raises a usage error for a path that does not exist,
is a directory, or is in a format pytest has no loader for. Such paths
were previously either ignored or reported as an unhandled
<code>FileNotFoundError</code>.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/8593">#8593</a>:
The <code>indirect</code>, <code>ids</code> and <code>scope</code>
arguments of <code>Metafunc.parametrize()
&lt;pytest.Metafunc.parametrize&gt;</code> -- and therefore of
<code>@pytest.mark.parametrize &lt;pytest.mark.parametrize
ref&gt;</code> -- are now keyword-only.</p>
<p>Passing them positionally was a common source of confusing errors,
e.g. <code>parametrize(&quot;arg1&quot;, &quot;arg2&quot;, [(1,
2)])</code> made the argvalues land in <code>indirect</code> and failed
with <code>indirect fixture '(1, 2)' doesn't exist</code>; such mistakes
now fail with an understandable <code>TypeError</code>. The type
annotations have always declared these arguments as keyword-only.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/993">#993</a>:
Plugin import failures at startup are now reported and classified
instead of escaping as a raw traceback with the accidental exit code
<code>1</code>:</p>
<ul>
<li>a plugin that cannot be found -- via <code>-p</code>,
<code>pytest_plugins</code> or <code>PYTEST_PLUGINS</code> -- exits with
<code>pytest.ExitCode</code> <code>USAGE_ERROR</code> (<code>4</code>),
like a <code>conftest.py</code> that fails to import;</li>
<li>a plugin that is found but raises while importing -- including a
broken <code>pytest11</code> entry point or a missing plugin dependency
-- exits with <code>pytest.ExitCode</code> <code>INTERNAL_ERROR</code>
(<code>3</code>), with the traceback preserved.</li>
</ul>
<p><code>pytest.main</code> now returns these codes instead of raising
<code>ImportError</code>. Also fixed an <code>IndexError</code> from
pytest's own internals when the plugin raised an exception with no
arguments.</p>
</li>
</ul>
<h2>Deprecations (removal in next major release)</h2>
<ul>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14742">#14742</a>:
The private <code>_pytest.python.CallSpec2</code> name has been renamed
to <code>CallSpec</code>.
The old <code>CallSpec2</code> alias remains available for now and will
be removed in pytest 10 or 11.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14755">#14755</a>:
Schedule <em>yield_fixture</em> decorator for removal in pytest 10 or
11.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14774">#14774</a>:
Similarly to the deprecation of class-scoped fixtures defined as
instance methods in pytest 9.1,
<em>all</em> higher-scoped fixtures (<code>module</code>,
<code>package</code>, and <code>session</code>) defined
as instance methods are now deprecated.</p>
<p>They suffer from the same issue the original deprecation only fixed
for
class-scoped fixtures, see <code>10819</code> and
<code>14011</code>.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14808">#14808</a>:
Passing a non-string value to a <code>string</code>-typed ini option now
emits a <code>pytest.PytestRemovedIn10Warning</code>. This affects
<code>[tool.pytest.ini_options]</code> in <code>pyproject.toml</code>.
In pytest 10 this will raise a <code>TypeError</code>, matching the
behavior of the corresponding TOML config path.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/7323">#7323</a>:
Passing <code>bytes</code> to <code>TerminalReporter.write_line()</code>
is now deprecated, pass a <code>str</code> instead.</p>
</li>
</ul>
<h2>New features</h2>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/14743">#14743</a>:
<!-- raw HTML omitted -->Full diff:<!-- raw HTML omitted --> now
contains a legend explaining the <!-- raw HTML omitted -->+<!-- raw HTML
omitted --> &amp; <!-- raw HTML omitted -->-<!-- raw HTML omitted -->
symbols in diff output.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/2781">#2781</a>:
When <code>strict_markers</code> is enabled, marker names used in
<code>-m</code> expressions are now validated against registered
markers.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/6881">#6881</a>:
Added the <code>parametrize_long_str_id_strategy</code> configuration
option to control how long <code>str</code>/<code>bytes</code> parameter
values are handled in auto-generated test IDs. Explicit IDs set via
<code>ids=[...]</code> or <code>pytest.param(..., id=...)</code> are not
affected. Available strategies: <code>short</code> (default, values over
100 chars fall back to <code>argname+index</code>), <code>sha256</code>
(SHA-256 hex digest), <code>legacy</code> (keep full value), and
<code>disallow</code> (error requesting explicit IDs).</li>
</ul>
<h2>Improvements in existing functionality</h2>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/10745">#10745</a>:
A <code>RecursionError</code> whose recursion origin cannot be located
now shows only the
first and last 10 stack frames, matching what pytest already did when
locating
the origin failed outright. Previously the full traceback -- often
around a
thousand near-identical frames -- was rendered, which was both slow and
unreadable. Pass <code>--full-trace</code> to see every frame.</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pytest-dev/pytest/commit/ae1d0ff57b8bd4252da9ade7353523ac0ac73281"><code>ae1d0ff</code></a>
Prepare release version 9.2.0</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/143ce31dea9b12ff2ab6add04361ee01ab114931"><code>143ce31</code></a>
pre-commit: exclude codespell on generated release announcements</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/532dc5fc78f57de5115c5ecc9c6c29257787ada7"><code>532dc5f</code></a>
tox: add attrs dependency to regen, needed in reportingdemo.rst</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/a7b2446ee41a7298d3a0bc22c52f3b8bacae1566"><code>a7b2446</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/15245">#15245</a>
from pytest-dev/claude/project-thread-9jcf91</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/679d09c6945156746e17e9ec0b1c8309bbde3ad3"><code>679d09c</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://redirect.github.com/pytest-dev/pytest/issues/15266">#15266</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/41d12cdbb4a35a7877768d93d8dc50a9117a8d8c"><code>41d12cd</code></a>
docs: clarify typing for yield fixtures</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/b9022ba04a33bfc76b5c9aefb8974755a80bf5ce"><code>b9022ba</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/15182">#15182</a>
from 1871698/docs/improve-getting-started-description</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/16f87a7f364a7362fbfbb204c79a47ad567b4fbd"><code>16f87a7</code></a>
docs: improve getting-started.rst test execution description</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/082ed70e314ee8e1ab117763d17fe801648f7508"><code>082ed70</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/15255">#15255</a>
from pytest-dev/claude/project-thread-eoi3d6</li>
<li><a
href="https://github.com/pytest-dev/pytest/commit/ae37a013763e9c4a143245eda1acdc3c27961685"><code>ae37a01</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/15227">#15227</a>
from pytest-dev/claude/project-thread-4etye4</li>
<li>Additional commits viewable in <a
href="https://github.com/pytest-dev/pytest/compare/9.1.1...9.2.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `ruff` from 0.17.1 to 0.17.3
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/ruff/releases">ruff's
releases</a>.</em></p>
<blockquote>
<h2>0.17.3</h2>
<h2>Release Notes</h2>
<p>Released on 2026-10-26.</p>
<h3>Preview features</h3>
<ul>
<li>[<code>suspicious</code>] Add <code>shared-clock-mock</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29074">#29074</a>)</li>
</ul>
<h3>Bug fixes</h3>
<ul>
<li>[<code>pyupgrade</code>] Avoid incorrect conversions to f-strings
(<code>UP032</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25485">#25485</a>)</li>
</ul>
<h3>Performance</h3>
<ul>
<li>Buffer stdout in <code>ruff format</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29631">#29631</a>)</li>
<li>Specialize ASCII identifier lexing (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29503">#29503</a>)</li>
<li>Speed up identifier and keyword lexing (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29463">#29463</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>[<code>flake8-bandit</code>] Describe what the rule actually checks
for <code>httpx</code> (<code>S113</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/27936">#27936</a>)</li>
</ul>
<h3>Contributors</h3>
<ul>
<li><a
href="https://github.com/itsvedantkumar"><code>@​itsvedantkumar</code></a></li>
<li><a
href="https://github.com/charliermarsh"><code>@​charliermarsh</code></a></li>
<li><a
href="https://github.com/anishgirianish"><code>@​anishgirianish</code></a></li>
</ul>
<h2>Install ruff 0.17.3</h2>
<h3>Install prebuilt binaries via shell script</h3>
<pre lang="sh"><code>curl --proto '=https' --tlsv1.2 -LsSf
https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-installer.sh
| sh
</code></pre>
<h3>Install prebuilt binaries via powershell script</h3>
<pre lang="sh"><code>powershell -ExecutionPolicy Bypass -c &quot;irm
https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-installer.ps1
| iex&quot;
</code></pre>
<h2>Download ruff 0.17.3</h2>
<table>
<thead>
<tr>
<th>File</th>
<th>Platform</th>
<th>Checksum</th>
</tr>
</thead>
<tbody>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-aarch64-apple-darwin.tar.gz">ruff-aarch64-apple-darwin.tar.gz</a></td>
<td>Apple Silicon macOS</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-aarch64-apple-darwin.tar.gz.sha256">checksum</a></td>
</tr>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-x86_64-apple-darwin.tar.gz">ruff-x86_64-apple-darwin.tar.gz</a></td>
<td>Intel macOS</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-x86_64-apple-darwin.tar.gz.sha256">checksum</a></td>
</tr>
<tr>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-aarch64-pc-windows-msvc.zip">ruff-aarch64-pc-windows-msvc.zip</a></td>
<td>ARM64 Windows</td>
<td><a
href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-aarch64-pc-windows-msvc.zip.sha256">checksum</a></td>
</tr>
</tbody>
</table>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md">ruff's
changelog</a>.</em></p>
<blockquote>
<h2>0.17.3</h2>
<p>Released on 2026-10-26.</p>
<h3>Preview features</h3>
<ul>
<li>[<code>suspicious</code>] Add <code>shared-clock-mock</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29074">#29074</a>)</li>
</ul>
<h3>Bug fixes</h3>
<ul>
<li>[<code>pyupgrade</code>] Avoid incorrect conversions to f-strings
(<code>UP032</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25485">#25485</a>)</li>
</ul>
<h3>Performance</h3>
<ul>
<li>Buffer stdout in <code>ruff format</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29631">#29631</a>)</li>
<li>Specialize ASCII identifier lexing (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29503">#29503</a>)</li>
<li>Speed up identifier and keyword lexing (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29463">#29463</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>[<code>flake8-bandit</code>] Describe what the rule actually checks
for <code>httpx</code> (<code>S113</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/27936">#27936</a>)</li>
</ul>
<h3>Contributors</h3>
<ul>
<li><a
href="https://github.com/itsvedantkumar"><code>@​itsvedantkumar</code></a></li>
<li><a
href="https://github.com/charliermarsh"><code>@​charliermarsh</code></a></li>
<li><a
href="https://github.com/anishgirianish"><code>@​anishgirianish</code></a></li>
</ul>
<h2>0.17.2</h2>
<p>Released on 2026-10-22.</p>
<h3>Preview features</h3>
<ul>
<li>[<code>complexity</code>] Add
<code>unnecessary-regular-expression-compile</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/25533">#25533</a>)</li>
</ul>
<h3>Bug fixes</h3>
<ul>
<li>Avoid syntax errors for type variables with starred constraints
(<code>UP040</code>, <code>UP046</code>, <code>UP047</code>,
<code>RUF053</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/28362">#28362</a>)</li>
<li>[<code>pydocstyle</code>] Treat backslash-escaped <code>*args</code>
and <code>**kwargs</code> as documented (<code>D417</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29536">#29536</a>)</li>
<li>[<code>pylint</code>] Avoid false positive on starred elements
(<code>PLE0643</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29483">#29483</a>)</li>
<li>[<code>pylint</code>] Mark fixes unsafe when deleting comments
(<code>PLR5501</code>, <code>PLW0120</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29414">#29414</a>)</li>
<li>[<code>pyupgrade</code>] Mark fix unsafe when deleting comments
(<code>UP035</code>) (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29413">#29413</a>)</li>
</ul>
<h3>Performance</h3>
<ul>
<li>Avoid intermediate names in lint name resolution (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29506">#29506</a>)</li>
<li>Prefilter bidirectional Unicode checks by UTF-8 leading bytes (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29561">#29561</a>)</li>
<li>Share postfix parsing and reduce expression copies (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29480">#29480</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/astral-sh/ruff/commit/ba65abf8ba7bfbcc059f7fb9712be5ba9cab6abc"><code>ba65abf</code></a>
Bump version to 0.17.3 (<a
href="https://redirect.github.com/astral-sh/ruff/issues/29745">#29745</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/fb2f9218793e3b0e979175d43d88dcac791e92d6"><code>fb2f921</code></a>
[ty] Fix narrowing of strings and integers compared with enum members
(<a
href="https://redirect.github.com/astral-sh/ruff/issues/29743">#29743</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/d1812878d5f81af6f5810d193ebc44413d1b21cc"><code>d181287</code></a>
[ty] Index nominal union alternatives (<a
href="https://redirect.github.com/astral-sh/ruff/issues/29196">#29196</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/07872adbafa7c00f42f1174d8aa3c3e324033009"><code>07872ad</code></a>
[ty] Preserve string literals in comparisons with
<code>LiteralString</code> (<a
href="https://redirect.github.com/astral-sh/ruff/issues/29741">#29741</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/95888b2edfaa34d0159732856b1466cf53b33e64"><code>95888b2</code></a>
[ty] Preserve narrowing after guarded match subject captures (<a
href="https://redirect.github.com/astral-sh/ruff/issues/29558">#29558</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/3c8166b683805aa89557b0739f5b9918ad58ea6d"><code>3c8166b</code></a>
[ty] Fix hang when negating recursive unions of instance types (<a
href="https://redirect.github.com/astral-sh/ruff/issues/29652">#29652</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/3fd20e08598ac345b8afd524d3f7086456e4e758"><code>3fd20e0</code></a>
[ty] Preserve generic callback specializations during return refinement
(<a
href="https://redirect.github.com/astral-sh/ruff/issues/29667">#29667</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/2f0a29ece1f1a539c65c0671c04c76bb886219fe"><code>2f0a29e</code></a>
[ty] Record predicate truthiness alongside expression inference (<a
href="https://redirect.github.com/astral-sh/ruff/issues/29706">#29706</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/60f104a1a2ec4e980198ff54c38ba6fe7045b29f"><code>60f104a</code></a>
[ty] Honor <a
href="https://github.com/override"><code>@​override</code></a> on
overload implementations in stubs (<a
href="https://redirect.github.com/astral-sh/ruff/issues/29470">#29470</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/207ec3affeb118fce03a65f9333959157e228312"><code>207ec3a</code></a>
[ty] Add diagnostic baseline support (<a
href="https://redirect.github.com/astral-sh/ruff/issues/27636">#27636</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/astral-sh/ruff/compare/0.17.1...0.17.3">compare
view</a></li>
</ul>
</details>
<br />

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-09 20:32:41 +07:00
dependabot[bot] d3ea8b30fc ci: bump the actions group across 1 directory with 3 updates (#10)
Bumps the actions group with 3 updates in the / directory:
[actions/setup-python](https://github.com/actions/setup-python),
[zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action)
and
[SonarSource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action).

Updates `actions/setup-python` from 7.0.0 to 7.1.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/setup-python/releases">actions/setup-python's
releases</a>.</em></p>
<blockquote>
<h2>v7.1.0</h2>
<h2>What's Changed</h2>
<h3>Enhancements</h3>
<ul>
<li>Add <code>mirror</code> and <code>mirror-token</code> inputs for
custom Python distribution sources by <a
href="https://github.com/luhenry"><code>@​luhenry</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1302">actions/setup-python#1302</a></li>
<li>Improve error message clarity by <a
href="https://github.com/v-lmvysakh"><code>@​v-lmvysakh</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1351">actions/setup-python#1351</a></li>
</ul>
<h3>Dependency Upgrade</h3>
<ul>
<li>Upgrade browserslist from 4.28.2 to 4.28.9 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1353">actions/setup-python#1353</a></li>
<li>Upgrade <code>@​typescript-eslint/parser</code> from 8.62.0 to
8.70.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1343">actions/setup-python#1343</a></li>
<li>Upgrade eslint-plugin-jest from 29.15.2 to 29.16.6 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1342">actions/setup-python#1342</a></li>
<li>Upgrade <code>@​vercel/ncc</code> from 0.44.0 to 0.45.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1357">actions/setup-python#1357</a></li>
<li>Upgrade <code>@​types/semver</code> from 7.7.1 to 7.8.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1359">actions/setup-python#1359</a></li>
<li>Upgrade undici from 6.28.0 to 6.29.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1364">actions/setup-python#1364</a></li>
<li>Upgrade ts-jest from 29.4.11 to 29.4.14 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1361">actions/setup-python#1361</a></li>
<li>Upgrade brace-expansion from 5.0.9 to 5.0.12 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1365">actions/setup-python#1365</a></li>
<li>Upgrade prettier from 3.8.4 to 3.9.9 and package.json from 7.0.0 to
7.1.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1363">actions/setup-python#1363</a></li>
<li>Upgrade <code>@​typescript-eslint/eslint-plugin</code> from 8.62.0
to 8.71.1 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1369">actions/setup-python#1369</a></li>
<li>Upgrade actions/checkout from 7.0.0 to 7.0.1 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-python/pull/1345">actions/setup-python#1345</a></li>
<li>Upgrade cache to 6.3.0 by <a
href="https://github.com/v-HarithaVattikuti"><code>@​v-HarithaVattikuti</code></a>
in <a
href="https://redirect.github.com/actions/setup-python/pull/1370">actions/setup-python#1370</a></li>
<li>Resolve Basic Validation audit failures by <a
href="https://github.com/v-HarithaVattikuti"><code>@​v-HarithaVattikuti</code></a>
in <a
href="https://redirect.github.com/actions/setup-python/pull/1347">actions/setup-python#1347</a></li>
<li>Resolve npm audit failures by <a
href="https://github.com/v-HarithaVattikuti"><code>@​v-HarithaVattikuti</code></a>
in <a
href="https://redirect.github.com/actions/setup-python/pull/1350">actions/setup-python#1350</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/luhenry"><code>@​luhenry</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/setup-python/pull/1302">actions/setup-python#1302</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/setup-python/compare/v7.0.0...v7.1.0">https://github.com/actions/setup-python/compare/v7.0.0...v7.1.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/actions/setup-python/commit/6d4fd22b20465ccc0f7354476588e8df7c9ca0e0"><code>6d4fd22</code></a>
Cache upgrade to 6.3.0 (<a
href="https://redirect.github.com/actions/setup-python/issues/1370">#1370</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/ec52d0af729a7c50ced4261d17a07916f43f5b8e"><code>ec52d0a</code></a>
Bump <code>@​typescript-eslint/eslint-plugin</code> from 8.62.0 to
8.71.1 (<a
href="https://redirect.github.com/actions/setup-python/issues/1369">#1369</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/ff73b2463e2f3baa703f830da214b8dfeeaeccf8"><code>ff73b24</code></a>
Bump prettier from 3.8.4 to 3.9.9 and package.json from 7.0.0 to 7.1.0
(<a
href="https://redirect.github.com/actions/setup-python/issues/1363">#1363</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/0e40890053525508c059c61932a6b8614f9e95db"><code>0e40890</code></a>
Bump brace-expansion from 5.0.9 to 5.0.12 (<a
href="https://redirect.github.com/actions/setup-python/issues/1365">#1365</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/3892123fbe74688ccc83ec7c465dc688359e5199"><code>3892123</code></a>
Bump ts-jest from 29.4.11 to 29.4.14 (<a
href="https://redirect.github.com/actions/setup-python/issues/1361">#1361</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/660965736c4aecc62797ea07d351a3c259f14660"><code>6609657</code></a>
Bump undici from 6.28.0 to 6.29.0 (<a
href="https://redirect.github.com/actions/setup-python/issues/1364">#1364</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/e1be392b26fb1917a7b2c455817e4b4dad6544ce"><code>e1be392</code></a>
Bump <code>@​types/semver</code> from 7.7.1 to 7.8.0 (<a
href="https://redirect.github.com/actions/setup-python/issues/1359">#1359</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/06da6279cdbca41027908073e81a4544dc79c06b"><code>06da627</code></a>
Bump <code>@​vercel/ncc</code> from 0.44.0 to 0.45.0 (<a
href="https://redirect.github.com/actions/setup-python/issues/1357">#1357</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/af9bcc7548695e66d75709de6f29e337624b8de8"><code>af9bcc7</code></a>
Bump eslint-plugin-jest from 29.15.2 to 29.16.6 (<a
href="https://redirect.github.com/actions/setup-python/issues/1342">#1342</a>)</li>
<li><a
href="https://github.com/actions/setup-python/commit/7aeabeba5501120d873c50398519dbfd0657031c"><code>7aeabeb</code></a>
Bump <code>@​typescript-eslint/parser</code> from 8.62.0 to 8.70.0 (<a
href="https://redirect.github.com/actions/setup-python/issues/1343">#1343</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/setup-python/compare/5fda3b95a4ea91299a34e894583c3862153e4b97...6d4fd22b20465ccc0f7354476588e8df7c9ca0e0">compare
view</a></li>
</ul>
</details>
<br />

Updates `zizmorcore/zizmor-action` from 0.7.1 to 0.8.1
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/zizmorcore/zizmor-action/releases">zizmorcore/zizmor-action's
releases</a>.</em></p>
<blockquote>
<h2>v0.8.1</h2>
<p><a href="https://github.com/sponsors/woodruffw/">Sponsorship is
appreciated!</a></p>
<p>zizmor 1.32 is now the default version used by this action.</p>
<p>Full release notes: <a
href="https://docs.zizmor.sh/release-notes/%5B#1320%5D(https://redirect.github.com/zizmorcore/zizmor-action/issues/1320)">zizmorcore/zizmor-action#1320</a></p>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/zizmorcore/zizmor-action/compare/v0.8.0...v0.8.1">https://github.com/zizmorcore/zizmor-action/compare/v0.8.0...v0.8.1</a></p>
<h2>v0.8.0</h2>
<p>The action now supports prereleases.</p>
<p>The default has not changed, but you can pass a prerelease version
of zizmor or <code>version: prerelease</code> to get whatever latest
prerelease the action knows about.</p>
<h2>What's Changed</h2>
<ul>
<li>Support prereleases by <a
href="https://github.com/woodruffw"><code>@​woodruffw</code></a> in <a
href="https://redirect.github.com/zizmorcore/zizmor-action/pull/182">zizmorcore/zizmor-action#182</a></li>
<li>Sync zizmor versions by <a
href="https://github.com/github-actions"><code>@​github-actions</code></a>[bot]
in <a
href="https://redirect.github.com/zizmorcore/zizmor-action/pull/184">zizmorcore/zizmor-action#184</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/zizmorcore/zizmor-action/compare/v0.7.1...v0.8.0">https://github.com/zizmorcore/zizmor-action/compare/v0.7.1...v0.8.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/45d7276c9ca790aabd705e31ca99c6185c3e76dd"><code>45d7276</code></a>
Sync zizmor versions (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/191">#191</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/ff3874113dd825e588b62d5ab9fe3da5411732ff"><code>ff38741</code></a>
chore(deps): bump the github-actions group across 1 directory with 2
updates ...</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/4a9eca449a683b2d742b9a431babf6a259edcdad"><code>4a9eca4</code></a>
README: another troubleshooting section (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/186">#186</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/83a041654ed09c7cc62da378a616f1eaba41c165"><code>83a0416</code></a>
Bump pins (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/185">#185</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/53290badfa369cb0bf7ad16342cb62c2fa47ac7b"><code>53290ba</code></a>
Sync zizmor versions (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/184">#184</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/76da2ee26867f8fbf24b824abef9e444636f76c3"><code>76da2ee</code></a>
Support prereleases (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/182">#182</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/fb1d87ba4b2f888025015a269a94ad7e991f6a7b"><code>fb1d87b</code></a>
chore(deps): bump the github-actions group with 2 updates (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/180">#180</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/be3660124653b2533ddba057e8651888379e64e2"><code>be36601</code></a>
README: bump pins (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/179">#179</a>)</li>
<li>See full diff in <a
href="https://github.com/zizmorcore/zizmor-action/compare/85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e...45d7276c9ca790aabd705e31ca99c6185c3e76dd">compare
view</a></li>
</ul>
</details>
<br />

Updates `SonarSource/sonarqube-scan-action` from 8.3.0 to 8.4.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/sonarsource/sonarqube-scan-action/releases">SonarSource/sonarqube-scan-action's
releases</a>.</em></p>
<blockquote>
<h2>v8.4.0</h2>
<h2>What's Changed</h2>
<ul>
<li>SQSCANGHA-174 NO-JIRA Bump actions/setup-node from 7.0.0 to 7.1.0 by
<a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/277">SonarSource/sonarqube-scan-action#277</a></li>
<li>Update Rollup and preserve scanner argument compatibility by <a
href="https://github.com/renovate"><code>@​renovate</code></a>[bot] in
<a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/275">SonarSource/sonarqube-scan-action#275</a></li>
<li>Update dependency rollup to v4.64.6 by <a
href="https://github.com/renovate"><code>@​renovate</code></a>[bot] in
<a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/279">SonarSource/sonarqube-scan-action#279</a></li>
<li>SQSCANGHA-177 Update SonarScanner CLI to 8.2.0.6438 by <a
href="https://github.com/github-actions"><code>@​github-actions</code></a>[bot]
in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/281">SonarSource/sonarqube-scan-action#281</a></li>
<li>SQSCANGHA-176 docs: refresh action and scanner version examples by
<a href="https://github.com/zglicz"><code>@​zglicz</code></a> in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/280">SonarSource/sonarqube-scan-action#280</a></li>
<li>Update dependency rollup to v4.64.7 by <a
href="https://github.com/renovate"><code>@​renovate</code></a>[bot] in
<a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/282">SonarSource/sonarqube-scan-action#282</a></li>
<li>[CONTENT-3798] README update for marketing by <a
href="https://github.com/tom-howlett-sonarsource"><code>@​tom-howlett-sonarsource</code></a>
in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/274">SonarSource/sonarqube-scan-action#274</a></li>
<li>Update dependency rollup to v4.64.9 by <a
href="https://github.com/renovate"><code>@​renovate</code></a>[bot] in
<a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/283">SonarSource/sonarqube-scan-action#283</a></li>
<li>Update dependency rollup to v4.64.12 by <a
href="https://github.com/renovate"><code>@​renovate</code></a>[bot] in
<a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/288">SonarSource/sonarqube-scan-action#288</a></li>
<li>Update dependency rollup to v4.65.0 by <a
href="https://github.com/renovate"><code>@​renovate</code></a>[bot] in
<a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/291">SonarSource/sonarqube-scan-action#291</a></li>
<li>SQSCANGHA-185 NO-JIRA Bump madhead/semver-utils from 5.0.0 to 5.1.1
by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/290">SonarSource/sonarqube-scan-action#290</a></li>
<li>Update SonarScanner CLI to 8.3.0.16463 by <a
href="https://github.com/github-actions"><code>@​github-actions</code></a>[bot]
in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/293">SonarSource/sonarqube-scan-action#293</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/zglicz"><code>@​zglicz</code></a> made
their first contribution in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/280">SonarSource/sonarqube-scan-action#280</a></li>
<li><a
href="https://github.com/tom-howlett-sonarsource"><code>@​tom-howlett-sonarsource</code></a>
made their first contribution in <a
href="https://redirect.github.com/SonarSource/sonarqube-scan-action/pull/274">SonarSource/sonarqube-scan-action#274</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/SonarSource/sonarqube-scan-action/compare/v8.3.0...v8.4.0">https://github.com/SonarSource/sonarqube-scan-action/compare/v8.3.0...v8.4.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/4d1dc0c91ee400dcf8a6dddf2f705ac36542e304"><code>4d1dc0c</code></a>
Update SonarScanner CLI to 8.3.0.16463 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/293">#293</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/ee2d75757be5d31327e91dc2f035266f31ee1a76"><code>ee2d757</code></a>
SQSCANGHA-185 NO-JIRA Bump madhead/semver-utils from 5.0.0 to 5.1.1 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/290">#290</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/a7de3345cf3ee5b190f46513ba3951d8b006f88d"><code>a7de334</code></a>
Update dependency rollup to v4.65.0 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/291">#291</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/38f03825196cad93cbb3d92e9d20d1f1fe7dc2a7"><code>38f0382</code></a>
Update dependency rollup to v4.64.12 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/288">#288</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/54ae8f2874648f708bc76d8c757313e288319534"><code>54ae8f2</code></a>
Update dependency rollup to v4.64.9 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/283">#283</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/3a63ba4c7c8dcbf781c1e379b3d6eae6b9327865"><code>3a63ba4</code></a>
CONTENT-3798 README update for marketing (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/274">#274</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/b632445a46f521460d97cad21057b904b24c326f"><code>b632445</code></a>
Update dependency rollup to v4.64.7 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/282">#282</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/c3c1d589358c42543e7cafc8b14229d4127c2d4e"><code>c3c1d58</code></a>
SQSCANGHA-176 docs: refresh action and scanner version examples (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/280">#280</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/b5414270defcbe368c8f9088a2bb8fa3ad845eab"><code>b541427</code></a>
SQSCANGHA-177 Update SonarScanner CLI to 8.2.0.6438 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/281">#281</a>)</li>
<li><a
href="https://github.com/SonarSource/sonarqube-scan-action/commit/15d1d914c7ae0a660e3c360fd04364291470b6af"><code>15d1d91</code></a>
Update dependency rollup to v4.64.6 (<a
href="https://redirect.github.com/sonarsource/sonarqube-scan-action/issues/279">#279</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/sonarsource/sonarqube-scan-action/compare/d209202bc7d53ff1cc128f7f907dac145c9d6ae9...4d1dc0c91ee400dcf8a6dddf2f705ac36542e304">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-09 20:29:41 +07:00
poli0981andClaude Opus 5.5 e7cb14a888 1.4.1: SonarQube Cloud CI analysis with coverage (#7)
Moves SonarQube Cloud from Automatic Analysis to CI-based analysis with
pytest coverage, makes its quality gate part of the required `ci` check,
and fixes what the first CI scan reported on `main`.

## SonarQube Cloud in CI

- `sonar-project.properties` (new) replaces `.sonarcloud.properties`,
which only Automatic Analysis read. Automatic Analysis is off in the
project settings; the two can't run together.
  - The whole repo is analysed as sources, with `tests/` as tests.
- `sonar.python.version=3.14`: the analyzer warns "No explicit support
for version 3.15" and falls back to 3.14 anyway.
  - It reads `coverage.xml` and sets `sonar.qualitygate.wait=true`.
- `ci.yml`:
- `test` runs `pytest --cov` and uploads `coverage.xml` as an artifact
kept 1 day.
- New `sonar` job: `SonarSource/sonarqube-scan-action` v8.3.0, the
latest release (SonarScanner CLI 8.1.0.6389), with full history.
- `sonar.projectVersion` comes from the newest `changelog/*.x.md`
heading, so "new code" on `main` restarts at each release.
- Only its scan step sees `SONAR_TOKEN`. The job runs no project code
and installs nothing.
- Without the token (Dependabot PRs) it skips with a notice and still
passes; `main` is analysed after the merge.
- The `ci` gate now needs `sonar`, so a failed quality gate blocks the
merge.
- `pyproject.toml`: `[tool.coverage.*]` measures `scripts/` with branch
coverage and relative paths, and sets `fail_under = 95`.

## The seven issues the CI scan found on `main`

| Rule | Where | Change |
|---|---|---|
| `githubactions:S8541` ×2 | pip installs in `lint` and `test` |
`--only-binary :all:` |
| `githubactions:S8544` ×2 | same | Hash-locked `requirements-dev.txt`,
compiled from the new `requirements-dev.in` with pip-tools on Python
3.14, installed with `--require-hashes` |
| `pythonsecurity:S8707` | `release_notes.py` | The version must look
like a release tag, and the file name is built from its major number
alone. The changelog directory is no longer a CLI argument;
`release.yml` never passed one. |
| `python:S5332` ×2 | `config.py`, the feed's XML namespaces | Accepted
in `sonar-project.properties` with the reason: they must equal the
feed's `xmlns` values and are never fetched. |

The lock is compiled on Python 3.14 because Dependabot's pip updater
takes the Python version from the lock's header and supports only up to
3.14 (the same setup as free-games-itchio-list).

## Coverage

Coverage of `scripts/` (line and branch) goes from 72 % to 100 %. The
new tests cover:

- `http_client`
- Bluesky, Discord and Mastodon
- `post_to_all`
- the multi-video and empty-window paths of `notify.main`
- `fetch_feed`
- the `release_notes` CLI

Tests still make no network calls.

The new tests also caught a real leak: `http_client` read the body of an
`HTTPError` but never closed it, and that error object is also the open
response. It is now closed.

## Audit, scanners and Dependabot

- zizmor 1.30.0 → 1.31.1. This needs zizmor-action v0.6.4 → v0.7.1,
because v0.6.4 can only run the zizmor releases it ships a lock for.
- New pins, all past the 7-day cooldown and on the same SHAs as the
other poli0981 repos: sonarqube-scan-action v8.3.0, upload-artifact
v7.0.2, download-artifact v8.0.2.
- Left for Dependabot because they are still inside the cooldown
(released 2026-10-19…23): ruff 0.17.2, setup-python v7.1.0,
zizmor-action v0.8.0, coverage 7.17.0, SonarScanner CLI 8.2.0.
- `dependabot.yml` is unchanged:
- the `pip` entry handles the `.in`/lock pair, and the groups still
match everything;
  - the `dependencies` label exists;
  - Dependabot alerts and security updates are on, with 0 open alerts.

## Verification

- Local (Python 3.15.1):
  - ruff is clean;
  - all tests pass with coverage at 100 %;
  - zizmor 1.31.1 reports no findings;
  - the lock installs with `--require-hashes --only-binary :all:`;
  - `release_notes.py v1.4.1` prints the new entry.
- CI on this PR: `lint`, `test`, `security`, `sonar` and `ci` pass. The
scanner log has no warnings, `coverage.xml` is imported, and the quality
gate passes.

## After the merge

- `main`'s first analysis with these settings closes the seven issues
above.
- Tags: `v1.4.0` (878c3eb) was never pushed. `v1.4.1` is yours to sign
and push as well.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 23:26:34 +00:00
poli0981andClaude Opus 5.5 878c3eb9a1 1.4.0: Python 3.15, ruff 0.17.1 (#6)
Moves the bot, CI and release workflows from Python 3.14 to 3.15.
`"3.15"` takes the newest 3.15.x the runner has: 3.15.0 from the image's
tool cache today, 3.15.1 once the image updates. Also replaces the stuck
Dependabot PR #4.

- `ci.yml` (lint, test), `notify.yml`, `release.yml`: `python-version:
"3.15"`.
- `requirements-dev.txt`: ruff 0.16.5 → 0.17.1, which is 7 days old and
so matches the Dependabot cooldown. pytest 9.1.1 is already the latest
and declares 3.15.
- `pyproject.toml`: ruff `target-version = "py315"`. pytest gets
`filterwarnings = ["error"]`, so a deprecated stdlib call fails CI
instead of breaking the bot on the next Python.
- `scripts/youtube.py`: the only change ruff format makes for py315,
`except ValueError, AttributeError:` (PEP 758). From here the code needs
Python 3.14+.
- `.sonarcloud.properties` (new): `sonar.python.version=3.15`. Without
it, Sonar also analyses for Python 2, where that `except` means
something else. The setting takes effect only once it is on `main`, so
this PR's own Sonar run still uses the defaults.
- README: local dev needs Python 3.15. When a Dependabot PR falls behind
`main`, comment `@dependabot rebase` instead of clicking "Update
branch", which rewrites the commit without a signature.
- `changelog/1.x.md`: 1.4.0 entry, dated 2026-10-22. Fix the date if
this merges later.

## Compatibility (measured on Python 3.15.1, 2026-10-22)

- All 44 tests pass on 3.15.1 and on 3.14.7 with every warning as an
error (`-X warn_default_encoding -W error`).
- CI on this PR set up CPython 3.15.0: ruff is clean and all 44 tests
pass with `filterwarnings = ["error"]`.
- None of the APIs removed or changed in 3.15 are used: `sre_*`,
`glob.glob0/glob1`, `PurePath.is_reserved`, `platform.java_ver`,
`CGIHTTPRequestHandler`, `typing.no_type_check_decorator`, the
`NamedTuple` keyword form, `load_module`, `locale.getdefaultlocale`,
`strptime` without a year, `utcnow`.
- Every text-mode `open`/`read_text`/`write_text` names an encoding.
- Live GETs through `http_client` work on 3.15.1: the watch page, a
ytimg thumbnail, the Bluesky PDS and Mastodon.
- PEP 686 (UTF-8 mode by default) changes nothing on Linux CI. On
Windows, `release_notes.py` piped to a file crashed with
`UnicodeEncodeError` on 3.14 and works on 3.15.

## Dependabot

- #4 is BLOCKED. On 2026-09-23 "Update branch" (rebase) rewrote its
commit without a signature, and the `main` ruleset requires signed
commits. Dependabot also stops updating a PR once a human has pushed to
it. This PR carries the ruff bump instead, and #4 gets closed after the
merge.
- The `dependencies` label that `dependabot.yml` asks for did not exist.
It is created alongside this PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 13:12:42 +07:00
dependabot[bot] ceaa53757e ci: bump zizmorcore/zizmor-action from 0.6.3 to 0.6.4 in the actions group (#5)
Bumps the actions group with 1 update:
[zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action).

Updates `zizmorcore/zizmor-action` from 0.6.3 to 0.6.4
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/zizmorcore/zizmor-action/releases">zizmorcore/zizmor-action's
releases</a>.</em></p>
<blockquote>
<h2>v0.6.4</h2>
<p><a href="https://github.com/sponsors/woodruffw/">Sponsorship is
appreciated!</a></p>
<p>zizmor 1.30.1 is now the default version.</p>
<p>Release notes: <a
href="https://docs.zizmor.sh/release-notes/%5B#1301%5D(https://redirect.github.com/zizmorcore/zizmor-action/issues/1301)">zizmorcore/zizmor-action#1301</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/cc914d7f3750a2d13d75c7f184a1060aa0e9d482"><code>cc914d7</code></a>
Sync zizmor versions (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/166">#166</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/bae72b71bc270806f906e8e2a1f5985a26effaa2"><code>bae72b7</code></a>
chore(deps): bump the github-actions group with 2 updates (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/165">#165</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/27604f9eef072d6456e69fc10ee36629710fa6f6"><code>27604f9</code></a>
chore(deps): bump the github-actions group with 2 updates (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/164">#164</a>)</li>
<li><a
href="https://github.com/zizmorcore/zizmor-action/commit/c41d66537b2d733801baec1e31ffc22aa2051a8f"><code>c41d665</code></a>
README: bump pins (<a
href="https://redirect.github.com/zizmorcore/zizmor-action/issues/163">#163</a>)</li>
<li>See full diff in <a
href="https://github.com/zizmorcore/zizmor-action/compare/70fb788f84895a7701f5643d103d587e460b5c99...cc914d7f3750a2d13d75c7f184a1060aa0e9d482">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=zizmorcore/zizmor-action&package-manager=github_actions&previous-version=0.6.3&new-version=0.6.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-23 07:29:44 +07:00
poli0981andClaude Fable 5.1 9e8718556a 1.3.0: drop X/Twitter and Facebook from the pipeline (#3)
Removes X/Twitter and Facebook Page from the posting pipeline at the
owner's request.

- Deleted `scripts/platforms/x_twitter.py` and `facebook.py`; registry
now posts to Telegram, Bluesky, Discord, Mastodon.
- Removed `X_*` / `FACEBOOK_*` config and the corresponding `env:` lines
in `notify.yml`.
- Removed the X-specific 280-weighted-char fitting from `message.py` and
its tests.
- README, `SETUP_NEW_PLATFORMS.md` (now Mastodon + Discord only) and
`changelog/1.x.md` (1.3.0) updated.

The `X_*` repository secrets are no longer read; they can be deleted
from Settings at any time.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 21:24:40 +07:00
poli0981andClaude Fable 5.1 4a40f1f929 1.2.0: fix Telegram markup, premieres, lookback; add CI, state branch, changelog (#2)
* feat: 1.2.0 — fix Telegram markup, premieres, lookback; add CI, state branch, changelog

Fixes
- Telegram: HTML parse mode; titles no longer render with backslashes.
- Skip scheduled Premieres until they are public (watch-page check).
- Replace "published today (UTC)" with a 48h lookback window so delayed
  scheduled runs cannot lose videos.
- Distinguish skipped vs failed platforms; exit 1 on failure so the
  CI-failure notifier fires.

Infrastructure
- ci.yml: ruff (incl. S rules), pytest, zizmor, actionlint; `ci` gate job.
- release.yml: tag v* -> GitHub Release from changelog/1.x.md -> Discord.
- Dependabot for actions + dev deps; actions SHA-pinned.
- State moves to the orphan `state` branch (main becomes ruleset-protected).
- Shared message builder and HTTP client; tests; docs rewritten.
- Remove unused .github/scripts/discord_notify.py.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: add 7-day Dependabot cooldown (zizmor dependabot-cooldown)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 20:36:41 +07:00
github-actions[bot] 4c2215716b chore: update last video state 2026-08-30 18:07:55 +00:00
github-actions[bot] 772abdaaa8 chore: update last video state 2026-08-30 12:04:38 +00:00
github-actions[bot] cd23fc61b9 chore: update last video state 2026-08-27 17:44:02 +00:00
github-actions[bot] 8de5b0cf82 chore: update last video state 2026-08-26 15:57:31 +00:00
github-actions[bot] db2520b6ef chore: update last video state 2026-08-19 15:00:05 +00:00
github-actions[bot] 6aef156384 chore: update last video state 2026-08-18 07:12:23 +00:00
github-actions[bot] 65e4b04752 chore: update last video state 2026-08-16 14:46:14 +00:00
github-actions[bot] fac2dce7c0 chore: update last video state 2026-08-16 07:07:21 +00:00
github-actions[bot] 6beda846fa chore: update last video state 2026-08-11 07:44:01 +00:00
github-actions[bot] ebc900fcd6 chore: update last video state 2026-08-10 15:29:48 +00:00
github-actions[bot] 4c59980043 chore: update last video state 2026-07-22 09:06:09 +00:00
github-actions[bot] 91a2235b87 chore: update last video state 2026-07-20 23:28:19 +00:00
github-actions[bot] 76c8566f04 chore: update last video state 2026-07-20 16:07:06 +00:00
github-actions[bot] 31f07e28cf chore: update last video state 2026-07-17 08:32:28 +00:00
github-actions[bot] d42c11ed25 chore: update last video state 2026-07-16 08:39:02 +00:00
github-actions[bot] a9aa8a261c chore: update last video state 2026-07-14 15:54:20 +00:00
github-actions[bot] 267cc9e2a6 chore: update last video state 2026-06-28 07:46:12 +00:00
github-actions[bot] a5c9b8df37 chore: update last video state 2026-06-21 15:13:41 +00:00
github-actions[bot] f185e9bf4e chore: update last video state 2026-06-20 22:51:20 +00:00
github-actions[bot] 2886caf748 chore: update last video state 2026-06-20 15:10:21 +00:00
github-actions[bot] 80cfc1aba0 chore: update last video state 2026-06-10 23:02:31 +00:00
github-actions[bot] 20a48dedfa chore: update last video state 2026-06-10 15:45:12 +00:00
github-actions[bot] 76d0cfa79c chore: update last video state 2026-06-09 22:59:44 +00:00
github-actions[bot] 8e450a6514 chore: update last video state 2026-06-05 15:32:36 +00:00
github-actions[bot] c945257f5f chore: update last video state 2026-06-02 08:07:05 +00:00
github-actions[bot] 47d5e22f5c chore: update last video state 2026-06-01 23:08:59 +00:00
github-actions[bot] 0b7ea8f3fa chore: update last video state 2026-05-31 22:47:26 +00:00
github-actions[bot] e514a4647d chore: update last video state 2026-05-31 15:00:37 +00:00
github-actions[bot] 1a596239fa chore: update last video state 2026-05-30 22:47:09 +00:00
github-actions[bot] c228003b4d chore: update last video state 2026-05-29 22:56:00 +00:00
github-actions[bot] 2a21e57548 chore: update last video state 2026-05-29 07:47:30 +00:00
github-actions[bot] 638355b098 chore: update last video state 2026-05-28 07:47:33 +00:00
github-actions[bot] 0c39e80283 chore: update last video state 2026-05-27 22:59:09 +00:00
github-actions[bot] f40addc54d chore: update last video state 2026-05-25 22:48:18 +00:00
github-actions[bot] 254eeec0ef chore: update last video state 2026-05-24 14:51:58 +00:00
github-actions[bot] 0da1302e11 chore: update last video state 2026-05-24 07:33:26 +00:00
github-actions[bot] d28cd47267 chore: update last video state 2026-05-21 22:52:28 +00:00
github-actions[bot] 4151d31a14 chore: update last video state 2026-05-21 07:46:25 +00:00
github-actions[bot] 481a49042c chore: update last video state 2026-05-18 15:45:40 +00:00
github-actions[bot] 50dce946e0 chore: update last video state 2026-05-17 22:46:33 +00:00
github-actions[bot] b535ac42d0 chore: update last video state 2026-05-17 14:47:47 +00:00
github-actions[bot] 4e01830066 chore: update last video state 2026-05-13 15:31:57 +00:00
poli0981 4e74cf4f2d discord notifi update script 2026-05-09 01:06:03 +07:00
poli0981 85dacd60e0 discord notifi update script 2026-05-08 20:04:44 +07:00
poli0981 c180c4629e discord notifi 2026-05-08 19:10:54 +07:00
github-actions[bot] 52525ef634 chore: update last video state 2026-05-07 07:28:12 +00:00
github-actions[bot] d7eca36581 chore: update last video state 2026-05-03 14:46:30 +00:00
github-actions[bot] 3e3fe9ef70 chore: update last video state 2026-04-30 22:46:48 +00:00
github-actions[bot] 6a19df16e0 chore: update last video state 2026-04-30 15:15:04 +00:00
github-actions[bot] ab92ef0008 chore: update last video state 2026-04-29 15:16:27 +00:00
github-actions[bot] 1b80a677e8 chore: update last video state 2026-04-29 07:17:45 +00:00
github-actions[bot] 8d0d4c51b5 chore: update last video state 2026-04-28 15:18:15 +00:00
github-actions[bot] 34fae99fa6 chore: update last video state 2026-04-27 15:13:57 +00:00
github-actions[bot] d3304b894b chore: update last video state 2026-04-27 07:23:31 +00:00
github-actions[bot] 7ed775bbee chore: update last video state 2026-04-26 14:45:24 +00:00
github-actions[bot] 8e85cd2d5f chore: update last video state 2026-04-26 07:05:52 +00:00
github-actions[bot] b0d7386ce2 chore: update last video state 2026-04-25 22:44:33 +00:00
github-actions[bot] 700f77f600 chore: update last video state 2026-04-25 14:45:02 +00:00
github-actions[bot] 7d41fd40a4 chore: update last video state 2026-04-22 07:06:52 +00:00
github-actions[bot] cc1da44b4e chore: update last video state 2026-04-21 14:59:02 +00:00
github-actions[bot] 5168a9941f chore: update last video state 2026-04-20 22:45:27 +00:00
github-actions[bot] ef11f3fdec chore: update last video state 2026-04-20 07:15:46 +00:00
github-actions[bot] 561e05b4d8 chore: update last video state 2026-04-19 15:37:05 +00:00
github-actions[bot] 4335ae8353 chore: update last video state 2026-04-19 14:44:48 +00:00
github-actions[bot] 1c00d6a675 chore: update last video state 2026-04-19 10:41:08 +00:00
github-actions[bot] 5e853ad5c0 chore: update last video state 2026-04-17 14:47:44 +00:00
github-actions[bot] eef88279d8 chore: update last video state 2026-04-16 15:07:46 +00:00
poli0981 b3dac25c4d Merge pull request #1 from poli0981/refactor/multi-video-daily-notification
refactor: multi-video daily notification with modular structure
2026-04-16 17:30:47 +07:00
poli0981andClaude Opus 4.6 f5b6534fd1 refactor: split monolith into modules and support multi-video daily posting
- Split 634-line notify.py into modular structure:
  config.py, youtube.py, state.py, and platforms/ package
- Fetch all videos published today (UTC) instead of just the latest
- State file now tracks multiple video IDs (one per line, max 100)
- Add 1-5s random delay between posting each video
- Reduce cron schedule from 24x/day to 3x/day (06:30, 14:30, 22:30 UTC)
- Add concurrency guard to prevent overlapping workflow runs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:30:00 +07:00
github-actions[bot] 4c5a1f40ce chore: update last video state 2026-04-16 08:32:36 +00:00
github-actions[bot] 1f71a1e0a5 chore: update last video state 2026-04-16 07:32:20 +00:00
github-actions[bot] 819542fb2c chore: update last video state 2026-04-15 07:32:24 +00:00
poli0981 858a93becb chore: update notification schedule to run every hour 2026-04-14 23:04:47 +07:00
github-actions[bot] 9906af020a chore: update last video state 2026-04-13 09:47:22 +00:00
poli0981 779499c1bf feat: add support for Mastodon, X/Twitter, and Facebook Page notifications 2026-04-13 13:49:34 +07:00
github-actions[bot] 4b7c5d9d6f chore: update last video state 2026-04-13 05:00:53 +00:00
poli0981 81a39cd04e feat: normalize Discord webhook URL and improve error handling 2026-04-13 11:44:39 +07:00
github-actions[bot] 623a9ca060 chore: update last video state 2026-04-13 04:12:29 +00:00
github-actions[bot] f8132df145 chore: update last video state 2026-04-13 03:28:06 +00:00
poli0981 6b95b8b104 feat: add YouTube auto-post notification script with Telegram, Bluesky, and Discord support 2026-04-13 10:26:49 +07:00
poli0981 c33274cec4 Initial commit 2026-04-13 09:43:53 +07:00
48 changed files with 3475 additions and 100 deletions

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
name: Announce Release to Discord
# Releases published by hand in the Gitea UI. A release that release.yml makes
# with the job token fires no `release` event, so that workflow announces its own.
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Existing release tag to re-announce"
required: true
type: string
# The reusable reads the release through the Gitea API with the job token.
permissions:
contents: read
jobs:
announce:
# Pinned to a commit of poli0981/.github, with `ops_ref` at the same SHA so the
# notifier script matches the workflow. Renovate does not bump this pin (the
# comment holds no version it reads): move both by hand when the ops repo is
# tagged (runbook §3.2 item 3).
uses: poli0981/.github/.gitea/workflows/announce-release.yml@8e6582af9a5846b4d8995b26b1421488d29d761b # ops main 2026-11-23 (untagged, after v2026.11.1)
with:
tag_override: ${{ inputs.tag || '' }}
ops_ref: 8e6582af9a5846b4d8995b26b1421488d29d761b
secrets:
DISCORD_RELEASES_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }}
DISCORD_REPO_WEBHOOK: ${{ secrets.DISCORD_REPO_WEBHOOK }}
DISCORD_PING_ROLE_ID: ${{ secrets.DISCORD_PING_ROLE_ID }}
+252
View File
@@ -0,0 +1,252 @@
# CI — lint, tests with coverage, workflow security audit, Qodana.
# The `ci` gate job is the required status check on `main`; add new jobs to its
# `needs` list, not to the branch protection rule.
#
# Gitea has no CodeQL and no code-scanning UI (runbook §1), so workflow security is
# covered by zizmor + actionlint, Python security by ruff's `S` (bandit) rules, and
# bugs and code smells by Qodana's PyCharm inspections. SonarQube Cloud was dropped
# with the move to Gitea (ops decision D1). Secrets, SAST and dependency checks
# from the ops repo run in security.yml.
name: ci
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.15"
cache: pip
cache-dependency-path: requirements-dev.txt
# Hash-locked (requirements-dev.in, compiled), wheels only: a new release of
# any package, indirect ones included, can't reach the job, and no build
# script runs. A block scalar, because the `: ` in `:all: -r` would end a
# plain one.
- name: Install dev tools
run: |
python -m pip install --require-hashes --only-binary :all: -r requirements-dev.txt
- name: Ruff check
run: ruff check .
- name: Ruff format
run: ruff format --check .
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.15"
cache: pip
cache-dependency-path: requirements-dev.txt
# Hash-locked, wheels only (see `lint`).
- name: Install dev tools
run: |
python -m pip install --require-hashes --only-binary :all: -r requirements-dev.txt
# Coverage settings (what is measured, branches, the floor) are in pyproject.toml.
- name: Pytest with coverage
run: pytest --cov --cov-report=term-missing
security:
runs-on: ubuntu-latest
timeout-minutes: 10
# Both tools without Docker: zizmor from the hash-locked dev tools, actionlint
# and shellcheck as release binaries at pinned versions, SHA-256 verified (the
# ops repo's ops-lint.yml pins). Renovate does not update the binaries: bump
# version and checksum together, by hand.
env:
ACTIONLINT_VERSION: 1.7.12
ACTIONLINT_SHA256: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8 # actionlint_1.7.12_linux_amd64.tar.gz (release checksums file)
SHELLCHECK_VERSION: v0.11.0
SHELLCHECK_SHA256: 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198 # shellcheck-v0.11.0.linux.x86_64.tar.xz
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.15"
cache: pip
cache-dependency-path: requirements-dev.txt
# Hash-locked, wheels only (see `lint`).
- name: Install dev tools
run: |
python -m pip install --require-hashes --only-binary :all: -r requirements-dev.txt
# The files by name: zizmor only looks for .github/workflows by itself.
# Offline: its online audits ask GitHub's API about the actions, with a token
# this runner does not have. No SARIF upload either: Gitea has no
# code-scanning UI, and zizmor's exit code fails the step on any finding.
- name: zizmor (workflow security audit)
run: zizmor --offline --config .github/zizmor.yml .gitea/workflows/*.yml
- name: Install actionlint ${{ env.ACTIONLINT_VERSION }} + shellcheck ${{ env.SHELLCHECK_VERSION }}
run: |
set -euo pipefail
tmp="${RUNNER_TEMP:-/tmp}"
bin="$tmp/lint-bin"
mkdir -p "$bin"
curl -fsSL --retry 3 -o "$tmp/actionlint.tar.gz" "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
echo "${ACTIONLINT_SHA256} $tmp/actionlint.tar.gz" | sha256sum -c -
tar -xzf "$tmp/actionlint.tar.gz" -C "$bin" actionlint
curl -fsSL --retry 3 -o "$tmp/shellcheck.tar.xz" "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
echo "${SHELLCHECK_SHA256} $tmp/shellcheck.tar.xz" | sha256sum -c -
tar -xJf "$tmp/shellcheck.tar.xz" -C "$bin" --strip-components=1 "shellcheck-${SHELLCHECK_VERSION}/shellcheck"
echo "$bin" >> "$GITHUB_PATH"
# .github/actionlint.yaml ignores only the Gitea features actionlint does not
# know; everything else stays an error.
- name: actionlint (workflow syntax and expressions)
run: |
actionlint -version
actionlint -color -config-file .github/actionlint.yaml -shellcheck "$(command -v shellcheck)" .gitea/workflows/*.yml
qodana:
# Qodana Cloud, the Ultimate Python linter (settings: qodana.yaml) in native
# mode with the job's Python 3.15. Any problem fails the job (failThreshold).
#
# The Qodana CLI, not JetBrains/qodana-action, which needs GitHub's APIs (runbook
# §3.2 item 6). A local job rather than a call to the ops repo's
# reusable-qodana.yml: qodana-python must analyse against the bot's Python 3.15
# (QODANA_PYTHON_PATH), so setup-python runs before the scan (runbook §3.5
# item 5). Gitea has no code-scanning UI: the findings live in Qodana Cloud and
# in the `qodana-report` artifact (SARIF + HTML report).
#
# The CLI is downloaded at the ops repo's pinned version and SHA-256 verified.
# Renovate does not update it (it is not an action): bump the version and the
# checksum together, by hand; JetBrains publishes both in qodana-action's
# common/cli.json.
#
# A job of its own with no pip install, so QODANA_TOKEN never shares a job with
# pip packages. Gitea gives every same-repo pull request the repository's
# secrets, Renovate's included, and a Renovate pull request carries the very
# update under review: runs by renovate-bot skip the scan with a notice and
# still pass, as Dependabot's did on GitHub. The push to main scans the update.
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
env:
QODANA_CLI_VERSION: 2026.3.1
QODANA_CLI_SHA256: dae6d31f481ed15c6c016fd746e907978f0c1437010326fa04a92f13c7c52338 # qodana_linux_x86_64.tar.gz
steps:
- name: Check for QODANA_TOKEN
id: token
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
ACTOR: ${{ github.actor }}
AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
if [ "$ACTOR" = renovate-bot ] || [ "$AUTHOR" = renovate-bot ]; then
echo "::notice::Renovate run: Qodana analysis skipped; the push to main analyses the update."
elif [ -n "$QODANA_TOKEN" ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::No QODANA_TOKEN in this run: Qodana analysis skipped."
fi
# On Gitea a pull request's ref is its head (refs/pull/N/head, no merge
# preview), so the report names a commit of the branch. Full history for
# Qodana Cloud's VCS data.
- name: Checkout
if: steps.token.outputs.present == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
if: steps.token.outputs.present == 'true'
id: python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.15"
- name: Install the Qodana CLI ${{ env.QODANA_CLI_VERSION }}
if: steps.token.outputs.present == 'true'
run: |
set -euo pipefail
tmp="${RUNNER_TEMP:-/tmp}"
tgz="$tmp/qodana.tar.gz"
curl -fsSL --retry 3 -o "$tgz" "https://github.com/JetBrains/qodana-cli/releases/download/v${QODANA_CLI_VERSION}/qodana_linux_x86_64.tar.gz"
echo "${QODANA_CLI_SHA256} $tgz" | sha256sum -c -
mkdir -p "$tmp/qodana-cli"
tar -xzf "$tgz" -C "$tmp/qodana-cli" qodana
echo "$tmp/qodana-cli" >> "$GITHUB_PATH"
# The whole project every time (the action's `pr-mode: false`): it is small.
- name: Qodana scan
if: steps.token.outputs.present == 'true'
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
QODANA_ENDPOINT: https://qodana.cloud
# The interpreter Qodana analyses against (the bot's Python).
QODANA_PYTHON_PATH: ${{ steps.python.outputs.python-path }}
run: |
set -euo pipefail
tmp="${RUNNER_TEMP:-/tmp}"
qodana --version
qodana scan --within-docker false --results-dir "$tmp/qodana/results" --cache-dir "$tmp/qodana/cache"
# !cancelled(), not the implicit success(): a scan that FINDS something fails,
# and those are exactly the findings the report must keep.
- name: Keep the report
if: ${{ !cancelled() && steps.token.outputs.present == 'true' }}
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: qodana-report
path: ${{ runner.temp }}/qodana/results/
if-no-files-found: ignore
retention-days: 14
ci:
# Gate job: the single required status check. `if: always()` so it reports even
# when a dependency fails, and the step below turns that into a red check.
needs: [lint, test, security, qodana]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: All jobs succeeded?
env:
RESULTS: ${{ toJSON(needs) }}
run: |
echo "$RESULTS"
if echo "$RESULTS" | grep -Eq '"result": "(failure|cancelled|skipped)"'; then
echo "::error::A required job did not succeed."
exit 1
fi
+24
View File
@@ -0,0 +1,24 @@
name: Notify CI Failures
# Gitea matches `workflows` as a glob against each workflow's `name:`, so "*"
# watches every workflow here. The reusable posts only failures on `main`, and
# skips its own notifiers, releases and Renovate.
on:
workflow_run:
workflows: ["*"]
types: [completed]
# Matches the reusable's needs: `actions: read` to read the workflow_run details.
permissions:
contents: read
actions: read
jobs:
notify:
# Pinned like announce-release.yml: `ops_ref` is the same SHA as `uses:`.
uses: poli0981/.github/.gitea/workflows/notify-ci-failure.yml@8e6582af9a5846b4d8995b26b1421488d29d761b # ops main 2026-11-23 (untagged, after v2026.11.1)
with:
default_branch: main
ops_ref: 8e6582af9a5846b4d8995b26b1421488d29d761b
secrets:
DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }}
+82
View File
@@ -0,0 +1,82 @@
name: YouTube Auto-Post
on:
schedule:
# Once a day at 14:47 UTC (21:47 Vietnam), this repo's slot in the ops registry.
# The runner is the maintainer's PC: scheduled jobs live inside 13:00-16:00 UTC,
# and while the PC is off a run waits, starts when it comes back, and is
# cancelled after 24 h unpicked (runbook §1, §3.2 item 9). The lookback window
# (LOOKBACK_HOURS) covers a late start and one missed day.
- cron: "47 14 * * *"
workflow_dispatch: # Manual trigger for testing
# `main` is protected and the job token cannot push to it, so the posted-ID state
# lives on the orphan `state` branch. Nothing here ever pushes to `main`.
permissions: {}
concurrency:
group: youtube-auto-post
cancel-in-progress: false
jobs:
notify:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write # push to the `state` branch
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Checkout state branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: state
path: state
# This checkout keeps its token on purpose: the last step pushes with it.
persist-credentials: true
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.15"
- name: Run notification script
env:
STATE_FILE: state/last_video.txt
LOOKBACK_HOURS: "72"
# Required
YOUTUBE_CHANNEL_ID: ${{ secrets.YOUTUBE_CHANNEL_ID }}
# Telegram
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
# Bluesky
BLUESKY_HANDLE: ${{ secrets.BLUESKY_HANDLE }}
BLUESKY_APP_PASSWORD: ${{ secrets.BLUESKY_APP_PASSWORD }}
# Discord (optional)
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
# Mastodon (optional)
MASTODON_INSTANCE_URL: ${{ secrets.MASTODON_INSTANCE_URL }}
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
run: python scripts/notify.py
# Runs even when the script exits 1 (a platform failed) so partial progress is
# kept; the job still ends red and the CI-failure notifier fires.
- name: Commit state
if: ${{ !cancelled() }}
working-directory: state
run: |
set -euo pipefail
# Gitea's own Actions user, as the job token is.
git config user.name "gitea-actions"
git config user.email "teabot@gitea.io"
git add last_video.txt
if git diff --cached --quiet; then
echo "No state changes."
exit 0
fi
git commit -m "chore: update posted video state"
git push origin HEAD:state
+75
View File
@@ -0,0 +1,75 @@
# Tag `vX.Y.Z` → Gitea release whose notes are that version's entry in
# `changelog/<major>.x.md` → Discord announcement.
#
# The announce job calls the ops reusable directly: a release created with the job
# token fires no `release: published` to other workflows (Gitea skips its Actions
# user, as GitHub skipped GITHUB_TOKEN), so announce-release.yml never fires for
# releases made here. It still covers releases published by hand in the UI.
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write # VERIFY which of contents / releases Gitea enforces
releases: write # for creating a release (runbook §3.2 item 5)
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.15"
- name: Extract release notes from changelog
env:
TAG: ${{ github.ref_name }}
run: python scripts/release_notes.py "$TAG" > release-notes.md
# A tag with a suffix (v2.0.0-beta.1) is a pre-release.
- name: Release kind
id: kind
env:
TAG: ${{ github.ref_name }}
run: |
case "$TAG" in
*-*) echo "prerelease=true" >> "$GITHUB_OUTPUT" ;;
*) echo "prerelease=false" >> "$GITHUB_OUTPUT" ;;
esac
# Notes only, no files: Gitea releases carry notes and links (runbook §1).
# The action uses the job token by default.
- name: Create the Gitea release
uses: https://gitea.com/actions/gitea-release-action@5a83c90484ef4355121df5eb60558c8ce66e81ac # v1.3.7
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: release-notes.md
prerelease: ${{ steps.kind.outputs.prerelease }}
announce:
needs: release
# Pinned like announce-release.yml: `ops_ref` is the same SHA as `uses:`.
uses: poli0981/.github/.gitea/workflows/announce-release.yml@8e6582af9a5846b4d8995b26b1421488d29d761b # ops main 2026-11-23 (untagged, after v2026.11.1)
with:
tag_override: ${{ github.ref_name }}
ops_ref: 8e6582af9a5846b4d8995b26b1421488d29d761b
secrets:
DISCORD_RELEASES_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }}
DISCORD_REPO_WEBHOOK: ${{ secrets.DISCORD_REPO_WEBHOOK }}
DISCORD_PING_ROLE_ID: ${{ secrets.DISCORD_PING_ROLE_ID }}
+34
View File
@@ -0,0 +1,34 @@
# Security checks from the ops repo (runbook §3.5 item 2, §4.3):
#
# secrets → gitleaks over the whole git history; fails on a finding
# sast → Opengrep: the workflow, Dockerfile and shell rules always, plus the
# Python rules (`python: true`); report only, SARIF as an artifact
# (Gitea has no code-scanning UI)
# deps → osv-scanner over the lockfiles (requirements-dev.txt); fails on a
# known vulnerability
#
# Next to ci.yml's own checks (ruff's `S` rules, zizmor, actionlint, Qodana), this
# stands in for the CodeQL that Gitea does not have. Not part of the required `ci`
# check. No secrets: nothing here needs a token.
name: Security
on:
push:
branches: [main]
pull_request:
schedule:
- cron: "47 15 * * 4" # weekly, Thursday 15:47 UTC = 22:47 Vietnam (ops registry slot)
workflow_dispatch:
# Explicit, and granted on the job.
permissions: {}
jobs:
security:
permissions:
contents: read
# Pinned like the notifier callers. Renovate does not bump this pin: move it by
# hand when the ops repo is tagged (runbook §3.2 item 3).
uses: poli0981/.github/.gitea/workflows/security.yml@8e6582af9a5846b4d8995b26b1421488d29d761b # ops main 2026-11-23 (untagged, after v2026.11.1)
with:
python: true
+12
View File
@@ -0,0 +1,12 @@
# actionlint settings, read by the `security` job in .gitea/workflows/ci.yml and by a
# local run from the repo root:
# actionlint -config-file .github/actionlint.yaml .gitea/workflows/*.yml
# Only Gitea features that actionlint does not know are ignored here (as in the ops
# repo's own .github/actionlint.yaml); everything else stays an error.
paths:
.gitea/workflows/*.yml:
ignore:
# Gitea's own token scope for releases (runbook §3.2 item 5)
- 'unknown permission scope "releases"'
# Gitea resolves full-URL actions; bare owner/repo goes to github.com (runbook §1)
- 'specifying action "https://gitea\.com/[^"]+" in invalid format'
+25
View File
@@ -0,0 +1,25 @@
# zizmor configuration — https://docs.zizmor.sh/configuration/
# Read by the `security` job in .gitea/workflows/ci.yml (`--config`), which audits
# .gitea/workflows offline.
#
# Every ignore below names the workflow it applies to and why the finding is
# accepted. Anything not listed here must be fixed, not ignored.
rules:
unpinned-uses:
config:
policies:
# Every action and every call into poli0981/.github is pinned to a full
# commit SHA, the ops repo included (runbook §3.2 item 3, rule 6).
"*": hash-pin
dangerous-triggers:
# `workflow_run` with no checkout of the triggering code and no use of
# PR-controlled input; it only forwards run metadata to a Discord webhook.
ignore:
- notify-ci-failure.yml
artipacked:
# The second checkout in notify.yml keeps its token on purpose: it is the
# checkout of the `state` branch that the last step pushes to.
ignore:
- notify.yml
+210
View File
@@ -0,0 +1,210 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[codz]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py.cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
#poetry.toml
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
#pdm.lock
#pdm.toml
.pdm-python
.pdm-build/
# pixi
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
#pixi.lock
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
# in the .venv directory. It is recommended not to include this directory in version control.
.pixi
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.envrc
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
# Abstra
# Abstra is an AI-powered process automation framework.
# Ignore directories containing user credentials, local state, and settings.
# Learn more at https://abstra.io/docs
.abstra/
# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc
# Cursor
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore
# Marimo
marimo/_static/
marimo/_lsp/
__marimo__/
# Local checkout of the orphan `state` branch (see README) and local state runs
state/
+7
View File
@@ -0,0 +1,7 @@
# gitleaks findings accepted on purpose (read by the ops repo's security.yml, which
# runs `gitleaks git` from the repo root). Each line is a finding's fingerprint
# (commit:file:rule:line), with the reason above it. Anything else gets fixed.
# SETUP_NEW_PLATFORMS.md, the Mastodon curl example: `Authorization: Bearer
# YOUR_TOKEN` is a placeholder for the reader's own token, not a credential.
779499c1bffca6e13b36d076e0df24160214ad43:SETUP_NEW_PLATFORMS.md:curl-auth-header:25
+9
View File
@@ -0,0 +1,9 @@
# Changelog
Chi tiết nằm trong [`changelog/`](changelog/), mỗi dòng major một file, bản mới nhất ở trên.
- **[1.x](changelog/1.x.md)** — từ 1.0.0 đến hiện tại
- [Quy ước và luật tách file](changelog/README.md)
File này chỉ trỏ, không chép lại nội dung. Một changelog duy nhất cứ dài mãi là thứ thư mục kia
sinh ra để tránh, và hai chỗ để ghi release note là một chỗ để quên.
+295
View File
@@ -0,0 +1,295 @@
# 🤖 YouTube Auto-Post
[![status: maintenance](https://img.shields.io/badge/status-maintenance-yellow)](#9-trạng-thái-dự-án)
[![ci](https://git.poli0981.dev/poli0981/youtube-auto-post/actions/workflows/ci.yml/badge.svg?branch=main)](https://git.poli0981.dev/poli0981/youtube-auto-post/actions?workflow=ci.yml)
[![Qodana](https://img.shields.io/badge/Qodana-analysed-000000?logo=jetbrains&logoColor=white)](https://qodana.cloud/projects/oDgKr)
[![Python 3.15](https://img.shields.io/badge/python-3.15-3776AB?logo=python&logoColor=white)](#6-phát-triển)
[![dependencies: stdlib only](https://img.shields.io/badge/dependencies-stdlib%20only-brightgreen)](#6-phát-triển)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![zizmor](https://img.shields.io/badge/%F0%9F%8C%88-zizmor-white?labelColor=white)](https://zizmor.sh/)
[![Renovate](https://img.shields.io/badge/renovate-enabled-1A1F6C?logo=renovatebot&logoColor=white)](renovate.json)
Tự động đăng thông báo video mới của kênh YouTube lên **Telegram, Bluesky, Discord, Mastodon**
bằng Gitea Actions. Script chỉ dùng thư viện chuẩn Python, không cài gì
thêm.
> [!IMPORTANT]
> **Chế độ bảo trì** từ 1.4.2: không thêm tính năng mới, trừ vài trường hợp ở
> [mục 9](#9-trạng-thái-dự-án) (cập nhật phụ thuộc, vá bảo mật, lên bản Python mới).
## Repo ở đâu
- **Mã nguồn (bản gốc):** [`git.poli0981.dev/poli0981/youtube-auto-post`](https://git.poli0981.dev/poli0981/youtube-auto-post), clone
`https://git.poli0981.dev/poli0981/youtube-auto-post.git`.
- **Issue và merge request:** mirror
[`gitlab.com/poli0981/youtube-auto-post`](https://gitlab.com/poli0981/youtube-auto-post/-/issues).
Gitea không mở đăng ký nên người ngoài không mở issue hay PR ở đó được; mirror trên GitLab không
chạy CI, CI chạy trên Gitea.
- **Gửi patch và câu hỏi:** `code@poli0981.dev`.
- **Bảo mật:** `security@poli0981.dev`, xem [SECURITY.md](SECURITY.md). Đừng mở issue công khai cho
lỗ hổng.
Repo chuyển khỏi GitHub vào tháng 11/2026; link `github.com/poli0981/youtube-auto-post` không còn
dẫn tới đâu.
---
## Mục lục
1. [Cách hoạt động](#1-cách-hoạt-động)
2. [Cấu trúc repo](#2-cấu-trúc-repo)
3. [Secrets và biến](#3-secrets-và-biến)
4. [Lấy token Telegram, Bluesky](#4-lấy-token-telegram-bluesky)
5. [Nhánh `state`](#5-nhánh-state)
6. [Phát triển](#6-phát-triển)
7. [Release](#7-release)
8. [Bảo vệ nhánh](#8-bảo-vệ-nhánh)
9. [Trạng thái dự án](#9-trạng-thái-dự-án)
---
## 1. Cách hoạt động
Workflow [`notify.yml`](.gitea/workflows/notify.yml) chạy mỗi ngày một lần lúc **14:47 UTC**
(21:47 giờ Việt Nam) hoặc khi bấm **Run workflow**. Runner là máy PC của maintainer, nên lịch của mọi
repo chỉ nằm trong khung 13:00–16:00 UTC. Máy tắt thì lần chạy chờ tới khi máy bật lại, quá 24 giờ
chưa chạy thì bị huỷ: một video có thể chờ tới một ngày mới được đăng. Script không phụ thuộc vào giờ
chạy chính xác.
1. Đọc RSS của kênh, giữ các video có `published` trong `LOOKBACK_HOURS` gần nhất (mặc định 72h,
đủ cho một lần chạy trễ cộng một ngày bị lỡ).
2. Bỏ các ID đã có trong state (`last_video.txt` trên nhánh `state`).
3. Với mỗi video còn lại, kiểm tra trang watch: **Premiere chưa lên sóng thì bỏ qua**, lần chạy sau
thử lại. RSS liệt kê Premiere từ lúc upload, nên không có bước này bot sẽ đăng sớm.
4. Đăng lên từng platform có secret; platform thiếu secret thì skip.
5. Lưu ID vào nhánh `state` khi ít nhất một platform đăng được. Nếu một platform **đã cấu hình** mà
lỗi, job kết thúc đỏ và [`notify-ci-failure.yml`](.gitea/workflows/notify-ci-failure.yml) báo
lên Discord.
Nội dung bài đăng:
```
🎬 New Video / Video Mới
<tiêu đề>
▶️ https://www.youtube.com/watch?v=...
```
Mastodon thêm dòng hashtag (`HASHTAGS`). Bluesky đính link card kèm thumbnail, tiêu đề quá dài
được cắt về 300 ký tự.
---
## 2. Cấu trúc repo
```
.gitea/
workflows/
notify.yml # Đăng bài theo lịch, ghi state lên nhánh `state`
ci.yml # ruff, pytest + coverage, zizmor, actionlint, Qodana — gate `ci` là required check
security.yml # Caller vào security.yml của poli0981/.github: gitleaks, Opengrep, osv-scanner
release.yml # tag v* → Gitea release từ changelog → Discord
announce-release.yml # Caller vào reusable của poli0981/.github (release tạo tay)
notify-ci-failure.yml # Caller vào reusable của poli0981/.github
.github/
actionlint.yaml # actionlint: chỉ bỏ qua tính năng riêng của Gitea
zizmor.yml # zizmor: các finding được chấp nhận, kèm lý do
scripts/
notify.py # Điều phối: RSS → lọc → kiểm tra public → đăng → state → exit code
youtube.py # Parse RSS, cửa sổ thời gian, kiểm tra Premiere
message.py # Dựng nội dung bài đăng, cắt độ dài
http_client.py # urllib + một kiểu lỗi chung (HttpError)
state.py # Đọc/ghi last_video.txt
config.py # Biến môi trường
release_notes.py # Trích entry changelog cho release.yml
platforms/ # Mỗi module: post(video) -> PostStatus
tests/ # pytest, không gọi mạng
changelog/ # Chi tiết từng phiên bản (CHANGELOG.md ở root chỉ trỏ tới đây)
requirements-dev.in # Công cụ dev; requirements-dev.txt là bản khoá theo hash của nó
renovate.json # Renovate, dùng preset chung poli0981/renovate-config
.gitleaksignore # gitleaks (security.yml): các finding được chấp nhận, kèm lý do
qodana.yaml # Qodana, đọc bởi job `qodana` của ci.yml
SECURITY.md # Cách báo lỗ hổng bảo mật
```
---
## 3. Secrets và biến
Trên Gitea: repo → **Settings → Actions → Secrets → Add secret**.
| Secret | Platform | Bắt buộc | Ghi chú |
|-------------------------|-----------|----------|-------------------------------------------------|
| `YOUTUBE_CHANNEL_ID` | YouTube | ✅ | `UC...` |
| `TELEGRAM_BOT_TOKEN` | Telegram | ✅ | Từ BotFather |
| `TELEGRAM_CHAT_ID` | Telegram | ✅ | `-100...` |
| `BLUESKY_HANDLE` | Bluesky | ✅ | `ten.bsky.social` |
| `BLUESKY_APP_PASSWORD` | Bluesky | ✅ | App Password, không phải mật khẩu đăng nhập |
| `DISCORD_WEBHOOK_URL` | Discord | Tuỳ chọn | `https://discord.com/api/webhooks/ID/TOKEN` |
| `MASTODON_INSTANCE_URL` | Mastodon | Tuỳ chọn | Không có `/` cuối |
| `MASTODON_ACCESS_TOKEN` | Mastodon | Tuỳ chọn | Scope `write:statuses` |
Cách lấy token Mastodon và Discord: [SETUP_NEW_PLATFORMS.md](SETUP_NEW_PLATFORMS.md).
Secret cho CI và thông báo, không phải cho bot. Secret dùng chung cho nhiều repo nên đặt ở mức user
(Gitea → Settings của tài khoản → Actions → Secrets), repo nào cũng đọc được:
| Secret | Dùng ở | Bắt buộc | Ghi chú |
|----------------------------|---------------------------------------|----------|--------------------------------------------|
| `QODANA_TOKEN` | Job `qodana` của `ci.yml` | ✅ | Project token của Qodana Cloud (mục 6) |
| `DISCORD_CI_WEBHOOK` | `notify-ci-failure.yml` | ✅ | Kênh Discord nhận báo workflow lỗi |
| `DISCORD_RELEASES_WEBHOOK` | `release.yml`, `announce-release.yml` | Tuỳ chọn | Cần ít nhất một trong hai webhook release |
| `DISCORD_REPO_WEBHOOK` | `release.yml`, `announce-release.yml` | Tuỳ chọn | |
| `DISCORD_PING_ROLE_ID` | `release.yml`, `announce-release.yml` | Tuỳ chọn | Role được ping khi có bản chính thức |
Biến đặt trực tiếp trong `notify.yml` (không phải secret):
| Biến | Mặc định | Ý nghĩa |
|------------------|-----------------------------------|-------------------------------------------------|
| `LOOKBACK_HOURS` | `72` | Chỉ xét video published trong khoảng này |
| `HASHTAGS` | `#gaming #gameplay #nocommentary` | Dòng hashtag cho Mastodon; để rỗng để tắt |
---
## 4. Lấy token Telegram, Bluesky
**Telegram Bot**
1. Nhắn `/newbot` cho [@BotFather](https://t.me/BotFather), nhận **Bot Token**.
2. Tạo Channel/Group, thêm bot làm admin.
3. Gửi một tin bất kỳ vào channel rồi mở `https://api.telegram.org/bot<TOKEN>/getUpdates`, tìm
`"chat":{"id": -100xxxxxxxxxx}`.
**Bluesky App Password**
1. [bsky.app](https://bsky.app) → Settings → App Passwords → tạo mới.
2. Handle dạng `ten.bsky.social`.
**Discord không cần code**: có thể dùng [MonitoRSS](https://monitorss.xyz) đọc thẳng RSS kênh thay
cho webhook.
---
## 5. Nhánh `state`
`main` được bảo vệ (mục 8) và job token của Gitea Actions không push được lên đó, nên bot không thể
commit lên `main`.
Danh sách ID đã đăng nằm trên nhánh orphan **`state`**, chỉ có một file `last_video.txt` (tối đa 100
ID, cũ nhất ở trên). Workflow checkout nhánh này vào thư mục `state/` và push lại sau khi chạy.
Xem state hiện tại:
```bash
git fetch origin state && git show origin/state:last_video.txt
```
Muốn bot đăng lại một video (hoặc bỏ qua một video): sửa file trên nhánh `state` và push — nhánh
này không được bảo vệ (job token phải push được lên nó).
Chạy local thì đặt `STATE_FILE` (mặc định `state/last_video.txt`, thư mục `state/` đã gitignore).
---
## 6. Phát triển
Cần **Python 3.15**, cùng bản với CI, bot và release. Code dùng cú pháp chỉ có từ 3.14
(`except A, B:` không ngoặc), nên Python 3.13 trở xuống không chạy được.
```bash
python -m pip install --require-hashes --only-binary :all: -r requirements-dev.txt
ruff check . && ruff format --check .
pytest --cov --cov-report=term-missing
```
CI chạy đúng ba lệnh trên, cộng zizmor và actionlint cho workflow và Qodana (dưới đây). Kiểm workflow
ở máy như CI (actionlint 1.7.12 tải từ trang release của nó):
```bash
zizmor --offline --config .github/zizmor.yml .gitea/workflows/*.yml
actionlint -config-file .github/actionlint.yaml .gitea/workflows/*.yml
```
Coverage đo `scripts/` theo cả dòng lẫn nhánh; dưới 95 % thì `pytest --cov` báo lỗi. Test không gọi
mạng: mọi request đi qua `http_client`, test thay hàm của nó bằng hàm giả. Các hàm `build_text`,
`select_recent`, `is_public_html` là chỗ để thêm test khi đổi hành vi.
**Công cụ dev** (ruff, zizmor, pytest, pytest-cov) khoá theo hash: sửa `requirements-dev.in`, rồi
biên dịch lại `requirements-dev.txt` bằng pip-tools chạy trên **Python 3.14** (Renovate chạy lại
lệnh ở header của file khoá, trên bản Python ghi ở đó):
```bash
pip-compile --generate-hashes --allow-unsafe --strip-extras --output-file=requirements-dev.txt requirements-dev.in
```
**Qodana** (JetBrains): job `qodana` chạy linter Ultimate `qodana-python` (bộ inspection của PyCharm
Professional, profile `qodana.recommended`) trên mỗi PR và mỗi lần push lên `main`, cấu hình ở
[`qodana.yaml`](qodana.yaml). Job tải Qodana CLI ở bản cố định, kiểm SHA-256, rồi chạy linter native
trên runner với Python 3.15 của job, không qua Docker. Có problem nào là job đỏ (`failThreshold: 0`),
kéo check `ci` đỏ theo. Kết quả nằm trên [Qodana Cloud](https://qodana.cloud/projects/oDgKr) và trong
artifact `qodana-report` của lần chạy (Gitea không có giao diện code scanning). Cần secret
`QODANA_TOKEN` (project token của Qodana Cloud, cũng là licence Ultimate). Gitea đưa secret cho mọi PR
mở từ chính repo, kể cả PR của Renovate, nên lần chạy của `renovate-bot` bỏ qua bước quét mà vẫn
xanh; lần push lên `main` sau khi merge mới quét bản cập nhật đó.
**`security.yml`** gọi workflow bảo mật chung của repo ops: gitleaks quét toàn bộ lịch sử git,
Opengrep với bộ rule cho workflow, shell và Python (chỉ báo cáo), osv-scanner quét file khoá. Chạy
khi push lên `main`, trên mỗi PR và mỗi thứ Năm lúc 15:47 UTC. Không nằm trong check `ci`.
Chạy thử script local (cần secret trong env):
```bash
STATE_FILE=/tmp/state.txt YOUTUBE_CHANNEL_ID=UC... TELEGRAM_BOT_TOKEN=... TELEGRAM_CHAT_ID=... python scripts/notify.py
```
---
## 7. Release
1. Thêm entry `## x.y.z — YYYY-MM-DD` vào đầu [`changelog/1.x.md`](changelog/1.x.md) qua PR.
2. Sau khi merge, tag đã ký trên `main` và push:
```bash
git tag -s v1.5.0 -m v1.5.0 && git push origin v1.5.0
```
3. [`release.yml`](.gitea/workflows/release.yml) tạo Gitea release (chỉ có ghi chú, không đính file)
với nội dung entry đó rồi gọi workflow thông báo Discord.
Quy ước changelog: [changelog/README.md](changelog/README.md).
---
## 8. Bảo vệ nhánh
Branch protection của Gitea trên `main`: không push thẳng, chỉ merge qua PR bằng **squash**, check
`ci` phải xanh, không force-push, không xoá. Commit trong PR vẫn ký GPG. Tag `v*` được bảo vệ khỏi
xoá/ghi đè (Settings → Tags), vì một tag phải đúng ngay lần đầu.
**Renovate** (tự host, chạy mỗi ngày lúc 13:31 UTC từ repo `poli0981/renovate-config`) thay
Dependabot: mở PR gộp các bản cập nhật non-major cho action và công cụ dev; bản PyPI mới chờ 3 ngày
mới được đề xuất; lỗ hổng đã biết thì có PR riêng mang nhãn `security`. Danh sách nằm ở issue
**Dependency Dashboard** của repo. PR của Renovate tụt sau `main` thì tick ô rebase/retry trong mô tả
PR, lần chạy sau của Renovate sẽ rebase.
Gitea không có CodeQL; thay bằng ruff rule `S`, zizmor, actionlint và Qodana trong CI, cùng gitleaks,
Opengrep và osv-scanner trong `security.yml` (mục 6).
---
## 9. Trạng thái dự án
**Bảo trì** từ 1.4.2 (2026-11-16). Bot đã làm đủ việc của nó, nên **không thêm tính năng mới**. Repo
chỉ thay đổi trong ba trường hợp:
1. **Cập nhật phụ thuộc định kỳ.** Renovate mở PR gộp cho các action và công cụ dev (mục 8); CI
xanh thì merge.
2. **Bảo mật, và tính năng thật sự cần thiết.** Phụ thuộc dính CVE mức **High** trở lên, hoặc thứ
bot chạy trên đó có lỗ hổng nghiêm trọng (như Node.js, runtime của các action), được sửa ngay,
không chờ lịch Renovate. Tính năng mới chỉ thêm khi được đánh giá là thật sự cần thiết.
3. **Bản ngôn ngữ mới.** Lên bản Python kế tiếp, như 3.14 → 3.15 ở 1.4.0.
Đề xuất tính năng (issue hay merge request trên mirror GitLab) ngoài ba trường hợp trên sẽ không
được nhận. Thay đổi nào cũng vẫn
đi qua PR và CI (mục 6–8), và có entry trong [changelog](changelog/1.x.md) nếu người dùng bot nhận
thấy.
+35
View File
@@ -0,0 +1,35 @@
# Security Policy
## Supported versions
Only `main` is supported. The bot runs from `main` on a schedule, so a fix is live from the first
run after it merges.
The project is in maintenance mode ([README §9](README.md#9-trạng-thái-dự-án)), and security is the
part of it that does not wait: a vulnerability rated **High** or above in a dependency, or a serious
one in what the bot runs on (Python, the CI actions and their Node.js runtime), is fixed as soon as a
fixed version exists.
## Reporting a vulnerability
**Report by e-mail to security@poli0981.dev, and do not open a public issue for a security problem,
on the GitLab mirror or anywhere else.** E-mail is the only private channel: the repository moved
from GitHub in November 2026, and GitHub's private vulnerability reporting went with it. A report
that arrives as a public GitLab issue is made confidential there and continued by e-mail.
This is a solo, unpaid project: there is no bounty and no formal response time, but genuine reports
are answered and credited unless you prefer otherwise.
## Scope
In scope: the scripts in `scripts/` (for example anything that leaks a platform token, or makes the
bot post something other than the channel's own videos), and the workflows in `.gitea/workflows/`
(anything that lets untrusted input run code or reach a secret).
Out of scope: the platforms the bot posts to (Telegram, Bluesky, Discord, Mastodon) and YouTube
itself, and anything that needs the maintainer's machine or accounts to be compromised first.
---
**Tiếng Việt:** báo lỗ hổng bảo mật qua e-mail tới `security@poli0981.dev`. Đừng mở issue công khai
cho lỗ hổng, kể cả trên mirror GitLab.
+59
View File
@@ -0,0 +1,59 @@
# 🆕 Hướng Dẫn Thiết Lập Platform Tuỳ Chọn
Telegram và Bluesky (bắt buộc) xem [README.md](README.md#4-lấy-token-telegram-bluesky). Dưới đây là
platform tuỳ chọn; thiếu secret thì bot tự bỏ qua platform đó.
---
## Mastodon
### Lấy Access Token
1. Đăng nhập Mastodon instance (e.g. `https://mastodon.social`)
2. Vào **Preferences → Development → New Application**
3. Tên: `YouTubeAutoPost`
4. Scopes: chỉ cần ✅ `write:statuses`
5. Submit → copy **Access Token**
### Secrets cần thêm
| Secret | Giá trị | Ví dụ |
|-------------------------|----------------------------------|---------------------------|
| `MASTODON_INSTANCE_URL` | URL instance (không có `/` cuối) | `https://mastodon.social` |
| `MASTODON_ACCESS_TOKEN` | Token từ bước trên | `abc123...` |
### Test nhanh
```bash
curl -X POST "https://mastodon.social/api/v1/statuses" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d "status=Test post from API&visibility=direct"
```
Dùng `visibility=direct` để test mà không public.
---
## Discord
1. Discord → Server Settings → Integrations → Webhooks → **New Webhook**
2. Chọn kênh, copy **Webhook URL** → secret `DISCORD_WEBHOOK_URL`
Không cần code cũng được: [MonitoRSS](https://monitorss.xyz) đọc thẳng RSS của kênh.
---
## Tổng Hợp Secrets
Thêm trên Gitea: repo → **Settings → Actions → Secrets → Add secret**.
| Secret | Platform | Bắt buộc |
|-------------------------|----------|----------|
| `YOUTUBE_CHANNEL_ID` | YouTube | ✅ |
| `TELEGRAM_BOT_TOKEN` | Telegram | ✅ |
| `TELEGRAM_CHAT_ID` | Telegram | ✅ |
| `BLUESKY_HANDLE` | Bluesky | ✅ |
| `BLUESKY_APP_PASSWORD` | Bluesky | ✅ |
| `DISCORD_WEBHOOK_URL` | Discord | Tuỳ chọn |
| `MASTODON_INSTANCE_URL` | Mastodon | Tuỳ chọn |
| `MASTODON_ACCESS_TOKEN` | Mastodon | Tuỳ chọn |
+168
View File
@@ -0,0 +1,168 @@
# 1.x
Mới nhất ở trên. Quy ước ở [`README.md`](README.md).
## 1.5.0 — 2026-11-23
Repo chuyển từ GitHub sang Gitea, và bot đăng bài mỗi ngày một lần. Nội dung bài đăng và secret của
bot không đổi.
### Changed
- **Mỗi ngày một lần**, lúc 14:47 UTC (21:47 giờ Việt Nam), thay cho ba lần (06:30, 14:30, 22:30
UTC). Workflow chạy trên Gitea Actions với runner là máy của maintainer: máy tắt thì lần chạy chờ
tới khi máy bật lại, quá 24 giờ thì bị huỷ, nên một video có thể chờ tới một ngày mới được đăng.
- `LOOKBACK_HOURS` mặc định là **72** (trước là 48), đủ cho một lần chạy trễ cộng một ngày bị lỡ.
- Mã nguồn ở [git.poli0981.dev/poli0981/youtube-auto-post](https://git.poli0981.dev/poli0981/youtube-auto-post);
issue và merge request qua mirror [GitLab](https://gitlab.com/poli0981/youtube-auto-post); lỗ hổng
bảo mật báo qua e-mail `security@poli0981.dev` ([SECURITY.md](https://git.poli0981.dev/poli0981/youtube-auto-post/src/branch/main/SECURITY.md)). User-Agent của bot
trỏ về địa chỉ Gitea.
- Secret đặt trong Gitea (repo → Settings → Actions → Secrets), cùng tên như trước. Release là Gitea
release, nội dung vẫn lấy từ entry changelog.
- CI: workflow mới `security.yml` (gitleaks, Opengrep, osv-scanner) từ repo ops, Renovate thay
Dependabot, Qodana chạy bằng CLI và lưu báo cáo thành artifact.
### Removed
- **SonarQube Cloud**: job `sonar` và `sonar-project.properties`. Secret `SONAR_TOKEN` không còn được
đọc. Qodana vẫn nằm trong check `ci`.
## 1.4.2 — 2026-11-16
Dự án chuyển sang chế độ bảo trì, và Qodana vào CI. Bài đăng, lịch chạy và secret của bot không đổi.
[PR #14](https://github.com/poli0981/youtube-auto-post/pull/14)
### Changed
- **Chế độ bảo trì**: không thêm tính năng mới. Repo chỉ còn thay đổi khi cập nhật phụ thuộc định
kỳ, khi một phụ thuộc dính CVE từ mức High trở lên hoặc nền chạy bot (như Node.js của các action)
có lỗ hổng nghiêm trọng, khi một tính năng được đánh giá là thật sự cần thiết, hoặc khi lên bản
Python mới. Chi tiết ở mục 9 của README.
- **Qodana** (JetBrains, bản Ultimate cho Python) phân tích trong CI cạnh SonarQube Cloud: job
`qodana` của `ci.yml`, cấu hình ở `qodana.yaml`. Có problem nào thì check `ci` đỏ và PR không merge
được. CI cần secret `QODANA_TOKEN`; PR của Dependabot bỏ qua bước này.
## 1.4.1 — 2026-10-25
SonarQube Cloud chạy trong CI, có coverage. Bài đăng, lịch chạy và secret của bot không đổi.
[PR #7](https://github.com/poli0981/youtube-auto-post/pull/7)
### Changed
- **SonarQube Cloud phân tích trong CI** (job `sonar` của `ci.yml`, cấu hình ở
`sonar-project.properties`) thay cho Automatic Analysis, kèm coverage của pytest. Quality gate nằm
trong check `ci`: gate fail thì PR không merge được. CI cần secret `SONAR_TOKEN`; PR của Dependabot
bỏ qua bước phân tích.
- Công cụ dev khoá theo hash (`requirements-dev.in` → `requirements-dev.txt`) và CI chỉ cài wheel, nên
bản mới của một gói, kể cả gói gián tiếp, không tự lọt vào CI. zizmor lên 1.31.1.
- `release_notes.py` chỉ nhận tag dạng `vX.Y.Z` hoặc `vX.Y.Z-…` và không còn tham số thư mục.
### Fixed
- Phản hồi lỗi HTTP (4xx/5xx) được đóng sau khi đọc, không còn để mở tới khi bị dọn.
## 1.4.0 — 2026-10-22
Chuyển lên Python 3.15. Bài đăng, lịch chạy và secret không đổi.
### Changed
- **Python 3.15** cho bot, CI và release (trước là 3.14). Chạy script hoặc test ở máy cần Python
3.15; code dùng cú pháp `except A, B:` của 3.14+, nên 3.13 trở xuống không chạy được.
- Trên Windows, script in tiếng Việt ra pipe hoặc file không còn lỗi `UnicodeEncodeError`: Python
3.15 mặc định bật UTF-8 mode (PEP 686).
- Công cụ dev: ruff 0.17.1, kiểm theo cú pháp Python 3.15. Test coi mọi warning là lỗi, nên một API
Python sắp gỡ làm CI đỏ trước khi kịp làm hỏng bot.
## 1.3.0 — 2026-09-02
### Removed
- **X/Twitter và Facebook Page** không còn trong quy trình: module, biến môi trường, dòng secret
trong `notify.yml`, phần cắt 280 ký tự và hướng dẫn lấy token đều gỡ. Bot đăng lên Telegram,
Bluesky, Discord và Mastodon. Các secret `X_*` còn trong repo không được đọc nữa, xoá tuỳ ý.
### Changed
- `HASHTAGS` giờ chỉ áp dụng cho Mastodon.
## 1.2.0 — 2026-09-02
Sửa ba lỗi khiến bài đăng sai hoặc thiếu, và dựng hạ tầng CI, bảo vệ nhánh, release.
### Fixed
- **Telegram hiển thị `\[2K\] ... \|` với backslash.** Tiêu đề được escape theo MarkdownV2 nhưng
gửi với `parse_mode=Markdown` cũ, nên backslash hiện nguyên. Chuyển sang HTML mode; tiêu đề
hiện đúng nguyên văn.
- **Premiere đã lên lịch bị đăng trước giờ lên sóng.** RSS liệt kê Premiere từ lúc upload với
`published` là giờ upload, nên bot đăng "video mới" khi người xem bấm vào chỉ thấy đếm ngược.
Nay mỗi video được kiểm tra trên trang watch; chưa public thì để lần chạy sau.
- **Video đăng cuối ngày có thể bị bỏ sót vĩnh viễn.** Bộ lọc "published hôm nay (UTC)" cộng với
lịch chạy bị GitHub trễ qua nửa đêm UTC làm video đăng sau lần chạy cuối trong ngày không bao
giờ được xét. Thay bằng cửa sổ `LOOKBACK_HOURS` (mặc định 48h); state vẫn chặn đăng trùng.
- **Lỗi platform không bao giờ được báo.** Skip (thiếu secret) và lỗi thật đều là "false" và job
luôn xanh. Nay phân biệt `OK / skipped / FAILED`; có platform đã cấu hình mà lỗi thì job đỏ và
thông báo CI-failure trên Discord bắn.
- RSS trả XML hỏng làm script crash; Bluesky đăng nhập lại cho từng video.
### Added
- **CI** (`ci.yml`): ruff (kèm rule bảo mật `S`), pytest, zizmor và actionlint cho workflow. Job
gate `ci` là required status check của `main`.
- **Dependabot** cho GitHub Actions và công cụ dev; action pin theo SHA.
- **`release.yml`**: push tag `v*` → GitHub Release với nội dung lấy từ entry changelog tương ứng →
thông báo Discord.
- Cắt tiêu đề quá dài cho Bluesky (300) và X (280, tính theo trọng số của X).
- Biến `HASHTAGS` (Mastodon, X) và `LOOKBACK_HOURS` đặt trong `notify.yml`.
- Thư mục `changelog/` này và `CHANGELOG.md` trỏ tới nó.
### Changed
- **State chuyển sang nhánh orphan `state`** (file `last_video.txt`). `main` không còn nhận
commit "chore: update last video state" và được bảo vệ bằng ruleset: bắt buộc PR, chỉ squash,
commit ký, CI xanh, không ai bypass.
- Nội dung bài đăng dựng ở một chỗ (`scripts/message.py`); mọi request HTTP đi qua
`scripts/http_client.py` với một kiểu lỗi chung.
- `actions/checkout` và `actions/setup-python` lên v7. README viết lại theo hiện trạng.
### Removed
- `.github/scripts/discord_notify.py` — bản sao không được workflow nào dùng; reusable workflow
lấy script từ `poli0981/.github`.
- `data/last_video.txt` trên `main` (đã sang nhánh `state`).
### Cần làm tay
- Thêm secret `X_API_KEY`: hiện thiếu nên X/Twitter luôn bị skip.
## 1.1.1 — 2026-05-09
### Added
- Thông báo Discord khi publish release và khi CI lỗi, qua reusable workflows của
`poli0981/.github`.
## 1.1.0 — 2026-04-16
Tách script đơn khối thành module và đăng được nhiều video trong một ngày.
[PR #1](https://github.com/poli0981/youtube-auto-post/pull/1)
### Added
- Đăng mọi video mới trong ngày, có nghỉ ngẫu nhiên 1–5 giây giữa các video.
- State giữ tối đa 100 ID thay vì một ID cuối.
### Changed
- Lịch chạy 3 lần/ngày (06:30, 14:30, 22:30 UTC) thay vì mỗi giờ.
- Mã tách thành `scripts/youtube.py`, `scripts/state.py`, `scripts/platforms/*`.
## 1.0.0 — 2026-04-13
### Added
- Đăng thông báo video mới lên Telegram, Bluesky và Discord; cùng ngày thêm Mastodon, X/Twitter
và Facebook Page. Platform thiếu secret tự bỏ qua.
- Chuẩn hoá URL webhook Discord và gợi ý lỗi theo mã HTTP.
- State `data/last_video.txt` commit lên `main` sau mỗi lần chạy.
+49
View File
@@ -0,0 +1,49 @@
# Changelog
Mỗi **dòng major** một file. `1.x.md` chứa mọi bản 1.y.z; khi lên 2.0.0 thì mở `2.x.md`.
| File | Phạm vi |
|---|---|
| [`1.x.md`](1.x.md) | 1.0.0 → hiện tại |
Bản **pre-release** có file riêng, đặt tên theo dòng nó dẫn tới — `2.0-beta.md` cho `2.0.0-beta.1`
trở đi — và không gộp vào `2.x.md` khi dòng đó ổn định.
## Định dạng một entry
```
## 1.2.0 — 2026-09-02
Một câu tóm tắt bản này (tuỳ chọn).
### Fixed
### Added
### Changed
### Removed
```
Heading phải đúng dạng `## x.y.z — YYYY-MM-DD` (gạch ngang dài `—`): `release.yml` dùng
`scripts/release_notes.py` cắt đúng phần dưới heading đó làm nội dung Gitea release khi push tag
`vX.Y.Z`. Sai định dạng thì release không tạo được.
Chỉ ghi những gì **người dùng** của bot nhận thấy: bài đăng khác đi, video bị bỏ qua hay đăng
thừa, secret/biến mới phải thêm. Link PR khi có. Không ghi số commit hay số test — con số về repo
viết trong repo lỗi thời ngay lúc commit.
## Khi file dài, tách theo khoảng minor
Mục đích của thư mục này là mở một file, thấy ngay phiên bản mình cần mà không cuộn qua những bản
không quan tâm. Luật là về **độ dài đọc**, không phải số bản:
**Tách khi file vượt khoảng 600 dòng**, thành các khoảng minor liền nhau — `1.0-1.4.md`,
`1.5-1.9.md` — và để `1.x.md` lại làm stub trỏ tới cả hai để link cũ không hỏng. Thêm file mới
vào bảng trên trong cùng commit.
- **Không đổi tên file đã có.** `1.0-1.4.md` giữ tên đó mãi, kể cả sau lần tách tiếp theo.
- **Mới nhất ở trên** trong một file, để phần đầu là phần người ta cần và điểm tách luôn ở cuối.
## Quy trình phát hành
1. Mở PR thêm entry `## x.y.z — YYYY-MM-DD` vào đầu file dòng major (cùng PR với code hoặc PR riêng).
2. Merge, rồi tag đã ký trên `main`: `git tag -s vX.Y.Z -m vX.Y.Z && git push origin vX.Y.Z`.
3. `release.yml` tạo Gitea release với nội dung entry đó và gọi workflow thông báo Discord.
-100
View File
@@ -1,100 +0,0 @@
qt7RVP32AV4
uZll6csX9kI
DRDhW9LMLMQ
4VuhBOTTkrQ
8WtLZYAhVg0
9SOW4GxxbLM
pYQib1AX1ks
VB7DjTeqXTI
-9rtdC9uSbg
uvzecbUqaJw
3UlnBbHmJbs
ApnNvVldt1s
esWbaCgUBPc
QE-bTkU_0IE
XRU-dsONddE
h-rycsixtcA
qrxVfwlIKzU
B2rKCyxHV8Y
rE8BNUIgyjE
9mCNQHsSc94
m1G-vd3bito
ho6J2SuH-7M
bVn-d9GhnDY
u_bjkT0Hr5U
IPeedP8whSI
Sm1kpYxnZlA
rJh14s1t2u0
rjUgg-e2kYA
-FFqAobCvWI
6koVzftcgzY
N7_aqUpek50
iXXF5iMJwYA
ArLjmBqJLSY
giIoDtgGIcg
-1pJWrS9qP0
uHogFOXPYME
IepgEU2rJ2w
8cNbRjfm-ag
C1bzYM7TnQY
1YdBNdsPS4w
L3ry1zbvYnA
3E5rQ1A_KC8
scQrHFvmXyg
Rj94dYEPaYU
dh3qlRq-Q8E
ecB7WwmlZao
_YoSCfjkVd4
FWf1VQq7Y2E
XXb0ZLIGc1k
kJSU9kflD6E
Ip4BKSfXBAo
91z2V3pTA48
y6gnQCZtFWI
Xll88Fk7_4c
VD8Lgura8KQ
-5GLcSWxGWs
PZWlYWJL9-k
oqWSuUzr8sw
FoyoXkpCtdU
GbZuHF6Ll8w
Ru9OvLe6MgQ
9n8Dkx_pfFI
Eo6y0jpwJWM
f3kG_8g3TCg
fjNGBL22V4w
KRSMLQZkWJ4
YeGCvXUlG6E
6Lwr4FeNt8A
YxK-_auE4LI
Vegjg8AObAQ
bIthyYDqqUA
EZ9HPFNSu80
b-sFO9vIdhc
JFHD34lBYdU
CaviT86imQ0
xtNNZmBdwBE
8adQpu22_38
aWdZq4QQLqc
8beMNIp_fBQ
a6qoMHtTP8M
kA5ZVnb_mTE
tPHbXvSxDa8
8C-NvlVVxmE
yERCN0W3CYA
tGqKh5Ojntc
ya3QDrO5fDY
pvxPJw3A-Zg
HLCDQ7QnVak
PfCeLnaPD1M
pCkG1eVQDJk
MaqNXKkTHWA
xhOQgyKitiw
73AL7Fv9OFg
qdWwUtlta1k
_ZRNX23D-80
znyMQmPtoK4
8B8d2ErMZt8
Z2fnRXXzqsk
EPOAN9NwHaE
CXHwqjHO7no
+40
View File
@@ -0,0 +1,40 @@
[tool.ruff]
target-version = "py315"
line-length = 100
extend-exclude = ["state"]
[tool.ruff.lint]
select = ["E", "F", "W", "I", "UP", "B", "S"]
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"] # assert is the point of a test
[tool.ruff.lint.isort]
known-first-party = [
"config",
"http_client",
"message",
"notify",
"platforms",
"release_notes",
"state",
"youtube",
]
[tool.pytest.ini_options]
pythonpath = ["scripts"]
testpaths = ["tests"]
addopts = "-q"
# A deprecated stdlib call fails CI here, not in production on the next Python.
filterwarnings = ["error"]
# `pytest --cov` (CI's test job) measures scripts/ and fails under the floor below.
[tool.coverage.run]
source = ["scripts"]
relative_files = true
branch = true
[tool.coverage.report]
exclude_also = ['if __name__ == "__main__":']
# A floor against slow decline, not the target.
fail_under = 95
+17
View File
@@ -0,0 +1,17 @@
# Qodana Cloud (JetBrains), CI-based: the `qodana` job in .gitea/workflows/ci.yml
# runs the Qodana CLI with this file on every PR and every push to main. Reference:
# https://www.jetbrains.com/help/qodana/qodana-yaml.html
version: "1.0"
# Qodana for Python, the Ultimate linter (PyCharm Professional's inspections; a
# Qodana Cloud project token, secret QODANA_TOKEN, is the licence). Native mode:
# it runs on the job's runner with the job's Python 3.15 (QODANA_PYTHON_PATH),
# the interpreter the bot runs on, not whatever the Docker image ships.
linter: qodana-python
withinDocker: "false"
profile:
name: qodana.recommended
# Any problem fails the job, and with it the required `ci` check.
failThreshold: 0
+19
View File
@@ -0,0 +1,19 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>poli0981/renovate-config"],
"pip-compile": {
"description": "requirements-dev.txt is the hash-locked compile of requirements-dev.in: Renovate updates the .in pin and re-runs pip-compile with the command and the Python version in the lock's header.",
"managerFilePatterns": ["/(^|/)requirements-dev\\.txt$/"]
},
"pip_requirements": {
"description": "Off: its default pattern also matches requirements-dev.txt, and editing the lock by hand would break its hashes. pip-compile above owns both files.",
"enabled": false
},
"packageRules": [
{
"description": "Every update here is a dev tool or a CI pin, never the bot's runtime (stdlib only): a chore, as Dependabot's were.",
"matchPackageNames": ["*"],
"semanticCommitType": "chore"
}
]
}
+16
View File
@@ -0,0 +1,16 @@
# Development-only: lint and test tools. The scripts themselves are stdlib-only.
# requirements-dev.txt is the hash-locked compile of this file. After an edit,
# regenerate it with pip-tools on Python 3.14 (Renovate re-runs the command in the
# lock's header on the Python version named there):
# pip-compile --generate-hashes --allow-unsafe --strip-extras --output-file=requirements-dev.txt requirements-dev.in
ruff==0.17.4
# Workflow security audit (the `security` job in ci.yml). A wheel per platform
# from PyPI, so the job needs no Docker.
zizmor==1.32.0
pytest==9.2.0
# `pytest --cov`: the coverage floor in pyproject.toml.
pytest-cov==7.1.0
coverage==7.17.2
# pytest needs it on Windows only; listed so a lock compiled on Linux (Renovate)
# still installs there.
colorama
+197
View File
@@ -0,0 +1,197 @@
#
# This file is autogenerated by pip-compile with Python 3.14
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements-dev.txt --strip-extras requirements-dev.in
#
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via
# -r requirements-dev.in
# pytest
coverage==7.17.2 \
--hash=sha256:01303d9e68b6e6bdc5459b54e3bd0e3539c94c25b50ac7362b7cbcacbc815fbc \
--hash=sha256:0439f77deb5c023003533ae8909a9aa1e174c847d655327035b1e542c7c8a54e \
--hash=sha256:0712a43e39410aa567f2e85846490f8dd6c839820e7edef2142767c5c03162ba \
--hash=sha256:075566a44289afb634ceaafa7d8d377bb2667a5b4a90fbee2609efdcd015c66e \
--hash=sha256:091eba4248d31b03828fc657c96d14adfaa8754f5aec7b73298b82894858db06 \
--hash=sha256:0a623de5c57c5c3f3aed830c73a3a5aad91dbf76d53bc30ec161be758c8ca408 \
--hash=sha256:0d8a5dc709da9b90ad5cc859a9b88c9b801e65ca2fbf7cbdbed5b9cbf457fcc9 \
--hash=sha256:0fc17882975fe485cfc95fb2f20eed937e05e0c0d8ffa5048857cda3aa838e8a \
--hash=sha256:1682d98ded28524bc6853cc4e7c65175b3e917f38b2e2ddebb28cafd8ab4de74 \
--hash=sha256:189cdffb3ebc53d6133de67952dac7cc88d1fcaff5480623fb00ef0bf1cef918 \
--hash=sha256:1947bd9d82e405c892c50b0d8dc0c1dea5df2a962129ca238c500a6bcf887509 \
--hash=sha256:19d508b0611486f8e23e28abcba77795ee865ff0e0cd936349ba692c8d0d8ca4 \
--hash=sha256:1c3146ef9d14c011517422489784a7ac344477e9cdacb05d9529e912721cd5d8 \
--hash=sha256:1da1999e3c371edd669b48a1029c86dc0474cdc6ff152d58cb3f15cb3337af72 \
--hash=sha256:205f9e329d9d5e47c320f8712326a01620689edae50531cc8934511e2c5e8f7e \
--hash=sha256:20faaaf3a49601afbcd6d46c17a594b0ae62631498def44e5eed94789962ea18 \
--hash=sha256:248873a144c067f981742ff4bbfb48b57e281a8cb7a3821d4e293bdb50b47970 \
--hash=sha256:249c4b4eaac9ced6fb85e465027ca26348111c2760108fffc356a16be4f54cd9 \
--hash=sha256:27fc4384a1154f7df30d304ccddc05ef457368c065670ecbd392606279b3329a \
--hash=sha256:289a24443352713745f79c1b6aae4e99ced2f5ff3e86bb630c33c631d50f217c \
--hash=sha256:298849ca0e385767096995cb57f72059b469f43f9927b8393f29d134f7bb1062 \
--hash=sha256:2a6281011cf85699763bf88ab55e0774f6696f87b390f39152b14ecefadccb59 \
--hash=sha256:2ad189c65706306644399e48530ad1aea1dfb311bd21d988df1ace422d09f3f8 \
--hash=sha256:2b7fe217808239437b8509b869fde2e0cac48776a68c626bd6b15411b087e3de \
--hash=sha256:2c42c222939b8699e7bc0e453149627f211ebbbb2f74c1a04331b0cd9834e2c8 \
--hash=sha256:2cd1a7472a972fed01c89589b1560846e32e942f8329a515c4059d4521c6579a \
--hash=sha256:34e5c7a2da36804c6e6f10b368eae01ad56f5a4ac5ecce7297300a3d46fdef2a \
--hash=sha256:36248fb6c03341501169539bcab35eb3a59159100be1246fad3c14cb73c17685 \
--hash=sha256:36314997533266bde3d07765289674304d61bfe49165bb1b4fa9be12cb4ba0d1 \
--hash=sha256:3bd065e75c077d6de8cd3fe68699a8b47be3ec595af6b66e3629926839094609 \
--hash=sha256:3d3d9d79a2b6cdcdde5a1ab1ae89953faea5cb28c0eea17a413ad997bb3cc8a1 \
--hash=sha256:3dfefb1ec16ca1a01e5da40ba162e268ced8bd3624b9eba4e9384ebfa14af7ec \
--hash=sha256:3f219efbc3ec71c377e278dee201633e1d4ad0d2d9bdaddfd9489b2869d584c4 \
--hash=sha256:42133a2647982db7968db138c0f4a57f5836101d8d504600a87ef8ebfa22a4cf \
--hash=sha256:4274acd35aae5bbbd0908792260819b9720b171ccc099a8168f7c20ef5d6ab3a \
--hash=sha256:460ba2139866e758c3a8e9d9422fdc889942bcbc5ccaf710dc4fbd8707d14aa8 \
--hash=sha256:485b2ed9e13b7e9209276843d7147e2f1cd1c816582655650a64c8f922093c58 \
--hash=sha256:51c6a60e63ea993113ea5cd24a401cc2faddc54aa7acfddaffa5d3b8c0161b9d \
--hash=sha256:545ca42488c7f0e62324fb2621aa05737db843b75e84e65a271bbf976f496f66 \
--hash=sha256:555257578e20a46020c27b2af4ef99059cd906aa9b8e163baf9da9a5afb65a64 \
--hash=sha256:565f1f1a9632d82678525d668a10fe070a285603a9d3581505b0e1a66624ad50 \
--hash=sha256:5b71aeaa4440cbece5498acda30838685793d3bb960aff87ec97fbb546715a5f \
--hash=sha256:603140eeae3f9adc562f91b1b98d4d1fc491bd1f66c5082482c568d0b7891bb1 \
--hash=sha256:635337a96895f2ffcfe2aa7554468a988f468fb67a8007c1a65e95148c1855a9 \
--hash=sha256:674bcd023a3743666d4d7a15238e57a00c968553780a36c80d3779fc410b912c \
--hash=sha256:686b6f8f9e57afc3a44096b17ee8de7e11e0a12f2da819e25047af1eb3b0fc6f \
--hash=sha256:698ca1575135215be25ac9c5d14f0b5455135d29602b7ee81e511d64a0435c85 \
--hash=sha256:6bdf3821fd0740b5369b9ab58b4e9d0d68a2c5c75a7ee0cd3beb624f9f15e4fa \
--hash=sha256:6fd6f218e39a621a30dbaf9543831fa10fe713afc8a44b52fc42cfe277412609 \
--hash=sha256:70daa8e4b49541b51c0baeba0d802b0d14d3214daeebc071b3db0b0c7dc84646 \
--hash=sha256:74d91af590514dda16165d5d7cfa94183150c6a6a80a99f61068369ae3959455 \
--hash=sha256:7565c17092f2f4021abbe3f5007300c224f362364a388f5ddad9216dab44b611 \
--hash=sha256:7804a6022fcd5e1d4de4dc676e985d6aea0119249e88c041e943f3cd07953527 \
--hash=sha256:79cd2d9742419b6d1aaeb1f3fb77a8e6a01c09ebe5bd1b27011752410a5e3781 \
--hash=sha256:7a3984fb8c2407721f9bc05573fc9a770752efc756d55068ccbde1fe53e42233 \
--hash=sha256:7c123b6bbc183a14372036769f033098026aa75fc8fba37d028b0b772356e90b \
--hash=sha256:7c17f716c837db550a202e7732cdfaa726b8515cba88be42193616913970d223 \
--hash=sha256:7ce0acb27a823e8e5169282f538f0e182854cc8b472b88d45456f09b6fe364fd \
--hash=sha256:81a432793440edef268dbadd493393bd6f70fa4b87f76c58114f7f77f1ccfaea \
--hash=sha256:85bccf6fe19ea3747147387971465f6a06197d6b9f6b644a97ba90ca5b09c5cd \
--hash=sha256:87b30f3daa0bedda6b770b303410a6def007844772aaa143dc52675b3d95cd8a \
--hash=sha256:882cade9b6dc43b2bc819bb444c0a13e4ed1f669a50e0de74adeec54fce486f3 \
--hash=sha256:88d4dc83b6ad09a2134cad9d8ec780b274b17ac7dfba8c2c6e92e3bc468fe85d \
--hash=sha256:8d3626b9816f7eadd0993c3703a1d8ed124b579cebe5201b446f1c0d551fa245 \
--hash=sha256:8dc07ed34bcb206f69d5b54fd3874f7bf39ac941c9f7aec2b53b29874fcfd77a \
--hash=sha256:8dc17707fd463b4dfab53792e41d50a23316ac6b98539007aa2388a1d44a8535 \
--hash=sha256:8de787f533b13aeeea5d7139610eadb56f249cc739840b973603d1d18d0fb023 \
--hash=sha256:8eab0a5cff8dbc563d1416a6e079ba3c146712e47167c022a5df5ea01bd76df9 \
--hash=sha256:90c6c5f93606b8803bd7f8a0b2ae05df7e35da4504a1c53cfe9294a1731e1f49 \
--hash=sha256:95bd8dc5b356f78f10a967ec50f8902d56f24c623753ac9fce0aba9d6213d5c5 \
--hash=sha256:960e199965e506d78f62252355397a05c8cee8072ad2d82d932745517d566539 \
--hash=sha256:99b64a12fe6017c254a8027790e0eaa22eaeec201e7dfda5eaac176a6984ef27 \
--hash=sha256:a3f49ac9c9e5fd4b450677eb44f4b14ea9ab71950b2896888c9f6a22d5cd1773 \
--hash=sha256:a472e23a7514478e1c8124ea056424d681e3173975650b0a06b6181658f1009a \
--hash=sha256:a5565a9dd715a5a94ffcf9a0ad4b6b1501b5441fd67d660e78742adff5d37a0a \
--hash=sha256:a5909dd087006c70c128297312ba67d877123e871100645d9bd73ae021a4d01d \
--hash=sha256:a65faa1ee98e090a5fd7c116f6d3ab5c6a85fcc46849b8494835608715836399 \
--hash=sha256:a838a10afb5b60a6cc6315348b176badaf2409d821208a3e3cda1dc608129e23 \
--hash=sha256:afd81658f17b1a50bbc1d247a61fa435be0be471246136eb946f9cbfc437a4fa \
--hash=sha256:b0209fff1ca92f1e2e344d54b5b3def74efbdb46ba807cd81976a5e9e569cac3 \
--hash=sha256:b08ee3ef53e80e5a50c68b3d9764363e373acba540e1b58daee0a9a7f23fdfb2 \
--hash=sha256:b94c509e26603ba7f8cb1bf8bb63967c7be533493be5668d8442cd06ec853d76 \
--hash=sha256:ba45dc072bfbf1798e68ec81379b73473fc912174bff9f91924d77711a1d2b30 \
--hash=sha256:bac3c79c31f45274117ed64c65efeaed85665668aeba7d809c7c38801ada6ed4 \
--hash=sha256:bb74283661a239fdaf738ac0b07db4ed9b476c7532d3e713abf0f6a072781e60 \
--hash=sha256:be0fec33b69c40f845c76f67fb4495b62a84da8c31a579dc6e18c5a63fa6a1f3 \
--hash=sha256:be699e76b57fede8920a0f568eff23b270d9004414b7cf6744bdda851638be6e \
--hash=sha256:c10f2a2748dd084e44811bb9b26979763af9003115d9bf93c1da69011944719f \
--hash=sha256:c5a98aff9eb681312ed403ecb7beb5f15fd25d6e0acc2554b9ca4b4d6f0b6705 \
--hash=sha256:c68f64d96857749a215657c172f7144ed026063489686b901774f271997923c2 \
--hash=sha256:c9639c2ea019c948b52067a0f74485039eb84b7a2de828ba6d178e663fb2b8bd \
--hash=sha256:cbf751ae86ef0d80e719915c087b05776c8d9300141f6c3e56f536d78a62c301 \
--hash=sha256:cfe64d2501806a04507217852a3132a9a9076321435500bf3b11943a5c872732 \
--hash=sha256:d0332e2b27fc5cc761d6b8a33118b958e6a46be7f00fd30e03a5cf103350c0b3 \
--hash=sha256:d05a1bef52f4d7f1b484a1cf46a8929e50963f910e51396373f06cd3b6248f38 \
--hash=sha256:d14872ccef35972c4ac290f2432f43d0a7bb230cae2b5ed26871ab86221e8b5f \
--hash=sha256:d2742952851c7f88b1484385f68c42c6388153520efb40ff09fc852c3783aa5c \
--hash=sha256:d4004fce7b3a8ae5ef2af835670763f12723e9b9d74837697607b89a17f77312 \
--hash=sha256:d5024913651813801fd43b65b6409b0d50f8bae95316c8f1512dfbd8ca96cb1f \
--hash=sha256:d7a363c0788435ff5324d9582d37c63f215c75f974d755cfd6cfc9fbe0e64b04 \
--hash=sha256:d88fcc24470d73ed4360e910f8549718b913ba56fb8775d9ef929a647835dfea \
--hash=sha256:da4b0aef427eb96e422b444e5c2c3d38768fedb9141346294c38717a8b15b416 \
--hash=sha256:df0a34d445eea64f3766e9ca2ff57bcde600a89c7c0330434a7a37e8d6e2549f \
--hash=sha256:e09c37817768bb71fe3e70b6ce5e6ac1a0cd7398536c2f30a4460218c7b66e93 \
--hash=sha256:e269dddf5ebac20dfcc5a2a459528a9d221ab828cb31dfdf19c7cfacdbcee673 \
--hash=sha256:e2fd4e664a34854cae8db58ca6132fb7b5a7efc67b14233e797194bd0d63b6b0 \
--hash=sha256:e674027ceb6bfd959f1bb035000fd20fa8b717dc6765adaaf8bca347822c8c7d \
--hash=sha256:e6bf531deaebf8f69ba6015bba3fb817cab6694dfb69ac2a708889dc59a3926e \
--hash=sha256:e6c89d63d43738712ce1febddb7758ffeb56de08f1b2be68aeb9a9c7fee712c7 \
--hash=sha256:e72cf9556f799c3fce7597c1bd7dbfc9104befbd08088deb3b9ae9fd98117c02 \
--hash=sha256:e86a66f96d80c770daeed78394c1d4f6e8d03e5a3e08c5dab5275d56414f296a \
--hash=sha256:e8da5e158d13556457f69245deacf6d8401a2c9c31afaddd18bea691e849b5fd \
--hash=sha256:eca90e028932de597e2c50f454ad8cc631281e14d20b9f801a649ab555deb580 \
--hash=sha256:ee083412170118074bcc74361fcbc7104eb6d0b7c9c75eb3b84a4c324410c531 \
--hash=sha256:ef07aae0a666ef5edcab5bc1bb590468c6f4120a8cdad50a010d042a59ab6e77 \
--hash=sha256:f25209696631752468a25e5954fe119503468b3b29b6fa2c621ae766153c6f50 \
--hash=sha256:f5a875e92f10c6463027d8151459f2d92b4c13527402ed1301eaddabd79d8cf5 \
--hash=sha256:f94d465ee00ebe694ca866d66bbe45fa04618b1afcb377de934694f624fa7cf6 \
--hash=sha256:ffbaadf8612781358b3f949ad68dce26c5a35beaafcc48125fc231dbcce7d362
# via
# -r requirements-dev.in
# pytest-cov
iniconfig==2.3.1 \
--hash=sha256:67f4b9c50da0dedf52af349e7749a80a9057a5031199791b906c3bb3ae878960 \
--hash=sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7
# via pytest
packaging==26.3 \
--hash=sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79 \
--hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c
# via pytest
pluggy==1.7.0 \
--hash=sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec \
--hash=sha256:d1eaa46ebb595891b860ab086b4d09c8588af65ebd4361b8e8f4bb8920b90ba8
# via
# pytest
# pytest-cov
pygments==2.21.0 \
--hash=sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9 \
--hash=sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c
# via pytest
pytest==9.2.0 \
--hash=sha256:07acdcf88ec174f907dc01af70bf52d49b014bbab03faeeade31c96b18c2e588 \
--hash=sha256:97c4f3b1f3c7414aa36465e09b8220f1d03627993bd51b1282e193753c80557b
# via
# -r requirements-dev.in
# pytest-cov
pytest-cov==7.1.0 \
--hash=sha256:30674f2b5f6351aa09702a9c8c364f6a01c27aae0c1366ae8016160d1efc56b2 \
--hash=sha256:a0461110b7865f9a271aa1b51e516c9a95de9d696734a2f71e3e78f46e1d4678
# via -r requirements-dev.in
ruff==0.17.4 \
--hash=sha256:0d1f4848fd2ec0499be4046db9b7dfcc952666885f00233cc7033515282556a8 \
--hash=sha256:13e781c3c5f663e7fba737eaaeb70dd943dd55171daf316afb25cd5268cfe0c7 \
--hash=sha256:181ae38a9a8fb94925bf7d0794327b48d7fd7f4b50cfd84c0e999cc09ef8d131 \
--hash=sha256:20e43d7a08e712e33067ba887e6574546c79bd4831596ce8f16803ac7ff9ad90 \
--hash=sha256:2b08c4ff98dc234f4a3871a3105353b922fa875ea1073ca31001eb8c06bb4d89 \
--hash=sha256:2cd025509b2e15721b426fc70fd946d71f43b3db3b08e946dfec2d696d911690 \
--hash=sha256:3971a78cba76298b284c8321e6d40d93045ed348bec5c369d85099efc97fb7cf \
--hash=sha256:49b77f7b3921669466882a4881168801bdb06ec2cd83fb936049016cf5fdece1 \
--hash=sha256:5f28cf0dd37cb172fa5a8d2e92e6ada3a9dbd0609f094ed24039929eef0b7524 \
--hash=sha256:6007e7f3a0e55b0fbdb947af69cf24c21b4928df6be8ef3e767c69b5ccccf496 \
--hash=sha256:67c5a894fc054cf41f75f7afa24815de5a74329d97634126c2a1015740ff4e8c \
--hash=sha256:6b21c771b296888e8a35c6f48555f4b44e4483f61675d6ed51810a5203469ce6 \
--hash=sha256:7e061dcc0933c7031a616ac8d66ac540309b2aa21ab558101a8f53e9ac7a1185 \
--hash=sha256:7ed2f416349944f908f9574215994602242b0836844eba48eec61473033afca0 \
--hash=sha256:8ea6e0017c785f7282092b11e46338e4ebed1b9e575ebf2e55a8a1eda968241a \
--hash=sha256:e3b84eb74f260d1c2dbd236fd9d4c011d4fdd0a52bdf8aea57a10e3a1b71fca5 \
--hash=sha256:f32d178b50e826e00f6c6c1be3f56333068acb9b67fe167143527fa9b81e890d \
--hash=sha256:f99e95a1515161138be3cbd1b06c06e739d8feb38ade35564556999fffc3686e
# via -r requirements-dev.in
zizmor==1.32.0 \
--hash=sha256:0a999c98015becd9f69919ce01febadfb1c2be9b8ec2ce9ef7eb13ff23ba8eba \
--hash=sha256:0cdd38fca6eb34ceb567548548d706332e3535ea66894b9168c048e03207b68c \
--hash=sha256:3f404b26791ed06a5ea9eaa0bfd5b973fc5228bac7db8b3c5ec7f0c7ad2ed16d \
--hash=sha256:84a6acb975accc13408786a2bd274b572537ca19c933ebbc13e78f3988562071 \
--hash=sha256:913fd3943bc1358aa6e23b33fe01cc98bf67af23985258b8fbf24eaa2f8728ea \
--hash=sha256:9cd1dd7734042f40ca0faa2a31fb4e9033dede620d996af2f903744b8f04fca9 \
--hash=sha256:aa4b4e216321dd5cf202cd79fc83296468f0eed79d850cd65ac8187a6bbc5496 \
--hash=sha256:bddcdb0e37d1aa53c9f831c55627a5829d0d552cb0afb4b80fbe16a3a3140366 \
--hash=sha256:d34dcfa702875202b4163d90ebb9cc5222f3d1a7d4b72bf796d87b5a15b24194 \
--hash=sha256:dd818f99d833b86cd432d5412d620d936b5df074b33404fff8b67acff55d3259 \
--hash=sha256:eaedf57859f026a0a7da2a6b574517b1fe01e256c6875b3319a06ee1cee026a7 \
--hash=sha256:f0b664d394576e08605fe8094e8e992056d74b808f30c0c9ca9ed227001dcf67
# via -r requirements-dev.in
+54
View File
@@ -0,0 +1,54 @@
"""
Configuration constants loaded from environment variables.
"""
import os
from pathlib import Path
_REPO_ROOT = Path(__file__).resolve().parent.parent
# YouTube
YOUTUBE_CHANNEL_ID = os.environ.get("YOUTUBE_CHANNEL_ID", "").strip()
YOUTUBE_RSS_URL = f"https://www.youtube.com/feeds/videos.xml?channel_id={YOUTUBE_CHANNEL_ID}"
YOUTUBE_WATCH_URL = "https://www.youtube.com/watch?v={video_id}"
# Only videos published within this window are considered. The state file dedups
# anything already posted, so the window only needs to outlast the gap between two
# successful runs: one scheduled run a day, which waits while the runner (the
# maintainer's PC) is off, so a late start plus one missed day.
LOOKBACK_HOURS = int(os.environ.get("LOOKBACK_HOURS", "72"))
# Hashtags appended on Mastodon. Empty string disables them.
HASHTAGS = os.environ.get("HASHTAGS", "#gaming #gameplay #nocommentary").strip()
USER_AGENT = "YouTubeAutoPost/1.2 (+https://git.poli0981.dev/poli0981/youtube-auto-post)"
HTTP_TIMEOUT = 30
# Telegram
TELEGRAM_BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
TELEGRAM_CHAT_ID = os.environ.get("TELEGRAM_CHAT_ID", "")
# Bluesky
BLUESKY_HANDLE = os.environ.get("BLUESKY_HANDLE", "")
BLUESKY_APP_PASSWORD = os.environ.get("BLUESKY_APP_PASSWORD", "")
# Discord
DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL", "").strip()
# Mastodon
MASTODON_INSTANCE_URL = os.environ.get("MASTODON_INSTANCE_URL", "").strip().rstrip("/")
MASTODON_ACCESS_TOKEN = os.environ.get("MASTODON_ACCESS_TOKEN", "")
# State file (one posted video ID per line). In CI this points into the checkout of
# the orphan `state` branch; locally it defaults to an untracked `state/` directory.
STATE_FILE = Path(os.environ.get("STATE_FILE") or _REPO_ROOT / "state" / "last_video.txt")
# Max IDs to keep in state file
MAX_STATE_IDS = 100
# XML namespaces for YouTube RSS
NS = {
"atom": "http://www.w3.org/2005/Atom",
"yt": "http://www.youtube.com/xml/schemas/2015",
"media": "http://search.yahoo.com/mrss/",
}
+121
View File
@@ -0,0 +1,121 @@
"""
Thin urllib wrapper shared by every platform module.
One request path, one exception type. Callers catch `HttpError` and decide what the
status means for them. The URL is kept on the exception but left out of its message
because several endpoints carry credentials in the path.
"""
from __future__ import annotations
import json
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from config import HTTP_TIMEOUT, USER_AGENT
class HttpError(Exception):
"""Non-2xx response (`status` > 0) or transport failure (`status` == 0)."""
def __init__(self, status: int, body: str, url: str) -> None:
self.status = status
self.body = body
self.url = url
detail = body.strip()[:300]
super().__init__(f"HTTP {status} — {detail}" if status else f"connection error — {detail}")
def _request(
url: str,
*,
data: bytes | None = None,
headers: dict[str, str] | None = None,
method: str | None = None,
timeout: int = HTTP_TIMEOUT,
) -> tuple[bytes, dict[str, str]]:
"""Perform a request. Returns (body, lower-cased response headers)."""
if not url.startswith("https://"):
raise ValueError("Refusing non-HTTPS URL")
req = Request( # noqa: S310 — scheme checked above
url, data=data, headers={"User-Agent": USER_AGENT, **(headers or {})}, method=method
)
try:
with urlopen(req, timeout=timeout) as resp: # noqa: S310
return resp.read(), {k.lower(): v for k, v in resp.headers.items()}
except HTTPError as e:
try:
body = e.read().decode("utf-8", errors="replace")
finally:
e.close() # the error is also the response; leaving it open leaks it
raise HttpError(e.code, body, url) from e
except OSError as e: # URLError, timeouts, connection resets
raise HttpError(0, str(e), url) from e
def _as_dict(body: bytes) -> dict:
"""Parse a JSON body. Empty bodies (e.g. Discord 204) become {}."""
if not body.strip():
return {}
try:
parsed = json.loads(body)
except json.JSONDecodeError:
return {"_raw": body.decode("utf-8", errors="replace")}
return parsed if isinstance(parsed, dict) else {"_data": parsed}
def get_text(url: str, headers: dict[str, str] | None = None, timeout: int = HTTP_TIMEOUT) -> str:
body, _ = _request(url, headers=headers, timeout=timeout)
return body.decode("utf-8", errors="replace")
def get_bytes(
url: str, headers: dict[str, str] | None = None, timeout: int = HTTP_TIMEOUT
) -> tuple[bytes, str]:
"""Returns (body, content-type)."""
body, resp_headers = _request(url, headers=headers, timeout=timeout)
return body, resp_headers.get("content-type", "application/octet-stream")
def post_json(
url: str, payload: dict, headers: dict[str, str] | None = None, timeout: int = HTTP_TIMEOUT
) -> dict:
body, _ = _request(
url,
data=json.dumps(payload).encode("utf-8"),
headers={"Content-Type": "application/json", **(headers or {})},
method="POST",
timeout=timeout,
)
return _as_dict(body)
def post_form(
url: str, fields: dict, headers: dict[str, str] | None = None, timeout: int = HTTP_TIMEOUT
) -> dict:
body, _ = _request(
url,
data=urlencode(fields).encode("utf-8"),
headers={"Content-Type": "application/x-www-form-urlencoded", **(headers or {})},
method="POST",
timeout=timeout,
)
return _as_dict(body)
def post_bytes(
url: str,
data: bytes,
content_type: str,
headers: dict[str, str] | None = None,
timeout: int = HTTP_TIMEOUT,
) -> dict:
body, _ = _request(
url,
data=data,
headers={"Content-Type": content_type, **(headers or {})},
method="POST",
timeout=timeout,
)
return _as_dict(body)
+53
View File
@@ -0,0 +1,53 @@
"""
Notification text shared by every platform.
Platforms differ only in markup (bold, hashtags) and length limits, so the body is
built here once and each platform decorates it.
"""
from __future__ import annotations
from collections.abc import Callable
HEADER = "🎬 New Video / Video Mới"
PLAY = "▶️"
ELLIPSIS = "…"
BLUESKY_MAX_GRAPHEMES = 300
def build_message(
video: dict, *, hashtags: str = "", title: str | None = None, header: str = HEADER
) -> str:
"""Header, title, play line, optional hashtags — separated by blank lines."""
parts = [header, video["title"] if title is None else title, f"{PLAY} {video['url']}", hashtags]
return "\n\n".join(p for p in parts if p)
def truncate(text: str, max_len: int, suffix: str = ELLIPSIS) -> str:
"""Cut `text` to at most `max_len` code points, ending with `suffix` when cut."""
if len(text) <= max_len:
return text
if max_len <= len(suffix):
return text[:max_len]
return text[: max_len - len(suffix)].rstrip() + suffix
def _fit(video: dict, hashtags: str, measure: Callable[[str], int], limit: int) -> str:
"""Shrink the title until `measure(text) <= limit`. Everything else is kept."""
text = build_message(video, hashtags=hashtags)
if measure(text) <= limit:
return text
title = video["title"]
budget = len(title)
while budget > 0:
budget -= 1
text = build_message(video, hashtags=hashtags, title=truncate(title, budget))
if measure(text) <= limit:
return text
return build_message(video, hashtags=hashtags, title="")
def fit_bluesky(video: dict, hashtags: str = "") -> str:
"""Bluesky allows 300 graphemes; code points are a safe upper bound."""
return _fit(video, hashtags, len, BLUESKY_MAX_GRAPHEMES)
+98
View File
@@ -0,0 +1,98 @@
"""
YouTube Auto-Post Notification Script
Polls the YouTube RSS feed for recently published videos and posts to:
- Telegram (Bot API)
- Bluesky (AT Protocol)
- Discord (Webhook, optional)
- Mastodon (REST API, optional)
Exit code is 1 when any configured platform failed, so the CI-failure notifier fires.
"""
from __future__ import annotations
import random
import sys
import time
from datetime import UTC, datetime
from config import LOOKBACK_HOURS, YOUTUBE_CHANNEL_ID
from http_client import HttpError
from platforms import post_to_all, summarize
from state import load_posted_ids, save_posted_ids
from youtube import fetch_feed, is_public, select_recent
def main() -> int:
if not YOUTUBE_CHANNEL_ID:
print("[ERROR] YOUTUBE_CHANNEL_ID not set.")
return 1
now = datetime.now(UTC)
print(f"[INFO] Checking YouTube RSS for channel: {YOUTUBE_CHANNEL_ID}")
try:
videos = fetch_feed()
except HttpError as e:
print(f"[ERROR] Failed to fetch RSS: {e}")
return 1
recent = select_recent(videos, now=now, lookback_hours=LOOKBACK_HOURS)
if not recent:
print(f"[INFO] No videos published in the last {LOOKBACK_HOURS}h. Exiting.")
return 0
posted_ids = load_posted_ids()
new_videos = [v for v in recent if v["video_id"] not in posted_ids]
if not new_videos:
print("[INFO] All recent videos already posted. Exiting.")
return 0
print(f"[INFO] Found {len(new_videos)} new video(s) to post.")
successfully_posted: list[str] = []
had_failure = False
attempted = 0
for i, video in enumerate(new_videos):
if i > 0:
delay = random.uniform(1, 5) # noqa: S311 — pacing only
print(f"[INFO] Waiting {delay:.1f}s before next video...")
time.sleep(delay)
print(f"\n[INFO] Video {i + 1}/{len(new_videos)}: {video['title']}")
if not is_public(video["video_id"], now=now):
print(f"[INFO] Skipping '{video['video_id']}' for now; will retry next run.")
continue
attempted += 1
results = post_to_all(video)
any_ok, any_failed = summarize(results)
for platform, status in results.items():
print(f" {platform}: {status.value}")
if any_ok:
successfully_posted.append(video["video_id"])
else:
print(f"[WARN] No platform posted '{video['video_id']}'. Will retry next run.")
if any_failed:
had_failure = True
if successfully_posted:
save_posted_ids(successfully_posted)
print(f"\n[INFO] State saved: {len(successfully_posted)} new ID(s).")
print(f"\n[SUMMARY] {len(successfully_posted)}/{len(new_videos)} videos posted.")
if had_failure:
print("[ERROR] At least one configured platform failed.")
return 1
if attempted and not successfully_posted:
print("[ERROR] No platform is configured; nothing was posted.")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())
+26
View File
@@ -0,0 +1,26 @@
"""
Platform registry. Each module exposes a post(video) -> PostStatus function.
"""
from __future__ import annotations
from platforms import bluesky, discord, mastodon, telegram
from platforms.base import PostStatus
PLATFORMS = [
("telegram", telegram.post),
("bluesky", bluesky.post),
("discord", discord.post),
("mastodon", mastodon.post),
]
def post_to_all(video: dict) -> dict[str, PostStatus]:
"""Post video to all platforms. Returns {platform_name: status}."""
return {name: post_fn(video) for name, post_fn in PLATFORMS}
def summarize(results: dict[str, PostStatus]) -> tuple[bool, bool]:
"""Returns (any_ok, any_failed)."""
statuses = set(results.values())
return PostStatus.OK in statuses, PostStatus.FAILED in statuses
+9
View File
@@ -0,0 +1,9 @@
"""Shared result type for platform modules."""
from enum import Enum
class PostStatus(Enum):
OK = "OK"
SKIPPED = "skipped" # platform not configured
FAILED = "FAILED" # configured, but the request failed
+114
View File
@@ -0,0 +1,114 @@
"""Bluesky AT Protocol integration."""
from __future__ import annotations
from datetime import UTC, datetime
from config import BLUESKY_APP_PASSWORD, BLUESKY_HANDLE
from http_client import HttpError, get_bytes, post_bytes, post_json
from message import fit_bluesky
from platforms.base import PostStatus
_PDS = "https://bsky.social/xrpc"
_session: dict | None = None
def reset_session() -> None:
global _session
_session = None
def _get_session() -> dict:
"""Authenticate once per process. Raises HttpError on failure."""
global _session
if _session is None:
_session = post_json(
f"{_PDS}/com.atproto.server.createSession",
{"identifier": BLUESKY_HANDLE, "password": BLUESKY_APP_PASSWORD},
)
return _session
def _auth(session: dict) -> dict[str, str]:
return {"Authorization": f"Bearer {session['accessJwt']}"}
def _upload_thumbnail(session: dict, image_url: str) -> dict | None:
"""Download thumbnail and upload as blob. Best effort."""
if not image_url:
return None
try:
image_data, content_type = get_bytes(image_url)
except HttpError as e:
print(f"[WARN] Bluesky: failed to download thumbnail ({e}).")
return None
try:
result = post_bytes(
f"{_PDS}/com.atproto.repo.uploadBlob", image_data, content_type, headers=_auth(session)
)
except HttpError as e:
print(f"[WARN] Bluesky: thumbnail upload failed ({e}).")
return None
return result.get("blob")
def build_record(video: dict, thumb_blob: dict | None, now: datetime) -> dict:
text = fit_bluesky(video)
# Facet makes the URL clickable; offsets are in UTF-8 bytes.
url_start = text.index(video["url"])
byte_start = len(text[:url_start].encode("utf-8"))
byte_end = byte_start + len(video["url"].encode("utf-8"))
embed = {
"$type": "app.bsky.embed.external",
"external": {
"uri": video["url"],
"title": video["title"],
"description": video.get("description", ""),
},
}
if thumb_blob:
embed["external"]["thumb"] = thumb_blob
return {
"$type": "app.bsky.feed.post",
"text": text,
"facets": [
{
"index": {"byteStart": byte_start, "byteEnd": byte_end},
"features": [{"$type": "app.bsky.richtext.facet#link", "uri": video["url"]}],
}
],
"embed": embed,
"createdAt": now.isoformat(),
}
def post(video: dict) -> PostStatus:
"""Post to Bluesky with link card and optional thumbnail."""
if not BLUESKY_HANDLE or not BLUESKY_APP_PASSWORD:
print("[SKIP] Bluesky: missing handle or app password.")
return PostStatus.SKIPPED
try:
session = _get_session()
except HttpError as e:
print(f"[ERROR] Bluesky auth: {e}")
return PostStatus.FAILED
thumb_blob = _upload_thumbnail(session, video.get("thumbnail", ""))
record = build_record(video, thumb_blob, datetime.now(UTC))
try:
post_json(
f"{_PDS}/com.atproto.repo.createRecord",
{"repo": session["did"], "collection": "app.bsky.feed.post", "record": record},
headers=_auth(session),
)
except HttpError as e:
print(f"[ERROR] Bluesky post: {e}")
return PostStatus.FAILED
print("[OK] Bluesky: posted successfully.")
return PostStatus.OK
+68
View File
@@ -0,0 +1,68 @@
"""Discord Webhook integration (optional)."""
from __future__ import annotations
import re
from config import DISCORD_WEBHOOK_URL
from http_client import HttpError, post_json
from message import HEADER, build_message
from platforms.base import PostStatus
_MARKDOWN_RE = re.compile(r"([\\*_~`])")
def escape_markdown(text: str) -> str:
"""Backslash-escape the inline markdown Discord would otherwise render."""
return _MARKDOWN_RE.sub(r"\\\1", text)
def normalize_webhook_url(url: str) -> str:
"""Normalize Discord webhook URL to the API form."""
url = url.replace("https://discordapp.com/", "https://discord.com/")
url = url.replace("https://discord.com/webhooks/", "https://discord.com/api/webhooks/")
return url.rstrip("/")
def build_text(video: dict) -> str:
return build_message(
video, header=f"**{HEADER}**", title=f"**{escape_markdown(video['title'])}**"
)
def post(video: dict) -> PostStatus:
"""Post to Discord via webhook."""
if not DISCORD_WEBHOOK_URL:
print("[SKIP] Discord: no webhook URL configured.")
return PostStatus.SKIPPED
webhook_url = normalize_webhook_url(DISCORD_WEBHOOK_URL)
if "/api/webhooks/" not in webhook_url:
print(
"[ERROR] Discord: invalid webhook URL format. "
"Expected: https://discord.com/api/webhooks/ID/TOKEN"
)
return PostStatus.FAILED
payload = {"content": build_text(video), "username": "YouTube Notifications"}
try:
post_json(webhook_url, payload)
except HttpError as e:
print(f"[ERROR] Discord webhook: {e}")
if e.status == 403:
print(
"[HINT] 403 Forbidden — possible causes:\n"
" 1. Webhook URL is invalid or token is wrong\n"
" 2. Webhook was deleted from Discord\n"
" 3. Channel type doesn't support webhooks\n"
" 4. Re-create webhook: Server Settings → Integrations → Webhooks"
)
elif e.status == 404:
print("[HINT] 404 Not Found — webhook was deleted. Create a new one.")
elif e.status == 429:
print("[HINT] 429 Rate Limited — too many requests. Will retry next run.")
return PostStatus.FAILED
print("[OK] Discord: posted successfully.")
return PostStatus.OK
+37
View File
@@ -0,0 +1,37 @@
"""Mastodon REST API integration (optional)."""
from __future__ import annotations
from config import HASHTAGS, MASTODON_ACCESS_TOKEN, MASTODON_INSTANCE_URL
from http_client import HttpError, post_form
from message import build_message
from platforms.base import PostStatus
def post(video: dict) -> PostStatus:
"""Post to Mastodon instance via REST API."""
if not MASTODON_INSTANCE_URL or not MASTODON_ACCESS_TOKEN:
print("[SKIP] Mastodon: missing instance URL or access token.")
return PostStatus.SKIPPED
text = build_message(video, hashtags=HASHTAGS)
try:
result = post_form(
f"{MASTODON_INSTANCE_URL}/api/v1/statuses",
{"status": text, "visibility": "public"},
headers={"Authorization": f"Bearer {MASTODON_ACCESS_TOKEN}"},
)
except HttpError as e:
print(f"[ERROR] Mastodon: {e}")
if e.status == 401:
print("[HINT] 401 Unauthorized — access token is invalid or revoked.")
elif e.status == 422:
print("[HINT] 422 — status might be too long or contain invalid content.")
return PostStatus.FAILED
if not result.get("id"):
print(f"[ERROR] Mastodon: unexpected response — {result}")
return PostStatus.FAILED
print(f"[OK] Mastodon: posted successfully (id: {result['id']}).")
return PostStatus.OK
+47
View File
@@ -0,0 +1,47 @@
"""Telegram Bot API integration."""
from __future__ import annotations
import html
from config import TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID
from http_client import HttpError, post_json
from message import HEADER, build_message
from platforms.base import PostStatus
def build_text(video: dict) -> str:
"""HTML parse mode: only <, > and & need escaping, so titles render verbatim."""
safe_video = {**video, "url": html.escape(video["url"], quote=False)}
return build_message(
safe_video,
header=f"<b>{html.escape(HEADER, quote=False)}</b>",
title=f"<b>{html.escape(video['title'], quote=False)}</b>",
)
def post(video: dict) -> PostStatus:
"""Send notification to Telegram channel/group."""
if not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID:
print("[SKIP] Telegram: missing token or chat ID.")
return PostStatus.SKIPPED
payload = {
"chat_id": TELEGRAM_CHAT_ID,
"text": build_text(video),
"parse_mode": "HTML",
"link_preview_options": {"is_disabled": False},
}
url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
try:
result = post_json(url, payload)
except HttpError as e:
print(f"[ERROR] Telegram: {e}")
return PostStatus.FAILED
if not result.get("ok"):
print(f"[ERROR] Telegram: unexpected response — {result}")
return PostStatus.FAILED
print("[OK] Telegram: posted successfully.")
return PostStatus.OK
+70
View File
@@ -0,0 +1,70 @@
"""
Print the changelog entry for one version, for use as Gitea release notes.
python scripts/release_notes.py v1.2.0
Entries live in `changelog/<major>.x.md` under `## x.y.z — YYYY-MM-DD` headings.
"""
from __future__ import annotations
import re
import sys
from pathlib import Path
HEADING_RE = re.compile(r"^## (?P<version>\S+) — \d{4}-\d{2}-\d{2}\s*$")
# A release tag: v1.2.0, or a pre-release such as v2.0.0-beta.1.
VERSION_RE = re.compile(r"v?(?P<major>\d+)\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?")
CHANGELOG_DIR = Path(__file__).resolve().parent.parent / "changelog"
def normalize_version(version: str) -> str:
return version.strip().removeprefix("v")
def changelog_file(version: str, changelog_dir: Path) -> Path:
"""`<major>.x.md` for a release version; the file name is built from the number alone."""
m = VERSION_RE.fullmatch(version.strip())
if m is None:
raise ValueError(f"Not a release version: {version!r}")
return changelog_dir / f"{int(m.group('major'))}.x.md"
def extract_section(text: str, version: str) -> str:
"""Body of the `## <version> — <date>` entry, without the heading."""
wanted = normalize_version(version)
lines = text.splitlines()
start: int | None = None
for i, line in enumerate(lines):
if start is None:
m = HEADING_RE.match(line)
if m and m.group("version") == wanted:
start = i + 1
elif line.startswith("## "):
return "\n".join(lines[start:i]).strip() + "\n"
if start is None:
raise LookupError(f"No changelog entry for {wanted}")
return "\n".join(lines[start:]).strip() + "\n"
def main(argv: list[str], changelog_dir: Path = CHANGELOG_DIR) -> int:
if len(argv) != 2:
print("Usage: release_notes.py <version>", file=sys.stderr)
return 2
try:
path = changelog_file(argv[1], changelog_dir)
except ValueError as e:
print(f"[ERROR] {e}", file=sys.stderr)
return 1
try:
text = path.read_text(encoding="utf-8")
section = extract_section(text, argv[1])
except (OSError, LookupError) as e:
print(f"[ERROR] {e} (looked in {path})", file=sys.stderr)
return 1
sys.stdout.write(section)
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv))
+35
View File
@@ -0,0 +1,35 @@
"""
State management for tracking posted video IDs.
State file: one video ID per line, oldest first, capped at MAX_STATE_IDS.
"""
from __future__ import annotations
from pathlib import Path
from config import MAX_STATE_IDS, STATE_FILE
def _read_ids(path: Path) -> list[str]:
if not path.exists():
return []
return [line.strip() for line in path.read_text(encoding="utf-8").splitlines() if line.strip()]
def load_posted_ids(path: Path = STATE_FILE) -> set[str]:
"""Read all posted video IDs from the state file."""
return set(_read_ids(path))
def save_posted_ids(new_ids: list[str], path: Path = STATE_FILE) -> None:
"""Append new IDs, keeping order and at most MAX_STATE_IDS entries."""
combined = _read_ids(path)
seen = set(combined)
for vid in new_ids:
if vid not in seen:
combined.append(vid)
seen.add(vid)
combined = combined[-MAX_STATE_IDS:]
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("\n".join(combined) + "\n", encoding="utf-8")
+129
View File
@@ -0,0 +1,129 @@
"""
YouTube RSS feed fetching, filtering and visibility checks.
The feed lists the channel's 15 most recent uploads, including scheduled Premieres
that are not public yet (their `published` value is the upload time until they go
live). So besides a time window, each candidate is checked against its watch page
before it is announced.
"""
from __future__ import annotations
import re
from datetime import UTC, datetime, timedelta
from xml.etree import ElementTree
from config import NS, YOUTUBE_RSS_URL, YOUTUBE_WATCH_URL
from http_client import HttpError, get_text
# YouTube serves the full player metadata only to browser-like user agents.
_WATCH_HEADERS = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) YouTubeAutoPost/1.2",
"Accept-Language": "en-US,en;q=0.9",
}
# Allow a little clock skew between YouTube and the runner.
FUTURE_GRACE = timedelta(minutes=5)
_UPCOMING_FLAG = '"isUpcoming":true'
_START_DATE_RE = re.compile(r'itemprop="startDate"\s+content="([^"]+)"')
_PLAYABILITY_RE = re.compile(r'"playabilityStatus":\{"status":"([A-Z_]+)"')
_NOT_PUBLIC_PLAYABILITY = {"LIVE_STREAM_OFFLINE"} # upcoming premiere / stream
def parse_feed(xml_text: str) -> list[dict]:
"""Parse the Atom feed into video dicts. Malformed XML yields an empty list."""
try:
root = ElementTree.fromstring(xml_text) # noqa: S314 — YouTube's own feed
except ElementTree.ParseError as e:
print(f"[ERROR] Could not parse RSS feed: {e}")
return []
return [_parse_entry(entry) for entry in root.findall("atom:entry", NS)]
def fetch_feed() -> list[dict]:
"""Fetch and parse the channel feed. Raises HttpError on transport failure."""
return parse_feed(get_text(YOUTUBE_RSS_URL))
def _parse_entry(entry: ElementTree.Element) -> dict:
video_id = entry.find("yt:videoId", NS)
title = entry.find("atom:title", NS)
link = entry.find("atom:link", NS)
published = entry.find("atom:published", NS)
media_group = entry.find("media:group", NS)
description = ""
thumbnail = ""
if media_group is not None:
desc_el = media_group.find("media:description", NS)
if desc_el is not None and desc_el.text:
description = desc_el.text[:200]
thumb_el = media_group.find("media:thumbnail", NS)
if thumb_el is not None:
thumbnail = thumb_el.get("url", "")
return {
"video_id": (video_id.text or "") if video_id is not None else "",
"title": (title.text or "Untitled") if title is not None else "Untitled",
"url": link.get("href", "") if link is not None else "",
"published": (published.text or "") if published is not None else "",
"description": description,
"thumbnail": thumbnail,
}
def parse_timestamp(value: str) -> datetime | None:
"""ISO 8601 → aware datetime (UTC assumed when no offset). None if unparsable."""
try:
dt = datetime.fromisoformat(value.strip())
except ValueError, AttributeError:
return None
return dt if dt.tzinfo else dt.replace(tzinfo=UTC)
def select_recent(videos: list[dict], *, now: datetime, lookback_hours: int) -> list[dict]:
"""Videos published within the lookback window, oldest first."""
lower = now - timedelta(hours=lookback_hours)
upper = now + FUTURE_GRACE
dated: list[tuple[datetime, dict]] = []
for video in videos:
published = parse_timestamp(video.get("published", ""))
if published is None:
print(f"[WARN] Bad date for {video.get('video_id')}: {video.get('published')!r}")
continue
if lower <= published <= upper:
dated.append((published, video))
dated.sort(key=lambda pair: pair[0])
return [video for _, video in dated]
def is_public_html(html: str, *, now: datetime) -> tuple[bool, str]:
"""Inspect a watch page. Returns (public, reason-if-not)."""
if _UPCOMING_FLAG in html:
return False, "flagged as upcoming"
m = _START_DATE_RE.search(html)
if m:
start = parse_timestamp(m.group(1))
if start is not None and start > now:
return False, f"premieres at {start.isoformat()}"
m = _PLAYABILITY_RE.search(html)
if m is None:
print("[WARN] Watch page has no playability marker; assuming public.")
elif m.group(1) in _NOT_PUBLIC_PLAYABILITY:
return False, f"playability {m.group(1)}"
return True, ""
def is_public(video_id: str, *, now: datetime) -> bool:
"""True when the video can be watched now. Fails open on network errors."""
url = YOUTUBE_WATCH_URL.format(video_id=video_id)
try:
html = get_text(url, headers=_WATCH_HEADERS)
except HttpError as e:
print(f"[WARN] Could not check visibility of {video_id} ({e}); assuming public.")
return True
public, reason = is_public_html(html, now=now)
if not public:
print(f"[INFO] Video {video_id} is not public yet ({reason}).")
return public
+22
View File
@@ -0,0 +1,22 @@
from pathlib import Path
import pytest
FIXTURES = Path(__file__).parent / "fixtures"
@pytest.fixture
def video() -> dict:
return {
"video_id": "E0jg71lJE1Q",
"title": "[2K] Dark Souls Remastered | Asylum Demon Boss Fight | Gameplay No Commentary",
"url": "https://www.youtube.com/watch?v=E0jg71lJE1Q",
"published": "2026-08-30T17:00:31+00:00",
"description": "First boss.",
"thumbnail": "https://i4.ytimg.com/vi/E0jg71lJE1Q/hqdefault.jpg",
}
@pytest.fixture
def feed_xml() -> str:
return (FIXTURES / "feed.xml").read_text(encoding="utf-8")
+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:yt="http://www.youtube.com/xml/schemas/2015" xmlns:media="http://search.yahoo.com/mrss/" xmlns="http://www.w3.org/2005/Atom">
<title>SkullMute</title>
<entry>
<id>yt:video:hnxTgODvLiQ</id>
<yt:videoId>hnxTgODvLiQ</yt:videoId>
<title>[2K] Be Missed And Remembered | Part 16 | Gameplay No Commentary</title>
<link rel="alternate" href="https://www.youtube.com/watch?v=hnxTgODvLiQ"/>
<published>2026-08-31T08:45:06+00:00</published>
<media:group>
<media:title>[2K] Be Missed And Remembered | Part 16 | Gameplay No Commentary</media:title>
<media:thumbnail url="https://i2.ytimg.com/vi/hnxTgODvLiQ/hqdefault.jpg" width="480" height="360"/>
<media:description>Part 16 &amp; more.</media:description>
</media:group>
</entry>
<entry>
<id>yt:video:E0jg71lJE1Q</id>
<yt:videoId>E0jg71lJE1Q</yt:videoId>
<title>[2K] Dark Souls Remastered | Asylum Demon Boss Fight | Gameplay No Commentary</title>
<link rel="alternate" href="https://www.youtube.com/watch?v=E0jg71lJE1Q"/>
<published>2026-08-30T17:00:31+00:00</published>
<media:group>
<media:thumbnail url="https://i4.ytimg.com/vi/E0jg71lJE1Q/hqdefault.jpg" width="480" height="360"/>
</media:group>
</entry>
<entry>
<id>yt:video:Op9T4uhBwm0</id>
<yt:videoId>Op9T4uhBwm0</yt:videoId>
<title>[2K] Soup's Tail | Demo | Gameplay No Commentary</title>
<link rel="alternate" href="https://www.youtube.com/watch?v=Op9T4uhBwm0"/>
<published>2026-08-11T06:00:06+00:00</published>
</entry>
<entry>
<id>yt:video:badDate0000</id>
<yt:videoId>badDate0000</yt:videoId>
<title>Broken date</title>
<link rel="alternate" href="https://www.youtube.com/watch?v=badDate0000"/>
<published>not-a-date</published>
</entry>
</feed>
+145
View File
@@ -0,0 +1,145 @@
from datetime import UTC, datetime
import pytest
from http_client import HttpError
from platforms import bluesky
from platforms.base import PostStatus
CREATE_SESSION = "com.atproto.server.createSession"
UPLOAD_BLOB = "com.atproto.repo.uploadBlob"
CREATE_RECORD = "com.atproto.repo.createRecord"
THUMBNAIL = "thumbnail"
SESSION = {"accessJwt": "jwt-for-tests", "did": "did:plc:skullmute"}
BLOB = {"$type": "blob", "ref": {"$link": "bafkrei"}, "mimeType": "image/jpeg", "size": 9}
NOW = datetime(2026, 8, 31, 10, 0, tzinfo=UTC)
class FakePds:
"""Stands in for http_client: records each call and fails the ones named in `fail`."""
def __init__(self) -> None:
self.calls: list[tuple[str, object, dict | None]] = []
self.fail: set[str] = set()
self.blob: dict | None = BLOB
def post_json(self, url, payload, headers=None, timeout=30):
name = url.rsplit("/", 1)[-1]
self.calls.append((name, payload, headers))
if name in self.fail:
raise HttpError(400, "bad request", url)
return dict(SESSION) if name == CREATE_SESSION else {"uri": "at://post"}
def get_bytes(self, url, headers=None, timeout=30):
self.calls.append((THUMBNAIL, url, headers))
if THUMBNAIL in self.fail:
raise HttpError(404, "not found", url)
return b"jpeg-data", "image/jpeg"
def post_bytes(self, url, data, content_type, headers=None, timeout=30):
name = url.rsplit("/", 1)[-1]
self.calls.append((name, (data, content_type), headers))
if name in self.fail:
raise HttpError(500, "server error", url)
return {"blob": self.blob} if self.blob else {}
def names(self) -> list[str]:
return [name for name, _, _ in self.calls]
def call(self, name: str) -> tuple[object, dict | None]:
return next((payload, headers) for n, payload, headers in self.calls if n == name)
@pytest.fixture(autouse=True)
def fresh_session():
bluesky.reset_session()
yield
bluesky.reset_session()
@pytest.fixture
def pds(monkeypatch):
fake = FakePds()
monkeypatch.setattr(bluesky, "BLUESKY_HANDLE", "skullmute.bsky.social")
monkeypatch.setattr(bluesky, "BLUESKY_APP_PASSWORD", "app-pass-for-tests")
monkeypatch.setattr(bluesky, "post_json", fake.post_json)
monkeypatch.setattr(bluesky, "get_bytes", fake.get_bytes)
monkeypatch.setattr(bluesky, "post_bytes", fake.post_bytes)
return fake
def test_post_skips_without_credentials(pds, monkeypatch, video):
monkeypatch.setattr(bluesky, "BLUESKY_APP_PASSWORD", "")
assert bluesky.post(video) is PostStatus.SKIPPED
assert pds.calls == []
def test_post_logs_in_uploads_thumbnail_and_creates_record(pds, video):
assert bluesky.post(video) is PostStatus.OK
assert pds.names() == [CREATE_SESSION, THUMBNAIL, UPLOAD_BLOB, CREATE_RECORD]
login, _ = pds.call(CREATE_SESSION)
assert login["identifier"] == "skullmute.bsky.social"
assert login["password"] == bluesky.BLUESKY_APP_PASSWORD
upload, upload_headers = pds.call(UPLOAD_BLOB)
assert upload == (b"jpeg-data", "image/jpeg")
assert upload_headers == {"Authorization": "Bearer jwt-for-tests"}
created, created_headers = pds.call(CREATE_RECORD)
assert created["repo"] == SESSION["did"]
assert created["collection"] == "app.bsky.feed.post"
assert created["record"]["embed"]["external"]["thumb"] == BLOB
assert created_headers == {"Authorization": "Bearer jwt-for-tests"}
def test_session_is_created_once_per_process(pds, video):
bluesky.post(video)
bluesky.post(video)
assert pds.names().count(CREATE_SESSION) == 1
def test_login_failure_fails_without_posting(pds, video):
pds.fail.add(CREATE_SESSION)
assert bluesky.post(video) is PostStatus.FAILED
assert pds.names() == [CREATE_SESSION]
@pytest.mark.parametrize("failing", [THUMBNAIL, UPLOAD_BLOB])
def test_thumbnail_failure_still_posts_without_thumb(pds, video, failing):
pds.fail.add(failing)
assert bluesky.post(video) is PostStatus.OK
created, _ = pds.call(CREATE_RECORD)
assert "thumb" not in created["record"]["embed"]["external"]
def test_upload_without_blob_posts_without_thumb(pds, video):
pds.blob = None
assert bluesky.post(video) is PostStatus.OK
created, _ = pds.call(CREATE_RECORD)
assert "thumb" not in created["record"]["embed"]["external"]
def test_video_without_thumbnail_skips_the_upload(pds, video):
assert bluesky.post({**video, "thumbnail": ""}) is PostStatus.OK
assert pds.names() == [CREATE_SESSION, CREATE_RECORD]
def test_create_record_failure_fails(pds, video):
pds.fail.add(CREATE_RECORD)
assert bluesky.post(video) is PostStatus.FAILED
def test_build_record_link_facet_counts_utf8_bytes(video):
record = bluesky.build_record({**video, "title": "Đánh boss 🎮 lần đầu"}, None, NOW)
facet = record["facets"][0]
start, end = facet["index"]["byteStart"], facet["index"]["byteEnd"]
assert record["text"].encode()[start:end] == video["url"].encode()
assert facet["features"] == [{"$type": "app.bsky.richtext.facet#link", "uri": video["url"]}]
assert record["embed"]["external"] == {
"uri": video["url"],
"title": "Đánh boss 🎮 lần đầu",
"description": video["description"],
}
assert record["createdAt"] == NOW.isoformat()
+79
View File
@@ -0,0 +1,79 @@
import pytest
from http_client import HttpError
from message import HEADER
from platforms import discord
from platforms.base import PostStatus
WEBHOOK = "https://discord.com/api/webhooks/123/abc"
def test_escape_markdown():
assert discord.escape_markdown(r"a*b_c~d`e\f") == r"a\*b\_c\~d\`e\\f"
@pytest.mark.parametrize(
"url",
[
WEBHOOK,
"https://discordapp.com/api/webhooks/123/abc",
"https://discord.com/webhooks/123/abc",
"https://discord.com/api/webhooks/123/abc/",
],
)
def test_normalize_webhook_url(url):
assert discord.normalize_webhook_url(url) == WEBHOOK
def test_build_text_bolds_header_and_escaped_title(video):
text = discord.build_text({**video, "title": "Dark_Souls *2*"})
assert text.split("\n\n") == [f"**{HEADER}**", r"**Dark\_Souls \*2\***", f"▶️ {video['url']}"]
@pytest.fixture
def webhook(monkeypatch):
"""Configure an old-style webhook URL and record what gets posted to it."""
sent = []
def fake_post_json(url, payload, headers=None, timeout=30):
sent.append((url, payload))
return {}
monkeypatch.setattr(discord, "DISCORD_WEBHOOK_URL", "https://discordapp.com/webhooks/123/abc/")
monkeypatch.setattr(discord, "post_json", fake_post_json)
return sent
def test_post_skips_without_webhook(monkeypatch, video):
monkeypatch.setattr(discord, "DISCORD_WEBHOOK_URL", "")
assert discord.post(video) is PostStatus.SKIPPED
def test_post_rejects_urls_that_are_not_webhooks(webhook, monkeypatch, video):
monkeypatch.setattr(discord, "DISCORD_WEBHOOK_URL", "https://discord.com/channels/123/456")
assert discord.post(video) is PostStatus.FAILED
assert webhook == []
def test_post_sends_to_the_normalized_webhook(webhook, video):
assert discord.post(video) is PostStatus.OK
assert webhook == [
(WEBHOOK, {"content": discord.build_text(video), "username": "YouTube Notifications"})
]
@pytest.mark.parametrize(
("status", "hint"),
[(403, "403 Forbidden"), (404, "404 Not Found"), (429, "429 Rate Limited"), (500, None)],
)
def test_post_failures_fail_with_a_hint(monkeypatch, capsys, webhook, video, status, hint):
def boom(url, payload, headers=None, timeout=30):
raise HttpError(status, "error body", url)
monkeypatch.setattr(discord, "post_json", boom)
assert discord.post(video) is PostStatus.FAILED
out = capsys.readouterr().out
if hint is None:
assert "[HINT]" not in out
else:
assert f"[HINT] {hint}" in out
+144
View File
@@ -0,0 +1,144 @@
import io
import json
from email.message import Message
from urllib.error import HTTPError, URLError
import pytest
import http_client
from config import HTTP_TIMEOUT, USER_AGENT
from http_client import HttpError, get_bytes, get_text, post_bytes, post_form, post_json
URL = "https://api.example.com/v1/endpoint"
class FakeResponse:
def __init__(self, body: bytes, headers: dict[str, str]) -> None:
self.body = body
self.headers = headers
def __enter__(self):
return self
def __exit__(self, *exc_info):
return False
def read(self) -> bytes:
return self.body
@pytest.fixture
def server(monkeypatch):
"""Fake urlopen: set `body`, `headers` or `error`; `request` is what was sent."""
state = {"body": b"{}", "headers": {}, "error": None}
def fake_urlopen(request, timeout):
state["request"] = request
state["timeout"] = timeout
if state["error"] is not None:
raise state["error"]
return FakeResponse(state["body"], state["headers"])
monkeypatch.setattr(http_client, "urlopen", fake_urlopen)
return state
def test_http_error_message_keeps_status_and_short_body_but_not_url():
err = HttpError(404, " " + "x" * 400 + "\n", URL)
assert str(err) == "HTTP 404 — " + "x" * 300
assert (err.status, err.url) == (404, URL)
assert str(HttpError(0, "timed out", URL)) == "connection error — timed out"
def test_refuses_urls_that_are_not_https(server):
with pytest.raises(ValueError, match="non-HTTPS"):
get_text("www.youtube.com/feeds/videos.xml")
assert "request" not in server
def test_get_text_decodes_utf8_and_sends_user_agent(server):
server["body"] = "Video Mới ✓".encode() + b"\xff"
assert get_text(URL) == "Video Mới ✓\N{REPLACEMENT CHARACTER}"
request = server["request"]
assert request.get_method() == "GET"
assert request.get_header("User-agent") == USER_AGENT
assert server["timeout"] == HTTP_TIMEOUT
def test_get_text_adds_headers_and_timeout(server):
get_text(URL, headers={"Accept-Language": "en-US"}, timeout=5)
assert server["request"].get_header("Accept-language") == "en-US"
assert server["timeout"] == 5
def test_get_bytes_returns_content_type_whatever_its_case(server):
server["body"], server["headers"] = b"\x89PNG", {"Content-Type": "image/png"}
assert get_bytes(URL) == (b"\x89PNG", "image/png")
def test_get_bytes_defaults_content_type(server):
assert get_bytes(URL) == (b"{}", "application/octet-stream")
def test_post_json_sends_json_and_parses_reply(server):
server["body"] = b'{"ok": true}'
payload = {"text": "Video Mới"}
assert post_json(URL, payload, headers={"Authorization": "Bearer abc"}) == {"ok": True}
request = server["request"]
assert request.get_method() == "POST"
assert request.data == json.dumps(payload).encode()
assert request.get_header("Content-type") == "application/json"
assert request.get_header("Authorization") == "Bearer abc"
def test_post_form_urlencodes_fields(server):
post_form(URL, {"status": "a b&c", "visibility": "public"})
request = server["request"]
assert request.data == b"status=a+b%26c&visibility=public"
assert request.get_header("Content-type") == "application/x-www-form-urlencoded"
def test_post_bytes_sends_raw_body_with_its_type(server):
post_bytes(URL, b"\xff\xd8jpeg", "image/jpeg")
request = server["request"]
assert request.data == b"\xff\xd8jpeg"
assert request.get_header("Content-type") == "image/jpeg"
@pytest.mark.parametrize(
("body", "expected"),
[
(b"", {}),
(b" \n", {}),
(b"not json", {"_raw": "not json"}),
(b"[1, 2]", {"_data": [1, 2]}),
(b'{"id": "42"}', {"id": "42"}),
],
)
def test_reply_bodies_always_become_dicts(server, body, expected):
server["body"] = body
assert post_json(URL, {}) == expected
def test_http_status_errors_keep_status_and_body_and_close_the_response(server):
body = io.BytesIO(b'{"error": "forbidden"}')
server["error"] = HTTPError(URL, 403, "Forbidden", Message(), body)
with pytest.raises(HttpError) as info:
post_json(URL, {})
assert (info.value.status, info.value.body, info.value.url) == (
403,
'{"error": "forbidden"}',
URL,
)
assert body.closed
@pytest.mark.parametrize(
"error", [URLError("timed out"), TimeoutError("timed out"), ConnectionResetError("reset")]
)
def test_transport_errors_become_status_zero(server, error):
server["error"] = error
with pytest.raises(HttpError) as info:
get_text(URL)
assert info.value.status == 0
assert str(error) in info.value.body
+60
View File
@@ -0,0 +1,60 @@
import pytest
from http_client import HttpError
from message import build_message
from platforms import mastodon
from platforms.base import PostStatus
@pytest.fixture
def instance(monkeypatch):
"""Configure an instance and record what gets posted; set `reply` to change the response."""
state = {"sent": [], "reply": {"id": "109"}}
def fake_post_form(url, fields, headers=None, timeout=30):
state["sent"].append((url, fields, headers))
return state["reply"]
monkeypatch.setattr(mastodon, "MASTODON_INSTANCE_URL", "https://mastodon.social")
monkeypatch.setattr(mastodon, "MASTODON_ACCESS_TOKEN", "access-for-tests")
monkeypatch.setattr(mastodon, "HASHTAGS", "#gaming #gameplay")
monkeypatch.setattr(mastodon, "post_form", fake_post_form)
return state
def test_post_skips_without_access_token(instance, monkeypatch, video):
monkeypatch.setattr(mastodon, "MASTODON_ACCESS_TOKEN", "")
assert mastodon.post(video) is PostStatus.SKIPPED
assert instance["sent"] == []
def test_post_publishes_a_public_status_with_hashtags(instance, video):
assert mastodon.post(video) is PostStatus.OK
assert instance["sent"] == [
(
"https://mastodon.social/api/v1/statuses",
{"status": build_message(video, hashtags="#gaming #gameplay"), "visibility": "public"},
{"Authorization": "Bearer access-for-tests"},
)
]
def test_post_without_status_id_fails(instance, video):
instance["reply"] = {"error": "unexpected"}
assert mastodon.post(video) is PostStatus.FAILED
@pytest.mark.parametrize(
("status", "hint"), [(401, "401 Unauthorized"), (422, "422 —"), (503, None)]
)
def test_post_failures_fail_with_a_hint(instance, monkeypatch, capsys, video, status, hint):
def boom(url, fields, headers=None, timeout=30):
raise HttpError(status, "error body", url)
monkeypatch.setattr(mastodon, "post_form", boom)
assert mastodon.post(video) is PostStatus.FAILED
out = capsys.readouterr().out
if hint is None:
assert "[HINT]" not in out
else:
assert f"[HINT] {hint}" in out
+38
View File
@@ -0,0 +1,38 @@
from message import BLUESKY_MAX_GRAPHEMES, HEADER, build_message, fit_bluesky, truncate
def test_build_message_layout(video):
text = build_message(video, hashtags="#a #b")
assert text.split("\n\n") == [HEADER, video["title"], f"▶️ {video['url']}", "#a #b"]
def test_build_message_without_hashtags_has_no_trailing_block(video):
assert build_message(video).endswith(video["url"])
def test_build_message_overrides(video):
text = build_message(video, title="<b>T</b>", header="H")
assert text.startswith("H\n\n<b>T</b>\n\n")
def test_truncate():
assert truncate("short", 10) == "short"
assert truncate("abcdefghij", 5) == "abcd…"
assert truncate("abcdefghij", 1) == "a"
def test_fit_bluesky_keeps_short_titles(video):
assert fit_bluesky(video) == build_message(video)
def test_fit_bluesky_truncates_long_titles(video):
long_video = {**video, "title": "x" * 400}
text = fit_bluesky(long_video)
assert len(text) <= BLUESKY_MAX_GRAPHEMES
assert video["url"] in text
assert "…" in text
def test_fit_bluesky_drops_the_title_when_even_that_is_not_enough(video):
long_url = {**video, "url": video["url"] + "&list=" + "x" * BLUESKY_MAX_GRAPHEMES}
assert fit_bluesky(long_url) == build_message(long_url, title="")
+71
View File
@@ -0,0 +1,71 @@
from datetime import UTC, datetime
import youtube
from http_client import HttpError
from youtube import is_public, is_public_html
NOW = datetime(2026, 8, 30, 18, 7, tzinfo=UTC)
PUBLIC = (
'<meta itemprop="isLiveBroadcast" content="True"><meta itemprop="startDate" '
'content="2026-08-30T17:00:31+00:00">...{"playabilityStatus":{"status":"OK","playableInEmbed":true}'
)
UPCOMING_FLAG = '{"playabilityStatus":{"status":"OK"},"videoDetails":{"isUpcoming":true}}'
UPCOMING_DATE = (
'<meta itemprop="startDate" content="2026-08-31T01:00:06+00:00">'
'{"playabilityStatus":{"status":"OK"}}'
)
OFFLINE = '{"playabilityStatus":{"status":"LIVE_STREAM_OFFLINE","reason":"Premieres in 2 hours"}}'
AGE_GATED = (
'{"playabilityStatus":{"status":"LOGIN_REQUIRED","reason":"Sign in to confirm your age"}}'
)
def test_public_video_passes():
assert is_public_html(PUBLIC, now=NOW) == (True, "")
def test_upcoming_flag_blocks():
public, reason = is_public_html(UPCOMING_FLAG, now=NOW)
assert not public and "upcoming" in reason
def test_future_start_date_blocks():
public, reason = is_public_html(UPCOMING_DATE, now=NOW)
assert not public and "2026-08-31T01:00:06" in reason
def test_offline_stream_blocks():
assert is_public_html(OFFLINE, now=NOW)[0] is False
def test_other_playability_statuses_do_not_block_forever():
assert is_public_html(AGE_GATED, now=NOW)[0] is True
def test_no_markers_assumes_public():
assert is_public_html("<html>consent wall</html>", now=NOW)[0] is True
def test_is_public_fetches_watch_page(monkeypatch):
seen = {}
def fake_get_text(url, headers=None, timeout=30):
seen["url"] = url
return OFFLINE
monkeypatch.setattr(youtube, "get_text", fake_get_text)
assert is_public("abc", now=NOW) is False
assert seen["url"] == "https://www.youtube.com/watch?v=abc"
def test_is_public_passes_a_public_watch_page(monkeypatch):
monkeypatch.setattr(youtube, "get_text", lambda url, headers=None, timeout=30: PUBLIC)
assert is_public("abc", now=NOW) is True
def test_is_public_fails_open_on_network_error(monkeypatch):
def boom(url, headers=None, timeout=30):
raise HttpError(0, "timed out", url)
monkeypatch.setattr(youtube, "get_text", boom)
assert is_public("abc", now=NOW) is True
+76
View File
@@ -0,0 +1,76 @@
import pytest
from release_notes import changelog_file, extract_section, main
CHANGELOG = """# 1.x
Intro paragraph.
## 1.2.0 — 2026-09-02
### Fixed
- Telegram titles.
## 1.1.0 — 2026-04-16
- Refactor.
"""
def test_extract_middle_section():
assert extract_section(CHANGELOG, "v1.2.0") == "### Fixed\n\n- Telegram titles.\n"
def test_extract_last_section():
assert extract_section(CHANGELOG, "1.1.0") == "- Refactor.\n"
def test_missing_version_raises():
with pytest.raises(LookupError):
extract_section(CHANGELOG, "9.9.9")
@pytest.mark.parametrize("version", ["v2.3.4", "2.3.4", " v2.0.0-beta.1 "])
def test_changelog_file_uses_major_line(tmp_path, version):
assert changelog_file(version, tmp_path) == tmp_path / "2.x.md"
@pytest.mark.parametrize("version", ["v1.2", "latest", "../1.0.0", "v1.0.0/../../x", ""])
def test_changelog_file_rejects_anything_but_a_version(tmp_path, version):
with pytest.raises(ValueError, match="Not a release version"):
changelog_file(version, tmp_path)
def test_main_prints_section(tmp_path, capsys):
(tmp_path / "1.x.md").write_text(CHANGELOG, encoding="utf-8")
assert main(["release_notes.py", "v1.2.0"], changelog_dir=tmp_path) == 0
assert capsys.readouterr().out == "### Fixed\n\n- Telegram titles.\n"
def test_main_reports_missing(tmp_path, capsys):
(tmp_path / "1.x.md").write_text(CHANGELOG, encoding="utf-8")
assert main(["release_notes.py", "v1.9.0"], changelog_dir=tmp_path) == 1
assert "No changelog entry" in capsys.readouterr().err
def test_main_reports_a_missing_major_line_file(tmp_path, capsys):
assert main(["release_notes.py", "v2.0.0"], changelog_dir=tmp_path) == 1
assert "2.x.md" in capsys.readouterr().err
def test_main_rejects_a_tag_that_is_not_a_version(capsys):
assert main(["release_notes.py", "nightly"]) == 1
assert "Not a release version" in capsys.readouterr().err
@pytest.mark.parametrize("argv", [["release_notes.py"], ["release_notes.py", "v1.2.0", "extra"]])
def test_main_takes_exactly_one_version(capsys, argv):
assert main(argv) == 2
assert "Usage" in capsys.readouterr().err
def test_main_reads_the_repository_changelog_by_default(capsys):
# The real changelog/1.x.md: an entry that release.yml once published.
assert main(["release_notes.py", "v1.2.0"]) == 0
assert "### Fixed" in capsys.readouterr().out
+112
View File
@@ -0,0 +1,112 @@
import pytest
import notify
import platforms
from http_client import HttpError
from platforms import post_to_all, summarize
from platforms.base import PostStatus
OK, SKIP, FAIL = PostStatus.OK, PostStatus.SKIPPED, PostStatus.FAILED
def test_summarize():
assert summarize({"a": OK, "b": SKIP}) == (True, False)
assert summarize({"a": OK, "b": FAIL}) == (True, True)
assert summarize({"a": SKIP, "b": SKIP}) == (False, False)
assert summarize({"a": FAIL}) == (False, True)
def test_post_to_all_asks_every_platform_in_order(monkeypatch, video):
asked = []
def platform(name, status):
def post(v):
asked.append((name, v["video_id"]))
return status
return post
monkeypatch.setattr(
platforms, "PLATFORMS", [("a", platform("a", OK)), ("b", platform("b", FAIL))]
)
assert post_to_all(video) == {"a": OK, "b": FAIL}
assert asked == [("a", video["video_id"]), ("b", video["video_id"])]
@pytest.fixture
def harness(monkeypatch, video):
"""Wire notify.main() to fakes; returns a mutable dict describing the scenario."""
state = {
"feed": [video],
"posted": set(),
"public": {video["video_id"]: True},
"results": {"telegram": OK, "bluesky": SKIP},
"saved": [],
}
monkeypatch.setattr(notify, "YOUTUBE_CHANNEL_ID", "UC123")
monkeypatch.setattr(notify, "fetch_feed", lambda: state["feed"])
monkeypatch.setattr(notify, "select_recent", lambda videos, **kw: videos)
monkeypatch.setattr(notify, "load_posted_ids", lambda: state["posted"])
monkeypatch.setattr(notify, "save_posted_ids", lambda ids: state["saved"].extend(ids))
monkeypatch.setattr(notify, "is_public", lambda vid, now: state["public"].get(vid, True))
monkeypatch.setattr(notify, "post_to_all", lambda v: dict(state["results"]))
monkeypatch.setattr(notify.time, "sleep", lambda s: None)
return state
def test_success_saves_state_and_exits_zero(harness, video):
assert notify.main() == 0
assert harness["saved"] == [video["video_id"]]
def test_platform_failure_exits_one_but_still_saves(harness, video):
harness["results"] = {"telegram": OK, "mastodon": FAIL}
assert notify.main() == 1
assert harness["saved"] == [video["video_id"]]
def test_all_platforms_skipped_exits_one_without_saving(harness):
harness["results"] = {"telegram": SKIP, "bluesky": SKIP}
assert notify.main() == 1
assert harness["saved"] == []
def test_premiere_not_public_is_skipped_and_not_saved(harness, video):
harness["public"][video["video_id"]] = False
assert notify.main() == 0
assert harness["saved"] == []
def test_already_posted_is_noop(harness, video):
harness["posted"] = {video["video_id"]}
assert notify.main() == 0
assert harness["saved"] == []
def test_nothing_in_the_lookback_window_is_noop(harness, monkeypatch):
monkeypatch.setattr(notify, "select_recent", lambda videos, **kw: [])
assert notify.main() == 0
assert harness["saved"] == []
def test_several_videos_are_paced_and_all_saved(harness, monkeypatch, video):
second = {**video, "video_id": "hnxTgODvLiQ", "title": "Part 16"}
harness["feed"] = [video, second]
pauses = []
monkeypatch.setattr(notify.time, "sleep", pauses.append)
assert notify.main() == 0
assert harness["saved"] == [video["video_id"], second["video_id"]]
assert len(pauses) == 1 and 1 <= pauses[0] <= 5
def test_feed_error_exits_one(harness, monkeypatch):
def boom():
raise HttpError(503, "down", "https://x")
monkeypatch.setattr(notify, "fetch_feed", boom)
assert notify.main() == 1
def test_missing_channel_id_exits_one(harness, monkeypatch):
monkeypatch.setattr(notify, "YOUTUBE_CHANNEL_ID", "")
assert notify.main() == 1
+27
View File
@@ -0,0 +1,27 @@
from config import MAX_STATE_IDS
from state import load_posted_ids, save_posted_ids
def test_load_missing_file_is_empty(tmp_path):
assert load_posted_ids(tmp_path / "nope.txt") == set()
def test_load_ignores_blank_lines_and_whitespace(tmp_path):
path = tmp_path / "s.txt"
path.write_text("a\n\n b \n", encoding="utf-8")
assert load_posted_ids(path) == {"a", "b"}
def test_save_appends_in_order_and_dedups(tmp_path):
path = tmp_path / "nested" / "s.txt"
save_posted_ids(["a", "b"], path)
save_posted_ids(["b", "c", "c"], path)
assert path.read_text(encoding="utf-8") == "a\nb\nc\n"
def test_save_caps_to_max_ids(tmp_path):
path = tmp_path / "s.txt"
save_posted_ids([f"v{i}" for i in range(MAX_STATE_IDS + 10)], path)
ids = path.read_text(encoding="utf-8").split()
assert len(ids) == MAX_STATE_IDS
assert ids[-1] == f"v{MAX_STATE_IDS + 9}"
+59
View File
@@ -0,0 +1,59 @@
import pytest
from http_client import HttpError
from platforms import telegram
from platforms.base import PostStatus
def test_build_text_keeps_brackets_and_pipes_verbatim(video):
text = telegram.build_text(video)
assert (
"<b>[2K] Dark Souls Remastered | Asylum Demon Boss Fight | Gameplay No Commentary</b>"
in text
)
assert "\\" not in text
def test_build_text_escapes_html_specials(video):
text = telegram.build_text({**video, "title": "Tom & Jerry <3"})
assert "<b>Tom &amp; Jerry &lt;3</b>" in text
@pytest.fixture
def configured(monkeypatch):
monkeypatch.setattr(telegram, "TELEGRAM_BOT_TOKEN", "123:abc")
monkeypatch.setattr(telegram, "TELEGRAM_CHAT_ID", "-100")
def test_post_skips_without_credentials(monkeypatch, video):
monkeypatch.setattr(telegram, "TELEGRAM_BOT_TOKEN", "")
assert telegram.post(video) is PostStatus.SKIPPED
def test_post_sends_html_payload(monkeypatch, configured, video):
calls = []
def fake_post_json(url, payload, headers=None, timeout=30):
calls.append((url, payload))
return {"ok": True}
monkeypatch.setattr(telegram, "post_json", fake_post_json)
assert telegram.post(video) is PostStatus.OK
url, payload = calls[0]
assert url == "https://api.telegram.org/bot123:abc/sendMessage"
assert payload["parse_mode"] == "HTML"
assert payload["link_preview_options"] == {"is_disabled": False}
assert "disable_web_page_preview" not in payload
def test_post_fails_on_http_error(monkeypatch, configured, video):
def boom(url, payload, headers=None, timeout=30):
raise HttpError(400, '{"ok":false}', url)
monkeypatch.setattr(telegram, "post_json", boom)
assert telegram.post(video) is PostStatus.FAILED
def test_post_fails_on_not_ok_body(monkeypatch, configured, video):
monkeypatch.setattr(telegram, "post_json", lambda *a, **k: {"ok": False})
assert telegram.post(video) is PostStatus.FAILED
+84
View File
@@ -0,0 +1,84 @@
from datetime import UTC, datetime
import youtube
from config import NS
from youtube import fetch_feed, parse_feed, parse_timestamp, select_recent
NOW = datetime(2026, 8, 31, 10, 0, tzinfo=UTC)
def test_fetch_feed_reads_the_channel_rss(monkeypatch, feed_xml):
requested = []
def fake_get_text(url, headers=None, timeout=30):
requested.append(url)
return feed_xml
monkeypatch.setattr(youtube, "get_text", fake_get_text)
assert len(fetch_feed()) == 4
assert requested == [youtube.YOUTUBE_RSS_URL]
def test_parse_feed_reads_entries(feed_xml):
videos = parse_feed(feed_xml)
assert [v["video_id"] for v in videos] == [
"hnxTgODvLiQ",
"E0jg71lJE1Q",
"Op9T4uhBwm0",
"badDate0000",
]
first = videos[0]
assert first["title"].startswith("[2K] Be Missed")
assert first["url"] == "https://www.youtube.com/watch?v=hnxTgODvLiQ"
assert first["description"] == "Part 16 & more."
assert first["thumbnail"].endswith("hqdefault.jpg")
assert videos[2]["description"] == "" and videos[2]["thumbnail"] == ""
def test_parse_feed_tolerates_malformed_xml():
assert parse_feed("<feed><entry></feed>") == []
def test_parse_feed_fills_in_missing_elements():
xml = (
f'<feed xmlns="{NS["atom"]}" xmlns:media="{NS["media"]}">'
"<entry><media:group><media:description/></media:group></entry>"
"</feed>"
)
assert parse_feed(xml) == [
{
"video_id": "",
"title": "Untitled",
"url": "",
"published": "",
"description": "",
"thumbnail": "",
}
]
def test_parse_timestamp():
assert parse_timestamp("2026-08-31T08:45:06+00:00") == datetime(
2026, 8, 31, 8, 45, 6, tzinfo=UTC
)
assert parse_timestamp("2026-08-31T08:45:06").tzinfo is UTC
assert parse_timestamp("nope") is None
assert parse_timestamp(None) is None
def test_select_recent_uses_lookback_window_and_sorts_oldest_first(feed_xml):
videos = parse_feed(feed_xml)
recent = select_recent(videos, now=NOW, lookback_hours=48)
assert [v["video_id"] for v in recent] == ["E0jg71lJE1Q", "hnxTgODvLiQ"]
def test_select_recent_keeps_videos_published_after_a_delayed_run(feed_xml):
# 22:30 cron actually ran at 00:21 the next day; a "today only" filter lost this video.
videos = parse_feed(feed_xml)
recent = select_recent(videos, now=datetime(2026, 8, 31, 0, 21, tzinfo=UTC), lookback_hours=48)
assert "E0jg71lJE1Q" in [v["video_id"] for v in recent]
def test_select_recent_drops_far_future_timestamps(video):
future = {**video, "published": "2026-09-01T00:00:00+00:00"}
assert select_recent([future], now=NOW, lookback_hours=48) == []