Primary User Story
As a PowerShell module maintainer managing multiple repositories, I need a single workflow configuration that automatically runs tests on pull requests and publishes releases when changes are merged to the main branch. This unified workflow eliminates the need to maintain two separate workflow files (CI.yml and workflow.yml) across all repositories, reducing configuration complexity and ensuring consistency.
Acceptance Scenarios
- Given a pull request is opened or updated, When the workflow runs, Then it MUST execute all CI tests without attempting any release operations
- Given a pull request is merged to the main branch, When the workflow runs, Then it MUST execute CI tests and proceed to release/publish operations if tests pass
- Given changes are pushed directly to the main branch (bypass PR), When the workflow runs, Then it MUST execute both CI tests and release operations
- Given CI tests fail on a PR, When the workflow completes, Then it MUST report failure status and NOT proceed to any release operations
- Given CI tests fail on main branch, When the workflow completes, Then it MUST report failure and halt before release operations
- Given a repository adopts this unified workflow, When migration is complete, Then maintainers MUST be able to remove separate CI.yml and workflow.yml files without losing functionality
Edge Cases
- What happens when a workflow is manually triggered (workflow_dispatch)?
- How does the workflow handle concurrent runs when multiple PRs are merged rapidly?
- What happens if release operations fail after CI tests pass on main branch?
- How does the workflow distinguish between testing-only and release-required contexts?
- What happens when a repository has custom test configurations or matrix strategies?
Requirements (mandatory)
Functional Requirements
| ID |
Requirement |
| FR-001 |
Workflow MUST trigger on pull request events (opened, synchronized, reopened) |
| FR-002 |
Workflow MUST trigger on push events to the main branch |
| FR-003 |
Workflow MUST execute CI test suite for all trigger events |
| FR-004 |
Workflow MUST conditionally execute release operations only on main branch pushes |
| FR-005 |
Workflow MUST skip release operations when running on pull request events |
| FR-006 |
Workflow MUST report test results as PR status checks |
| FR-007 |
Workflow MUST fail fast and halt execution if CI tests fail |
| FR-008 |
Workflow MUST publish module releases to [NEEDS CLARIFICATION: target registry not specified - PowerShell Gallery, private feed, both?] |
| FR-009 |
Workflow MUST create GitHub releases with [NEEDS CLARIFICATION: versioning strategy not specified - semantic versioning, date-based, manual tags?] |
| FR-010 |
Workflow MUST be compatible with existing repository structures used in PSModule repositories |
| FR-011 |
Workflow MUST support manual triggering (workflow_dispatch) with [NEEDS CLARIFICATION: should manual triggers allow release operations, or tests only?] |
| FR-012 |
Workflow MUST handle authentication for [NEEDS CLARIFICATION: authentication targets not specified - PowerShell Gallery API keys, GitHub tokens, other credentials?] |
Non-Functional Requirements
| ID |
Requirement |
| NFR-001 |
Workflow MUST complete CI test phase within reasonable time limits [NEEDS CLARIFICATION: acceptable time limits not specified] |
| NFR-002 |
Workflow MUST be maintainable as a single source of truth across multiple repositories |
| NFR-003 |
Workflow MUST provide clear logging to distinguish CI and release phases |
| NFR-004 |
Workflow MUST be idempotent for release operations (safe to re-run without duplicate publishes) |
| NFR-005 |
Workflow configuration MUST be simple enough for module maintainers to understand and customize |
| NFR-006 |
Workflow MUST minimize redundant work when transitioning from PR to main branch merge |
Quality Attributes Addressed
| Attribute |
Target Metric |
| Maintainability |
Single workflow file replaces two separate files; changes apply to all repositories via template updates |
| Reliability |
Consistent behavior across all trigger scenarios; fail-safe design prevents accidental releases |
| Usability |
Clear phase separation; easy to understand which operations run in which context |
| Efficiency |
Reduced configuration overhead; faster onboarding for new repositories |
Constraints
| Constraint |
Description |
| GitHub Actions |
Must run on GitHub Actions platform using composite actions or reusable workflows |
| PowerShell Module Structure |
Must work with PSModule repository structure conventions |
| Backward Compatibility |
Must not break existing CI or release behaviors when migrating from separate workflows |
| Existing Actions |
Must leverage existing PSModule GitHub actions (PSModule/GitHub-Script@v1, PSModule/Install-PSModuleHelpers@v1) |
Key Entities
| Entity |
Description |
| Workflow Configuration |
Single YAML file defining triggers, jobs, and conditional logic for CI and release phases |
| CI Phase |
Test execution, validation, and quality checks that run on all events |
| Release Phase |
Module publishing, GitHub release creation, and post-release operations that run only on main branch |
| Trigger Context |
Runtime information determining whether workflow runs in PR mode or release mode |
| Test Results |
Output from CI phase determining whether release phase can proceed |
Feature Branch: 001-merge-ci-release-workflows
Created: 2025-10-02
Status: Draft