Skip to content

ci: add maintainer baseline checks - #20

Merged
tnware merged 3 commits into
mainfrom
ci/maintainer-baseline
May 26, 2026
Merged

tnware merged 3 commits into
mainfrom
ci/maintainer-baseline

Conversation

@tnware

@tnware tnware commented May 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a basic maintainer safety baseline before making user-visible API behavior changes:

  • Add PR/push CI for lint, smoke tests, package build, twine metadata check, and strict docs build
  • Add initial smoke tests for public imports, package metadata, and bundled device model data
  • Fix Sphinx heading warnings so docs can build with -W
  • Fix README quick-start issues found during audit:
    • UniFi OS/legacy port comment was reversed
    • typed-object example now passes raw=False
    • example method names now match the actual public API
  • Switch release automation from Release Drafter to Release Please
  • Add Release Please manifest/config and seed CHANGELOG.md
  • Modernize setuptools package discovery and license metadata to remove build warnings

Why

The project has real downstream usage, but currently has no PR CI gate, no tests, and release-time docs failures. This PR establishes the minimum safety net needed before addressing higher-risk API behavior fixes.

Validation

  • ruff check . ✅
  • pytest -q ✅ 3 passed
  • python -m build ✅
  • twine check dist/* ✅
  • sphinx-build -E -W -b html docs docs/_build/html ✅

Follow-ups intentionally left out

  • PyPI Trusted Publishing migration; that needs PyPI-side Trusted Publisher setup before the workflow can safely change.
  • Runtime API behavior changes such as timeout defaults and API-level error handling; those should be separate PRs with focused tests.
  • Live UniFi integration tests; those need a credential strategy and probably a manually triggered/private workflow.

Summary by CodeRabbit

  • Chores

    • Implemented automated release and version management
    • Established CI/CD pipeline with multi-version testing, code linting, and documentation building
  • Documentation

    • Fixed README typos and improved configuration examples
    • Enhanced documentation formatting and structure
    • Added CHANGELOG documenting release history

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@tnware, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 33 minutes and 10 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d6c8ab3-4591-43a9-ad1a-f71efc5daf01

📥 Commits

Reviewing files that changed from the base of the PR and between 9ca7ee0 and b57b18d.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml
  • .github/workflows/release-please.yml
  • docs/api/overview.rst
  • tests/test_package_smoke.py
📝 Walkthrough

Walkthrough

This PR modernizes release management and packaging infrastructure by replacing release-drafter with Release Please automation, establishes CI/CD pipelines for testing and documentation builds, refines package metadata, adds a changelog, updates user-facing documentation, and implements package validation tests.

Changes

Release Automation and Packaging

Layer / File(s) Summary
Release automation with Release Please
.github/workflows/release-please.yml, .release-please-manifest.json, release-please-config.json
Replaces release-drafter with Release Please: new workflow triggers on main push and manual dispatch, configured to manage version tracking (0.3.2), Python package type, and automated CHANGELOG.md updates.
CI/CD pipeline workflows
.github/workflows/ci.yml, .github/workflows/docs.yml
Adds GitHub Actions CI workflow with test job (Python 3.9–3.13, Ruff, pytest, build, twine check) and docs job (Python 3.12, Sphinx strict mode). Updates docs workflow to use explicit sphinx-build command with -E -W flags.
Package metadata and distribution
pyproject.toml
Simplifies license metadata to string form (license = "MIT"), switches to dynamic package discovery via packages.find, and narrows package data to include only device-models.json.
Release notes and changelog infrastructure
CHANGELOG.md, docs/changelog.rst
Adds CHANGELOG.md documenting releases v0.1.0–v0.3.2; updates docs changelog to redirect users to repository CHANGELOG.md with note on Release Please auto-updates.
Documentation updates: user guidance and RST formatting
README.md, docs/api/export.rst, docs/api/overview.rst, docs/api/utilities.rst, docs/contributing.rst, docs/examples.rst, docs/index.rst, docs/changelog.rst
Fixes "Opitionally" typo, updates UniFi controller port guidance, adds raw=False argument to example call, refreshes method list. Applies consistent RST heading underline formatting across all documentation files.
Package validation smoke tests
tests/test_package_smoke.py
Adds three smoke tests validating public imports, packaged JSON resource parsing, and distribution metadata accessibility via importlib.metadata.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

minor

Poem

🐰 Release Please hops to the scene,
Automation's now clean and serene,
Workflows in place, docs freshly dressed,
Packaging tests put code to the test!
Version 0.3.2, a journey complete. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding CI workflows and maintainer baseline checks, which aligns with the dominant changes in the PR (CI workflows, smoke tests, docs fixes, and release automation setup).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/maintainer-baseline

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
.github/workflows/ci.yml (2)

17-18: ⚖️ Poor tradeoff

Consider pinning actions to commit SHAs for supply chain security.

Actions are currently pinned to major version tags (@v4, @v5), which can float to new minor/patch releases. For stronger supply chain guarantees, you can pin to immutable commit SHAs:

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683  # v4.2.2
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b  # v5.3.0

This prevents potential supply chain attacks where a tag is moved to malicious code, though it increases maintenance burden. Many projects accept the tag-based approach as a reasonable tradeoff. As per static analysis hints, actions are not pinned to a hash as required by blanket policy.

Also applies to: 40-41

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 17 - 18, Replace floating tag
references for GitHub Actions with immutable commit SHAs: locate the uses
entries "actions/checkout@v4" and "actions/setup-python@v5" and update them to
their corresponding commit SHA pins (e.g., the commit SHAs for the intended
versions) so the workflow uses exact immutable revisions; apply the same change
to the other occurrences of these actions noted in the diff (the second
"actions/checkout" and "actions/setup-python" uses) to ensure all action usages
are pinned consistently.

1-51: ⚡ Quick win

Consider scoping workflow permissions to read-only.

The workflow inherits default repository permissions, which may include write access. Since this CI workflow only validates code and doesn't push changes or create comments, you can harden security by adding an explicit read-only permissions block at the workflow level:

name: CI

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  test:
    # ...

This follows the principle of least privilege and addresses the excessive-permissions finding from static analysis. As per static analysis hints, default permissions are used due to no explicit permissions block.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 1 - 51, Add an explicit workflow-level
permissions block to restrict repository access to read-only by adding a
top-level "permissions" mapping with "contents: read" in the CI workflow (i.e.,
alongside the existing name/on keys), and verify no job/step in the workflow
(such as publishing or commenting steps) requires write permissions; if any do,
either remove/adjust them or scope permissions more narrowly for those jobs
instead of allowing default write access.
tests/test_package_smoke.py (1)

27-28: ⚡ Quick win

Test name suggests comparison but only checks existence.

The function name test_distribution_metadata_matches_importable_package implies that some matching or comparison is performed, but the test only verifies that metadata is retrievable. Consider either:

  1. Renaming to test_distribution_metadata_is_accessible() to reflect actual behavior, or
  2. Adding a version comparison to match the implied behavior.
Option 1: Rename to clarify intent
-def test_distribution_metadata_matches_importable_package():
+def test_distribution_metadata_is_accessible():
     assert importlib.metadata.version('unifi-controller-api')
Option 2: Add version comparison to match name
 def test_distribution_metadata_matches_importable_package():
-    assert importlib.metadata.version('unifi-controller-api')
+    version = importlib.metadata.version('unifi-controller-api')
+    assert version == '0.3.2'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_package_smoke.py` around lines 27 - 28, Rename the test function
currently named test_distribution_metadata_matches_importable_package to
test_distribution_metadata_is_accessible and update its definition accordingly
so it reflects the actual assertion (i.e., keep the body assert
importlib.metadata.version('unifi-controller-api')); locate the function by the
symbol name test_distribution_metadata_matches_importable_package in
tests/test_package_smoke.py and change only the function name to the new clearer
name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/release-please.yml:
- Line 16: Replace the mutable tag used for the GitHub Action by resolving the
current commit SHA that the ref googleapis/release-please-action@v4 points to
and update the workflow line that currently reads
"googleapis/release-please-action@v4" to use the exact immutable commit SHA
(e.g., googleapis/release-please-action@<commit-sha>); ensure you copy the full
40-character SHA for the release-please-action repository and commit, commit the
updated .github/workflows/release-please.yml, and verify the workflow runs
against that SHA.

In `@docs/api/overview.rst`:
- Around line 53-54: The example imports and calls export_to_csv but the public
helper is named export_csv; update the snippet so both the import and usage
reference export_csv (replace export_to_csv with export_csv in the import
statement and the function call) to ensure the example matches the actual API
(look for occurrences of export_to_csv in the example and change them to
export_csv).

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 17-18: Replace floating tag references for GitHub Actions with
immutable commit SHAs: locate the uses entries "actions/checkout@v4" and
"actions/setup-python@v5" and update them to their corresponding commit SHA pins
(e.g., the commit SHAs for the intended versions) so the workflow uses exact
immutable revisions; apply the same change to the other occurrences of these
actions noted in the diff (the second "actions/checkout" and
"actions/setup-python" uses) to ensure all action usages are pinned
consistently.
- Around line 1-51: Add an explicit workflow-level permissions block to restrict
repository access to read-only by adding a top-level "permissions" mapping with
"contents: read" in the CI workflow (i.e., alongside the existing name/on keys),
and verify no job/step in the workflow (such as publishing or commenting steps)
requires write permissions; if any do, either remove/adjust them or scope
permissions more narrowly for those jobs instead of allowing default write
access.

In `@tests/test_package_smoke.py`:
- Around line 27-28: Rename the test function currently named
test_distribution_metadata_matches_importable_package to
test_distribution_metadata_is_accessible and update its definition accordingly
so it reflects the actual assertion (i.e., keep the body assert
importlib.metadata.version('unifi-controller-api')); locate the function by the
symbol name test_distribution_metadata_matches_importable_package in
tests/test_package_smoke.py and change only the function name to the new clearer
name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b9c22d6-e428-4e60-808f-124e0e0085ed

📥 Commits

Reviewing files that changed from the base of the PR and between 0f3375d and 9ca7ee0.

📒 Files selected for processing (18)
  • .github/release-drafter.yml
  • .github/workflows/ci.yml
  • .github/workflows/docs.yml
  • .github/workflows/release-drafter.yml
  • .github/workflows/release-please.yml
  • .release-please-manifest.json
  • CHANGELOG.md
  • README.md
  • docs/api/export.rst
  • docs/api/overview.rst
  • docs/api/utilities.rst
  • docs/changelog.rst
  • docs/contributing.rst
  • docs/examples.rst
  • docs/index.rst
  • pyproject.toml
  • release-please-config.json
  • tests/test_package_smoke.py
💤 Files with no reviewable changes (2)
  • .github/workflows/release-drafter.yml
  • .github/release-drafter.yml

Comment thread .github/workflows/release-please.yml Outdated
Comment thread docs/api/overview.rst Outdated
@tnware
tnware merged commit 820a70c into main May 26, 2026
7 checks passed
@tnware
tnware deleted the ci/maintainer-baseline branch May 26, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant