⚙️ [Maintenance]: Test infrastructure consolidated with shared repos and run-scoped cleanup#541
⚙️ [Maintenance]: Test infrastructure consolidated with shared repos and run-scoped cleanup#541
Conversation
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
- Created TEMPLATE.ps1 for structuring tests with Pester. - Implemented Teams.Tests.ps1 to test GitHub Teams API functionalities including team creation, retrieval, updating, and deletion. - Developed Users.Tests.ps1 to validate user-related API calls, including user retrieval and updates. - Added Variables.Tests.ps1 to test GitHub variable management across different scopes (organization, repository, environment). - Included necessary suppressions for Pester warnings and established logging for better output visibility during test execution.
- Created TEMPLATE.ps1 for structuring Pester tests with common setup. - Implemented Teams.Tests.ps1 to test GitHub Teams API functionalities including team creation, retrieval, updating, and deletion. - Developed Users.Tests.ps1 to validate user-related API calls, including user retrieval and updates. - Added Variables.Tests.ps1 to test GitHub repository and organization variable management, including creation, updating, and removal of variables.
…in BeforeAll script
… in AfterAll script
ad98f64 to
3dbdfc3
Compare
…t/consolidate-test-setup-tasks
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
Build, test, and publish stages will be skipped for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. |
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
Build, test, and publish stages will be skipped for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. |
…t/consolidate-test-setup-tasks
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
Build, test, and publish stages will be skipped for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. |
Phase 1 fixes: - Environments.Tests.ps1: Add missing $testName variable - AfterAll.ps1: Fix 'setup' labels to 'teardown/cleanup', remove unused vars Phase 2 - Lightweight tests moved from tmp/ to tests/: - GitHubFormatter.Tests.ps1 (pure unit tests, no API calls) - Emojis.Tests.ps1 (read-only API) - Enterprise.Tests.ps1 (read-only, fix Describe 'Template' bug) - Permissions.Tests.ps1 (read-only validation) - Artifacts.Tests.ps1 (reads existing workflow artifacts) - GitHub.Tests.ps1 (read-only/config, no remote resources) - Apps.Tests.ps1 (uses existing app installations) - Users.Tests.ps1 (user-specific, can't be pre-shared) Phase 3 - Medium complexity: - Teams.Tests.ps1 (team creation not a rate-limit hotspot) Remaining in tmp/ for Phase 4 (heavy, need shared infra expansion): - Organizations.Tests.ps1 - Releases.Tests.ps1 - Repositories.Tests.ps1 - Secrets.Tests.ps1 - Variables.Tests.ps1
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
Build, test, and publish stages will be skipped for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. |
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
Build, test, and publish stages will be skipped for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. |
…ings JSON for improved clarity and consistency
…ory creation process
- Move all test files from tmp/ back to tests/ - BeforeAll.ps1: create primary repo with readme/license/gitignore + 2 extra repos for SelectedRepository tests - AfterAll.ps1: scope cleanup to current GITHUB_RUN_ID only - All test files: replace GUID/Get-Random naming with GITHUB_RUN_ID - Secrets/Variables: use shared repos via Get-GitHubRepository instead of creating their own - Releases: use shared repo (now has readme/license/gitignore) - Repositories: keeps own CRUD since it tests repo creation/deletion - GitHub.Tests.ps1: fix bare if-APP pattern to use -Skip + BeforeAll - TEMPLATE.ps1: update to new shared-repo pattern - Remove tmp/ folder and duplicate README - Revert unrelated changes (manifest tag, copilot-instructions typos)
…est-setup-tasks # Conflicts: # tests/Enterprise.Tests.ps1 # tests/TEMPLATE.ps1
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
Build, test, and publish stages will be skipped for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. |
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
Build, test, and publish stages will be skipped for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. |
No Significant Changes DetectedThis PR does not contain changes to files that would trigger a new release:
Build, test, and publish stages will be skipped for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. |
No changes to the module's public API or behavior. Test infrastructure now uses shared global setup and teardown scripts (
BeforeAll.ps1/AfterAll.ps1) that run once before and after all parallel test jobs. All test files have been migrated fromtmp/back intotests/, and cleanup is scoped to the currentGITHUB_RUN_IDfor safe parallel execution of concurrent workflow runs.Technical Details
BeforeAll.ps1/AfterAll.ps1global setup/teardown scripts that run once before and after all parallel test jobs.BeforeAll.ps1creates 3 repos per auth-case/OS (primary + 2 extras). Primary repo includes readme, MIT license, and VisualStudio gitignore — satisfying release asset test requirements.tmp/totests/, each updated to use the shared repository pattern.GITHUB_RUN_IDinstead of prefix-based matching, preventing concurrent workflow runs from interfering with each other.Get-RandomandGUIDwithGITHUB_RUN_IDfor deterministic, debuggable naming across the entire test suite.Connect-GitHubAppmoved intoBeforeAll+-SkippatternGet-Random→GITHUB_RUN_IDGUID→GITHUB_RUN_IDGet-GitHubRepository; repo creation removedGITHUB_RUN_IDAfterAll.ps1: ScopedWhere-Objectfilter from$repoPrefix*to$repoName*.Repositories.Tests.ps1: Only test file that still creates/deletes its own repos (it tests CRUD operations).Secrets.Tests.ps1/Variables.Tests.ps1: Repo creation replaced withGet-GitHubRepositoryfor shared repos.tmp/directory andtmp/README-SETUP-TEARDOWN.md; content consolidated intotests/README.md.