Skip to content

⚙️ [Maintenance]: Test infrastructure consolidated with shared repos and run-scoped cleanup#541

Draft
Copilot wants to merge 32 commits intomainfrom
copilot/consolidate-test-setup-tasks
Draft

⚙️ [Maintenance]: Test infrastructure consolidated with shared repos and run-scoped cleanup#541
Copilot wants to merge 32 commits intomainfrom
copilot/consolidate-test-setup-tasks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 5, 2026

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 from tmp/ back into tests/, and cleanup is scoped to the current GITHUB_RUN_ID for safe parallel execution of concurrent workflow runs.

Technical Details

  • Added BeforeAll.ps1 / AfterAll.ps1 global setup/teardown scripts that run once before and after all parallel test jobs.
  • BeforeAll.ps1 creates 3 repos per auth-case/OS (primary + 2 extras). Primary repo includes readme, MIT license, and VisualStudio gitignore — satisfying release asset test requirements.
  • All test files migrated from tmp/ to tests/, each updated to use the shared repository pattern.
  • Cleanup scoped to current GITHUB_RUN_ID instead of prefix-based matching, preventing concurrent workflow runs from interfering with each other.
  • Replaced Get-Random and GUID with GITHUB_RUN_ID for deterministic, debuggable naming across the entire test suite.
File Change
Apps, Artifacts, GitHubFormatter, Permissions Moved as-is (read-only, no repos)
Emojis, Users, Enterprise Already updated or moved as-is
GitHub.Tests Connect-GitHubApp moved into BeforeAll + -Skip pattern
Organizations Get-RandomGITHUB_RUN_ID
Teams GUIDGITHUB_RUN_ID
Secrets, Variables Use shared repos via Get-GitHubRepository; repo creation removed
Releases Uses shared repo (now has readme/license/gitignore)
Repositories Keeps own CRUD (that is what it tests); naming updated to GITHUB_RUN_ID
TEMPLATE Rewritten to new shared-repo pattern
  • AfterAll.ps1: Scoped Where-Object filter 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 with Get-GitHubRepository for shared repos.
  • Deleted tmp/ directory and tmp/README-SETUP-TEARDOWN.md; content consolidated into tests/README.md.
  • Reverted unrelated changes from earlier commits (manifest tag, copilot-instructions typos).

Copilot AI and others added 4 commits January 5, 2026 23:04
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>
Copilot AI changed the title [WIP] Consolidate test setup and teardown tasks Add BeforeAll/AfterAll scripts for centralized test resource cleanup Jan 5, 2026
- 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.
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title Add BeforeAll/AfterAll scripts for centralized test resource cleanup Fix: skip repo linting on merge to main Jan 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

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.

@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title Fix: skip repo linting on merge to main 🩹 [Patch]: Consolidate test setup/teardown tasks Feb 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

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.

@github-actions
Copy link
Copy Markdown
Contributor

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

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
@github-actions
Copy link
Copy Markdown
Contributor

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

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.

@github-actions
Copy link
Copy Markdown
Contributor

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

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
- 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)
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🩹 [Patch]: Consolidate test setup/teardown tasks 🩹 [Patch]: Test infrastructure consolidated with shared repos and run-scoped cleanup Apr 4, 2026
…est-setup-tasks

# Conflicts:
#	tests/Enterprise.Tests.ps1
#	tests/TEMPLATE.ps1
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

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.

@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🩹 [Patch]: Test infrastructure consolidated with shared repos and run-scoped cleanup ⚙️ [Maintenance]: Test infrastructure consolidated with shared repos and run-scoped cleanup Apr 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Path Description
src/** Module source code
README.md Documentation

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.

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

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Consolidate test setup/teardown tasks

2 participants