Skip to content

Promote develop to main - #111

Merged
mikemadeja merged 7 commits into
mainfrom
develop
Sep 25, 2026
Merged

mikemadeja merged 7 commits into
mainfrom
develop

Conversation

@mikemadeja

Copy link
Copy Markdown
Owner

Summary

Promotes the following merged PRs from develop to main:

  • chore: reorg tests to mirror module structure, scope CI to changed files #110 - Reorg tests/ to mirror PiHoleShell/Public// structure; scope Azure DevOps PR builds to only the test file(s) for what actually changed (falls back to the full suite for shared/private code, module manifest changes, or any ambiguity); also fixed a shallow-clone diff bug and a pre-existing false-failure in the History(database) tests (empty result window is valid, not an error)
  • feat: add Invoke-PiHoleFlushLogs #109 - Add Invoke-PiHoleFlushLogs (POST /action/flush/logs), completing the "Actions" API area

Test plan

  • Both source PRs passed PSScriptAnalyzer and the full Pester suite (including real-server integration tests) in CI before merging into develop

🤖 Generated with Claude Code

mikemadeja and others added 7 commits September 24, 2026 17:44
Implements POST /action/flush/logs, one of the two remaining "Actions" gaps
from the API coverage audit. Flushes the DNS log file and purges the most
recent 24 hours of query history from both the database and FTL's internal
memory.

The other gap, POST /action/flush/arp, is deprecated by Pi-hole itself in
favor of /action/flush/network ("Deprecated! Use '/action/flush/network'
instead."), which the module already implements via
Invoke-PiHoleFlushNetwork - so it's intentionally not being added as a
separate function.

Also fixed a copy-paste bug found along the way: Invoke-PiHoleFlushNetwork's
.DESCRIPTION described flushing a log file, which is what this new function
actually does, not what flushing the network table does.

Verified against a real Pi-hole v6 server: formatted output, RawOutput, and
bad-password error handling. Added a dedicated integration test file.
README regenerated.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Moves every per-function test file from a flat tests/ directory into
tests/<Category>/, mirroring PiHoleShell/Public/<Category>/ exactly (e.g.
PiHoleShell/Public/Actions/Invoke-PiHoleFlushNetwork.ps1 now pairs with
tests/Actions/Invoke-PiHoleFlushNetwork.Integration.Tests.ps1). Shared
support files (IntegrationConfig.example.ps1, IntegrationConfig.local.ps1,
Initialize-PiHoleTestData.ps1) stay at tests/ root since they don't belong
to any single function. Updated every moved file's $PSScriptRoot-relative
path lookups for those shared files accordingly (Pester still discovers
tests recursively by default, so no path change was needed on the Pester
side).

This mirroring is what makes the second change straightforward: the Azure
DevOps pipeline now scopes PR builds to only the test file(s) matching
whatever PiHoleShell/Public/<Category>/<Function>.ps1 files actually
changed, instead of always running the entire suite (which includes many
real-server integration tests that individually take 10-40+ seconds).

Direct pushes to develop/main still always run the full suite. On a PR
build, anything that isn't a clean 1:1 function-to-test-file match falls
back to the full suite rather than risk silently skipping coverage:
changes to Private/ files, PiHoleShell.psm1/.psd1, the shared
Request-PiHoleAuth helper (used by every function), the shared test
helpers, or a failure computing the diff itself. Changed test files run
directly; non-code changes (README, workflows, tools/) are ignored.

Verified the scoping logic locally against real git diffs before trusting
it in CI, and re-ran a representative slice of the moved integration tests
against the real Pi-hole server to confirm the path fixes work end-to-end.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… windows

The changed-file scoping added in the previous commit failed on its first
real run: the default Azure Pipelines checkout is shallow, so there's no
common ancestor with the target branch to diff against ("no merge base"/
"unknown revision"). Fixed by unshallowing first when the repo is shallow,
and fetching the target branch with an explicit refspec so origin/<branch>
gets created even under a checkout whose default fetch refspec is
restricted to a single branch. Verified both fixes end-to-end against a
real shallow, single-branch clone before trusting them in CI again.

Because the scoping fallback ran the full suite on that failed attempt, it
also surfaced a real, pre-existing bug (unrelated to this PR, already
broken on main): Get-PiHoleHistoryDatabase/Get-PiHoleHistoryDatabaseClient
asserted `Should -Not -BeNullOrEmpty` on their history array, but an empty
array is a legitimate response when nothing was logged in the queried
window - unlike the Stats(database) summary endpoints, which always return
a populated object shape even with zero matching rows. Changed those
assertions to verify the call succeeds (and, when data is present, that
its shape is correct) instead of requiring non-empty results.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…-file-ci

chore: reorg tests to mirror module structure, scope CI to changed files
Merges the latest develop (which reorganized tests/ to mirror
PiHoleShell/Public/<Category>/) into this branch, then moves this PR's own
new test file - added before that reorg landed - into tests/Actions/ to
match, fixing its $PSScriptRoot-relative IntegrationConfig.local.ps1
lookup accordingly. Verified against the real Pi-hole server post-move.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mikemadeja
mikemadeja merged commit 4c17e93 into main Sep 25, 2026
5 checks passed
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