Skip to content

Conversation

MariusStorhaug
Copy link
Member

@MariusStorhaug MariusStorhaug commented Jul 19, 2025

Description

This pull request introduces improvements to the GitHub App uninstallation workflow, adding more flexible and robust ways to uninstall apps both as an authenticated app and as an enterprise installation. The changes include new internal functions, enhanced parameter handling, improved context validation, and expanded test coverage to ensure reliability and clarity in uninstall scenarios.

Enhancements to GitHub App Uninstallation:

  • Added new function Uninstall-GitHubAppAsApp to support uninstalling app installations as the authenticated app, with support for confirmation and verbose output.
  • Updated Uninstall-GitHubAppOnEnterpriseOrganization to clarify its purpose, improve parameter validation, add confirmation support, and provide better feedback on successful uninstalls.

Expanded and Flexible Public API:

  • Refactored Uninstall-GitHubApp to support multiple uninstallation modes (by target, by object, by installation ID, by app slug), improved parameter sets, and added context and authentication checks for safer operation.

Documentation and Examples:

  • Added a comprehensive example script examples/Apps/UninstallingApps.ps1 showing various uninstallation scenarios for both app and enterprise contexts.

Testing and Reliability:

  • Improved organization tests to clean up existing app installations before and after tests, and added a test to verify app uninstall behavior after organization deletion.

Other Improvements:

  • Increased robustness in token revocation error handling in Disconnect-GitHubAccount.
  • Fixed a minor property default in GitHubContext.Types.ps1xml for better handling of missing token expiration.
  • Updated .github/PSModule.yml to enable and skip specific test and build steps as appropriate.

Type of change

  • 📖 [Docs]
  • 🪲 [Fix]
  • 🩹 [Patch]
  • ⚠️ [Security fix]
  • 🚀 [Feature]
  • 🌟 [Breaking change]

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

- Created TEMPLATE.ps1 for structuring Pester tests with common setup.
- Added Teams.Tests.ps1 to test GitHub Teams API functionalities including team creation, retrieval, updating, and deletion.
- Implemented Users.Tests.ps1 to validate user-related API calls such as fetching user details and updating user information.
- Developed Variables.Tests.ps1 to test GitHub repository and organization variable management, including setting, updating, and removing variables.
@Copilot Copilot AI review requested due to automatic review settings July 19, 2025 00:31
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner July 19, 2025 00:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds functionality for uninstalling GitHub App installations, along with test infrastructure and configuration changes. The main focus is implementing proper cleanup mechanisms for GitHub App installations in organization contexts.

  • Implements Remove-GitHubAppInstallation private function for deleting app installations via API
  • Enhances Uninstall-GitHubApp public function with improved parameter handling and installation deletion logic
  • Adds comprehensive test coverage for app installation cleanup in organization lifecycle tests

Reviewed Changes

Copilot reviewed 4 out of 17 changed files in this pull request and generated 2 comments.

File Description
src/functions/private/Apps/GitHub Apps/Remove-GitHubAppInstallation.ps1 New private function implementing GitHub API call to delete app installations
src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 Enhanced parameter set handling and added default parameter set for installation deletion
tests/Organizations.Tests.ps1 Added pre-test and post-test cleanup logic for app installations in organization tests
.github/PSModule.yml Uncommented configuration to skip various test components and documentation builds
Comments suppressed due to low confidence (1)

tests/Organizations.Tests.ps1:174

  • The test assertion should include a descriptive message to make test failures more informative. Consider adding '-Because' parameter to explain what this assertion validates.
                    $remainingInstallations | Should -BeNullOrEmpty

@MariusStorhaug MariusStorhaug changed the title Add initial test scripts for GitHub API interactions Add function to remove app installation as a GitHub App Jul 22, 2025
… enhance GitHubAppContext with TokenExpiresIn property
…d 10 minutes for 'APP' in GitHub context formatting
…eOrganization function to clarify it uninstalls from enterprise-owned organizations
…parameter handling for improved clarity and functionality
- Created TEMPLATE.ps1 for structuring Pester tests with common setup.
- Added Teams.Tests.ps1 to test GitHub Teams API functionalities including team creation, retrieval, updating, and deletion.
- Introduced Users.Tests.ps1 to validate user-related API calls, including user retrieval and updates.
- Developed Variables.Tests.ps1 to test GitHub variable management, covering organization and repository scopes, variable creation, updates, and deletions.
- Revise README to include automatic token renewal details.
- Remove JwtTimeTolerance from GitHubConfig and related formats.
- Adjust JWT generation to use fixed expiration times.
- Update token expiration checks in relevant functions.
- Add tests for token expiration handling and emoji retrieval.
@MariusStorhaug MariusStorhaug self-assigned this Sep 6, 2025
@MariusStorhaug MariusStorhaug changed the title Add function to remove app installation as a GitHub App 🩹 [Patch]: Add function to remove app installation as a GitHub App Sep 6, 2025
@MariusStorhaug MariusStorhaug merged commit 8427e91 into main Sep 6, 2025
181 of 192 checks passed
@MariusStorhaug MariusStorhaug deleted the removeinstalls branch September 6, 2025 13:51
@github-project-automation github-project-automation bot moved this from Todo to Done in GitHub PowerShell Module Sep 6, 2025
Copy link
Contributor

github-actions bot commented Sep 6, 2025

Module GitHub - 0.36.7 published to the PowerShell Gallery.

Copy link
Contributor

github-actions bot commented Sep 6, 2025

GitHub release for GitHub v0.36.7 has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant