Skip to content

Conversation

MariusStorhaug
Copy link
Member

@MariusStorhaug MariusStorhaug commented Jun 9, 2025

Description

This pull request includes improvements to Get-GitHubContext, replacing a thrown exception with a warning, causing it not error out if there are no contexts to return.

Error Handling Improvements:

  • Replaced the thrown exception for missing default GitHub context with a warning message and an early return. This prevents the script from terminating unexpectedly.
  • Added a new test case to verify that Get-GitHubContext does not throw an exception when no contexts are available and returns an empty result.

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

@Copilot Copilot AI review requested due to automatic review settings June 9, 2025 19:11
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner June 9, 2025 19:11
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 addresses issues related to the GitHub context retrieval by ensuring that Get-GitHubContext handles the case with 0 available contexts without failing, and it updates the PSModule YAML configuration to skip several build, test, and coverage steps.

  • Adds a new test case to verify that Get-GitHubContext does not throw and returns an empty value when no contexts exist.
  • Updates the .github/PSModule.yml file to skip unnecessary build targets and tests.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

File Description
tests/GitHub.Tests.ps1 Added a test to ensure Get-GitHubContext handles 0 contexts gracefully.
.github/PSModule.yml Updated configuration to skip specific build and test steps.

…ing instead of throw for missing default context
- Created a template test file for structuring Pester tests.
- Implemented tests for GitHub Teams API, including team creation, retrieval, updating, and deletion.
- Developed tests for GitHub Users API, covering user retrieval and updates, including email management.
- Added extensive tests for GitHub Variables API, focusing on variable creation, updates, retrieval, and deletion across different scopes (user, organization, repository, environment).
- Ensured all tests log context and results for better traceability in CI/CD environments.
- Included necessary suppressions for Pester warnings to maintain clean test output.
@MariusStorhaug MariusStorhaug self-assigned this Jun 9, 2025
@MariusStorhaug MariusStorhaug changed the title Fix get context 🪲 [Fix]: Get-GitHubContext should not fail when there are no contexts to return Jun 9, 2025
@MariusStorhaug MariusStorhaug changed the title 🪲 [Fix]: Get-GitHubContext should not fail when there are no contexts to return 🪲 [Fix]: Get-GitHubContext no longer fails when there are no contexts to return Jun 9, 2025
@MariusStorhaug MariusStorhaug merged commit 63c95b3 into main Jun 9, 2025
10 checks passed
@MariusStorhaug MariusStorhaug deleted the fixGetContext branch June 9, 2025 20:52
@github-project-automation github-project-automation bot moved this from Todo to Done in GitHub PowerShell Module Jun 9, 2025
Copy link
Contributor

github-actions bot commented Jun 9, 2025

Module GitHub - 0.29.4 published to the PowerShell Gallery.

Copy link
Contributor

github-actions bot commented Jun 9, 2025

GitHub release for GitHub v0.29.4 has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant