diff --git a/.github/workflows/Build-Module.yml b/.github/workflows/Build-Module.yml index a49da7de..75857ccc 100644 --- a/.github/workflows/Build-Module.yml +++ b/.github/workflows/Build-Module.yml @@ -30,8 +30,10 @@ jobs: fetch-depth: 0 - name: Build module - uses: PSModule/Build-PSModule@345728124d201f371a8b0f1aacb98f89000a06dc # v4.0.14 + uses: PSModule/Build-PSModule@v4.1 with: Name: ${{ fromJson(inputs.Settings).Name }} + Version: ${{ fromJson(inputs.Settings).Module.Version != '' && fromJson(inputs.Settings).Module.Version || '0.0.0' }} + Prerelease: ${{ fromJson(inputs.Settings).Module.Prerelease }} ArtifactName: ${{ inputs.ArtifactName }} WorkingDirectory: ${{ fromJson(inputs.Settings).WorkingDirectory }} diff --git a/.github/workflows/Get-Settings.yml b/.github/workflows/Get-Settings.yml deleted file mode 100644 index 860fb436..00000000 --- a/.github/workflows/Get-Settings.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Get-Settings - -on: - workflow_call: - inputs: - SettingsPath: - type: string - description: The path to the settings file. - required: false - Debug: - type: boolean - description: Enable debug output. - required: false - default: false - Verbose: - type: boolean - description: Enable verbose output. - required: false - default: false - Version: - type: string - description: Specifies the version of the GitHub module to be installed. The value must be an exact version. - required: false - default: '' - Prerelease: - type: boolean - description: Whether to use a prerelease version of the 'GitHub' module. - required: false - default: false - WorkingDirectory: - type: string - description: The path to the root of the repo. - required: false - default: '.' - ImportantFilePatterns: - type: string - description: | - Newline-separated list of regex patterns that identify important files. - Changes matching these patterns trigger build, test, and publish stages. - When set, fully replaces the defaults (^src/ and ^README\.md$). - required: false - default: | - ^src/ - ^README\.md$ - - outputs: - Settings: - description: The complete settings object including test suites - value: ${{ jobs.Get-Settings.outputs.Settings }} - -permissions: - contents: read # to checkout the repo - pull-requests: write # to add labels to PRs - -jobs: - Get-Settings: - name: Get-Settings - runs-on: ubuntu-latest - outputs: - Settings: ${{ steps.Get-Settings.outputs.Settings }} - steps: - - name: Checkout Code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - fetch-depth: 0 - - - name: Get-Settings - uses: PSModule/Get-PSModuleSettings@1e3d156786c56e6fbd839a1ba5ab21ff8858090e # v1.5.0 - id: Get-Settings - with: - SettingsPath: ${{ inputs.SettingsPath }} - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - WorkingDirectory: ${{ inputs.WorkingDirectory }} - ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }} diff --git a/.github/workflows/Plan.yml b/.github/workflows/Plan.yml new file mode 100644 index 00000000..0c87fd86 --- /dev/null +++ b/.github/workflows/Plan.yml @@ -0,0 +1,124 @@ +name: Plan + +# The Plan job is the single decision point for the workflow. +# It runs two steps: +# 1. Get-PSModuleSettings - loads and resolves configuration +# 2. Resolve-PSModuleVersion - calculates the next version from settings + PR labels +# The resolved version is merged into the Settings object (Settings.Module.*) by the Enrich-Settings step. +# All downstream jobs receive one self-contained Settings JSON with no separate version outputs. + +on: + workflow_call: + inputs: + SettingsPath: + type: string + description: The path to the settings file. + required: false + Debug: + type: boolean + description: Enable debug output. + required: false + default: false + Verbose: + type: boolean + description: Enable verbose output. + required: false + default: false + Version: + type: string + description: Specifies the version of the GitHub module to be installed. The value must be an exact version. + required: false + default: '' + Prerelease: + type: boolean + description: Whether to use a prerelease version of the 'GitHub' module. + required: false + default: false + WorkingDirectory: + type: string + description: The path to the root of the repo. + required: false + default: '.' + ImportantFilePatterns: + type: string + description: | + Newline-separated list of regex patterns that identify important files. + Changes matching these patterns trigger build, test, and publish stages. + When set, fully replaces the defaults (^src/ and ^README\.md$). + required: false + default: | + ^src/ + ^README\.md$ + + outputs: + Settings: + description: The complete settings object including test suites and resolved module version. + value: ${{ jobs.Plan.outputs.Settings }} + +permissions: + contents: read # to checkout the repo + pull-requests: write # to add labels / comments to PRs + +jobs: + Plan: + name: Plan + runs-on: ubuntu-latest + outputs: + Settings: ${{ steps.Enrich-Settings.outputs.Settings }} + steps: + - name: Checkout Code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Get-Settings + uses: PSModule/Get-PSModuleSettings@1e3d156786c56e6fbd839a1ba5ab21ff8858090e # v1.5.0 + id: Get-Settings + with: + SettingsPath: ${{ inputs.SettingsPath }} + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + WorkingDirectory: ${{ inputs.WorkingDirectory }} + ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }} + + - name: Resolve-Version + # Resolve only when the workflow is going to create a release/prerelease. + if: fromJson(steps.Get-Settings.outputs.Settings).Publish.Module.ReleaseType != 'None' + uses: PSModule/Resolve-PSModuleVersion@65b7cb026cb3414943778473fd82ee6cf4f0363e # v1.0.1 + id: Resolve-Version + env: + GH_TOKEN: ${{ github.token }} + with: + Settings: ${{ steps.Get-Settings.outputs.Settings }} + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + WorkingDirectory: ${{ inputs.WorkingDirectory }} + + - name: Enrich-Settings + # Merge the resolved version into the Settings object so all downstream jobs + # receive a single, self-contained Settings JSON with no separate version outputs. + id: Enrich-Settings + shell: pwsh + env: + SETTINGS: ${{ steps.Get-Settings.outputs.Settings }} + VERSION: ${{ steps.Resolve-Version.outputs.Version }} + PRERELEASE: ${{ steps.Resolve-Version.outputs.Prerelease }} + FULL_VERSION: ${{ steps.Resolve-Version.outputs.FullVersion }} + RELEASE_TYPE: ${{ steps.Resolve-Version.outputs.ReleaseType }} + CREATE_RELEASE: ${{ steps.Resolve-Version.outputs.CreateRelease }} + run: | + $settings = $env:SETTINGS | ConvertFrom-Json + $settings | Add-Member -MemberType NoteProperty -Name Module -Value ([pscustomobject]@{ + Version = $env:VERSION + Prerelease = $env:PRERELEASE + FullVersion = $env:FULL_VERSION + ReleaseType = if ([string]::IsNullOrEmpty($env:RELEASE_TYPE)) { 'None' } else { $env:RELEASE_TYPE } + CreateRelease = $env:CREATE_RELEASE -eq 'true' + }) + $enriched = $settings | ConvertTo-Json -Depth 10 -Compress + "Settings=$enriched" >> $env:GITHUB_OUTPUT diff --git a/.github/workflows/Publish-Module.yml b/.github/workflows/Publish-Module.yml index 6a67831f..2edc731a 100644 --- a/.github/workflows/Publish-Module.yml +++ b/.github/workflows/Publish-Module.yml @@ -13,7 +13,7 @@ on: required: true permissions: - contents: write # to checkout the repo and create releases + contents: write # to checkout the repo, create releases, and upload release artifacts pull-requests: write # to comment on PRs jobs: @@ -30,7 +30,7 @@ jobs: fetch-depth: 0 - name: Publish module - uses: PSModule/Publish-PSModule@8917aed588dae1bd1aa2873b1caec1c50c20d255 # v2.2.4 + uses: PSModule/Publish-PSModule@main env: GH_TOKEN: ${{ github.token }} with: @@ -39,15 +39,6 @@ jobs: APIKey: ${{ secrets.APIKEY }} WhatIf: ${{ github.repository == 'PSModule/Process-PSModule' }} AutoCleanup: ${{ fromJson(inputs.Settings).Publish.Module.AutoCleanup }} - AutoPatching: ${{ fromJson(inputs.Settings).Publish.Module.AutoPatching }} - DatePrereleaseFormat: ${{ fromJson(inputs.Settings).Publish.Module.DatePrereleaseFormat }} - IgnoreLabels: ${{ fromJson(inputs.Settings).Publish.Module.IgnoreLabels }} - ReleaseType: ${{ fromJson(inputs.Settings).Publish.Module.ReleaseType }} - IncrementalPrerelease: ${{ fromJson(inputs.Settings).Publish.Module.IncrementalPrerelease }} - MajorLabels: ${{ fromJson(inputs.Settings).Publish.Module.MajorLabels }} - MinorLabels: ${{ fromJson(inputs.Settings).Publish.Module.MinorLabels }} - PatchLabels: ${{ fromJson(inputs.Settings).Publish.Module.PatchLabels }} - VersionPrefix: ${{ fromJson(inputs.Settings).Publish.Module.VersionPrefix }} UsePRTitleAsReleaseName: ${{ fromJson(inputs.Settings).Publish.Module.UsePRTitleAsReleaseName }} UsePRBodyAsReleaseNotes: ${{ fromJson(inputs.Settings).Publish.Module.UsePRBodyAsReleaseNotes }} UsePRTitleAsNotesHeading: ${{ fromJson(inputs.Settings).Publish.Module.UsePRTitleAsNotesHeading }} diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 9a4bc6af..7296e007 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -70,11 +70,11 @@ on: ^README\.md$ permissions: - contents: write # to checkout the repo and create releases on the repo + contents: write # to checkout the repo and create releases on the repo pull-requests: write # to write comments to PRs - statuses: write # to update the status of the workflow from linter - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source + statuses: write # to update the status of the workflow from linter + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source jobs: # Runs on: @@ -82,8 +82,8 @@ jobs: # - ✅ Merged PR - Always runs to load configuration # - ✅ Abandoned PR - Always runs to load configuration # - ✅ Manual run - Always runs to load configuration - Get-Settings: - uses: ./.github/workflows/Get-Settings.yml + Plan: + uses: ./.github/workflows/Plan.yml with: SettingsPath: ${{ inputs.SettingsPath }} Debug: ${{ inputs.Debug }} @@ -99,12 +99,12 @@ jobs: # - ❌ Abandoned PR - No need to lint abandoned changes # - ❌ Manual run - Only runs for PR events Lint-Repository: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.LintRepository + if: fromJson(needs.Plan.outputs.Settings).Run.LintRepository needs: - - Get-Settings + - Plan uses: ./.github/workflows/Lint-Repository.yml with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Builds module for testing @@ -112,12 +112,12 @@ jobs: # - ❌ Abandoned PR - Skips building abandoned changes # - ✅ Manual run - Builds module when manually triggered Build-Module: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.BuildModule + if: fromJson(needs.Plan.outputs.Settings).Run.BuildModule uses: ./.github/workflows/Build-Module.yml needs: - - Get-Settings + - Plan with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Tests source code changes @@ -125,12 +125,12 @@ jobs: # - ❌ Abandoned PR - Skips testing abandoned changes # - ✅ Manual run - Tests source code when manually triggered Test-SourceCode: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.TestSourceCode + if: fromJson(needs.Plan.outputs.Settings).Run.TestSourceCode needs: - - Get-Settings + - Plan uses: ./.github/workflows/Test-SourceCode.yml with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Lints source code changes @@ -138,12 +138,12 @@ jobs: # - ❌ Abandoned PR - Skips linting abandoned changes # - ✅ Manual run - Lints source code when manually triggered Lint-SourceCode: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.LintSourceCode + if: fromJson(needs.Plan.outputs.Settings).Run.LintSourceCode needs: - - Get-Settings + - Plan uses: ./.github/workflows/Lint-SourceCode.yml with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Tests built module @@ -151,13 +151,13 @@ jobs: # - ❌ Abandoned PR - Skips testing abandoned changes # - ✅ Manual run - Tests built module when manually triggered Test-Module: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.TestModule && needs.Build-Module.result == 'success' && !cancelled() + if: fromJson(needs.Plan.outputs.Settings).Run.TestModule && needs.Build-Module.result == 'success' && !cancelled() needs: - Build-Module - - Get-Settings + - Plan uses: ./.github/workflows/Test-Module.yml with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Runs setup scripts before local module tests @@ -165,7 +165,7 @@ jobs: # - ❌ Abandoned PR - Skips setup for abandoned changes # - ✅ Manual run - Runs setup scripts when manually triggered BeforeAll-ModuleLocal: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.BeforeAllModuleLocal && needs.Build-Module.result == 'success' && !cancelled() + if: fromJson(needs.Plan.outputs.Settings).Run.BeforeAllModuleLocal && needs.Build-Module.result == 'success' && !cancelled() uses: ./.github/workflows/BeforeAll-ModuleLocal.yml secrets: TEST_APP_ENT_CLIENT_ID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} @@ -177,9 +177,9 @@ jobs: TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} needs: - Build-Module - - Get-Settings + - Plan with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Tests module in local environment @@ -187,10 +187,10 @@ jobs: # - ❌ Abandoned PR - Skips testing abandoned changes # - ✅ Manual run - Tests module in local environment when manually triggered Test-ModuleLocal: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.TestModuleLocal && needs.Build-Module.result == 'success' && !cancelled() + if: fromJson(needs.Plan.outputs.Settings).Run.TestModuleLocal && needs.Build-Module.result == 'success' && !cancelled() needs: - Build-Module - - Get-Settings + - Plan - BeforeAll-ModuleLocal uses: ./.github/workflows/Test-ModuleLocal.yml secrets: @@ -202,7 +202,7 @@ jobs: TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Runs teardown scripts after local module tests @@ -210,7 +210,7 @@ jobs: # - ✅ Abandoned PR - Runs teardown if tests were started (cleanup) # - ✅ Manual run - Runs teardown scripts after local module tests AfterAll-ModuleLocal: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.AfterAllModuleLocal && needs.Test-ModuleLocal.result != 'skipped' && always() + if: fromJson(needs.Plan.outputs.Settings).Run.AfterAllModuleLocal && needs.Test-ModuleLocal.result != 'skipped' && always() uses: ./.github/workflows/AfterAll-ModuleLocal.yml secrets: TEST_APP_ENT_CLIENT_ID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} @@ -221,10 +221,10 @@ jobs: TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} needs: - - Get-Settings + - Plan - Test-ModuleLocal with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Collects and reports test results @@ -232,16 +232,16 @@ jobs: # - ❌ Abandoned PR - Skips collecting results for abandoned changes # - ✅ Manual run - Collects and reports test results when manually triggered Get-TestResults: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.GetTestResults && needs.Get-Settings.result == 'success' && always() && !cancelled() + if: fromJson(needs.Plan.outputs.Settings).Run.GetTestResults && needs.Plan.result == 'success' && always() && !cancelled() needs: - - Get-Settings + - Plan - Test-SourceCode - Lint-SourceCode - Test-Module - Test-ModuleLocal uses: ./.github/workflows/Get-TestResults.yml with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Calculates and reports code coverage @@ -249,14 +249,14 @@ jobs: # - ❌ Abandoned PR - Skips coverage for abandoned changes # - ✅ Manual run - Calculates and reports code coverage when manually triggered Get-CodeCoverage: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.GetCodeCoverage && needs.Get-Settings.result == 'success' && always() && !cancelled() + if: fromJson(needs.Plan.outputs.Settings).Run.GetCodeCoverage && needs.Plan.result == 'success' && always() && !cancelled() needs: - - Get-Settings + - Plan - Test-Module - Test-ModuleLocal uses: ./.github/workflows/Get-CodeCoverage.yml with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Only with prerelease label: publishes prerelease version @@ -264,17 +264,17 @@ jobs: # - ✅ Abandoned PR - Cleans up prereleases for the abandoned branch (no version published) # - ❌ Manual run - Only runs for PR events Publish-Module: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.PublishModule && needs.Get-Settings.result == 'success' && !cancelled() && (needs.Get-TestResults.result == 'success' || needs.Get-TestResults.result == 'skipped') && (needs.Get-CodeCoverage.result == 'success' || needs.Get-CodeCoverage.result == 'skipped') && (needs.Build-Site.result == 'success' || needs.Build-Site.result == 'skipped') + if: fromJson(needs.Plan.outputs.Settings).Run.PublishModule && needs.Plan.result == 'success' && !cancelled() && (needs.Get-TestResults.result == 'success' || needs.Get-TestResults.result == 'skipped') && (needs.Get-CodeCoverage.result == 'success' || needs.Get-CodeCoverage.result == 'skipped') && (needs.Build-Site.result == 'success' || needs.Build-Site.result == 'skipped') uses: ./.github/workflows/Publish-Module.yml secrets: APIKey: ${{ secrets.APIKey }} needs: - - Get-Settings + - Plan - Get-TestResults - Get-CodeCoverage - Build-Site with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Builds documentation for review @@ -282,13 +282,13 @@ jobs: # - ❌ Abandoned PR - Skips building docs for abandoned changes # - ✅ Manual run - Builds documentation when manually triggered Build-Docs: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.BuildDocs + if: fromJson(needs.Plan.outputs.Settings).Run.BuildDocs needs: - - Get-Settings + - Plan - Build-Module uses: ./.github/workflows/Build-Docs.yml with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ✅ Open/Updated PR - Builds site for preview @@ -296,13 +296,13 @@ jobs: # - ❌ Abandoned PR - Skips building site for abandoned changes # - ✅ Manual run - Builds site when manually triggered Build-Site: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.BuildSite + if: fromJson(needs.Plan.outputs.Settings).Run.BuildSite needs: - - Get-Settings + - Plan - Build-Docs uses: ./.github/workflows/Build-Site.yml with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} # Runs on: # - ❌ Open/Updated PR - Site not published for PRs in progress @@ -310,12 +310,12 @@ jobs: # - ❌ Abandoned PR - Site not published for abandoned changes # - ❌ Manual run - Only publishes on merged PRs to default branch Publish-Site: - if: fromJson(needs.Get-Settings.outputs.Settings).Run.PublishSite && needs.Get-TestResults.result == 'success' && needs.Get-CodeCoverage.result == 'success' && needs.Build-Site.result == 'success' && !cancelled() + if: fromJson(needs.Plan.outputs.Settings).Run.PublishSite && needs.Get-TestResults.result == 'success' && needs.Get-CodeCoverage.result == 'success' && needs.Build-Site.result == 'success' && !cancelled() uses: ./.github/workflows/Publish-Site.yml needs: - - Get-Settings + - Plan - Get-TestResults - Get-CodeCoverage - Build-Site with: - Settings: ${{ needs.Get-Settings.outputs.Settings }} + Settings: ${{ needs.Plan.outputs.Settings }} diff --git a/README.md b/README.md index c74caadb..65571c96 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,8 @@ Depending on the labels in the pull requests, the [workflow will result in diffe - [How to get started](#how-to-get-started) - [How it works](#how-it-works) - [Workflow overview](#workflow-overview) - - [Get-Settings](#get-settings) + - [Plan](#plan) - [Lint-Repository](#lint-repository) - - [Get settings](#get-settings-1) - [Build module](#build-module) - [Test source code](#test-source-code) - [Lint source code](#lint-source-code) @@ -106,29 +105,30 @@ Depending on the labels in the pull requests, the [workflow will result in diffe - [Colocation of concerns](#colocation-of-concerns) - [Compatibility](#compatibility) -### Get-Settings +### Plan -[workflow](./.github/workflows/Get-Settings.yml) +[workflow](./.github/workflows/Plan.yml) + +The Plan job is the single decision point of the workflow. It reads the settings file (`.github/PSModule.yml`), +collects event context from GitHub, and decides what should happen in the rest of the process. Using that +situational awareness it calculates the next module version. All decisions are captured in a single `Settings` +object — including version data under `Settings.Module` — that every downstream job receives. ### Lint-Repository [workflow](./.github/workflows/Lint-Repository.yml) -### Get settings - -[workflow](#get-settings) -- Reads the settings file `github/PSModule.yml` in the module repository to configure the workflow. -- Gathers context for the process from GitHub and the repo files, configuring what tests to run, if and what kind of release to create, and whether - to setup testing infrastructure and what operating systems to run the tests on. - ### Build module [workflow](./.github/workflows/Build-Module.yml) -- Compiles the module source code into a PowerShell module. + +- Compiles the module source code into a PowerShell module, stamping the version from `Settings.Module` into the manifest. +- Uploads the built artifact. ### Test source code [workflow](./.github/workflows/Test-SourceCode.yml) + - Tests the source code in parallel (matrix) using: - [PSModule framework settings for style and standards for source code](https://github.com/PSModule/Test-PSModule?tab=readme-ov-file#sourcecode-tests) - This produces a JSON-based report that is used by [Get-PesterTestResults](#get-test-results) evaluate the results of the tests. @@ -148,10 +148,10 @@ The [PSModule - SourceCode tests](./scripts/tests/SourceCode/PSModule/PSModule.T | ParamBlock | Functions (Generic) | Functions should have a parameter block (`param()`). | | FunctionTest | Functions (Public) | All public functions/filters should have corresponding tests. | - ### Lint source code [workflow](./.github/workflows/Lint-SourceCode.yml) + - Lints the source code in parallel (matrix) using: - [PSScriptAnalyzer rules](https://github.com/PSModule/Invoke-ScriptAnalyzer) - This produces a JSON-based report that is used by [Get-PesterTestResults](#get-test-results) evaluate the results of the linter. @@ -159,6 +159,7 @@ The [PSModule - SourceCode tests](./scripts/tests/SourceCode/PSModule/PSModule.T ### Framework test [workflow](./.github/workflows/Test-Module.yml) + - Tests and lints the module in parallel (matrix) using: - [PSModule framework settings for style and standards for modules](https://github.com/PSModule/Test-PSModule?tab=readme-ov-file#module-tests) - [PSScriptAnalyzer rules](https://github.com/PSModule/Invoke-ScriptAnalyzer) @@ -175,6 +176,7 @@ The [PSModule - SourceCode tests](./scripts/tests/SourceCode/PSModule/PSModule.T ### Test module [workflow](./.github/workflows/Test-ModuleLocal.yml) + - Imports and tests the module in parallel (matrix) using Pester tests from the module repository. - Supports setup and teardown scripts executed via separate dedicated jobs: - `BeforeAll`: Runs once before all test matrix jobs to set up the test environment (e.g., deploy infrastructure, download test data). @@ -287,7 +289,6 @@ Use a consistent naming scheme so that resources are easy to identify and clean When tests use multiple authentication contexts that share the same runner, include a token or context identifier in the name to avoid collisions (for example, `Test-{OS}-{ContextID}-{RunID}`). - #### Module tests The [PSModule - Module tests](./scripts/tests/Module/PSModule/PSModule.Tests.ps1) verifies the following coding practices that the framework enforces: @@ -300,12 +301,14 @@ The [PSModule - Module tests](./scripts/tests/Module/PSModule/PSModule.Tests.ps1 ### Get test results [workflow](./.github/workflows/Get-TestResults.yml) + - Gathers the test results from the previous steps and creates a summary of the results. - If any tests have failed, the workflow will fail here. ### Get code coverage [workflow](./.github/workflows/Get-CodeCoverage.yml) + - Gathers the code coverage from the previous steps and creates a summary of the results. - Aggregates coverage from the [Framework test](#framework-test) step (framework-generated boilerplate) and the [Test module](#test-module) step (module author code). A command executed in either step counts as covered, so @@ -315,8 +318,10 @@ The [PSModule - Module tests](./scripts/tests/Module/PSModule/PSModule.Tests.ps1 ### Publish module [workflow](./.github/workflows/Publish-Module.yml) -- Publishes the module to the PowerShell Gallery. -- Creates a release on the GitHub repository. + +- Publishes the artifact to the PowerShell Gallery exactly as built — no version mutation. +- Creates a GitHub Release using the version already stamped in the manifest. +- Attaches the built module as a `.zip` asset on the GitHub Release so consumers can download the exact bytes that were tested and pushed to the PowerShell Gallery. - **Abandoned PR cleanup**: When a PR is closed without merging (abandoned), the workflow automatically cleans up any prerelease versions and tags that were created for that PR. This ensures that abandoned work doesn't leave orphaned prereleases in the PowerShell Gallery or repository. This behavior is controlled by the `Publish.Module.AutoCleanup` @@ -325,12 +330,14 @@ The [PSModule - Module tests](./scripts/tests/Module/PSModule/PSModule.Tests.ps1 ### Build docs [workflow](./.github/workflows/Build-Docs.yml) + - Generates documentation and lints the documentation using: - [super-linter](https://github.com/super-linter/super-linter). ### Build site [workflow](./.github/workflows/Build-Site.yml) + - Generates a static site using: - [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/). @@ -398,16 +405,16 @@ jobs: The following secrets are used by the workflow. They can be automatically provided (if available) by setting `secrets: inherit` in the workflow file. -| Name | Location | Description | Default | -| ---- | -------------- | ------------------------------------------------------------------------- | ------- | -| `APIKEY` | GitHub secrets | The API key for the PowerShell Gallery. | N/A | -| `TEST_APP_ENT_CLIENT_ID` | GitHub secrets | The client ID of an Enterprise GitHub App for running tests. | N/A | -| `TEST_APP_ENT_PRIVATE_KEY` | GitHub secrets | The private key of an Enterprise GitHub App for running tests. | N/A | -| `TEST_APP_ORG_CLIENT_ID` | GitHub secrets | The client ID of an Organization GitHub App for running tests. | N/A | -| `TEST_APP_ORG_PRIVATE_KEY` | GitHub secrets | The private key of an Organization GitHub App for running tests. | N/A | -| `TEST_USER_ORG_FG_PAT` | GitHub secrets | The fine-grained PAT with organization access for running tests. | N/A | -| `TEST_USER_USER_FG_PAT` | GitHub secrets | The fine-grained PAT with user account access for running tests. | N/A | -| `TEST_USER_PAT` | GitHub secrets | The classic personal access token for running tests. | N/A | +| Name | Location | Description | +| -------------------------- | -------------- | ---------------------------------------------------------------- | +| `APIKEY` | GitHub secrets | The API key for the PowerShell Gallery. | +| `TEST_APP_ENT_CLIENT_ID` | GitHub secrets | The client ID of an Enterprise GitHub App for running tests. | +| `TEST_APP_ENT_PRIVATE_KEY` | GitHub secrets | The private key of an Enterprise GitHub App for running tests. | +| `TEST_APP_ORG_CLIENT_ID` | GitHub secrets | The client ID of an Organization GitHub App for running tests. | +| `TEST_APP_ORG_PRIVATE_KEY` | GitHub secrets | The private key of an Organization GitHub App for running tests. | +| `TEST_USER_ORG_FG_PAT` | GitHub secrets | The fine-grained PAT with organization access for running tests. | +| `TEST_USER_USER_FG_PAT` | GitHub secrets | The fine-grained PAT with user account access for running tests. | +| `TEST_USER_PAT` | GitHub secrets | The classic personal access token for running tests. | ### Permissions @@ -430,7 +437,7 @@ This table shows when each job runs based on the trigger scenario: | Job | Open/Updated PR | Merged PR | Abandoned PR | Manual Run | | ------------------------- | --------------- | ---------- | ------------ | ---------- | -| **Get-Settings** | ✅ Always | ✅ Always | ✅ Always | ✅ Always | +| **Plan** | ✅ Always | ✅ Always | ✅ Always | ✅ Always | | **Lint-Repository** | ✅ Yes | ❌ No | ❌ No | ❌ No | | **Build-Module** | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes | | **Build-Docs** | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes | @@ -539,7 +546,7 @@ The following settings are available in the settings file: | Name | Type | Description | Default | | ----------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | | `Name` | `String` | Name of the module to publish. Defaults to the repository name. | `null` | -| `ImportantFilePatterns` | `Array` | Regular expression patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. When set, fully replaces the defaults. | `['^src/', '^README\.md$']` | +| `ImportantFilePatterns` | `Array` | Regular expression patterns that identify important files. Changes matching these patterns trigger build, test, and publish stages. When set, fully replaces the defaults. | `['^src/', '^README\.md$']` | | `Test.Skip` | `Boolean` | Skip all tests | `false` | | `Test.Linux.Skip` | `Boolean` | Skip tests on Linux | `false` | | `Test.MacOS.Skip` | `Boolean` | Skip tests on macOS | `false` | @@ -677,7 +684,7 @@ Test: ### Example 2 - Rapid testing -This example ends up running Get-Settings, Build-Module and Test-Module (tests from the module repo) on **ubuntu-latest** only. +This example ends up running Plan, Build-Module and Test-Module (tests from the module repo) on **ubuntu-latest** only. ```yaml Test: