Skip to content

Refactor and enhance Pester tests batch #9773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 14, 2025
Merged

Refactor and enhance Pester tests batch #9773

merged 5 commits into from
Aug 14, 2025

Conversation

potatoqualitee
Copy link
Member

@potatoqualitee potatoqualitee commented Aug 12, 2025

Couldn't be auto-converted

New-DbaAgentSchedule
New-DbaAvailabilityGroup
New-DbaConnectionStringBuilder
New-DbaDbSnapshot
New-DbaDbTransfer
New-DbaReplCreationScriptOptions
Read-DbaTraceFile

commit 7aefc63
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 14:44:56 2025 +0200

    Improve build ID extraction and PR test repair logic

    Adds explicit checks for $Matches.Count when extracting AppVeyor build IDs to prevent errors if the regex does not match. Refactors Repair-PullRequestTest.ps1 to handle BuildId mode first, skipping PR/branch auto-detection when a build number is specified, and improves the logic for selecting the branch or PR context for test repair operations.

commit 1a1c432
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 13:04:32 2025 +0200

    Add appveyor.pester.ps1 to cache file paths

    Included the appveyor.pester.ps1 test file in the CacheFilePath array within Update-PesterTest.ps1 to ensure it is considered during cache operations.

commit 842ae4e
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 12:50:40 2025 +0200

    Update Repair-PullRequestTest.ps1

commit f372c02
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 11:20:57 2025 +0200

    Improve AppVeyor build detection using branch name

    Enhances the logic for detecting AppVeyor build status and IDs by first attempting to use the branch name directly with GitHub's API, falling back to commit SHA only if necessary. Adds more robust handling for check-runs and status APIs, and restricts fallback to processing all open PRs to only the development branch, providing clearer warnings and verbose output.

commit 4a9a862
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 11:06:53 2025 +0200

    Remove Test-BranchPublished and improve failure detection

    Eliminates the Test-BranchPublished helper and its early exit logic, simplifying the process flow. Now, if no failures are detected for the current branch, the script logs a verbose message and exits, improving clarity and reducing redundant checks.

commit 02cbec1
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 11:04:15 2025 +0200

    Improve branch unpublished warnings and temp dir handling

    Changed verbose messages to warnings when the current branch is unpublished in both Get-AppVeyorFailure and Repair-PullRequestTest. Refactored Repair-PullRequestTest to initialize and clean up the temp directory only when needed, preventing null reference issues.

commit e1de4ae
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 11:00:47 2025 +0200

    Add branch publication check before AppVeyor actions

    Introduced a Test-BranchPublished helper function in both Get-AppVeyorFailure.ps1 and Repair-PullRequestTest.ps1 to verify if the current branch has been published to AppVeyor before proceeding. This prevents unnecessary operations and error checks on unpublished branches, improving script reliability and user feedback.

commit 3e991a4
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 10:58:01 2025 +0200

    Enhance AppVeyor failure detection and repair logic

    Improved Get-AppVeyorFailure and Repair-PullRequestTest to support automatic detection of AppVeyor build failures from the current branch or a specified branch, with multiple fallback methods (PR checks, commit status, check-runs API). Updated parameter documentation and examples to reflect new capabilities, and refactored logic to allow explicit branch-based repair and more robust auto-detection, reducing manual input and improving usability.

commit f893538
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 10:47:01 2025 +0200

    Rename parameters in Repair-PullRequestTest

    Renamed the 'PRNumber' parameter to 'PullRequest' and 'MaxPRs' to 'Limit' in Repair-PullRequestTest.ps1 for clarity and consistency. Updated all references and documentation in both the script and README accordingly.

commit 6f07f99
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 10:43:26 2025 +0200

    Rename BuildNumber parameter to BuildId in scripts

    Replaces all references to the BuildNumber parameter with BuildId in Get-AppVeyorFailure.ps1 and Repair-PullRequestTest.ps1 for clarity and consistency. Updates parameter names, documentation, and usage examples accordingly.

commit 025d224
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 10:11:43 2025 +0200

    Refactor PR test repair and failure filtering logic

    Replaces the Branch parameter with a Pattern parameter in Get-AppVeyorFailure, allowing regex-based filtering of failures by filename. Updates Repair-PullRequestTest to pass the pattern through, simplifies logic by removing special handling for standalone branches and the Force flag, and streamlines parallel job management and cleanup. Improves documentation and usage examples for both scripts.

commit 7549513
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 10:01:48 2025 +0200

    fox

commit f86b7a3
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 09:42:41 2025 +0200

    Add GitHub CLI integration to resolve AppVeyor builds

    Enhances Get-AppVeyorFailure.ps1 to first attempt resolving the latest AppVeyor build for a branch using the GitHub CLI and GitHub API, falling back to the previous AppVeyor history API logic if necessary. This improves reliability and accuracy when identifying the correct build associated with a branch.

commit 2936ed5
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 09:05:35 2025 +0200

    Add Branch parameter to Get-AppVeyorFailure

    Introduces a new -Branch parameter to the Get-AppVeyorFailure function, allowing users to retrieve test failures from the latest AppVeyor build for a specified branch. Updates parameter documentation and logic to support branch-based build selection.

commit 0f90e72
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 09:03:10 2025 +0200

    Update Repair-PullRequestTest.ps1

commit 5ca93c6
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 09:00:46 2025 +0200

    Improve handling of current branch without AppVeyor failures

    Adds logic to only process test files matching a pattern when on the current branch without AppVeyor failure data. Provides clearer warnings and instructions when no failures are found, and avoids running all tests by default unless a pattern is specified.

commit 3de8fe5
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 08:37:01 2025 +0200

    Add Force flag to allow PR processing on Development branch

    Introduces a Force switch parameter to Repair-PullRequestTest, enabling PR test failure processing even when on the Development branch. Updates logic to require Force for PR handling on Development, improves filtering of test failures to only include those in changed files, and enhances verbose output for clarity.

commit bdb9950
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 08:25:43 2025 +0200

    Rename NoAuthFix to NoAutoFix in Update-PesterTest

    Renames the NoAuthFix parameter to NoAutoFix in Update-PesterTest.ps1 for clarity and consistency. Updates all references in Repair-PullRequestTest.ps1 and the function implementation. Also adds a call to Invoke-DbatoolsFormatter before invoking AutoFix.

commit 19f8fca
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 08:08:34 2025 +0200

    Handle test repair for non-PR branches in script

    Enhances Repair-PullRequestTest.ps1 to support running test repairs on branches without open PRs, except for the Development branch. For such branches, the script now processes all relevant test files even without AppVeyor failure data, improving usability for feature and local branches.

commit 44ce246
Author: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
Date:   Tue Aug 12 08:02:03 2025 +0200

    Add strict dev branch protection and Ctrl-C job cleanup

    Prevents the Repair-PullRequestTest script from running repairs directly on the development branch, enforcing branch protection. Adds robust Ctrl-C (interrupt) handling to stop and clean up background jobs immediately, including registering and unregistering event handlers and traps for pipeline interruptions. Improves reliability and safety during parallel test repair operations.
@potatoqualitee potatoqualitee merged commit 19736d4 into development Aug 14, 2025
14 checks passed
@potatoqualitee potatoqualitee deleted the b11 branch August 14, 2025 10:31
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