Upload 2661 files
Browse filesThis view is limited to 50 files because it contains too many changes. Β See raw diff
- .gitattributes +13 -0
- PowerShell-master/.config/suppress.json +17 -0
- PowerShell-master/.config/tsaoptions.json +12 -0
- PowerShell-master/.devcontainer/Dockerfile +25 -0
- PowerShell-master/.devcontainer/devcontainer.json +23 -0
- PowerShell-master/.editorconfig +213 -0
- PowerShell-master/.gitattributes +7 -0
- PowerShell-master/.github/CODEOWNERS +69 -0
- PowerShell-master/.github/CONTRIBUTING.md +431 -0
- PowerShell-master/.github/ISSUE_TEMPLATE/Bug_Report.yaml +75 -0
- PowerShell-master/.github/ISSUE_TEMPLATE/Feature_Request.yaml +20 -0
- PowerShell-master/.github/ISSUE_TEMPLATE/Microsoft_Update_Issue.yaml +87 -0
- PowerShell-master/.github/ISSUE_TEMPLATE/Release_Process.yaml +41 -0
- PowerShell-master/.github/ISSUE_TEMPLATE/WG_member_request.yaml +66 -0
- PowerShell-master/.github/ISSUE_TEMPLATE/config.yml +11 -0
- PowerShell-master/.github/Images/Codespaces.png +0 -0
- PowerShell-master/.github/Images/GitHub-PR.png +0 -0
- PowerShell-master/.github/PULL_REQUEST_TEMPLATE.md +31 -0
- PowerShell-master/.github/SECURITY.md +39 -0
- PowerShell-master/.github/SUPPORT.md +13 -0
- PowerShell-master/.github/action-filters.yml +23 -0
- PowerShell-master/.github/actions/build/ci/action.yml +40 -0
- PowerShell-master/.github/actions/infrastructure/get-changed-files/README.md +122 -0
- PowerShell-master/.github/actions/infrastructure/get-changed-files/action.yml +117 -0
- PowerShell-master/.github/actions/infrastructure/markdownlinks/Parse-MarkdownLink.ps1 +182 -0
- PowerShell-master/.github/actions/infrastructure/markdownlinks/README.md +177 -0
- PowerShell-master/.github/actions/infrastructure/markdownlinks/Verify-MarkdownLinks.ps1 +317 -0
- PowerShell-master/.github/actions/infrastructure/markdownlinks/action.yml +110 -0
- PowerShell-master/.github/actions/infrastructure/merge-conflict-checker/README.md +86 -0
- PowerShell-master/.github/actions/infrastructure/merge-conflict-checker/action.yml +37 -0
- PowerShell-master/.github/actions/infrastructure/path-filters/action.yml +137 -0
- PowerShell-master/.github/actions/test/linux-packaging/action.yml +69 -0
- PowerShell-master/.github/actions/test/nix/action.yml +158 -0
- PowerShell-master/.github/actions/test/process-pester-results/action.yml +27 -0
- PowerShell-master/.github/actions/test/process-pester-results/process-pester-results.ps1 +124 -0
- PowerShell-master/.github/actions/test/windows/action.yml +107 -0
- PowerShell-master/.github/agents/SplitADOPipelines.agent.md +164 -0
- PowerShell-master/.github/chatmodes/cherry-pick-commits.chatmode.md +78 -0
- PowerShell-master/.github/dependabot.yml +32 -0
- PowerShell-master/.github/instructions/build-and-packaging-steps.instructions.md +127 -0
- PowerShell-master/.github/instructions/build-checkout-prerequisites.instructions.md +148 -0
- PowerShell-master/.github/instructions/build-configuration-guide.instructions.md +150 -0
- PowerShell-master/.github/instructions/code-review-branch-strategy.instructions.md +230 -0
- PowerShell-master/.github/instructions/instruction-file-format.instructions.md +220 -0
- PowerShell-master/.github/instructions/log-grouping-guidelines.instructions.md +181 -0
- PowerShell-master/.github/instructions/onebranch-condition-syntax.instructions.md +223 -0
- PowerShell-master/.github/instructions/onebranch-restore-phase-pattern.instructions.md +83 -0
- PowerShell-master/.github/instructions/onebranch-signing-configuration.instructions.md +195 -0
- PowerShell-master/.github/instructions/pester-set-itresult-pattern.instructions.md +198 -0
- PowerShell-master/.github/instructions/pester-test-status-and-working-meaning.instructions.md +299 -0
.gitattributes
CHANGED
|
@@ -58,3 +58,16 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
PowerShell-master/assets/Powershell_av_colors.ico filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
PowerShell-master/assets/Powershell_avatar.ico filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
PowerShell-master/assets/Powershell_black.ico filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
PowerShell-master/assets/Powershell-preview.icns filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
PowerShell-master/assets/Powershell.icns filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
PowerShell-master/src/Schemas/PSMaml/developerCommand.rld filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
PowerShell-master/src/Schemas/PSMaml/Maml.rld filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
PowerShell-master/test/powershell/engine/Help/assets/Microsoft.PowerShell.Core_00000000-0000-0000-0000-000000000000_en-US_HelpContent.cab filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
PowerShell-master/test/powershell/engine/Help/assets/Microsoft.PowerShell.Management_eefcb906-b326-4e99-9f54-8b4bb6ef3c6d_en-US_helpcontent.cab filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
PowerShell-master/test/powershell/engine/Help/assets/Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_en-US_helpcontent.cab filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
PowerShell-master/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/assets/BadCounterSamples.blg filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
PowerShell-master/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/assets/CounterSamples.blg filter=lfs diff=lfs merge=lfs -text
|
| 73 |
+
PowerShell-master/tools/terms/PowerShell-Terms-Rules.mdb filter=lfs diff=lfs merge=lfs -text
|
PowerShell-master/.config/suppress.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"tool": "Credential Scanner",
|
| 3 |
+
"suppressions": [
|
| 4 |
+
{
|
| 5 |
+
"file": "\\test\\tools\\Modules\\WebListener\\ClientCert.pfx",
|
| 6 |
+
"_justification": "Test certificate with private key"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"file": "\\test\\tools\\Modules\\WebListener\\ServerCert.pfx",
|
| 10 |
+
"_justification": "Test certificate with private key"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"file": "\\test\\powershell\\Modules\\Microsoft.PowerShell.Security\\certificateCommon.psm1",
|
| 14 |
+
"_justification": "Test certificate with private key and inline suppression isn't working"
|
| 15 |
+
}
|
| 16 |
+
]
|
| 17 |
+
}
|
PowerShell-master/.config/tsaoptions.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"codebaseName": "TFSMSAzure_PowerShell",
|
| 3 |
+
"instanceUrl": "https://msazure.visualstudio.com",
|
| 4 |
+
"projectName": "One",
|
| 5 |
+
"areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell\\PowerShell Core\\pwsh",
|
| 6 |
+
"notificationAliases": [
|
| 7 |
+
"adityap@microsoft.com",
|
| 8 |
+
"dongbow@microsoft.com",
|
| 9 |
+
"pmeinecke@microsoft.com",
|
| 10 |
+
"tplunk@microsoft.com"
|
| 11 |
+
]
|
| 12 |
+
}
|
PowerShell-master/.devcontainer/Dockerfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#-------------------------------------------------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) Microsoft Corporation.
|
| 3 |
+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
| 4 |
+
#-------------------------------------------------------------------------------------------------------------
|
| 5 |
+
|
| 6 |
+
FROM mcr.microsoft.com/powershell/test-deps:ubuntu-20.04@sha256:d1609c57d2426b9cfffa3a3ab7bda5ebc4448700f8ba8ef377692c4a70e64b8c
|
| 7 |
+
|
| 8 |
+
# Avoid warnings by switching to noninteractive
|
| 9 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 10 |
+
|
| 11 |
+
# Configure apt and install packages
|
| 12 |
+
RUN apt-get update \
|
| 13 |
+
&& apt-get -y upgrade \
|
| 14 |
+
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
|
| 15 |
+
#
|
| 16 |
+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
|
| 17 |
+
&& apt-get -y install --no-install-recommends git procps lsb-release \
|
| 18 |
+
#
|
| 19 |
+
# Clean up
|
| 20 |
+
&& apt-get autoremove -y \
|
| 21 |
+
&& apt-get clean -y \
|
| 22 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
+
|
| 24 |
+
# Switch back to dialog for any ad-hoc use of apt-get
|
| 25 |
+
ENV DEBIAN_FRONTEND=dialog
|
PowerShell-master/.devcontainer/devcontainer.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
|
| 2 |
+
{
|
| 3 |
+
"name": ".NET Core 6.0, including pwsh (Ubuntu 18.04)",
|
| 4 |
+
"dockerFile": "Dockerfile",
|
| 5 |
+
|
| 6 |
+
"workspaceMount": "source=${localWorkspaceFolder},target=/PowerShell,type=bind",
|
| 7 |
+
"workspaceFolder": "/PowerShell",
|
| 8 |
+
|
| 9 |
+
// Uncomment the next line to run commands after the container is created.
|
| 10 |
+
"postCreateCommand": "cd src/powershell-unix && dotnet restore",
|
| 11 |
+
|
| 12 |
+
"customizations": {
|
| 13 |
+
"vscode": {
|
| 14 |
+
"extensions": [
|
| 15 |
+
"ms-azure-devops.azure-pipelines",
|
| 16 |
+
"ms-dotnettools.csharp",
|
| 17 |
+
"ms-vscode.powershell",
|
| 18 |
+
"DavidAnson.vscode-markdownlint",
|
| 19 |
+
"vitaliymaz.vscode-svg-previewer"
|
| 20 |
+
]
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
PowerShell-master/.editorconfig
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# EditorConfig is awesome: https://EditorConfig.org
|
| 2 |
+
# .NET coding convention settings for EditorConfig
|
| 3 |
+
# https://learn.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference
|
| 4 |
+
#
|
| 5 |
+
# This file comes from dotnet repositories:
|
| 6 |
+
# https://github.com/dotnet/runtime/blob/master/.editorconfig
|
| 7 |
+
# https://github.com/dotnet/roslyn/blob/master/.editorconfig
|
| 8 |
+
|
| 9 |
+
# Top-most EditorConfig file
|
| 10 |
+
root = true
|
| 11 |
+
|
| 12 |
+
[*]
|
| 13 |
+
charset = utf-8
|
| 14 |
+
# indent_size intentionally not specified in this section
|
| 15 |
+
indent_style = space
|
| 16 |
+
insert_final_newline = true
|
| 17 |
+
|
| 18 |
+
# Source code
|
| 19 |
+
[*.{cs,ps1,psd1,psm1}]
|
| 20 |
+
indent_size = 4
|
| 21 |
+
|
| 22 |
+
# Shell scripts
|
| 23 |
+
[*.sh]
|
| 24 |
+
end_of_line = lf
|
| 25 |
+
indent_size = 4
|
| 26 |
+
|
| 27 |
+
# Xml project files
|
| 28 |
+
[*.{csproj,resx,ps1xml}]
|
| 29 |
+
indent_size = 2
|
| 30 |
+
|
| 31 |
+
# Data serialization
|
| 32 |
+
[*.{json,yaml,yml}]
|
| 33 |
+
indent_size = 2
|
| 34 |
+
|
| 35 |
+
# Markdown
|
| 36 |
+
[*.md]
|
| 37 |
+
indent_size = 2
|
| 38 |
+
|
| 39 |
+
# Xml files
|
| 40 |
+
[*.{resx,ruleset,stylecop,xml,xsd,xsl}]
|
| 41 |
+
indent_size = 2
|
| 42 |
+
|
| 43 |
+
# Xml config files
|
| 44 |
+
[*.{props,targets,config,nuspec}]
|
| 45 |
+
indent_size = 2
|
| 46 |
+
|
| 47 |
+
[*.tsv]
|
| 48 |
+
indent_style = tab
|
| 49 |
+
|
| 50 |
+
# Dotnet code style settings:
|
| 51 |
+
[*.cs]
|
| 52 |
+
# Sort using and Import directives with System.* appearing first
|
| 53 |
+
dotnet_sort_system_directives_first = true
|
| 54 |
+
|
| 55 |
+
file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.
|
| 56 |
+
|
| 57 |
+
# Modifier preferences
|
| 58 |
+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
|
| 59 |
+
|
| 60 |
+
# Avoid "this." and "Me." if not necessary
|
| 61 |
+
dotnet_style_qualification_for_field = false:suggestion
|
| 62 |
+
dotnet_style_qualification_for_property = false:suggestion
|
| 63 |
+
dotnet_style_qualification_for_method = false:suggestion
|
| 64 |
+
dotnet_style_qualification_for_event = false:suggestion
|
| 65 |
+
|
| 66 |
+
# Use language keywords instead of framework type names for type references
|
| 67 |
+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
| 68 |
+
dotnet_style_predefined_type_for_member_access = true:suggestion
|
| 69 |
+
|
| 70 |
+
# Name all constant fields using PascalCase
|
| 71 |
+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
|
| 72 |
+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
|
| 73 |
+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
|
| 74 |
+
|
| 75 |
+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
|
| 76 |
+
dotnet_naming_symbols.constant_fields.required_modifiers = const
|
| 77 |
+
|
| 78 |
+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
|
| 79 |
+
|
| 80 |
+
# Static fields should have s_ prefix
|
| 81 |
+
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
|
| 82 |
+
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
|
| 83 |
+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
|
| 84 |
+
|
| 85 |
+
dotnet_naming_symbols.static_fields.applicable_kinds = field
|
| 86 |
+
dotnet_naming_symbols.static_fields.required_modifiers = static
|
| 87 |
+
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
|
| 88 |
+
|
| 89 |
+
dotnet_naming_style.static_prefix_style.required_prefix = s_
|
| 90 |
+
dotnet_naming_style.static_prefix_style.capitalization = camel_case
|
| 91 |
+
|
| 92 |
+
# Internal and private fields should be _camelCase
|
| 93 |
+
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
|
| 94 |
+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
|
| 95 |
+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
|
| 96 |
+
|
| 97 |
+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
|
| 98 |
+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
|
| 99 |
+
|
| 100 |
+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
|
| 101 |
+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
|
| 102 |
+
|
| 103 |
+
# Suggest more modern language features when available
|
| 104 |
+
dotnet_style_object_initializer = true:suggestion
|
| 105 |
+
dotnet_style_collection_initializer = true:suggestion
|
| 106 |
+
# Background Info: https://github.com/dotnet/runtime/pull/100250
|
| 107 |
+
dotnet_style_prefer_collection_expression = when_types_exactly_match
|
| 108 |
+
dotnet_style_coalesce_expression = true:suggestion
|
| 109 |
+
dotnet_style_null_propagation = true:suggestion
|
| 110 |
+
dotnet_style_explicit_tuple_names = true:suggestion
|
| 111 |
+
dotnet_style_readonly_field = true:suggestion
|
| 112 |
+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
|
| 113 |
+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
| 114 |
+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
| 115 |
+
dotnet_style_prefer_conditional_expression_over_return = true:silent
|
| 116 |
+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
|
| 117 |
+
dotnet_style_prefer_auto_properties = true:suggestion
|
| 118 |
+
csharp_prefer_simple_default_expression = true:suggestion
|
| 119 |
+
|
| 120 |
+
dotnet_code_quality_unused_parameters = non_public:suggestion
|
| 121 |
+
|
| 122 |
+
# Dotnet diagnostic settings:
|
| 123 |
+
[*.cs]
|
| 124 |
+
|
| 125 |
+
# CA1859: Use concrete types when possible for improved performance
|
| 126 |
+
# https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/quality-rules/ca1859
|
| 127 |
+
dotnet_diagnostic.CA1859.severity = suggestion
|
| 128 |
+
|
| 129 |
+
# Disable SA1600 (ElementsMustBeDocumented) for test directory only
|
| 130 |
+
[test/**/*.cs]
|
| 131 |
+
dotnet_diagnostic.SA1600.severity = none
|
| 132 |
+
|
| 133 |
+
# CSharp code style settings:
|
| 134 |
+
[*.cs]
|
| 135 |
+
|
| 136 |
+
csharp_preserve_single_line_blocks = true
|
| 137 |
+
csharp_preserve_single_line_statements = false
|
| 138 |
+
csharp_prefer_braces = true:silent
|
| 139 |
+
|
| 140 |
+
csharp_prefer_static_local_function = true:suggestion
|
| 141 |
+
csharp_prefer_simple_using_statement = false:none
|
| 142 |
+
csharp_style_prefer_switch_expression = true:suggestion
|
| 143 |
+
csharp_style_prefer_range_operator = false:none
|
| 144 |
+
csharp_style_prefer_index_operator = false:none
|
| 145 |
+
csharp_style_pattern_local_over_anonymous_function = false:none
|
| 146 |
+
|
| 147 |
+
csharp_using_directive_placement = outside_namespace:suggestion
|
| 148 |
+
|
| 149 |
+
# Indentation preferences
|
| 150 |
+
csharp_indent_block_contents = true
|
| 151 |
+
csharp_indent_braces = false
|
| 152 |
+
csharp_indent_case_contents = true
|
| 153 |
+
csharp_indent_case_contents_when_block = true
|
| 154 |
+
csharp_indent_switch_labels = true
|
| 155 |
+
csharp_indent_labels = one_less_than_current
|
| 156 |
+
|
| 157 |
+
# Only use var when it's obvious what the variable type is
|
| 158 |
+
csharp_style_var_for_built_in_types = false:none
|
| 159 |
+
csharp_style_var_when_type_is_apparent = false:none
|
| 160 |
+
csharp_style_var_elsewhere = false:suggestion
|
| 161 |
+
|
| 162 |
+
# Expression-bodied members
|
| 163 |
+
csharp_style_expression_bodied_local_functions = true:silent
|
| 164 |
+
|
| 165 |
+
# Prefer method-like constructs to have a block body
|
| 166 |
+
csharp_style_expression_bodied_methods = false:none
|
| 167 |
+
csharp_style_expression_bodied_constructors = false:none
|
| 168 |
+
csharp_style_expression_bodied_operators = false:none
|
| 169 |
+
|
| 170 |
+
# Prefer property-like constructs to have an expression-body
|
| 171 |
+
csharp_style_expression_bodied_properties = true:none
|
| 172 |
+
csharp_style_expression_bodied_indexers = true:none
|
| 173 |
+
csharp_style_expression_bodied_accessors = true:none
|
| 174 |
+
|
| 175 |
+
# Suggest more modern language features when available
|
| 176 |
+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
| 177 |
+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
| 178 |
+
csharp_style_inlined_variable_declaration = true:suggestion
|
| 179 |
+
csharp_style_throw_expression = true:suggestion
|
| 180 |
+
csharp_style_conditional_delegate_call = true:suggestion
|
| 181 |
+
|
| 182 |
+
# Space preferences
|
| 183 |
+
csharp_space_after_cast = false
|
| 184 |
+
csharp_space_after_colon_in_inheritance_clause = true
|
| 185 |
+
csharp_space_after_comma = true
|
| 186 |
+
csharp_space_after_dot = false
|
| 187 |
+
csharp_space_after_keywords_in_control_flow_statements = true
|
| 188 |
+
csharp_space_after_semicolon_in_for_statement = true
|
| 189 |
+
csharp_space_around_binary_operators = before_and_after
|
| 190 |
+
csharp_space_around_declaration_statements = do_not_ignore
|
| 191 |
+
csharp_space_before_colon_in_inheritance_clause = true
|
| 192 |
+
csharp_space_before_comma = false
|
| 193 |
+
csharp_space_before_dot = false
|
| 194 |
+
csharp_space_before_open_square_brackets = false
|
| 195 |
+
csharp_space_before_semicolon_in_for_statement = false
|
| 196 |
+
csharp_space_between_empty_square_brackets = false
|
| 197 |
+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
| 198 |
+
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
| 199 |
+
csharp_space_between_method_call_parameter_list_parentheses = false
|
| 200 |
+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
| 201 |
+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
| 202 |
+
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
| 203 |
+
csharp_space_between_parentheses = false
|
| 204 |
+
csharp_space_between_square_brackets = false
|
| 205 |
+
|
| 206 |
+
# Newline settings
|
| 207 |
+
csharp_new_line_before_open_brace = all
|
| 208 |
+
csharp_new_line_before_else = true
|
| 209 |
+
csharp_new_line_before_catch = true
|
| 210 |
+
csharp_new_line_before_finally = true
|
| 211 |
+
csharp_new_line_before_members_in_object_initializers = true
|
| 212 |
+
csharp_new_line_before_members_in_anonymous_types = true
|
| 213 |
+
csharp_new_line_between_query_expression_clauses = true
|
PowerShell-master/.gitattributes
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CHANGELOG.md merge=union
|
| 2 |
+
* text=auto
|
| 3 |
+
*.png binary
|
| 4 |
+
*.rtf binary
|
| 5 |
+
*.sh text eol=lf
|
| 6 |
+
testablescript.ps1 text eol=lf
|
| 7 |
+
TestFileCatalog.txt text eol=lf
|
PowerShell-master/.github/CODEOWNERS
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://help.github.com/articles/about-codeowners/
|
| 2 |
+
|
| 3 |
+
# Areas are not limited to the filters defined in this file
|
| 4 |
+
# First, let's start with areas with no filters or paths
|
| 5 |
+
|
| 6 |
+
# Default
|
| 7 |
+
* @PowerShell/powershell-maintainers
|
| 8 |
+
|
| 9 |
+
# Area: Performance
|
| 10 |
+
# @adityapatwardhan
|
| 11 |
+
|
| 12 |
+
# Area: Security
|
| 13 |
+
src/System.Management.Automation/security/wldpNativeMethods.cs @TravisEz13 @seeminglyscience
|
| 14 |
+
|
| 15 |
+
# Area: CI Build
|
| 16 |
+
.github/workflows @PowerShell/powershell-maintainers @jshigetomi
|
| 17 |
+
.github/actions @PowerShell/powershell-maintainers @jshigetomi
|
| 18 |
+
|
| 19 |
+
# Now, areas that should have paths or filters, although we might not have them defined
|
| 20 |
+
# According to the docs, order here must be by precedence of the filter, with later rules overwritting
|
| 21 |
+
# but the feature seems to make taking a union of all the matching rules.
|
| 22 |
+
|
| 23 |
+
# Area: Cmdlets Management
|
| 24 |
+
# src/Microsoft.PowerShell.Commands.Management/ @daxian-dbw @adityapatwardhan
|
| 25 |
+
|
| 26 |
+
# Area: Utility Cmdlets
|
| 27 |
+
# src/Microsoft.PowerShell.Commands.Utility/
|
| 28 |
+
|
| 29 |
+
# Area: Console
|
| 30 |
+
# src/Microsoft.PowerShell.ConsoleHost/ @daxian-dbw
|
| 31 |
+
|
| 32 |
+
# Area: DSC
|
| 33 |
+
# src/System.Management.Automation/DscSupport @TravisEz13 @SteveL-MSFT
|
| 34 |
+
|
| 35 |
+
# Area: Engine
|
| 36 |
+
# src/System.Management.Automation/engine @daxian-dbw
|
| 37 |
+
|
| 38 |
+
# Area: Debugging
|
| 39 |
+
# Must be below engine to override
|
| 40 |
+
# src/System.Management.Automation/engine/debugger/
|
| 41 |
+
|
| 42 |
+
# Area: Help
|
| 43 |
+
src/System.Management.Automation/help @adityapatwardhan @daxian-dbw
|
| 44 |
+
|
| 45 |
+
# Area: Intellisense
|
| 46 |
+
# @daxian-dbw
|
| 47 |
+
|
| 48 |
+
# Area: Language
|
| 49 |
+
src/System.Management.Automation/engine/parser @daxian-dbw @seeminglyscience
|
| 50 |
+
|
| 51 |
+
# Area: Providers
|
| 52 |
+
# src/System.Management.Automation/namespaces
|
| 53 |
+
|
| 54 |
+
# Area: Remoting
|
| 55 |
+
src/System.Management.Automation/engine/remoting @daxian-dbw @TravisEz13
|
| 56 |
+
|
| 57 |
+
# Areas: Build
|
| 58 |
+
# Must be last
|
| 59 |
+
*.config @PowerShell/powershell-maintainers @jshigetomi
|
| 60 |
+
*.props @PowerShell/powershell-maintainers @jshigetomi
|
| 61 |
+
*.yml @PowerShell/powershell-maintainers @jshigetomi
|
| 62 |
+
*.csproj @PowerShell/powershell-maintainers @jshigetomi
|
| 63 |
+
build.* @PowerShell/powershell-maintainers @jshigetomi
|
| 64 |
+
tools/ @PowerShell/powershell-maintainers @jshigetomi
|
| 65 |
+
# docker/ @PowerShell/powershell-maintainers @jshigetomi
|
| 66 |
+
|
| 67 |
+
# Area: Compliance
|
| 68 |
+
tools/terms @TravisEz13
|
| 69 |
+
tools/credScan @TravisEz13
|
PowerShell-master/.github/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contributing to PowerShell
|
| 2 |
+
|
| 3 |
+
We welcome and appreciate contributions from the community!
|
| 4 |
+
|
| 5 |
+
There are many ways to become involved with PowerShell including:
|
| 6 |
+
|
| 7 |
+
- [Contributing to Documentation](#contributing-to-documentation)
|
| 8 |
+
- [Contributing to Issues](#contributing-to-issues)
|
| 9 |
+
- [Contributing to Code](#contributing-to-code)
|
| 10 |
+
|
| 11 |
+
Please read the rest of this document to ensure a smooth contribution process.
|
| 12 |
+
|
| 13 |
+
## Contributing to Documentation
|
| 14 |
+
|
| 15 |
+
Contributing to the docs is an excellent way to get started with the process of making open source contributions with minimal technical skill required.
|
| 16 |
+
|
| 17 |
+
Please see the [Contributor Guide in `MicrosoftDocs/PowerShell-Docs`](https://aka.ms/PSDocsContributor).
|
| 18 |
+
|
| 19 |
+
Learn how to [Contribute to Docs like a Microsoft Insider](https://www.youtube.com/watch?v=ZQODV8krq1Q) (by @sdwheeler)
|
| 20 |
+
|
| 21 |
+
### Updating Documentation for an existing cmdlet
|
| 22 |
+
|
| 23 |
+
If you made a change to an existing cmdlet and would like to update the documentation using PlatyPS,
|
| 24 |
+
here are the quick steps:
|
| 25 |
+
|
| 26 |
+
1. Install
|
| 27 |
+
`PlatyPS`
|
| 28 |
+
if you don't have it -
|
| 29 |
+
`Install-Module PlatyPS`.
|
| 30 |
+
1. Clone the
|
| 31 |
+
[`MicrosoftDocs/PowerShell-Docs`](https://github.com/MicrosoftDocs/PowerShell-Docs)
|
| 32 |
+
repository if you don't already have it.
|
| 33 |
+
1. Start your local build of PowerShell
|
| 34 |
+
(with the change to the cmdlet you made).
|
| 35 |
+
1. Find the cmdlet's Markdown file in PowerShell Docs - usually under
|
| 36 |
+
`PowerShell-Docs/reference/<latest powershell version>/<module cmdlet is a part of>/<your changed cmdlet>.md`
|
| 37 |
+
(Ex. `PowerShell-Docs/reference/7/Microsoft.PowerShell.Utility/Select-String.md`)
|
| 38 |
+
1. Run
|
| 39 |
+
`Update-MarkdownHelp -Path <path to cmdlet Markdown file>`
|
| 40 |
+
which will update the documentation for you.
|
| 41 |
+
1. Make any additional changes needed for the cmdlet to be properly documented.
|
| 42 |
+
1. Send a Pull Request to the PowerShell Docs repository with the changes that
|
| 43 |
+
`PlatyPS`
|
| 44 |
+
made.
|
| 45 |
+
1. Link your Docs PR to your original change PR.
|
| 46 |
+
|
| 47 |
+
### Style notes for documentation related to maintaining or contributing to the PowerShell project
|
| 48 |
+
|
| 49 |
+
* When writing Markdown documentation, use [semantic linefeeds][].
|
| 50 |
+
In most cases, it means "one clause/idea per line".
|
| 51 |
+
* Otherwise, these issues should be treated like any other issue in this repository.
|
| 52 |
+
|
| 53 |
+
### Spell checking documentation
|
| 54 |
+
|
| 55 |
+
Documentation is spellchecked. We use the
|
| 56 |
+
[textlint](https://github.com/textlint/textlint/wiki/Collection-of-textlint-rule) command-line tool,
|
| 57 |
+
which can be run in interactive mode to correct typos.
|
| 58 |
+
|
| 59 |
+
To run the spell checker, follow these steps:
|
| 60 |
+
|
| 61 |
+
* install [Node.js](https://nodejs.org/en/) (v10 or up)
|
| 62 |
+
* install [textlint](https://github.com/textlint/textlint/wiki/Collection-of-textlint-rule) by
|
| 63 |
+
`npm install -g textlint textlint-rule-terminology`
|
| 64 |
+
* run `textlint --rule terminology <changedFileName>`,
|
| 65 |
+
adding `--fix` will accept all the recommendations.
|
| 66 |
+
|
| 67 |
+
If you need to add a term or disable checking part of a file see the [configuration sections of the rule](https://github.com/sapegin/textlint-rule-terminology).
|
| 68 |
+
|
| 69 |
+
### Checking links in documentation
|
| 70 |
+
|
| 71 |
+
Documentation is link-checked. We make use of the
|
| 72 |
+
`markdown-link-check` command-line tool,
|
| 73 |
+
which can be run to see if any links are dead.
|
| 74 |
+
|
| 75 |
+
To run the link-checker, follow these steps:
|
| 76 |
+
|
| 77 |
+
* install [Node.js](https://nodejs.org/en/) (v10 or up)
|
| 78 |
+
* install `markdown-link-check` by
|
| 79 |
+
`npm install -g markdown-link-check@3.8.5`
|
| 80 |
+
* run `find . \*.md -exec markdown-link-check {} \;`
|
| 81 |
+
|
| 82 |
+
## Contributing to Issues
|
| 83 |
+
|
| 84 |
+
1. Review [Issue Management][issue-management].
|
| 85 |
+
1. Check if the issue you are going to file already exists in our [GitHub issues][open-issue].
|
| 86 |
+
1. If you can't find your issue already,
|
| 87 |
+
[open a new issue](https://github.com/PowerShell/PowerShell/issues/new/choose),
|
| 88 |
+
making sure to follow the directions as best you can.
|
| 89 |
+
1. If the issue is marked as [`Up-for-Grabs`][up-for-grabs],
|
| 90 |
+
the PowerShell Maintainers are looking for help with the issue.
|
| 91 |
+
1. Issues marked as [`First-Time-Issue`][first-time-issue],
|
| 92 |
+
are identified as being easy and a great way to learn about this project and making
|
| 93 |
+
contributions.
|
| 94 |
+
|
| 95 |
+
### Finding or creating an issue
|
| 96 |
+
|
| 97 |
+
1. Follow the instructions in [Contributing to Issues][contribute-issues] to find or open an issue.
|
| 98 |
+
1. Mention in the issue that you are working on the issue and ask `@powershell/powershell` for an assignment.
|
| 99 |
+
|
| 100 |
+
### Forks and Pull Requests
|
| 101 |
+
|
| 102 |
+
GitHub fosters collaboration through the notion of [pull requests][using-prs].
|
| 103 |
+
On GitHub, anyone can [fork][fork-a-repo] an existing repository
|
| 104 |
+
into their own user account, where they can make private changes to their fork.
|
| 105 |
+
To contribute these changes back into the original repository,
|
| 106 |
+
a user simply creates a pull request in order to "request" that the changes be taken "upstream".
|
| 107 |
+
|
| 108 |
+
Additional references:
|
| 109 |
+
|
| 110 |
+
* GitHub's guide on [forking](https://guides.github.com/activities/forking/)
|
| 111 |
+
* GitHub's guide on [Contributing to Open Source](https://guides.github.com/activities/contributing-to-open-source/#pull-request)
|
| 112 |
+
* GitHub's guide on [Understanding the GitHub Flow](https://guides.github.com/introduction/flow/)
|
| 113 |
+
|
| 114 |
+
## Contributing to Code
|
| 115 |
+
|
| 116 |
+
### Quick Start Checklist
|
| 117 |
+
|
| 118 |
+
* Review the [Contributor License Agreement][CLA] requirement.
|
| 119 |
+
* Get familiar with the [PowerShell Repository Git Concepts](../docs/git/README.md).
|
| 120 |
+
* Start a [GitHub Codespace](#Dev Container) and start exploring the repository.
|
| 121 |
+
* Consider if what you want to do might be implementable as a [PowerShell Binary Module](https://learn.microsoft.com/powershell/scripting/developer/module/how-to-write-a-powershell-binary-module?view=powershell-7.5).
|
| 122 |
+
The PowerShell repository has a rigorous acceptance process due to its huge popularity and emphasis on stability and long term support, and with a binary module you can contribute to the community much more quickly.
|
| 123 |
+
* Pick an existing issue to work on! For instance, clarifying a confusing or unclear error message is a great starting point.
|
| 124 |
+
|
| 125 |
+
### Intro to Git and GitHub
|
| 126 |
+
|
| 127 |
+
1. Sign up for a [GitHub account](https://github.com/signup/free).
|
| 128 |
+
1. Learning Git and GitHub:
|
| 129 |
+
- [Git Basics](../docs/git/basics.md): install and getting started
|
| 130 |
+
- [Good Resources for Learning Git and GitHub][good-git-resources]
|
| 131 |
+
1. The PowerShell repository uses GitHub Flow as the primary branching strategy. [Learn about GitHub Flow](https://guides.github.com/introduction/flow/)
|
| 132 |
+
|
| 133 |
+
### Code Editing
|
| 134 |
+
|
| 135 |
+
PowerShell is primarily written in [C#](https://learn.microsoft.com/dotnet/csharp/tour-of-csharp/overview). While you can use any C# development environment you prefer, [Visual Studio Code][use-vscode-editor] is recommended.
|
| 136 |
+
|
| 137 |
+
### Dev Container
|
| 138 |
+
|
| 139 |
+
There is a PowerShell [Dev Container](https://code.visualstudio.com/docs/devcontainers/containers) which enables you get up and running quickly with a prepared Visual Studio Code environment with all the required prerequisites already installed.
|
| 140 |
+
|
| 141 |
+
[GitHub Codespaces](https://github.com/features/codespaces) is the fastest way to get started.
|
| 142 |
+
Codespaces allows you to start a Github-hosted devcontainer from anywhere and contribute from your browser or via Visual Studio Code remoting.
|
| 143 |
+
All GitHub users get 15 hours per month of a 4-core codespace for free.
|
| 144 |
+
|
| 145 |
+
To start a codespace for the PowerShell repository:
|
| 146 |
+
|
| 147 |
+
1. Go to https://github.com/PowerShell/PowerShell
|
| 148 |
+
1. Click the green button on the right and choose to create a codespace
|
| 149 |
+
|
| 150 |
+

|
| 151 |
+
1. Alternatively, just hit the comma `,` key on your keyboard which should instantly start a codespace as well.
|
| 152 |
+
|
| 153 |
+
Once the codespace starts, you can press `ctrl+shift+b` (`cmd+shift+b` on Mac) to run the default build task. If you would like to interactivey test your changes, you can press `F5` to start debugging, add breakpoints, etc.
|
| 154 |
+
|
| 155 |
+
[Learn more about how to get started with C# in Visual Studio Code](https://code.visualstudio.com/docs/csharp/get-started)
|
| 156 |
+
|
| 157 |
+
### Building and Testing
|
| 158 |
+
|
| 159 |
+
#### Building PowerShell
|
| 160 |
+
|
| 161 |
+
[Building PowerShell](../README.md#Building-Powershell) has instructions for various platforms.
|
| 162 |
+
|
| 163 |
+
#### Testing PowerShell
|
| 164 |
+
|
| 165 |
+
Please see PowerShell [Testing Guidelines - Running Tests Outside of CI][running-tests-outside-of-ci] on how to test your build locally.
|
| 166 |
+
|
| 167 |
+
### Lifecycle of a pull request
|
| 168 |
+
|
| 169 |
+
#### Before submitting
|
| 170 |
+
|
| 171 |
+
* If your change would fix a security vulnerability,
|
| 172 |
+
first follow the [vulnerability issue reporting policy][vuln-reporting], before submitting a PR.
|
| 173 |
+
* To avoid merge conflicts, make sure your branch is rebased on the `master` branch of this repository.
|
| 174 |
+
* Many code changes will require new tests,
|
| 175 |
+
so make sure you've added a new test if existing tests do not effectively test the code changed.
|
| 176 |
+
* Clean up your commit history.
|
| 177 |
+
Each commit should be a **single complete** change.
|
| 178 |
+
This discipline is important when reviewing the changes as well as when using `git bisect` and `git revert`.
|
| 179 |
+
|
| 180 |
+
#### Pull request - Submission
|
| 181 |
+
|
| 182 |
+
**Always create a pull request to the `master` branch of this repository**.
|
| 183 |
+
|
| 184 |
+

|
| 185 |
+
|
| 186 |
+
* It's recommended to avoid a PR with too many changes.
|
| 187 |
+
A large PR not only stretches the review time, but also makes it much harder to spot issues.
|
| 188 |
+
In such case, it's better to split the PR to multiple smaller ones.
|
| 189 |
+
For large features, try to approach it in an incremental way, so that each PR won't be too big.
|
| 190 |
+
* If you're contributing in a way that changes the user or developer experience, you are expected to document those changes.
|
| 191 |
+
See [Contributing to documentation related to PowerShell](#contributing-to-documentation).
|
| 192 |
+
* Add a meaningful title of the PR describing what change you want to check in.
|
| 193 |
+
Don't simply put: "Fix issue #5".
|
| 194 |
+
Also don't directly use the issue title as the PR title.
|
| 195 |
+
An issue title is to briefly describe what is wrong, while a PR title is to briefly describe what is changed.
|
| 196 |
+
A better example is: "Add Ensure parameter to New-Item cmdlet", with "Fix #5" in the PR's body.
|
| 197 |
+
* When you create a pull request,
|
| 198 |
+
include a summary about your changes in the PR description.
|
| 199 |
+
The description is used to create changelogs,
|
| 200 |
+
so try to have the first sentence explain the benefit to end users.
|
| 201 |
+
If the changes are related to an existing GitHub issue,
|
| 202 |
+
please reference the issue in the PR description (e.g. ```Fix #11```).
|
| 203 |
+
See [this][closing-via-message] for more details.
|
| 204 |
+
|
| 205 |
+
* Please use the present tense and imperative mood when describing your changes:
|
| 206 |
+
* Instead of "Adding support for Windows Server 2012 R2", write "Add support for Windows Server 2012 R2".
|
| 207 |
+
* Instead of "Fixed for server connection issue", write "Fix server connection issue".
|
| 208 |
+
|
| 209 |
+
This form is akin to giving commands to the codebase
|
| 210 |
+
and is recommended by the Git SCM developers.
|
| 211 |
+
It is also used in the [Git commit messages](#common-engineering-practices).
|
| 212 |
+
* If the change is related to a specific resource, please prefix the description with the resource name:
|
| 213 |
+
* Instead of "New parameter 'ConnectionCredential' in New-SqlConnection",
|
| 214 |
+
write "New-SqlConnection: add parameter 'ConnectionCredential'".
|
| 215 |
+
* If your change warrants an update to user-facing documentation,
|
| 216 |
+
a Maintainer will add the `Documentation Needed` label to your PR and add an issue to the [PowerShell-Docs repository][PowerShell-Docs],
|
| 217 |
+
so that we make sure to update official documentation to reflect your contribution.
|
| 218 |
+
As an example, this requirement includes any changes to cmdlets (including cmdlet parameters) and features which have associated about_* topics.
|
| 219 |
+
While not required, we appreciate any contributors who add this label and create the issue themselves.
|
| 220 |
+
Even better, all contributors are free to contribute the documentation themselves.
|
| 221 |
+
(See [Contributing to documentation related to PowerShell](#contributing-to-documentation) for more info.)
|
| 222 |
+
* If your change adds a new source file, ensure the appropriate copyright and license headers is on top.
|
| 223 |
+
It is standard practice to have both a copyright and license notice for each source file.
|
| 224 |
+
* For `.cs` files use the copyright header with empty line after it:
|
| 225 |
+
|
| 226 |
+
```c#
|
| 227 |
+
// Copyright (c) Microsoft Corporation.
|
| 228 |
+
// Licensed under the MIT License.
|
| 229 |
+
<Add empty line here>
|
| 230 |
+
```
|
| 231 |
+
|
| 232 |
+
* For `.ps1` and `.psm1` files use the copyright header with empty line after it:
|
| 233 |
+
|
| 234 |
+
```powershell
|
| 235 |
+
# Copyright (c) Microsoft Corporation.
|
| 236 |
+
# Licensed under the MIT License.
|
| 237 |
+
<Add empty line here>
|
| 238 |
+
```
|
| 239 |
+
|
| 240 |
+
* If your change adds a new module manifest (.psd1 file), ensure that:
|
| 241 |
+
|
| 242 |
+
```powershell
|
| 243 |
+
Author = "PowerShell"
|
| 244 |
+
Company = "Microsoft Corporation"
|
| 245 |
+
Copyright = "Copyright (c) Microsoft Corporation."
|
| 246 |
+
```
|
| 247 |
+
|
| 248 |
+
is at the top.
|
| 249 |
+
|
| 250 |
+
### Pull Request - Work in Progress
|
| 251 |
+
|
| 252 |
+
* If your pull request is not ready to merge, please add the prefix `WIP:` to the beginning of the title and remove the prefix when the PR is ready.
|
| 253 |
+
|
| 254 |
+
#### Pull Request - Automatic Checks
|
| 255 |
+
|
| 256 |
+
* If this is your first contribution to PowerShell,
|
| 257 |
+
you may be asked to sign a [Contribution Licensing Agreement][CLA] (CLA)
|
| 258 |
+
before your changes will be accepted.
|
| 259 |
+
* Make sure you follow the [Common Engineering Practices](#common-engineering-practices)
|
| 260 |
+
and [testing guidelines](../docs/testing-guidelines/testing-guidelines.md).
|
| 261 |
+
* After submitting your pull request,
|
| 262 |
+
our [CI system (Azure DevOps Pipelines)][ci-system]
|
| 263 |
+
will run a suite of tests and automatically update the status of the pull request.
|
| 264 |
+
* Our CI contains automated spell checking and link checking for Markdown files. If there is any false-positive,
|
| 265 |
+
[run the spell checker command-line tool in interactive mode](#spell-checking-documentation)
|
| 266 |
+
to add words to the `.spelling` file.
|
| 267 |
+
|
| 268 |
+
You could update the `.spelling` file manually in accordance with messages in the test log file, or
|
| 269 |
+
[run the spell checker command-line tool in interactive mode](#spell-checking-documentation)
|
| 270 |
+
to add the false-positive words directly.
|
| 271 |
+
|
| 272 |
+
#### Pull Request - Workflow
|
| 273 |
+
|
| 274 |
+
1. The PR *author* creates a pull request from a fork.
|
| 275 |
+
1. The *author* ensures that their pull request passes the [CI system][ci-system] build.
|
| 276 |
+
- If the build fails, a [Repository Maintainer][repository-maintainer] adds the `Review - waiting on author` label to the pull request.
|
| 277 |
+
The *author* can then continue to update the pull request until the build passes.
|
| 278 |
+
1. If the *author* knows whom should participate in the review, they should add them otherwise they can add the recommended *reviewers*.
|
| 279 |
+
1. Once the build passes, if there is not sufficient review, the *maintainer* adds the `Review - needed` label.
|
| 280 |
+
1. An [Area Expert][area-expert] should also review the pull request.
|
| 281 |
+
- If the *author* does not meet the *reviewer*'s standards, the *reviewer* makes comments. A *maintainer* then removes the `Review - needed` label and adds
|
| 282 |
+
the `Review - waiting on author` label. The *author* must address the comments and repeat from step 2.
|
| 283 |
+
- If the *author* meets the *reviewer*'s standards, the *reviewer* approves the PR. A maintainer then removes the `need review` label.
|
| 284 |
+
1. Once the code review is completed, a *maintainer* merges the pull request after one business day to allow for additional critical feedback.
|
| 285 |
+
|
| 286 |
+
#### Pull Request - Roles and Responsibilities
|
| 287 |
+
|
| 288 |
+
1. The PR *author* is responsible for moving the PR forward to get it approved.
|
| 289 |
+
This includes addressing feedback within a timely period and indicating feedback has been addressed by adding a comment and mentioning the specific *reviewers*.
|
| 290 |
+
When updating your pull request, please **create new commits** and **don't rewrite the commits history**.
|
| 291 |
+
This way it's very easy for the reviewers to see diff between iterations.
|
| 292 |
+
If you rewrite the history in the pull request, review could be much slower.
|
| 293 |
+
The PR is likely to be squash-merged to master by the *assignee*.
|
| 294 |
+
1. *Reviewers* are anyone who wants to contribute.
|
| 295 |
+
They are responsible for ensuring the code: addresses the issue being fixed, does not create new issues (functional, performance, reliability, or security), and implements proper design.
|
| 296 |
+
*Reviewers* should use the `Review changes` drop down to indicate they are done with their review.
|
| 297 |
+
- `Request changes` if you believe the PR merge should be blocked if your feedback is not addressed,
|
| 298 |
+
- `Approve` if you believe your feedback has been addressed or the code is fine as-is, it is customary (although not required) to leave a simple "Looks good to me" (or "LGTM") as the comment for approval.
|
| 299 |
+
- `Comment` if you are making suggestions that the *author* does not have to accept.
|
| 300 |
+
Early in the review, it is acceptable to provide feedback on coding formatting based on the published [Coding Guidelines][coding-guidelines], however,
|
| 301 |
+
after the PR has been approved, it is generally *not* recommended to focus on formatting issues unless they go against the [Coding Guidelines][coding-guidelines].
|
| 302 |
+
Non-critical late feedback (after PR has been approved) can be submitted as a new issue or new pull request from the *reviewer*.
|
| 303 |
+
1. *Assignees* who are always *Maintainers* ensure that proper review has occurred and if they believe one approval is not sufficient, the *maintainer* is responsible to add more reviewers.
|
| 304 |
+
An *assignee* may also be a reviewer, but the roles are distinct.
|
| 305 |
+
Once the PR has been approved and the CI system is passing, the *assignee* will merge the PR after giving one business day for any critical feedback.
|
| 306 |
+
For more information on the PowerShell Maintainers' process, see the [documentation](../docs/maintainers).
|
| 307 |
+
|
| 308 |
+
#### Pull Requests - Abandoned
|
| 309 |
+
|
| 310 |
+
A pull request with the label `Review - waiting on author` for **more than two weeks** without a word from the author is considered abandoned.
|
| 311 |
+
|
| 312 |
+
In these cases:
|
| 313 |
+
|
| 314 |
+
1. *Assignee* will ping the author of PR to remind them of pending changes.
|
| 315 |
+
- If the *author* responds, it's no longer an abandoned; the pull request proceeds as normal.
|
| 316 |
+
1. If the *author* does not respond **within a week**:
|
| 317 |
+
- If the *reviewer*'s comments are very minor, merge the change, fix the code immediately, and create a new PR with the fixes addressing the minor comments.
|
| 318 |
+
- If the changes required to merge the pull request are significant but needed, *assignee* creates a new branch with the changes and open an issue to merge the code into the dev branch.
|
| 319 |
+
Mention the original pull request ID in the description of the new issue and close the abandoned pull request.
|
| 320 |
+
- If the changes in an abandoned pull request are no longer needed (e.g. due to refactoring of the codebase or a design change), *assignee* will simply close the pull request.
|
| 321 |
+
|
| 322 |
+
### Making Breaking Changes
|
| 323 |
+
|
| 324 |
+
When you make code changes,
|
| 325 |
+
please pay attention to these that can affect the [Public Contract][breaking-changes-contract].
|
| 326 |
+
For example, changing PowerShell parameters, APIs, or protocols break the public contract.
|
| 327 |
+
Before making changes to the code,
|
| 328 |
+
first review the [breaking changes contract][breaking-changes-contract]
|
| 329 |
+
and follow the guidelines to keep PowerShell backward compatible.
|
| 330 |
+
|
| 331 |
+
### Making Design Changes
|
| 332 |
+
|
| 333 |
+
To add new features such as cmdlets or making design changes,
|
| 334 |
+
please follow the [PowerShell Request for Comments (RFC)][rfc-process] process.
|
| 335 |
+
|
| 336 |
+
### Common Engineering Practices
|
| 337 |
+
|
| 338 |
+
Other than the guidelines for [coding][coding-guidelines],
|
| 339 |
+
the [RFC process][rfc-process] for design,
|
| 340 |
+
[documentation](#contributing-to-documentation) and [testing](../docs/testing-guidelines/testing-guidelines.md) discussed above,
|
| 341 |
+
we encourage contributors to follow these common engineering practices:
|
| 342 |
+
|
| 343 |
+
* Format commit messages following these guidelines:
|
| 344 |
+
|
| 345 |
+
```text
|
| 346 |
+
Summarize change in 50 characters or less
|
| 347 |
+
|
| 348 |
+
Similar to email, this is the body of the commit message,
|
| 349 |
+
and the above is the subject.
|
| 350 |
+
Always leave a single blank line between the subject and the body
|
| 351 |
+
so that `git log` and `git rebase` work nicely.
|
| 352 |
+
|
| 353 |
+
The subject of the commit should use the present tense and
|
| 354 |
+
imperative mood, like issuing a command:
|
| 355 |
+
|
| 356 |
+
> Makes abcd do wxyz
|
| 357 |
+
|
| 358 |
+
The body should be a useful message explaining
|
| 359 |
+
why the changes were made.
|
| 360 |
+
|
| 361 |
+
If significant alternative solutions were available,
|
| 362 |
+
explain why they were discarded.
|
| 363 |
+
|
| 364 |
+
Keep in mind that the person most likely to refer to your commit message
|
| 365 |
+
is you in the future, so be detailed!
|
| 366 |
+
|
| 367 |
+
As Git commit messages are most frequently viewed in the terminal,
|
| 368 |
+
you should wrap all lines around 72 characters.
|
| 369 |
+
|
| 370 |
+
Using semantic line feeds (breaks that separate ideas)
|
| 371 |
+
is also appropriate, as is using Markdown syntax.
|
| 372 |
+
```
|
| 373 |
+
|
| 374 |
+
* These are based on Tim Pope's [guidelines](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
|
| 375 |
+
Git SCM [submitting patches](https://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches),
|
| 376 |
+
Brandon Rhodes' [semantic linefeeds][],
|
| 377 |
+
and John Gruber's [Markdown syntax](https://daringfireball.net/projects/markdown/syntax).
|
| 378 |
+
* Don't commit code that you didn't write.
|
| 379 |
+
If you find code that you think is a good fit to add to PowerShell,
|
| 380 |
+
file an issue and start a discussion before proceeding.
|
| 381 |
+
* Create and/or update tests when making code changes.
|
| 382 |
+
* Run tests and ensure they are passing before opening a pull request.
|
| 383 |
+
* All pull requests **must** pass CI systems before they can be approved.
|
| 384 |
+
* Avoid making big pull requests.
|
| 385 |
+
Before you invest a large amount of time,
|
| 386 |
+
file an issue and start a discussion with the community.
|
| 387 |
+
|
| 388 |
+
### Contributor License Agreement (CLA)
|
| 389 |
+
|
| 390 |
+
To speed up the acceptance of any contribution to any PowerShell repositories,
|
| 391 |
+
you should sign the Microsoft [Contributor License Agreement (CLA)](https://cla.microsoft.com/) ahead of time.
|
| 392 |
+
If you've already contributed to PowerShell or Microsoft repositories in the past, congratulations!
|
| 393 |
+
You've already completed this step.
|
| 394 |
+
This a one-time requirement for the PowerShell project.
|
| 395 |
+
Signing the CLA process is simple and can be done in less than a minute.
|
| 396 |
+
You don't have to do this up-front.
|
| 397 |
+
You can simply clone, fork, and submit your pull request as usual.
|
| 398 |
+
When your pull request is created, it is checked by the CLA bot.
|
| 399 |
+
If you have signed the CLA, the status check will be set to `passing`. Otherwise, it will stay at `pending`.
|
| 400 |
+
Once you sign a CLA, all your existing and future pull requests will have the status check automatically set at `passing`.
|
| 401 |
+
|
| 402 |
+
## Code of Conduct Enforcement
|
| 403 |
+
|
| 404 |
+
Reports of abuse will be reviewed by the [PowerShell Committee][ps-committee] and if it has been determined that violations of the
|
| 405 |
+
[Code of Conduct](../CODE_OF_CONDUCT.md) has occurred, then a temporary ban may be imposed.
|
| 406 |
+
The duration of the temporary ban will depend on the impact and/or severity of the infraction.
|
| 407 |
+
This can vary from 1 day, a few days, a week, and up to 30 days.
|
| 408 |
+
Repeat offenses may result in a permanent ban from the PowerShell org.
|
| 409 |
+
|
| 410 |
+
[running-tests-outside-of-ci]: ../docs/testing-guidelines/testing-guidelines.md#running-tests-outside-of-ci
|
| 411 |
+
[issue-management]: ../docs/maintainers/issue-management.md
|
| 412 |
+
[vuln-reporting]: ./SECURITY.md
|
| 413 |
+
[using-prs]: https://help.github.com/articles/using-pull-requests/
|
| 414 |
+
[fork-a-repo]: https://help.github.com/articles/fork-a-repo/
|
| 415 |
+
[closing-via-message]: https://help.github.com/articles/closing-issues-via-commit-messages/
|
| 416 |
+
[CLA]: #contributor-license-agreement-cla
|
| 417 |
+
[ci-system]: ../docs/testing-guidelines/testing-guidelines.md#ci-system
|
| 418 |
+
[good-git-resources]: https://help.github.com/articles/good-resources-for-learning-git-and-github/
|
| 419 |
+
[contribute-issues]: #contributing-to-issues
|
| 420 |
+
[open-issue]: https://github.com/PowerShell/PowerShell/issues
|
| 421 |
+
[up-for-grabs]: https://github.com/powershell/powershell/issues?q=is%3Aopen+is%3Aissue+label%3AUp-for-Grabs
|
| 422 |
+
[semantic linefeeds]: https://rhodesmill.org/brandon/2012/one-sentence-per-line/
|
| 423 |
+
[PowerShell-Docs]: https://github.com/powershell/powershell-docs/
|
| 424 |
+
[use-vscode-editor]: https://learn.microsoft.com/dotnet/core/tutorials/with-visual-studio-code
|
| 425 |
+
[repository-maintainer]: ../docs/community/governance.md#repository-maintainers
|
| 426 |
+
[area-expert]: ../.github/CODEOWNERS
|
| 427 |
+
[first-time-issue]: https://github.com/powershell/powershell/issues?q=is%3Aopen+is%3Aissue+label%3AFirst-Time-Issue
|
| 428 |
+
[coding-guidelines]: ../docs/dev-process/coding-guidelines.md
|
| 429 |
+
[breaking-changes-contract]: ../docs/dev-process/breaking-change-contract.md
|
| 430 |
+
[rfc-process]: https://github.com/PowerShell/PowerShell-RFC
|
| 431 |
+
[ps-committee]: ../docs/community/governance.md#powershell-committee
|
PowerShell-master/.github/ISSUE_TEMPLATE/Bug_Report.yaml
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Bug report π
|
| 2 |
+
description: Report errors or unexpected behavior π€
|
| 3 |
+
labels: Needs-Triage
|
| 4 |
+
body:
|
| 5 |
+
- type: markdown
|
| 6 |
+
attributes:
|
| 7 |
+
value: >
|
| 8 |
+
For Windows PowerShell 5.1 issues, suggestions, or feature requests please use the
|
| 9 |
+
[Feedback Hub app](https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332)
|
| 10 |
+
|
| 11 |
+
This repository is **ONLY** for PowerShell Core 6 and PowerShell 7+ issues.
|
| 12 |
+
- type: checkboxes
|
| 13 |
+
attributes:
|
| 14 |
+
label: Prerequisites
|
| 15 |
+
options:
|
| 16 |
+
- label: Write a descriptive title.
|
| 17 |
+
required: true
|
| 18 |
+
- label: Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)
|
| 19 |
+
required: true
|
| 20 |
+
- label: Search the existing issues.
|
| 21 |
+
required: true
|
| 22 |
+
- label: Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).
|
| 23 |
+
required: true
|
| 24 |
+
- label: Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).
|
| 25 |
+
required: true
|
| 26 |
+
- type: textarea
|
| 27 |
+
attributes:
|
| 28 |
+
label: Steps to reproduce
|
| 29 |
+
description: >
|
| 30 |
+
List of steps, sample code, failing test or link to a project that reproduces the behavior.
|
| 31 |
+
Make sure you place a stack trace inside a code (```) block to avoid linking unrelated issues.
|
| 32 |
+
placeholder: >
|
| 33 |
+
I am experiencing a problem with X.
|
| 34 |
+
I think Y should be happening but Z is actually happening.
|
| 35 |
+
validations:
|
| 36 |
+
required: true
|
| 37 |
+
- type: textarea
|
| 38 |
+
attributes:
|
| 39 |
+
label: Expected behavior
|
| 40 |
+
render: console
|
| 41 |
+
placeholder: |
|
| 42 |
+
PS> 2 + 2
|
| 43 |
+
4
|
| 44 |
+
validations:
|
| 45 |
+
required: true
|
| 46 |
+
- type: textarea
|
| 47 |
+
attributes:
|
| 48 |
+
label: Actual behavior
|
| 49 |
+
render: console
|
| 50 |
+
placeholder: |
|
| 51 |
+
PS> 2 + 2
|
| 52 |
+
5
|
| 53 |
+
validations:
|
| 54 |
+
required: true
|
| 55 |
+
- type: textarea
|
| 56 |
+
attributes:
|
| 57 |
+
label: Error details
|
| 58 |
+
description: Paste verbatim output from `Get-Error` if PowerShell return an error.
|
| 59 |
+
render: console
|
| 60 |
+
placeholder: PS> Get-Error
|
| 61 |
+
- type: textarea
|
| 62 |
+
attributes:
|
| 63 |
+
label: Environment data
|
| 64 |
+
description: Paste verbatim output from `$PSVersionTable` below.
|
| 65 |
+
render: powershell
|
| 66 |
+
placeholder: PS> $PSVersionTable
|
| 67 |
+
validations:
|
| 68 |
+
required: true
|
| 69 |
+
- type: textarea
|
| 70 |
+
attributes:
|
| 71 |
+
label: Visuals
|
| 72 |
+
description: >
|
| 73 |
+
Please upload images or animations that can be used to reproduce issues in the area below.
|
| 74 |
+
Try the [Steps Recorder](https://support.microsoft.com/en-us/windows/record-steps-to-reproduce-a-problem-46582a9b-620f-2e36-00c9-04e25d784e47)
|
| 75 |
+
on Windows or [Screenshot](https://support.apple.com/en-us/HT208721) on macOS.
|
PowerShell-master/.github/ISSUE_TEMPLATE/Feature_Request.yaml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Feature Request / Idea π
|
| 2 |
+
description: Suggest a new feature or improvement (this does not mean you have to implement it)
|
| 3 |
+
labels: [Issue-Enhancement, Needs-Triage]
|
| 4 |
+
body:
|
| 5 |
+
- type: textarea
|
| 6 |
+
attributes:
|
| 7 |
+
label: Summary of the new feature / enhancement
|
| 8 |
+
description: >
|
| 9 |
+
A clear and concise description of what the problem is that the
|
| 10 |
+
new feature would solve. Try formulating it in user story style
|
| 11 |
+
(if applicable).
|
| 12 |
+
placeholder: "'As a user I want X so that Y...' with X being the being the action and Y being the value of the action."
|
| 13 |
+
validations:
|
| 14 |
+
required: true
|
| 15 |
+
- type: textarea
|
| 16 |
+
attributes:
|
| 17 |
+
label: Proposed technical implementation details (optional)
|
| 18 |
+
placeholder: >
|
| 19 |
+
A clear and concise description of what you want to happen.
|
| 20 |
+
Consider providing an example PowerShell experience with expected result.
|
PowerShell-master/.github/ISSUE_TEMPLATE/Microsoft_Update_Issue.yaml
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Microsoft Update issue report π
|
| 2 |
+
description: Report issue installing a PowerShell 7 Update or fresh install through Microsoft Update π€
|
| 3 |
+
labels: Needs-Triage
|
| 4 |
+
assignees:
|
| 5 |
+
- TravisEz13
|
| 6 |
+
body:
|
| 7 |
+
- type: markdown
|
| 8 |
+
attributes:
|
| 9 |
+
value: >
|
| 10 |
+
For Windows PowerShell 5.1 issues, suggestions, or feature requests please use the
|
| 11 |
+
[Feedback Hub app](https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332)
|
| 12 |
+
|
| 13 |
+
This repository is **ONLY** for PowerShell Core 6 and PowerShell 7+ issues.
|
| 14 |
+
- type: checkboxes
|
| 15 |
+
attributes:
|
| 16 |
+
label: Prerequisites
|
| 17 |
+
options:
|
| 18 |
+
- label: Write a descriptive title.
|
| 19 |
+
required: true
|
| 20 |
+
- label: Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)
|
| 21 |
+
required: true
|
| 22 |
+
- label: Search the existing issues.
|
| 23 |
+
required: true
|
| 24 |
+
- label: Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).
|
| 25 |
+
required: true
|
| 26 |
+
- label: Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).
|
| 27 |
+
required: true
|
| 28 |
+
- type: textarea
|
| 29 |
+
attributes:
|
| 30 |
+
label: Steps to reproduce
|
| 31 |
+
description: >
|
| 32 |
+
List of steps, sample code, failing test or link to a project that reproduces the behavior.
|
| 33 |
+
Make sure you place a stack trace inside a code (```) block to avoid linking unrelated issues.
|
| 34 |
+
placeholder: >
|
| 35 |
+
I am experiencing a problem with X.
|
| 36 |
+
I think Y should be happening but Z is actually happening.
|
| 37 |
+
validations:
|
| 38 |
+
required: true
|
| 39 |
+
- type: textarea
|
| 40 |
+
attributes:
|
| 41 |
+
label: Expected behavior
|
| 42 |
+
render: console
|
| 43 |
+
placeholder: |
|
| 44 |
+
PS> 2 + 2
|
| 45 |
+
4
|
| 46 |
+
validations:
|
| 47 |
+
required: true
|
| 48 |
+
- type: textarea
|
| 49 |
+
attributes:
|
| 50 |
+
label: Actual behavior
|
| 51 |
+
render: console
|
| 52 |
+
placeholder: |
|
| 53 |
+
PS> 2 + 2
|
| 54 |
+
5
|
| 55 |
+
validations:
|
| 56 |
+
required: true
|
| 57 |
+
- type: textarea
|
| 58 |
+
attributes:
|
| 59 |
+
label: Environment data
|
| 60 |
+
description: Paste verbatim output from `$PSVersionTable` below.
|
| 61 |
+
render: powershell
|
| 62 |
+
placeholder: PS> $PSVersionTable
|
| 63 |
+
validations:
|
| 64 |
+
required: true
|
| 65 |
+
- type: textarea
|
| 66 |
+
attributes:
|
| 67 |
+
label: OS Data
|
| 68 |
+
description: Paste verbatim output from `(Get-CimInstance Win32_OperatingSystem) | Select-Object -Property Version, Caption` below.
|
| 69 |
+
render: powershell
|
| 70 |
+
placeholder: PS> (Get-CimInstance Win32_OperatingSystem) | Select-Object -Property Version, Caption
|
| 71 |
+
validations:
|
| 72 |
+
required: true
|
| 73 |
+
- type: textarea
|
| 74 |
+
attributes:
|
| 75 |
+
label: Windows update log
|
| 76 |
+
description: Please run `Get-WindowsUpdateLog` and upload the resulting file to this issue.
|
| 77 |
+
render: markdown
|
| 78 |
+
placeholder: PS> Get-WindowsUpdateLog
|
| 79 |
+
validations:
|
| 80 |
+
required: true
|
| 81 |
+
- type: textarea
|
| 82 |
+
attributes:
|
| 83 |
+
label: Visuals
|
| 84 |
+
description: >
|
| 85 |
+
Please upload images or animations that can be used to reproduce issues in the area below.
|
| 86 |
+
Try the [Steps Recorder](https://support.microsoft.com/en-us/windows/record-steps-to-reproduce-a-problem-46582a9b-620f-2e36-00c9-04e25d784e47)
|
| 87 |
+
on Windows or [Screenshot](https://support.apple.com/en-us/HT208721) on macOS.
|
PowerShell-master/.github/ISSUE_TEMPLATE/Release_Process.yaml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Release Process
|
| 2 |
+
description: Maintainers Only - Release Process
|
| 3 |
+
title: "Release Process for v7.x.x"
|
| 4 |
+
labels: [Issue-Meta, Needs-Triage]
|
| 5 |
+
body:
|
| 6 |
+
- type: markdown
|
| 7 |
+
attributes:
|
| 8 |
+
value: >
|
| 9 |
+
This template is for maintainers to create an issues to track the release process.
|
| 10 |
+
Please **only** use this template if you are a maintainer.
|
| 11 |
+
- type: textarea
|
| 12 |
+
attributes:
|
| 13 |
+
label: Checklist
|
| 14 |
+
value: |
|
| 15 |
+
- [ ] Verify that [`PowerShell-Native`](https://github.com/PowerShell/PowerShell-Native) has been updated / released as needed.
|
| 16 |
+
- [ ] Check for `PowerShellGet` and `PackageManagement` release plans.
|
| 17 |
+
- [ ] Start process to sync Azure DevOps artifacts feed such as modules and NuGet packages.
|
| 18 |
+
- [ ] Create a private branch named `release/v6.x.x` in Azure DevOps repository.
|
| 19 |
+
All release related changes should happen in this branch.
|
| 20 |
+
- [ ] Prepare packages
|
| 21 |
+
- [ ] Kick off coordinated build.
|
| 22 |
+
- [ ] Kick off Release pipeline.
|
| 23 |
+
- *These tasks are orchestrated by the release pipeline, but here as status to the community.*
|
| 24 |
+
- [ ] Prepare packages
|
| 25 |
+
- [ ] Sign the RPM package.
|
| 26 |
+
- [ ] Install and verify the packages.
|
| 27 |
+
- [ ] Trigger the docker staging builds (signing must be done).
|
| 28 |
+
- [ ] Create the release tag and push the tag to `PowerShell/PowerShell` repository.
|
| 29 |
+
- [ ] Run tests on all supported Linux distributions and publish results.
|
| 30 |
+
- [ ] Update documentation, and scripts.
|
| 31 |
+
- [ ] Update [CHANGELOG.md](../../CHANGELOG.md) with the finalized change log draft.
|
| 32 |
+
- [ ] Stage a PR to master to update other documents and
|
| 33 |
+
scripts to use the new package names, links, and `metadata.json`.
|
| 34 |
+
- [ ] For preview releases,
|
| 35 |
+
merge the release branch to GitHub `master` with a merge commit.
|
| 36 |
+
- [ ] For non-preview releases,
|
| 37 |
+
make sure all changes are either already in master or have a PR open.
|
| 38 |
+
- [ ] Delete the release branch.
|
| 39 |
+
- [ ] Trigger the Docker image release.
|
| 40 |
+
- [ ] Retain builds.
|
| 41 |
+
- [ ] Update https://github.com/dotnet/dotnet-docker/tree/master/3.0/sdk with new version and SHA hashes for global tool. NOTE: this link is broken!
|
PowerShell-master/.github/ISSUE_TEMPLATE/WG_member_request.yaml
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Working Group Member Request
|
| 2 |
+
description: Request membership to serve on a PowerShell Working Group
|
| 3 |
+
title: Working Group Member Request
|
| 4 |
+
labels: [WG-NeedsReview, WG-Cmdlets, WG-Engine, WG-Interactive-Console, WG-Remoting, Needs-Triage]
|
| 5 |
+
body:
|
| 6 |
+
- type: markdown
|
| 7 |
+
attributes:
|
| 8 |
+
value: |
|
| 9 |
+
## Thank you for your interest in joining a PowerShell Working Group.
|
| 10 |
+
|
| 11 |
+
### Please complete the following public form to request membership to a PowerShell Working Group.
|
| 12 |
+
|
| 13 |
+
> [!NOTE]
|
| 14 |
+
> Not all Working Groups are accepting new members at this time.
|
| 15 |
+
- type : dropdown
|
| 16 |
+
id : request_type
|
| 17 |
+
validations:
|
| 18 |
+
required: true
|
| 19 |
+
attributes:
|
| 20 |
+
label: Name of Working Group you are requesting to join?
|
| 21 |
+
description: >-
|
| 22 |
+
Please select the name of the working group you are requesting to join. (Select one)
|
| 23 |
+
options:
|
| 24 |
+
- "Cmdlets and Modules"
|
| 25 |
+
- "Engine"
|
| 26 |
+
- "Interactive UX"
|
| 27 |
+
- "Remoting"
|
| 28 |
+
- type: dropdown
|
| 29 |
+
id: time
|
| 30 |
+
validations:
|
| 31 |
+
required: true
|
| 32 |
+
attributes:
|
| 33 |
+
label: Can you provide at least 1 hour per week to the Working Group? Note that time commitments will vary per Working Group and decided by its members.
|
| 34 |
+
description: >-
|
| 35 |
+
Please select Yes or No.
|
| 36 |
+
options:
|
| 37 |
+
- "Yes"
|
| 38 |
+
- "No"
|
| 39 |
+
- type: markdown
|
| 40 |
+
attributes:
|
| 41 |
+
value: |
|
| 42 |
+
## β οΈ This form is public. Do not provide any private or proprietary information. β οΈ
|
| 43 |
+
- type: textarea
|
| 44 |
+
attributes:
|
| 45 |
+
label: Why do you want to join this working group?
|
| 46 |
+
description: Please provide a brief description of why you want to join this working group.
|
| 47 |
+
placeholder: >
|
| 48 |
+
I want to join this working group because...
|
| 49 |
+
validations:
|
| 50 |
+
required: true
|
| 51 |
+
- type: textarea
|
| 52 |
+
attributes:
|
| 53 |
+
label: What skills do you bring to this working group?
|
| 54 |
+
description: Please provide a brief description of what skills you bring to this working group.
|
| 55 |
+
placeholder: >
|
| 56 |
+
I bring the following skills to this working group...
|
| 57 |
+
validations:
|
| 58 |
+
required: true
|
| 59 |
+
- type: textarea
|
| 60 |
+
attributes:
|
| 61 |
+
label: Public links to articles, code, or other resources that demonstrate your skills.
|
| 62 |
+
description: Please provide public links to articles, code, or other resources that demonstrate your skills.
|
| 63 |
+
placeholder: >
|
| 64 |
+
I have the following public links to articles, code, or other resources that demonstrate my skills...
|
| 65 |
+
validations:
|
| 66 |
+
required: true
|
PowerShell-master/.github/ISSUE_TEMPLATE/config.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
blank_issues_enabled: false
|
| 2 |
+
contact_links:
|
| 3 |
+
- name: Windows PowerShell
|
| 4 |
+
url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
|
| 5 |
+
about: Windows PowerShell issues or suggestions.
|
| 6 |
+
- name: Support
|
| 7 |
+
url: https://github.com/PowerShell/PowerShell/blob/master/.github/SUPPORT.md
|
| 8 |
+
about: PowerShell Support Questions/Help
|
| 9 |
+
- name: Documentation Issue
|
| 10 |
+
url: https://github.com/MicrosoftDocs/PowerShell-Docs/issues/new/choose
|
| 11 |
+
about: Please open issues on documentation for PowerShell here.
|
PowerShell-master/.github/Images/Codespaces.png
ADDED
|
PowerShell-master/.github/Images/GitHub-PR.png
ADDED
|
PowerShell-master/.github/PULL_REQUEST_TEMPLATE.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- Anything that looks like this is a comment and can't be seen after the Pull Request is created. -->
|
| 2 |
+
|
| 3 |
+
# PR Summary
|
| 4 |
+
|
| 5 |
+
<!-- Summarize your PR between here and the checklist. -->
|
| 6 |
+
|
| 7 |
+
## PR Context
|
| 8 |
+
|
| 9 |
+
<!-- Provide a little reasoning as to why this Pull Request helps and why you have opened it. -->
|
| 10 |
+
|
| 11 |
+
## PR Checklist
|
| 12 |
+
|
| 13 |
+
- [ ] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
|
| 14 |
+
- Use the present tense and imperative mood when describing your changes
|
| 15 |
+
- [ ] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
|
| 16 |
+
- [ ] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
|
| 17 |
+
- [ ] This PR is ready to merge. If this PR is a work in progress, please open this as a [Draft Pull Request and mark it as Ready to Review when it is ready to merge](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests).
|
| 18 |
+
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)**
|
| 19 |
+
- [ ] None
|
| 20 |
+
- **OR**
|
| 21 |
+
- [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.5/Microsoft.PowerShell.Core/About/about_Experimental_Features.md)
|
| 22 |
+
- [ ] Experimental feature name(s): <!-- Experimental feature name(s) here -->
|
| 23 |
+
- **User-facing changes**
|
| 24 |
+
- [ ] Not Applicable
|
| 25 |
+
- **OR**
|
| 26 |
+
- [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
|
| 27 |
+
- [ ] Issue filed: <!-- Number/link of that issue here -->
|
| 28 |
+
- **Testing - New and feature**
|
| 29 |
+
- [ ] N/A or can only be tested interactively
|
| 30 |
+
- **OR**
|
| 31 |
+
- [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting)
|
PowerShell-master/.github/SECURITY.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
|
| 2 |
+
|
| 3 |
+
## Security
|
| 4 |
+
|
| 5 |
+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin) and [PowerShell](https://github.com/PowerShell).
|
| 6 |
+
|
| 7 |
+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
|
| 8 |
+
|
| 9 |
+
## Reporting Security Issues
|
| 10 |
+
|
| 11 |
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
| 12 |
+
|
| 13 |
+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
|
| 14 |
+
|
| 15 |
+
You should receive a response within 24 hours. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
|
| 16 |
+
|
| 17 |
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
| 18 |
+
|
| 19 |
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
| 20 |
+
* Full paths of source file(s) related to the manifestation of the issue
|
| 21 |
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
| 22 |
+
* Any special configuration required to reproduce the issue
|
| 23 |
+
* Step-by-step instructions to reproduce the issue
|
| 24 |
+
* Proof-of-concept or exploit code (if possible)
|
| 25 |
+
* Impact of the issue, including how an attacker might exploit the issue
|
| 26 |
+
|
| 27 |
+
This information will help us triage your report more quickly.
|
| 28 |
+
|
| 29 |
+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
|
| 30 |
+
|
| 31 |
+
## Preferred Languages
|
| 32 |
+
|
| 33 |
+
We prefer all communications to be in English.
|
| 34 |
+
|
| 35 |
+
## Policy
|
| 36 |
+
|
| 37 |
+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
|
| 38 |
+
|
| 39 |
+
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
PowerShell-master/.github/SUPPORT.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PowerShell Support
|
| 2 |
+
|
| 3 |
+
If you have any problems, please consult the [known issues][], developer [FAQ][], and [GitHub issues][].
|
| 4 |
+
If you do not see your problem captured, please file a [new issue][] and follow the provided template.
|
| 5 |
+
Also make sure to see the [Official Support Policy][].
|
| 6 |
+
If you know how to fix the issue, feel free to send a pull request our way. (The [Contribution Guides][] apply to that pull request, you may want to give it a read!)
|
| 7 |
+
|
| 8 |
+
[Official Support Policy]: https://learn.microsoft.com/powershell/scripting/powershell-support-lifecycle
|
| 9 |
+
[FAQ]: https://github.com/PowerShell/PowerShell/tree/master/docs/FAQ.md
|
| 10 |
+
[Contribution Guides]: https://github.com/PowerShell/PowerShell/tree/master/.github/CONTRIBUTING.md
|
| 11 |
+
[known issues]: https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell
|
| 12 |
+
[GitHub issues]: https://github.com/PowerShell/PowerShell/issues
|
| 13 |
+
[new issue]: https://github.com/PowerShell/PowerShell/issues/new/choose
|
PowerShell-master/.github/action-filters.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
github: &github
|
| 2 |
+
- .github/actions/**
|
| 3 |
+
- .github/workflows/**-ci.yml
|
| 4 |
+
tools: &tools
|
| 5 |
+
- tools/buildCommon/**
|
| 6 |
+
- tools/ci.psm1
|
| 7 |
+
props: &props
|
| 8 |
+
- '**.props'
|
| 9 |
+
tests: &tests
|
| 10 |
+
- test/powershell/**
|
| 11 |
+
- test/tools/**
|
| 12 |
+
- test/xUnit/**
|
| 13 |
+
mainSource: &mainSource
|
| 14 |
+
- src/**
|
| 15 |
+
buildModule: &buildModule
|
| 16 |
+
- build.psm1
|
| 17 |
+
source:
|
| 18 |
+
- *github
|
| 19 |
+
- *tools
|
| 20 |
+
- *props
|
| 21 |
+
- *buildModule
|
| 22 |
+
- *mainSource
|
| 23 |
+
- *tests
|
PowerShell-master/.github/actions/build/ci/action.yml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CI Build
|
| 2 |
+
description: 'Builds PowerShell'
|
| 3 |
+
runs:
|
| 4 |
+
using: composite
|
| 5 |
+
steps:
|
| 6 |
+
- name: Capture Environment
|
| 7 |
+
if: success() || failure()
|
| 8 |
+
run: |-
|
| 9 |
+
Import-Module .\tools\ci.psm1
|
| 10 |
+
Show-Environment
|
| 11 |
+
shell: pwsh
|
| 12 |
+
- name: Set Build Name for Non-PR
|
| 13 |
+
if: github.event_name != 'PullRequest'
|
| 14 |
+
run: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
|
| 15 |
+
shell: pwsh
|
| 16 |
+
- uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
|
| 17 |
+
with:
|
| 18 |
+
global-json-file: ./global.json
|
| 19 |
+
- name: Bootstrap
|
| 20 |
+
if: success()
|
| 21 |
+
run: |-
|
| 22 |
+
Write-Verbose -Verbose "Running Bootstrap..."
|
| 23 |
+
Import-Module .\tools\ci.psm1
|
| 24 |
+
Invoke-CIInstall -SkipUser
|
| 25 |
+
Write-Verbose -Verbose "Start Sync-PSTags"
|
| 26 |
+
Sync-PSTags -AddRemoteIfMissing
|
| 27 |
+
Write-Verbose -Verbose "End Sync-PSTags"
|
| 28 |
+
shell: pwsh
|
| 29 |
+
- name: Build
|
| 30 |
+
if: success()
|
| 31 |
+
run: |-
|
| 32 |
+
Write-Verbose -Verbose "Running Build..."
|
| 33 |
+
Import-Module .\tools\ci.psm1
|
| 34 |
+
Invoke-CIBuild
|
| 35 |
+
shell: pwsh
|
| 36 |
+
- name: Upload build artifact
|
| 37 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
| 38 |
+
with:
|
| 39 |
+
name: build
|
| 40 |
+
path: ${{ runner.workspace }}/build
|
PowerShell-master/.github/actions/infrastructure/get-changed-files/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Get Changed Files Action
|
| 2 |
+
|
| 3 |
+
A reusable composite action that retrieves the list of files changed in a pull request or push event.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
|
| 7 |
+
- Supports both `pull_request` and `push` events
|
| 8 |
+
- Optional filtering by file pattern
|
| 9 |
+
- Returns files as JSON array for easy consumption
|
| 10 |
+
- Filters out deleted files (only returns added, modified, or renamed files)
|
| 11 |
+
- Handles up to 100 changed files per request
|
| 12 |
+
|
| 13 |
+
## Usage
|
| 14 |
+
|
| 15 |
+
### Basic Usage (Pull Requests Only)
|
| 16 |
+
|
| 17 |
+
```yaml
|
| 18 |
+
- name: Get changed files
|
| 19 |
+
id: changed-files
|
| 20 |
+
uses: "./.github/actions/infrastructure/get-changed-files"
|
| 21 |
+
|
| 22 |
+
- name: Process files
|
| 23 |
+
run: |
|
| 24 |
+
echo "Changed files: ${{ steps.changed-files.outputs.files }}"
|
| 25 |
+
echo "Count: ${{ steps.changed-files.outputs.count }}"
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
### With Filtering
|
| 29 |
+
|
| 30 |
+
```yaml
|
| 31 |
+
# Get only markdown files
|
| 32 |
+
- name: Get changed markdown files
|
| 33 |
+
id: changed-md
|
| 34 |
+
uses: "./.github/actions/infrastructure/get-changed-files"
|
| 35 |
+
with:
|
| 36 |
+
filter: '*.md'
|
| 37 |
+
|
| 38 |
+
# Get only GitHub workflow/action files
|
| 39 |
+
- name: Get changed GitHub files
|
| 40 |
+
id: changed-github
|
| 41 |
+
uses: "./.github/actions/infrastructure/get-changed-files"
|
| 42 |
+
with:
|
| 43 |
+
filter: '.github/'
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### Support Both PR and Push Events
|
| 47 |
+
|
| 48 |
+
```yaml
|
| 49 |
+
- name: Get changed files
|
| 50 |
+
id: changed-files
|
| 51 |
+
uses: "./.github/actions/infrastructure/get-changed-files"
|
| 52 |
+
with:
|
| 53 |
+
event-types: 'pull_request,push'
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Inputs
|
| 57 |
+
|
| 58 |
+
| Name | Description | Required | Default |
|
| 59 |
+
|------|-------------|----------|---------|
|
| 60 |
+
| `filter` | Optional filter pattern (e.g., `*.md` for markdown files, `.github/` for GitHub files) | No | `''` |
|
| 61 |
+
| `event-types` | Comma-separated list of event types to support (`pull_request`, `push`) | No | `pull_request` |
|
| 62 |
+
|
| 63 |
+
## Outputs
|
| 64 |
+
|
| 65 |
+
| Name | Description |
|
| 66 |
+
|------|-------------|
|
| 67 |
+
| `files` | JSON array of changed file paths |
|
| 68 |
+
| `count` | Number of changed files |
|
| 69 |
+
|
| 70 |
+
## Filter Patterns
|
| 71 |
+
|
| 72 |
+
The action supports simple filter patterns:
|
| 73 |
+
|
| 74 |
+
- **Extension matching**: Use `*.ext` to match files with a specific extension
|
| 75 |
+
- Example: `*.md` matches all markdown files
|
| 76 |
+
- Example: `*.yml` matches all YAML files
|
| 77 |
+
|
| 78 |
+
- **Path prefix matching**: Use a path prefix to match files in a directory
|
| 79 |
+
- Example: `.github/` matches all files in the `.github` directory
|
| 80 |
+
- Example: `tools/` matches all files in the `tools` directory
|
| 81 |
+
|
| 82 |
+
## Example: Processing Changed Files
|
| 83 |
+
|
| 84 |
+
```yaml
|
| 85 |
+
- name: Get changed files
|
| 86 |
+
id: changed-files
|
| 87 |
+
uses: "./.github/actions/infrastructure/get-changed-files"
|
| 88 |
+
|
| 89 |
+
- name: Process each file
|
| 90 |
+
shell: pwsh
|
| 91 |
+
env:
|
| 92 |
+
CHANGED_FILES: ${{ steps.changed-files.outputs.files }}
|
| 93 |
+
run: |
|
| 94 |
+
$changedFilesJson = $env:CHANGED_FILES
|
| 95 |
+
$changedFiles = $changedFilesJson | ConvertFrom-Json
|
| 96 |
+
|
| 97 |
+
foreach ($file in $changedFiles) {
|
| 98 |
+
Write-Host "Processing: $file"
|
| 99 |
+
# Your processing logic here
|
| 100 |
+
}
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
## Limitations
|
| 104 |
+
|
| 105 |
+
- Simple filter patterns only (no complex glob or regex patterns)
|
| 106 |
+
|
| 107 |
+
## Pagination
|
| 108 |
+
|
| 109 |
+
The action automatically handles pagination to fetch **all** changed files in a PR, regardless of how many files were changed:
|
| 110 |
+
|
| 111 |
+
- Fetches files in batches of 100 per page
|
| 112 |
+
- Continues fetching until all files are retrieved
|
| 113 |
+
- Logs a note when pagination occurs, showing the total file count
|
| 114 |
+
- **No file limit** - all changed files will be processed, even in very large PRs
|
| 115 |
+
|
| 116 |
+
This ensures that critical workflows (such as merge conflict checking, link validation, etc.) don't miss files due to pagination limits.
|
| 117 |
+
|
| 118 |
+
## Related Actions
|
| 119 |
+
|
| 120 |
+
- **markdownlinks**: Uses this pattern to get changed markdown files
|
| 121 |
+
- **merge-conflict-checker**: Uses this pattern to get changed files for conflict detection
|
| 122 |
+
- **path-filters**: Similar functionality but with more complex filtering logic
|
PowerShell-master/.github/actions/infrastructure/get-changed-files/action.yml
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: 'Get Changed Files'
|
| 2 |
+
description: 'Gets the list of files changed in a pull request or push event'
|
| 3 |
+
inputs:
|
| 4 |
+
filter:
|
| 5 |
+
description: 'Optional filter pattern (e.g., "*.md" for markdown files, ".github/" for GitHub files)'
|
| 6 |
+
required: false
|
| 7 |
+
default: ''
|
| 8 |
+
event-types:
|
| 9 |
+
description: 'Comma-separated list of event types to support (pull_request, push)'
|
| 10 |
+
required: false
|
| 11 |
+
default: 'pull_request'
|
| 12 |
+
outputs:
|
| 13 |
+
files:
|
| 14 |
+
description: 'JSON array of changed file paths'
|
| 15 |
+
value: ${{ steps.get-files.outputs.files }}
|
| 16 |
+
count:
|
| 17 |
+
description: 'Number of changed files'
|
| 18 |
+
value: ${{ steps.get-files.outputs.count }}
|
| 19 |
+
runs:
|
| 20 |
+
using: 'composite'
|
| 21 |
+
steps:
|
| 22 |
+
- name: Get changed files
|
| 23 |
+
id: get-files
|
| 24 |
+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
|
| 25 |
+
with:
|
| 26 |
+
script: |
|
| 27 |
+
const eventTypes = '${{ inputs.event-types }}'.split(',').map(t => t.trim());
|
| 28 |
+
const filter = '${{ inputs.filter }}';
|
| 29 |
+
let changedFiles = [];
|
| 30 |
+
|
| 31 |
+
if (eventTypes.includes('pull_request') && context.eventName === 'pull_request') {
|
| 32 |
+
console.log(`Getting files changed in PR #${context.payload.pull_request.number}`);
|
| 33 |
+
|
| 34 |
+
// Fetch all files changed in the PR with pagination
|
| 35 |
+
let allFiles = [];
|
| 36 |
+
let page = 1;
|
| 37 |
+
let fetchedCount;
|
| 38 |
+
|
| 39 |
+
do {
|
| 40 |
+
const { data: files } = await github.rest.pulls.listFiles({
|
| 41 |
+
owner: context.repo.owner,
|
| 42 |
+
repo: context.repo.repo,
|
| 43 |
+
pull_number: context.payload.pull_request.number,
|
| 44 |
+
per_page: 100,
|
| 45 |
+
page: page
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
allFiles = allFiles.concat(files);
|
| 49 |
+
fetchedCount = files.length;
|
| 50 |
+
page++;
|
| 51 |
+
} while (fetchedCount === 100);
|
| 52 |
+
|
| 53 |
+
if (allFiles.length >= 100) {
|
| 54 |
+
console.log(`Note: This PR has ${allFiles.length} changed files. All files fetched using pagination.`);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
changedFiles = allFiles
|
| 58 |
+
.filter(file => file.status === 'added' || file.status === 'modified' || file.status === 'renamed')
|
| 59 |
+
.map(file => file.filename);
|
| 60 |
+
|
| 61 |
+
} else if (eventTypes.includes('push') && context.eventName === 'push') {
|
| 62 |
+
console.log(`Getting files changed in push to ${context.ref}`);
|
| 63 |
+
|
| 64 |
+
const { data: comparison } = await github.rest.repos.compareCommits({
|
| 65 |
+
owner: context.repo.owner,
|
| 66 |
+
repo: context.repo.repo,
|
| 67 |
+
base: context.payload.before,
|
| 68 |
+
head: context.payload.after,
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
changedFiles = comparison.files
|
| 72 |
+
.filter(file => file.status === 'added' || file.status === 'modified' || file.status === 'renamed')
|
| 73 |
+
.map(file => file.filename);
|
| 74 |
+
|
| 75 |
+
} else {
|
| 76 |
+
core.setFailed(`Unsupported event type: ${context.eventName}. Supported types: ${eventTypes.join(', ')}`);
|
| 77 |
+
return;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// Apply filter if provided
|
| 81 |
+
if (filter) {
|
| 82 |
+
const filterLower = filter.toLowerCase();
|
| 83 |
+
const beforeFilter = changedFiles.length;
|
| 84 |
+
changedFiles = changedFiles.filter(file => {
|
| 85 |
+
const fileLower = file.toLowerCase();
|
| 86 |
+
// Support simple patterns like "*.md" or ".github/"
|
| 87 |
+
if (filterLower.startsWith('*.')) {
|
| 88 |
+
const ext = filterLower.substring(1);
|
| 89 |
+
return fileLower.endsWith(ext);
|
| 90 |
+
} else {
|
| 91 |
+
return fileLower.startsWith(filterLower);
|
| 92 |
+
}
|
| 93 |
+
});
|
| 94 |
+
console.log(`Filter '${filter}' applied: ${beforeFilter} β ${changedFiles.length} files`);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
// Calculate simple hash for verification
|
| 98 |
+
const crypto = require('crypto');
|
| 99 |
+
const filesJson = JSON.stringify(changedFiles.sort());
|
| 100 |
+
const hash = crypto.createHash('sha256').update(filesJson).digest('hex').substring(0, 8);
|
| 101 |
+
|
| 102 |
+
// Log changed files in a collapsible group
|
| 103 |
+
core.startGroup(`Changed Files (${changedFiles.length} total, hash: ${hash})`);
|
| 104 |
+
if (changedFiles.length > 0) {
|
| 105 |
+
changedFiles.forEach(file => console.log(` - ${file}`));
|
| 106 |
+
} else {
|
| 107 |
+
console.log(' (no files changed)');
|
| 108 |
+
}
|
| 109 |
+
core.endGroup();
|
| 110 |
+
|
| 111 |
+
console.log(`Found ${changedFiles.length} changed files`);
|
| 112 |
+
core.setOutput('files', JSON.stringify(changedFiles));
|
| 113 |
+
core.setOutput('count', changedFiles.length);
|
| 114 |
+
|
| 115 |
+
branding:
|
| 116 |
+
icon: 'file-text'
|
| 117 |
+
color: 'blue'
|
PowerShell-master/.github/actions/infrastructure/markdownlinks/Parse-MarkdownLink.ps1
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Microsoft Corporation.
|
| 2 |
+
# Licensed under the MIT License.
|
| 3 |
+
|
| 4 |
+
#requires -version 7
|
| 5 |
+
# Markdig is always available in PowerShell 7
|
| 6 |
+
<#
|
| 7 |
+
.SYNOPSIS
|
| 8 |
+
Parse CHANGELOG files using Markdig to extract links.
|
| 9 |
+
|
| 10 |
+
.DESCRIPTION
|
| 11 |
+
This script uses Markdig.Markdown.Parse to parse all markdown files in the CHANGELOG directory
|
| 12 |
+
and extract different types of links (inline links, reference links, etc.).
|
| 13 |
+
|
| 14 |
+
.PARAMETER ChangelogPath
|
| 15 |
+
Path to the CHANGELOG directory. Defaults to ./CHANGELOG
|
| 16 |
+
|
| 17 |
+
.PARAMETER LinkType
|
| 18 |
+
Filter by link type: All, Inline, Reference, AutoLink. Defaults to All.
|
| 19 |
+
|
| 20 |
+
.EXAMPLE
|
| 21 |
+
.\Parse-MarkdownLink.ps1
|
| 22 |
+
|
| 23 |
+
.EXAMPLE
|
| 24 |
+
.\Parse-MarkdownLink.ps1 -LinkType Reference
|
| 25 |
+
#>
|
| 26 |
+
|
| 27 |
+
param(
|
| 28 |
+
[string]$ChangelogPath = "./CHANGELOG",
|
| 29 |
+
[ValidateSet("All", "Inline", "Reference", "AutoLink")]
|
| 30 |
+
[string]$LinkType = "All"
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
Write-Verbose "Using built-in Markdig functionality to parse markdown files"
|
| 34 |
+
|
| 35 |
+
function Get-LinksFromMarkdownAst {
|
| 36 |
+
param(
|
| 37 |
+
[Parameter(Mandatory)]
|
| 38 |
+
[object]$Node,
|
| 39 |
+
[Parameter(Mandatory)]
|
| 40 |
+
[string]$FileName,
|
| 41 |
+
[System.Collections.ArrayList]$Links
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
if ($null -eq $Links) {
|
| 45 |
+
return
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
# Check if current node is a link
|
| 49 |
+
if ($Node -is [Markdig.Syntax.Inlines.LinkInline]) {
|
| 50 |
+
$linkInfo = [PSCustomObject]@{
|
| 51 |
+
Path = $FileName
|
| 52 |
+
Line = $Node.Line + 1 # Convert to 1-based line numbering
|
| 53 |
+
Column = $Node.Column + 1 # Convert to 1-based column numbering
|
| 54 |
+
Url = $Node.Url ?? ""
|
| 55 |
+
Text = $Node.FirstChild?.ToString() ?? ""
|
| 56 |
+
Type = "Inline"
|
| 57 |
+
IsImage = $Node.IsImage
|
| 58 |
+
}
|
| 59 |
+
[void]$Links.Add($linkInfo)
|
| 60 |
+
}
|
| 61 |
+
elseif ($Node -is [Markdig.Syntax.Inlines.AutolinkInline]) {
|
| 62 |
+
$linkInfo = [PSCustomObject]@{
|
| 63 |
+
Path = $FileName
|
| 64 |
+
Line = $Node.Line + 1
|
| 65 |
+
Column = $Node.Column + 1
|
| 66 |
+
Url = $Node.Url ?? ""
|
| 67 |
+
Text = $Node.Url ?? ""
|
| 68 |
+
Type = "AutoLink"
|
| 69 |
+
IsImage = $false
|
| 70 |
+
}
|
| 71 |
+
[void]$Links.Add($linkInfo)
|
| 72 |
+
}
|
| 73 |
+
elseif ($Node -is [Markdig.Syntax.LinkReferenceDefinitionGroup]) {
|
| 74 |
+
foreach ($refDef in $Node) {
|
| 75 |
+
$linkInfo = [PSCustomObject]@{
|
| 76 |
+
Path = $FileName
|
| 77 |
+
Line = $refDef.Line + 1
|
| 78 |
+
Column = $refDef.Column + 1
|
| 79 |
+
Url = $refDef.Url ?? ""
|
| 80 |
+
Text = $refDef.Label ?? ""
|
| 81 |
+
Type = "Reference"
|
| 82 |
+
IsImage = $false
|
| 83 |
+
}
|
| 84 |
+
[void]$Links.Add($linkInfo)
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
elseif ($Node -is [Markdig.Syntax.LinkReferenceDefinition]) {
|
| 88 |
+
$linkInfo = [PSCustomObject]@{
|
| 89 |
+
Path = $FileName
|
| 90 |
+
Line = $Node.Line + 1
|
| 91 |
+
Column = $Node.Column + 1
|
| 92 |
+
Url = $Node.Url ?? ""
|
| 93 |
+
Text = $Node.Label ?? ""
|
| 94 |
+
Type = "Reference"
|
| 95 |
+
IsImage = $false
|
| 96 |
+
}
|
| 97 |
+
[void]$Links.Add($linkInfo)
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
# For MarkdownDocument (root), iterate through all blocks
|
| 101 |
+
if ($Node -is [Markdig.Syntax.MarkdownDocument]) {
|
| 102 |
+
foreach ($block in $Node) {
|
| 103 |
+
Get-LinksFromMarkdownAst -Node $block -FileName $FileName -Links $Links
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
# For block containers, iterate through children
|
| 107 |
+
elseif ($Node -is [Markdig.Syntax.ContainerBlock]) {
|
| 108 |
+
foreach ($child in $Node) {
|
| 109 |
+
Get-LinksFromMarkdownAst -Node $child -FileName $FileName -Links $Links
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
# For leaf blocks with inlines, process the inline content
|
| 113 |
+
elseif ($Node -is [Markdig.Syntax.LeafBlock] -and $Node.Inline) {
|
| 114 |
+
Get-LinksFromMarkdownAst -Node $Node.Inline -FileName $FileName -Links $Links
|
| 115 |
+
}
|
| 116 |
+
# For inline containers, process all child inlines
|
| 117 |
+
elseif ($Node -is [Markdig.Syntax.Inlines.ContainerInline]) {
|
| 118 |
+
$child = $Node.FirstChild
|
| 119 |
+
while ($child) {
|
| 120 |
+
Get-LinksFromMarkdownAst -Node $child -FileName $FileName -Links $Links
|
| 121 |
+
$child = $child.NextSibling
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
# For other inline elements that might have children
|
| 125 |
+
elseif ($Node.PSObject.Properties.Name -contains "FirstChild" -and $Node.FirstChild) {
|
| 126 |
+
$child = $Node.FirstChild
|
| 127 |
+
while ($child) {
|
| 128 |
+
Get-LinksFromMarkdownAst -Node $child -FileName $FileName -Links $Links
|
| 129 |
+
$child = $child.NextSibling
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
function Parse-ChangelogFiles {
|
| 135 |
+
param(
|
| 136 |
+
[string]$Path
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
if (-not (Test-Path $Path)) {
|
| 140 |
+
Write-Error "CHANGELOG directory not found: $Path"
|
| 141 |
+
return
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
$markdownFiles = Get-ChildItem -Path $Path -Filter "*.md" -File
|
| 145 |
+
|
| 146 |
+
if ($markdownFiles.Count -eq 0) {
|
| 147 |
+
Write-Warning "No markdown files found in $Path"
|
| 148 |
+
return
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
$allLinks = [System.Collections.ArrayList]::new()
|
| 152 |
+
|
| 153 |
+
foreach ($file in $markdownFiles) {
|
| 154 |
+
Write-Verbose "Processing file: $($file.Name)"
|
| 155 |
+
|
| 156 |
+
try {
|
| 157 |
+
$content = Get-Content -Path $file.FullName -Raw -Encoding UTF8
|
| 158 |
+
|
| 159 |
+
# Parse the markdown content using Markdig
|
| 160 |
+
$document = [Markdig.Markdown]::Parse($content, [Markdig.MarkdownPipelineBuilder]::new())
|
| 161 |
+
|
| 162 |
+
# Extract links from the AST
|
| 163 |
+
Get-LinksFromMarkdownAst -Node $document -FileName $file.FullName -Links $allLinks
|
| 164 |
+
|
| 165 |
+
} catch {
|
| 166 |
+
Write-Warning "Error processing file $($file.Name): $($_.Exception.Message)"
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
# Filter by link type if specified
|
| 171 |
+
if ($LinkType -ne "All") {
|
| 172 |
+
$allLinks = $allLinks | Where-Object { $_.Type -eq $LinkType }
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
return $allLinks
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
# Main execution
|
| 179 |
+
$links = Parse-ChangelogFiles -Path $ChangelogPath
|
| 180 |
+
|
| 181 |
+
# Output PowerShell objects
|
| 182 |
+
$links
|
PowerShell-master/.github/actions/infrastructure/markdownlinks/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Verify Markdown Links Action
|
| 2 |
+
|
| 3 |
+
A GitHub composite action that verifies all links in markdown files using PowerShell and Markdig.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
|
| 7 |
+
- β
Parses markdown files using Markdig (built into PowerShell 7)
|
| 8 |
+
- β
Extracts all link types: inline links, reference links, and autolinks
|
| 9 |
+
- β
Verifies HTTP/HTTPS links with configurable timeouts and retries
|
| 10 |
+
- β
Validates local file references
|
| 11 |
+
- β
Supports excluding specific URL patterns
|
| 12 |
+
- β
Provides detailed error reporting with file locations
|
| 13 |
+
- β
Outputs metrics for CI/CD integration
|
| 14 |
+
|
| 15 |
+
## Usage
|
| 16 |
+
|
| 17 |
+
### Basic Usage
|
| 18 |
+
|
| 19 |
+
```yaml
|
| 20 |
+
- name: Verify Markdown Links
|
| 21 |
+
uses: ./.github/actions/infrastructure/markdownlinks
|
| 22 |
+
with:
|
| 23 |
+
path: './CHANGELOG'
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
### Advanced Usage
|
| 27 |
+
|
| 28 |
+
```yaml
|
| 29 |
+
- name: Verify Markdown Links
|
| 30 |
+
uses: ./.github/actions/infrastructure/markdownlinks
|
| 31 |
+
with:
|
| 32 |
+
path: './docs'
|
| 33 |
+
fail-on-error: 'true'
|
| 34 |
+
timeout: 30
|
| 35 |
+
max-retries: 2
|
| 36 |
+
exclude-patterns: '*.example.com/*,*://localhost/*'
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
### With Outputs
|
| 40 |
+
|
| 41 |
+
```yaml
|
| 42 |
+
- name: Verify Markdown Links
|
| 43 |
+
id: verify-links
|
| 44 |
+
uses: ./.github/actions/infrastructure/markdownlinks
|
| 45 |
+
with:
|
| 46 |
+
path: './CHANGELOG'
|
| 47 |
+
fail-on-error: 'false'
|
| 48 |
+
|
| 49 |
+
- name: Display Results
|
| 50 |
+
run: |
|
| 51 |
+
echo "Total links: ${{ steps.verify-links.outputs.total-links }}"
|
| 52 |
+
echo "Passed: ${{ steps.verify-links.outputs.passed-links }}"
|
| 53 |
+
echo "Failed: ${{ steps.verify-links.outputs.failed-links }}"
|
| 54 |
+
echo "Skipped: ${{ steps.verify-links.outputs.skipped-links }}"
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Inputs
|
| 58 |
+
|
| 59 |
+
| Input | Description | Required | Default |
|
| 60 |
+
|-------|-------------|----------|---------|
|
| 61 |
+
| `path` | Path to the directory containing markdown files to verify | No | `./CHANGELOG` |
|
| 62 |
+
| `exclude-patterns` | Comma-separated list of URL patterns to exclude from verification | No | `''` |
|
| 63 |
+
| `fail-on-error` | Whether to fail the action if any links are broken | No | `true` |
|
| 64 |
+
| `timeout` | Timeout in seconds for HTTP requests | No | `30` |
|
| 65 |
+
| `max-retries` | Maximum number of retries for failed requests | No | `2` |
|
| 66 |
+
|
| 67 |
+
## Outputs
|
| 68 |
+
|
| 69 |
+
| Output | Description |
|
| 70 |
+
|--------|-------------|
|
| 71 |
+
| `total-links` | Total number of unique links checked |
|
| 72 |
+
| `passed-links` | Number of links that passed verification |
|
| 73 |
+
| `failed-links` | Number of links that failed verification |
|
| 74 |
+
| `skipped-links` | Number of links that were skipped |
|
| 75 |
+
|
| 76 |
+
## Excluded Link Types
|
| 77 |
+
|
| 78 |
+
The action automatically skips the following link types:
|
| 79 |
+
|
| 80 |
+
- **Anchor links** (`#section-name`) - Would require full markdown parsing
|
| 81 |
+
- **Email links** (`mailto:user@example.com`) - Cannot be verified without sending email
|
| 82 |
+
|
| 83 |
+
## GitHub Workflow Test
|
| 84 |
+
|
| 85 |
+
This section provides a workflow example and instructions for testing the link verification action.
|
| 86 |
+
|
| 87 |
+
### Testing the Workflow
|
| 88 |
+
|
| 89 |
+
To test that the workflow properly detects broken links:
|
| 90 |
+
|
| 91 |
+
1. Make change to this file (e.g., this README.md file already contains one in the [Broken Link Test](#broken-link-test) section)
|
| 92 |
+
1. The workflow will run and should fail, reporting the broken link(s)
|
| 93 |
+
1. Revert your change to this file
|
| 94 |
+
1. Push again to verify the workflow passes
|
| 95 |
+
|
| 96 |
+
### Example Workflow Configuration
|
| 97 |
+
|
| 98 |
+
```yaml
|
| 99 |
+
name: Verify Links
|
| 100 |
+
|
| 101 |
+
on:
|
| 102 |
+
push:
|
| 103 |
+
branches: [ main ]
|
| 104 |
+
paths:
|
| 105 |
+
- '**/*.md'
|
| 106 |
+
pull_request:
|
| 107 |
+
branches: [ main ]
|
| 108 |
+
paths:
|
| 109 |
+
- '**/*.md'
|
| 110 |
+
schedule:
|
| 111 |
+
# Run weekly to catch external link rot
|
| 112 |
+
- cron: '0 0 * * 0'
|
| 113 |
+
|
| 114 |
+
jobs:
|
| 115 |
+
verify-links:
|
| 116 |
+
runs-on: ubuntu-latest
|
| 117 |
+
steps:
|
| 118 |
+
- name: Checkout
|
| 119 |
+
uses: actions/checkout@v4
|
| 120 |
+
|
| 121 |
+
- name: Verify CHANGELOG Links
|
| 122 |
+
uses: ./.github/actions/infrastructure/markdownlinks
|
| 123 |
+
with:
|
| 124 |
+
path: './CHANGELOG'
|
| 125 |
+
fail-on-error: 'true'
|
| 126 |
+
|
| 127 |
+
- name: Verify Documentation Links
|
| 128 |
+
uses: ./.github/actions/infrastructure/markdownlinks
|
| 129 |
+
with:
|
| 130 |
+
path: './docs'
|
| 131 |
+
fail-on-error: 'false'
|
| 132 |
+
exclude-patterns: '*.internal.example.com/*'
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
## How It Works
|
| 136 |
+
|
| 137 |
+
1. **Parse Markdown**: Uses `Parse-MarkdownLink.ps1` to extract all links from markdown files using Markdig
|
| 138 |
+
2. **Deduplicate**: Groups links by URL to avoid checking the same link multiple times
|
| 139 |
+
3. **Verify Links**:
|
| 140 |
+
- HTTP/HTTPS links: Makes HEAD/GET requests with configurable timeout and retries
|
| 141 |
+
- Local file references: Checks if the file exists relative to the markdown file
|
| 142 |
+
- Excluded patterns: Skips links matching the exclude patterns
|
| 143 |
+
4. **Report Results**: Displays detailed results with file locations for failed links
|
| 144 |
+
5. **Set Outputs**: Provides metrics for downstream steps
|
| 145 |
+
|
| 146 |
+
## Error Output Example
|
| 147 |
+
|
| 148 |
+
```
|
| 149 |
+
β FAILED: https://example.com/broken-link - HTTP 404
|
| 150 |
+
Found in: /path/to/file.md:42:15
|
| 151 |
+
Found in: /path/to/other.md:100:20
|
| 152 |
+
|
| 153 |
+
Link Verification Summary
|
| 154 |
+
============================================================
|
| 155 |
+
Total URLs checked: 150
|
| 156 |
+
Passed: 145
|
| 157 |
+
Failed: 2
|
| 158 |
+
Skipped: 3
|
| 159 |
+
|
| 160 |
+
Failed Links:
|
| 161 |
+
β’ https://example.com/broken-link
|
| 162 |
+
Error: HTTP 404
|
| 163 |
+
Occurrences: 2
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
## Requirements
|
| 167 |
+
|
| 168 |
+
- PowerShell 7+ (includes Markdig)
|
| 169 |
+
- Runs on: `ubuntu-latest`, `windows-latest`, `macos-latest`
|
| 170 |
+
|
| 171 |
+
## Broken Link Test
|
| 172 |
+
|
| 173 |
+
- [Broken Link](https://github.com/PowerShell/PowerShell/wiki/NonExistentPage404)
|
| 174 |
+
|
| 175 |
+
## License
|
| 176 |
+
|
| 177 |
+
Same as the PowerShell repository.
|
PowerShell-master/.github/actions/infrastructure/markdownlinks/Verify-MarkdownLinks.ps1
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Microsoft Corporation.
|
| 2 |
+
# Licensed under the MIT License.
|
| 3 |
+
|
| 4 |
+
#Requires -Version 7.0
|
| 5 |
+
|
| 6 |
+
<#
|
| 7 |
+
.SYNOPSIS
|
| 8 |
+
Verify all links in markdown files.
|
| 9 |
+
|
| 10 |
+
.DESCRIPTION
|
| 11 |
+
This script parses markdown files to extract links and verifies their accessibility.
|
| 12 |
+
It supports HTTP/HTTPS links and local file references.
|
| 13 |
+
|
| 14 |
+
.PARAMETER Path
|
| 15 |
+
Path to the directory containing markdown files. Defaults to current directory.
|
| 16 |
+
|
| 17 |
+
.PARAMETER File
|
| 18 |
+
Array of specific markdown files to verify. If provided, Path parameter is ignored.
|
| 19 |
+
|
| 20 |
+
.PARAMETER TimeoutSec
|
| 21 |
+
Timeout in seconds for HTTP requests. Defaults to 30.
|
| 22 |
+
|
| 23 |
+
.PARAMETER MaximumRetryCount
|
| 24 |
+
Maximum number of retries for failed requests. Defaults to 2.
|
| 25 |
+
|
| 26 |
+
.PARAMETER RetryIntervalSec
|
| 27 |
+
Interval in seconds between retry attempts. Defaults to 2.
|
| 28 |
+
|
| 29 |
+
.EXAMPLE
|
| 30 |
+
.\Verify-MarkdownLinks.ps1 -Path ./CHANGELOG
|
| 31 |
+
|
| 32 |
+
.EXAMPLE
|
| 33 |
+
.\Verify-MarkdownLinks.ps1 -Path ./docs -FailOnError
|
| 34 |
+
|
| 35 |
+
.EXAMPLE
|
| 36 |
+
.\Verify-MarkdownLinks.ps1 -File @('CHANGELOG/7.5.md', 'README.md')
|
| 37 |
+
#>
|
| 38 |
+
|
| 39 |
+
param(
|
| 40 |
+
[Parameter(ParameterSetName = 'ByPath', Mandatory)]
|
| 41 |
+
[string]$Path = "Q:\src\git\powershell\docs\git",
|
| 42 |
+
[Parameter(ParameterSetName = 'ByFile', Mandatory)]
|
| 43 |
+
[string[]]$File = @(),
|
| 44 |
+
[int]$TimeoutSec = 30,
|
| 45 |
+
[int]$MaximumRetryCount = 2,
|
| 46 |
+
[int]$RetryIntervalSec = 2
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
$ErrorActionPreference = 'Stop'
|
| 50 |
+
|
| 51 |
+
# Get the script directory
|
| 52 |
+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
| 53 |
+
|
| 54 |
+
# Determine what to process: specific files or directory
|
| 55 |
+
if ($File.Count -gt 0) {
|
| 56 |
+
Write-Host "Extracting links from $($File.Count) specified markdown file(s)" -ForegroundColor Cyan
|
| 57 |
+
|
| 58 |
+
# Process each file individually
|
| 59 |
+
$allLinks = @()
|
| 60 |
+
$parseScriptPath = Join-Path $scriptDir "Parse-MarkdownLink.ps1"
|
| 61 |
+
|
| 62 |
+
foreach ($filePath in $File) {
|
| 63 |
+
if (Test-Path $filePath) {
|
| 64 |
+
Write-Verbose "Processing: $filePath"
|
| 65 |
+
$fileLinks = & $parseScriptPath -ChangelogPath $filePath
|
| 66 |
+
$allLinks += $fileLinks
|
| 67 |
+
}
|
| 68 |
+
else {
|
| 69 |
+
Write-Warning "File not found: $filePath"
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
else {
|
| 74 |
+
Write-Host "Extracting links from markdown files in: $Path" -ForegroundColor Cyan
|
| 75 |
+
|
| 76 |
+
# Get all links from markdown files using the Parse-ChangelogLinks script
|
| 77 |
+
$parseScriptPath = Join-Path $scriptDir "Parse-MarkdownLink.ps1"
|
| 78 |
+
$allLinks = & $parseScriptPath -ChangelogPath $Path
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
if ($allLinks.Count -eq 0) {
|
| 82 |
+
Write-Host "No links found in markdown files." -ForegroundColor Yellow
|
| 83 |
+
exit 0
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
Write-Host "Found $($allLinks.Count) links to verify" -ForegroundColor Green
|
| 87 |
+
|
| 88 |
+
# Group links by URL to avoid duplicate checks
|
| 89 |
+
$uniqueLinks = $allLinks | Group-Object -Property Url
|
| 90 |
+
|
| 91 |
+
Write-Host "Unique URLs to verify: $($uniqueLinks.Count)" -ForegroundColor Cyan
|
| 92 |
+
|
| 93 |
+
$results = @{
|
| 94 |
+
Total = $uniqueLinks.Count
|
| 95 |
+
Passed = 0
|
| 96 |
+
Failed = 0
|
| 97 |
+
Skipped = 0
|
| 98 |
+
Errors = [System.Collections.ArrayList]::new()
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function Test-HttpLink {
|
| 102 |
+
param(
|
| 103 |
+
[string]$Url
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
try {
|
| 107 |
+
# Try HEAD request first (faster, doesn't download content)
|
| 108 |
+
$response = Invoke-WebRequest -Uri $Url `
|
| 109 |
+
-Method Head `
|
| 110 |
+
-TimeoutSec $TimeoutSec `
|
| 111 |
+
-MaximumRetryCount $MaximumRetryCount `
|
| 112 |
+
-RetryIntervalSec $RetryIntervalSec `
|
| 113 |
+
-UserAgent "Mozilla/5.0 (compatible; GitHubActions/1.0; +https://github.com/PowerShell/PowerShell)" `
|
| 114 |
+
-SkipHttpErrorCheck
|
| 115 |
+
|
| 116 |
+
# If HEAD fails with 404 or 405, retry with GET (some servers don't support HEAD)
|
| 117 |
+
if ($response.StatusCode -eq 404 -or $response.StatusCode -eq 405) {
|
| 118 |
+
Write-Verbose "HEAD request failed with $($response.StatusCode), retrying with GET for: $Url"
|
| 119 |
+
$response = Invoke-WebRequest -Uri $Url `
|
| 120 |
+
-Method Get `
|
| 121 |
+
-TimeoutSec $TimeoutSec `
|
| 122 |
+
-MaximumRetryCount $MaximumRetryCount `
|
| 123 |
+
-RetryIntervalSec $RetryIntervalSec `
|
| 124 |
+
-UserAgent "Mozilla/5.0 (compatible; GitHubActions/1.0; +https://github.com)" `
|
| 125 |
+
-SkipHttpErrorCheck
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
if ($response.StatusCode -ge 200 -and $response.StatusCode -lt 400) {
|
| 129 |
+
return @{ Success = $true; StatusCode = $response.StatusCode }
|
| 130 |
+
}
|
| 131 |
+
else {
|
| 132 |
+
return @{ Success = $false; StatusCode = $response.StatusCode; Error = "HTTP $($response.StatusCode)" }
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
catch {
|
| 136 |
+
return @{ Success = $false; StatusCode = 0; Error = $_.Exception.Message }
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
function Test-LocalLink {
|
| 141 |
+
param(
|
| 142 |
+
[string]$Url,
|
| 143 |
+
[string]$BasePath
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
# Strip query parameters (e.g., ?sanitize=true) and anchors (e.g., #section)
|
| 147 |
+
$cleanUrl = $Url -replace '\?.*$', '' -replace '#.*$', ''
|
| 148 |
+
|
| 149 |
+
# Handle relative paths
|
| 150 |
+
$targetPath = Join-Path $BasePath $cleanUrl
|
| 151 |
+
|
| 152 |
+
if (Test-Path $targetPath) {
|
| 153 |
+
return @{ Success = $true }
|
| 154 |
+
}
|
| 155 |
+
else {
|
| 156 |
+
return @{ Success = $false; Error = "File not found: $targetPath" }
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
# Verify each unique link
|
| 161 |
+
$progressCount = 0
|
| 162 |
+
foreach ($linkGroup in $uniqueLinks) {
|
| 163 |
+
$progressCount++
|
| 164 |
+
$url = $linkGroup.Name
|
| 165 |
+
$occurrences = $linkGroup.Group
|
| 166 |
+
Write-Verbose -Verbose "[$progressCount/$($uniqueLinks.Count)] Checking: $url"
|
| 167 |
+
|
| 168 |
+
# Determine link type and verify
|
| 169 |
+
$verifyResult = $null
|
| 170 |
+
if ($url -match '^https?://') {
|
| 171 |
+
$verifyResult = Test-HttpLink -Url $url
|
| 172 |
+
}
|
| 173 |
+
elseif ($url -match '^#') {
|
| 174 |
+
Write-Verbose -Verbose "Skipping anchor link: $url"
|
| 175 |
+
$results.Skipped++
|
| 176 |
+
continue
|
| 177 |
+
}
|
| 178 |
+
elseif ($url -match '^mailto:') {
|
| 179 |
+
Write-Verbose -Verbose "Skipping mailto link: $url"
|
| 180 |
+
$results.Skipped++
|
| 181 |
+
continue
|
| 182 |
+
}
|
| 183 |
+
else {
|
| 184 |
+
$basePath = Split-Path -Parent $occurrences[0].Path
|
| 185 |
+
$verifyResult = Test-LocalLink -Url $url -BasePath $basePath
|
| 186 |
+
}
|
| 187 |
+
if ($verifyResult.Success) {
|
| 188 |
+
Write-Host "β OK: $url" -ForegroundColor Green
|
| 189 |
+
$results.Passed++
|
| 190 |
+
}
|
| 191 |
+
else {
|
| 192 |
+
$errorMsg = if ($verifyResult.StatusCode) {
|
| 193 |
+
"HTTP $($verifyResult.StatusCode)"
|
| 194 |
+
}
|
| 195 |
+
else {
|
| 196 |
+
$verifyResult.Error
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
# Determine if this status code should be ignored or treated as failure
|
| 200 |
+
# Ignore: 401 (Unauthorized), 403 (Forbidden), 429 (Too Many Requests - already retried)
|
| 201 |
+
# Fail: 404 (Not Found), 410 (Gone), 406 (Not Acceptable) - these indicate broken links
|
| 202 |
+
$shouldIgnore = $false
|
| 203 |
+
$ignoreReason = ""
|
| 204 |
+
|
| 205 |
+
switch ($verifyResult.StatusCode) {
|
| 206 |
+
401 {
|
| 207 |
+
$shouldIgnore = $true
|
| 208 |
+
$ignoreReason = "authentication required"
|
| 209 |
+
}
|
| 210 |
+
403 {
|
| 211 |
+
$shouldIgnore = $true
|
| 212 |
+
$ignoreReason = "access forbidden"
|
| 213 |
+
}
|
| 214 |
+
429 {
|
| 215 |
+
$shouldIgnore = $true
|
| 216 |
+
$ignoreReason = "rate limited (already retried)"
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
if ($shouldIgnore) {
|
| 221 |
+
Write-Host "β IGNORED: $url - $errorMsg ($ignoreReason)" -ForegroundColor Yellow
|
| 222 |
+
Write-Verbose -Verbose "Ignored error details for $url - Status: $($verifyResult.StatusCode) - $ignoreReason"
|
| 223 |
+
foreach ($occurrence in $occurrences) {
|
| 224 |
+
Write-Verbose -Verbose " Found in: $($occurrence.Path):$($occurrence.Line):$($occurrence.Column)"
|
| 225 |
+
}
|
| 226 |
+
$results.Skipped++
|
| 227 |
+
}
|
| 228 |
+
else {
|
| 229 |
+
Write-Host "β FAILED: $url - $errorMsg" -ForegroundColor Red
|
| 230 |
+
foreach ($occurrence in $occurrences) {
|
| 231 |
+
Write-Host " Found in: $($occurrence.Path):$($occurrence.Line):$($occurrence.Column)" -ForegroundColor DarkGray
|
| 232 |
+
}
|
| 233 |
+
$results.Failed++
|
| 234 |
+
[void]$results.Errors.Add(@{
|
| 235 |
+
Url = $url
|
| 236 |
+
Error = $errorMsg
|
| 237 |
+
Occurrences = $occurrences
|
| 238 |
+
})
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
# Print summary
|
| 244 |
+
Write-Host "`n" + ("=" * 60) -ForegroundColor Cyan
|
| 245 |
+
Write-Host "Link Verification Summary" -ForegroundColor Cyan
|
| 246 |
+
Write-Host ("=" * 60) -ForegroundColor Cyan
|
| 247 |
+
Write-Host "Total URLs checked: $($results.Total)" -ForegroundColor White
|
| 248 |
+
Write-Host "Passed: $($results.Passed)" -ForegroundColor Green
|
| 249 |
+
Write-Host "Failed: $($results.Failed)" -ForegroundColor $(if ($results.Failed -gt 0) { "Red" } else { "Green" })
|
| 250 |
+
Write-Host "Skipped: $($results.Skipped)" -ForegroundColor Gray
|
| 251 |
+
|
| 252 |
+
if ($results.Failed -gt 0) {
|
| 253 |
+
Write-Host "`nFailed Links:" -ForegroundColor Red
|
| 254 |
+
foreach ($failedLink in $results.Errors) {
|
| 255 |
+
Write-Host " β’ $($failedLink.Url)" -ForegroundColor Red
|
| 256 |
+
Write-Host " Error: $($failedLink.Error)" -ForegroundColor DarkGray
|
| 257 |
+
Write-Host " Occurrences: $($failedLink.Occurrences.Count)" -ForegroundColor DarkGray
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
Write-Host "`nβ Link verification failed!" -ForegroundColor Red
|
| 261 |
+
exit 1
|
| 262 |
+
}
|
| 263 |
+
else {
|
| 264 |
+
Write-Host "`nβ
All links verified successfully!" -ForegroundColor Green
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
# Write to GitHub Actions step summary if running in a workflow
|
| 268 |
+
if ($env:GITHUB_STEP_SUMMARY) {
|
| 269 |
+
$summaryContent = @"
|
| 270 |
+
|
| 271 |
+
# Markdown Link Verification Results
|
| 272 |
+
|
| 273 |
+
## Summary
|
| 274 |
+
- **Total URLs checked:** $($results.Total)
|
| 275 |
+
- **Passed:** β
$($results.Passed)
|
| 276 |
+
- **Failed:** $(if ($results.Failed -gt 0) { "β" } else { "β
" }) $($results.Failed)
|
| 277 |
+
- **Skipped:** $($results.Skipped)
|
| 278 |
+
|
| 279 |
+
"@
|
| 280 |
+
|
| 281 |
+
if ($results.Failed -gt 0) {
|
| 282 |
+
$summaryContent += @"
|
| 283 |
+
|
| 284 |
+
## Failed Links
|
| 285 |
+
|
| 286 |
+
| URL | Error | Occurrences |
|
| 287 |
+
|-----|-------|-------------|
|
| 288 |
+
|
| 289 |
+
"@
|
| 290 |
+
foreach ($failedLink in $results.Errors) {
|
| 291 |
+
$summaryContent += "| $($failedLink.Url) | $($failedLink.Error) | $($failedLink.Occurrences.Count) |`n"
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
$summaryContent += @"
|
| 295 |
+
|
| 296 |
+
<details>
|
| 297 |
+
<summary>Click to see all failed link locations</summary>
|
| 298 |
+
|
| 299 |
+
"@
|
| 300 |
+
foreach ($failedLink in $results.Errors) {
|
| 301 |
+
$summaryContent += "`n### $($failedLink.Url)`n"
|
| 302 |
+
$summaryContent += "**Error:** $($failedLink.Error)`n`n"
|
| 303 |
+
foreach ($occurrence in $failedLink.Occurrences) {
|
| 304 |
+
$summaryContent += "- `$($occurrence.Path):$($occurrence.Line):$($occurrence.Column)`n"
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
+
$summaryContent += "`n</details>`n"
|
| 308 |
+
}
|
| 309 |
+
else {
|
| 310 |
+
$summaryContent += "`n## β
All links verified successfully!`n"
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
Write-Verbose -Verbose "Writing `n $summaryContent `n to ${env:GITHUB_STEP_SUMMARY}"
|
| 314 |
+
$summaryContent | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
|
| 315 |
+
Write-Verbose -Verbose "Summary written to GitHub Actions step summary"
|
| 316 |
+
}
|
| 317 |
+
|
PowerShell-master/.github/actions/infrastructure/markdownlinks/action.yml
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: 'Verify Markdown Links'
|
| 2 |
+
description: 'Verify all links in markdown files using PowerShell and Markdig'
|
| 3 |
+
author: 'PowerShell Team'
|
| 4 |
+
|
| 5 |
+
inputs:
|
| 6 |
+
timeout-sec:
|
| 7 |
+
description: 'Timeout in seconds for HTTP requests'
|
| 8 |
+
required: false
|
| 9 |
+
default: '30'
|
| 10 |
+
maximum-retry-count:
|
| 11 |
+
description: 'Maximum number of retries for failed requests'
|
| 12 |
+
required: false
|
| 13 |
+
default: '2'
|
| 14 |
+
|
| 15 |
+
outputs:
|
| 16 |
+
total-links:
|
| 17 |
+
description: 'Total number of unique links checked'
|
| 18 |
+
value: ${{ steps.verify.outputs.total }}
|
| 19 |
+
passed-links:
|
| 20 |
+
description: 'Number of links that passed verification'
|
| 21 |
+
value: ${{ steps.verify.outputs.passed }}
|
| 22 |
+
failed-links:
|
| 23 |
+
description: 'Number of links that failed verification'
|
| 24 |
+
value: ${{ steps.verify.outputs.failed }}
|
| 25 |
+
skipped-links:
|
| 26 |
+
description: 'Number of links that were skipped'
|
| 27 |
+
value: ${{ steps.verify.outputs.skipped }}
|
| 28 |
+
|
| 29 |
+
runs:
|
| 30 |
+
using: 'composite'
|
| 31 |
+
steps:
|
| 32 |
+
- name: Get changed markdown files
|
| 33 |
+
id: changed-files
|
| 34 |
+
uses: "./.github/actions/infrastructure/get-changed-files"
|
| 35 |
+
with:
|
| 36 |
+
filter: '*.md'
|
| 37 |
+
event-types: 'pull_request,push'
|
| 38 |
+
|
| 39 |
+
- name: Verify markdown links
|
| 40 |
+
id: verify
|
| 41 |
+
shell: pwsh
|
| 42 |
+
env:
|
| 43 |
+
CHANGED_FILES_JSON: ${{ steps.changed-files.outputs.files }}
|
| 44 |
+
run: |
|
| 45 |
+
Write-Host "Starting markdown link verification..." -ForegroundColor Cyan
|
| 46 |
+
|
| 47 |
+
# Get changed markdown files from environment variable (secure against injection)
|
| 48 |
+
$changedFilesJson = $env:CHANGED_FILES_JSON
|
| 49 |
+
$changedFiles = $changedFilesJson | ConvertFrom-Json
|
| 50 |
+
|
| 51 |
+
if ($changedFiles.Count -eq 0) {
|
| 52 |
+
Write-Host "No markdown files changed, skipping verification" -ForegroundColor Yellow
|
| 53 |
+
"total=0" >> $env:GITHUB_OUTPUT
|
| 54 |
+
"passed=0" >> $env:GITHUB_OUTPUT
|
| 55 |
+
"failed=0" >> $env:GITHUB_OUTPUT
|
| 56 |
+
"skipped=0" >> $env:GITHUB_OUTPUT
|
| 57 |
+
exit 0
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
Write-Host "Changed markdown files: $($changedFiles.Count)" -ForegroundColor Cyan
|
| 61 |
+
$changedFiles | ForEach-Object { Write-Host " - $_" -ForegroundColor Gray }
|
| 62 |
+
|
| 63 |
+
# Build parameters for each file
|
| 64 |
+
$params = @{
|
| 65 |
+
File = $changedFiles
|
| 66 |
+
TimeoutSec = [int]'${{ inputs.timeout-sec }}'
|
| 67 |
+
MaximumRetryCount = [int]'${{ inputs.maximum-retry-count }}'
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
# Run the verification script
|
| 71 |
+
$scriptPath = Join-Path '${{ github.action_path }}' 'Verify-MarkdownLinks.ps1'
|
| 72 |
+
|
| 73 |
+
# Capture output and parse results
|
| 74 |
+
$output = & $scriptPath @params 2>&1 | Tee-Object -Variable capturedOutput
|
| 75 |
+
|
| 76 |
+
# Try to extract metrics from output
|
| 77 |
+
$totalLinks = 0
|
| 78 |
+
$passedLinks = 0
|
| 79 |
+
$failedLinks = 0
|
| 80 |
+
$skippedLinks = 0
|
| 81 |
+
|
| 82 |
+
foreach ($line in $capturedOutput) {
|
| 83 |
+
if ($line -match 'Total URLs checked: (\d+)') {
|
| 84 |
+
$totalLinks = $Matches[1]
|
| 85 |
+
}
|
| 86 |
+
elseif ($line -match 'Passed: (\d+)') {
|
| 87 |
+
$passedLinks = $Matches[1]
|
| 88 |
+
}
|
| 89 |
+
elseif ($line -match 'Failed: (\d+)') {
|
| 90 |
+
$failedLinks = $Matches[1]
|
| 91 |
+
}
|
| 92 |
+
elseif ($line -match 'Skipped: (\d+)') {
|
| 93 |
+
$skippedLinks = $Matches[1]
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
# Set outputs
|
| 98 |
+
"total=$totalLinks" >> $env:GITHUB_OUTPUT
|
| 99 |
+
"passed=$passedLinks" >> $env:GITHUB_OUTPUT
|
| 100 |
+
"failed=$failedLinks" >> $env:GITHUB_OUTPUT
|
| 101 |
+
"skipped=$skippedLinks" >> $env:GITHUB_OUTPUT
|
| 102 |
+
|
| 103 |
+
Write-Host "Action completed" -ForegroundColor Cyan
|
| 104 |
+
|
| 105 |
+
# Exit with the same code as the verification script
|
| 106 |
+
exit $LASTEXITCODE
|
| 107 |
+
|
| 108 |
+
branding:
|
| 109 |
+
icon: 'link'
|
| 110 |
+
color: 'blue'
|
PowerShell-master/.github/actions/infrastructure/merge-conflict-checker/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Merge Conflict Checker
|
| 2 |
+
|
| 3 |
+
This composite GitHub Action checks for Git merge conflict markers in files changed in pull requests.
|
| 4 |
+
|
| 5 |
+
## Purpose
|
| 6 |
+
|
| 7 |
+
Automatically detects leftover merge conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) in pull request files to prevent them from being merged into the codebase.
|
| 8 |
+
|
| 9 |
+
## Usage
|
| 10 |
+
|
| 11 |
+
### In a Workflow
|
| 12 |
+
|
| 13 |
+
```yaml
|
| 14 |
+
- name: Check for merge conflict markers
|
| 15 |
+
uses: "./.github/actions/infrastructure/merge-conflict-checker"
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
### Complete Example
|
| 19 |
+
|
| 20 |
+
```yaml
|
| 21 |
+
jobs:
|
| 22 |
+
merge_conflict_check:
|
| 23 |
+
name: Check for Merge Conflict Markers
|
| 24 |
+
runs-on: ubuntu-latest
|
| 25 |
+
if: github.event_name == 'pull_request'
|
| 26 |
+
permissions:
|
| 27 |
+
pull-requests: read
|
| 28 |
+
contents: read
|
| 29 |
+
steps:
|
| 30 |
+
- name: checkout
|
| 31 |
+
uses: actions/checkout@v5
|
| 32 |
+
|
| 33 |
+
- name: Check for merge conflict markers
|
| 34 |
+
uses: "./.github/actions/infrastructure/merge-conflict-checker"
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
## How It Works
|
| 38 |
+
|
| 39 |
+
1. **File Detection**: Uses GitHub's API to get the list of files changed in the pull request
|
| 40 |
+
2. **Marker Scanning**: Reads each changed file and searches for the following markers:
|
| 41 |
+
- `<<<<<<<` (conflict start marker)
|
| 42 |
+
- `=======` (conflict separator)
|
| 43 |
+
- `>>>>>>>` (conflict end marker)
|
| 44 |
+
3. **Result Reporting**:
|
| 45 |
+
- If markers are found, the action fails and lists all affected files
|
| 46 |
+
- If no markers are found, the action succeeds
|
| 47 |
+
|
| 48 |
+
## Outputs
|
| 49 |
+
|
| 50 |
+
- `files-checked`: Number of files that were checked
|
| 51 |
+
- `conflicts-found`: Number of files containing merge conflict markers
|
| 52 |
+
|
| 53 |
+
## Behavior
|
| 54 |
+
|
| 55 |
+
- **Event Support**: Only works with `pull_request` events
|
| 56 |
+
- **File Handling**:
|
| 57 |
+
- Checks only files that were added, modified, or renamed
|
| 58 |
+
- Skips deleted files
|
| 59 |
+
- **Filters out `*.cs` files** (C# files are excluded from merge conflict checking)
|
| 60 |
+
- Skips binary/unreadable files
|
| 61 |
+
- Skips directories
|
| 62 |
+
- **Empty File List**: Gracefully handles cases where no files need checking (e.g., PRs that only delete files)
|
| 63 |
+
|
| 64 |
+
## Example Output
|
| 65 |
+
|
| 66 |
+
When conflict markers are detected:
|
| 67 |
+
|
| 68 |
+
```
|
| 69 |
+
β Merge conflict markers detected in the following files:
|
| 70 |
+
- src/example.cs
|
| 71 |
+
Markers found: <<<<<<<, =======, >>>>>>>
|
| 72 |
+
- README.md
|
| 73 |
+
Markers found: <<<<<<<, =======, >>>>>>>
|
| 74 |
+
|
| 75 |
+
Please resolve these conflicts before merging.
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
When no markers are found:
|
| 79 |
+
|
| 80 |
+
```
|
| 81 |
+
β
No merge conflict markers found
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## Integration
|
| 85 |
+
|
| 86 |
+
This action is integrated into the `linux-ci.yml` workflow and runs automatically on all pull requests to ensure code quality before merging.
|
PowerShell-master/.github/actions/infrastructure/merge-conflict-checker/action.yml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: 'Check for Merge Conflict Markers'
|
| 2 |
+
description: 'Checks for Git merge conflict markers in changed files for pull requests'
|
| 3 |
+
author: 'PowerShell Team'
|
| 4 |
+
|
| 5 |
+
outputs:
|
| 6 |
+
files-checked:
|
| 7 |
+
description: 'Number of files checked for merge conflict markers'
|
| 8 |
+
value: ${{ steps.check.outputs.files-checked }}
|
| 9 |
+
conflicts-found:
|
| 10 |
+
description: 'Number of files with merge conflict markers'
|
| 11 |
+
value: ${{ steps.check.outputs.conflicts-found }}
|
| 12 |
+
|
| 13 |
+
runs:
|
| 14 |
+
using: 'composite'
|
| 15 |
+
steps:
|
| 16 |
+
- name: Get changed files
|
| 17 |
+
id: changed-files
|
| 18 |
+
uses: "./.github/actions/infrastructure/get-changed-files"
|
| 19 |
+
|
| 20 |
+
- name: Check for merge conflict markers
|
| 21 |
+
id: check
|
| 22 |
+
shell: pwsh
|
| 23 |
+
env:
|
| 24 |
+
CHANGED_FILES_JSON: ${{ steps.changed-files.outputs.files }}
|
| 25 |
+
run: |
|
| 26 |
+
# Get changed files from environment variable (secure against injection)
|
| 27 |
+
$changedFilesJson = $env:CHANGED_FILES_JSON
|
| 28 |
+
# Ensure we always have an array (ConvertFrom-Json returns null for empty JSON arrays)
|
| 29 |
+
$changedFiles = @($changedFilesJson | ConvertFrom-Json)
|
| 30 |
+
|
| 31 |
+
# Import ci.psm1 and run the check
|
| 32 |
+
Import-Module "$env:GITHUB_WORKSPACE/tools/ci.psm1" -Force
|
| 33 |
+
Test-MergeConflictMarker -File $changedFiles -WorkspacePath $env:GITHUB_WORKSPACE
|
| 34 |
+
|
| 35 |
+
branding:
|
| 36 |
+
icon: 'alert-triangle'
|
| 37 |
+
color: 'red'
|
PowerShell-master/.github/actions/infrastructure/path-filters/action.yml
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Path Filters
|
| 2 |
+
description: 'Path Filters'
|
| 3 |
+
inputs:
|
| 4 |
+
GITHUB_TOKEN:
|
| 5 |
+
description: 'GitHub token'
|
| 6 |
+
required: true
|
| 7 |
+
outputs:
|
| 8 |
+
source:
|
| 9 |
+
description: 'Source code changes (composite of all changes)'
|
| 10 |
+
value: ${{ steps.filter.outputs.source }}
|
| 11 |
+
githubChanged:
|
| 12 |
+
description: 'GitHub workflow changes'
|
| 13 |
+
value: ${{ steps.filter.outputs.githubChanged }}
|
| 14 |
+
toolsChanged:
|
| 15 |
+
description: 'Tools changes'
|
| 16 |
+
value: ${{ steps.filter.outputs.toolsChanged }}
|
| 17 |
+
propsChanged:
|
| 18 |
+
description: 'Props changes'
|
| 19 |
+
value: ${{ steps.filter.outputs.propsChanged }}
|
| 20 |
+
testsChanged:
|
| 21 |
+
description: 'Tests changes'
|
| 22 |
+
value: ${{ steps.filter.outputs.testsChanged }}
|
| 23 |
+
mainSourceChanged:
|
| 24 |
+
description: 'Main source code changes (any changes in src/)'
|
| 25 |
+
value: ${{ steps.filter.outputs.mainSourceChanged }}
|
| 26 |
+
buildModuleChanged:
|
| 27 |
+
description: 'Build module changes'
|
| 28 |
+
value: ${{ steps.filter.outputs.buildModuleChanged }}
|
| 29 |
+
packagingChanged:
|
| 30 |
+
description: 'Packaging related changes'
|
| 31 |
+
value: ${{ steps.filter.outputs.packagingChanged }}
|
| 32 |
+
runs:
|
| 33 |
+
using: composite
|
| 34 |
+
steps:
|
| 35 |
+
- name: Get changed files
|
| 36 |
+
id: get-files
|
| 37 |
+
if: github.event_name == 'pull_request'
|
| 38 |
+
uses: "./.github/actions/infrastructure/get-changed-files"
|
| 39 |
+
|
| 40 |
+
- name: Check if GitHubWorkflowChanges is present
|
| 41 |
+
id: filter
|
| 42 |
+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
| 43 |
+
env:
|
| 44 |
+
FILES_JSON: ${{ steps.get-files.outputs.files }}
|
| 45 |
+
with:
|
| 46 |
+
github-token: ${{ inputs.GITHUB_TOKEN }}
|
| 47 |
+
script: |
|
| 48 |
+
console.log(`Event Name: ${context.eventName}`);
|
| 49 |
+
|
| 50 |
+
// Just say everything changed if this is not a PR
|
| 51 |
+
if (context.eventName !== 'pull_request') {
|
| 52 |
+
console.log('Not a pull request, setting all outputs to true');
|
| 53 |
+
core.setOutput('toolsChanged', true);
|
| 54 |
+
core.setOutput('githubChanged', true);
|
| 55 |
+
core.setOutput('propsChanged', true);
|
| 56 |
+
core.setOutput('testsChanged', true);
|
| 57 |
+
core.setOutput('mainSourceChanged', true);
|
| 58 |
+
core.setOutput('buildModuleChanged', true);
|
| 59 |
+
core.setOutput('source', true);
|
| 60 |
+
return;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
// Get files from environment variable (secure against injection)
|
| 64 |
+
const files = JSON.parse(process.env.FILES_JSON || '[]');
|
| 65 |
+
|
| 66 |
+
// Calculate hash for verification (matches get-changed-files action)
|
| 67 |
+
const crypto = require('crypto');
|
| 68 |
+
const filesJson = JSON.stringify(files.sort());
|
| 69 |
+
const hash = crypto.createHash('sha256').update(filesJson).digest('hex').substring(0, 8);
|
| 70 |
+
console.log(`Received ${files.length} files (hash: ${hash})`);
|
| 71 |
+
|
| 72 |
+
// Analyze changes with detailed logging
|
| 73 |
+
core.startGroup('Path Filter Analysis');
|
| 74 |
+
|
| 75 |
+
const actionsChanged = files.some(file => file.startsWith('.github/actions'));
|
| 76 |
+
console.log(`β Actions changed: ${actionsChanged}`);
|
| 77 |
+
|
| 78 |
+
const workflowsChanged = files.some(file => file.startsWith('.github/workflows'));
|
| 79 |
+
console.log(`β Workflows changed: ${workflowsChanged}`);
|
| 80 |
+
|
| 81 |
+
const githubChanged = actionsChanged || workflowsChanged;
|
| 82 |
+
console.log(`β GitHub changed (actions OR workflows): ${githubChanged}`);
|
| 83 |
+
|
| 84 |
+
const toolsCiPsm1Changed = files.some(file => file === 'tools/ci.psm1');
|
| 85 |
+
console.log(`β tools/ci.psm1 changed: ${toolsCiPsm1Changed}`);
|
| 86 |
+
|
| 87 |
+
const toolsBuildCommonChanged = files.some(file => file.startsWith('tools/buildCommon/'));
|
| 88 |
+
console.log(`β tools/buildCommon/ changed: ${toolsBuildCommonChanged}`);
|
| 89 |
+
|
| 90 |
+
const toolsChanged = toolsCiPsm1Changed || toolsBuildCommonChanged;
|
| 91 |
+
console.log(`β Tools changed: ${toolsChanged}`);
|
| 92 |
+
|
| 93 |
+
const propsChanged = files.some(file => file.endsWith('.props'));
|
| 94 |
+
console.log(`β Props files changed: ${propsChanged}`);
|
| 95 |
+
|
| 96 |
+
const testsChanged = files.some(file => file.startsWith('test/powershell/') || file.startsWith('test/tools/') || file.startsWith('test/xUnit/'));
|
| 97 |
+
console.log(`β Tests changed: ${testsChanged}`);
|
| 98 |
+
|
| 99 |
+
const mainSourceChanged = files.some(file => file.startsWith('src/'));
|
| 100 |
+
console.log(`β Main source (src/) changed: ${mainSourceChanged}`);
|
| 101 |
+
|
| 102 |
+
const buildModuleChanged = files.some(file => file === 'build.psm1');
|
| 103 |
+
console.log(`β build.psm1 changed: ${buildModuleChanged}`);
|
| 104 |
+
|
| 105 |
+
const globalConfigChanged = files.some(file => file === '.globalconfig' || file === 'nuget.config' || file === 'global.json');
|
| 106 |
+
console.log(`β Global config changed: ${globalConfigChanged}`);
|
| 107 |
+
|
| 108 |
+
const packagingChanged = files.some(file =>
|
| 109 |
+
file === '.github/workflows/windows-ci.yml' ||
|
| 110 |
+
file === '.github/workflows/linux-ci.yml' ||
|
| 111 |
+
file.startsWith('assets/wix/') ||
|
| 112 |
+
file === 'PowerShell.Common.props' ||
|
| 113 |
+
file.match(/^src\/.*\.csproj$/) ||
|
| 114 |
+
file.startsWith('test/packaging/windows/') ||
|
| 115 |
+
file.startsWith('test/packaging/linux/') ||
|
| 116 |
+
file.startsWith('tools/packaging/') ||
|
| 117 |
+
file.startsWith('tools/wix/')
|
| 118 |
+
) ||
|
| 119 |
+
buildModuleChanged ||
|
| 120 |
+
globalConfigChanged ||
|
| 121 |
+
toolsCiPsm1Changed;
|
| 122 |
+
console.log(`β Packaging changed: ${packagingChanged}`);
|
| 123 |
+
|
| 124 |
+
const source = mainSourceChanged || toolsChanged || githubChanged || propsChanged || testsChanged || globalConfigChanged;
|
| 125 |
+
console.log(`β Source (composite): ${source}`);
|
| 126 |
+
|
| 127 |
+
core.endGroup();
|
| 128 |
+
|
| 129 |
+
core.setOutput('toolsChanged', toolsChanged);
|
| 130 |
+
core.setOutput('githubChanged', githubChanged);
|
| 131 |
+
core.setOutput('propsChanged', propsChanged);
|
| 132 |
+
core.setOutput('testsChanged', testsChanged);
|
| 133 |
+
core.setOutput('mainSourceChanged', mainSourceChanged);
|
| 134 |
+
core.setOutput('buildModuleChanged', buildModuleChanged);
|
| 135 |
+
core.setOutput('globalConfigChanged', globalConfigChanged);
|
| 136 |
+
core.setOutput('packagingChanged', packagingChanged);
|
| 137 |
+
core.setOutput('source', source);
|
PowerShell-master/.github/actions/test/linux-packaging/action.yml
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: linux_packaging
|
| 2 |
+
description: 'Linux packaging for PowerShell'
|
| 3 |
+
|
| 4 |
+
runs:
|
| 5 |
+
using: composite
|
| 6 |
+
steps:
|
| 7 |
+
- name: Capture Environment
|
| 8 |
+
if: success() || failure()
|
| 9 |
+
run: |-
|
| 10 |
+
Import-Module ./tools/ci.psm1
|
| 11 |
+
Show-Environment
|
| 12 |
+
shell: pwsh
|
| 13 |
+
|
| 14 |
+
- uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
|
| 15 |
+
with:
|
| 16 |
+
global-json-file: ./global.json
|
| 17 |
+
|
| 18 |
+
- name: Bootstrap
|
| 19 |
+
run: |-
|
| 20 |
+
Import-Module ./build.psm1
|
| 21 |
+
Start-PSBootstrap -Scenario Package
|
| 22 |
+
Import-Module ./tools/ci.psm1
|
| 23 |
+
Invoke-CIInstall -SkipUser
|
| 24 |
+
shell: pwsh
|
| 25 |
+
|
| 26 |
+
- name: Build and Package
|
| 27 |
+
run: |-
|
| 28 |
+
Import-Module ./tools/ci.psm1
|
| 29 |
+
$releaseTag = Get-ReleaseTag
|
| 30 |
+
Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag
|
| 31 |
+
Invoke-CIFinish
|
| 32 |
+
shell: pwsh
|
| 33 |
+
|
| 34 |
+
- name: Install Pester
|
| 35 |
+
run: |-
|
| 36 |
+
Import-Module ./tools/ci.psm1
|
| 37 |
+
Install-CIPester
|
| 38 |
+
shell: pwsh
|
| 39 |
+
|
| 40 |
+
- name: Validate Package Names
|
| 41 |
+
run: |-
|
| 42 |
+
# Run Pester tests to validate package names
|
| 43 |
+
Import-Module Pester -Force
|
| 44 |
+
$testResults = Invoke-Pester -Path ./test/packaging/linux/package-validation.tests.ps1 -PassThru
|
| 45 |
+
if ($testResults.FailedCount -gt 0) {
|
| 46 |
+
throw "Package validation tests failed"
|
| 47 |
+
}
|
| 48 |
+
shell: pwsh
|
| 49 |
+
|
| 50 |
+
- name: Upload deb packages
|
| 51 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
| 52 |
+
with:
|
| 53 |
+
name: packages-deb
|
| 54 |
+
path: ${{ runner.workspace }}/packages/*.deb
|
| 55 |
+
if-no-files-found: ignore
|
| 56 |
+
|
| 57 |
+
- name: Upload rpm packages
|
| 58 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
| 59 |
+
with:
|
| 60 |
+
name: packages-rpm
|
| 61 |
+
path: ${{ runner.workspace }}/packages/*.rpm
|
| 62 |
+
if-no-files-found: ignore
|
| 63 |
+
|
| 64 |
+
- name: Upload tar.gz packages
|
| 65 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
| 66 |
+
with:
|
| 67 |
+
name: packages-tar
|
| 68 |
+
path: ${{ runner.workspace }}/packages/*.tar.gz
|
| 69 |
+
if-no-files-found: ignore
|
PowerShell-master/.github/actions/test/nix/action.yml
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: nix_test
|
| 2 |
+
description: 'Test PowerShell on non-Windows platforms'
|
| 3 |
+
|
| 4 |
+
inputs:
|
| 5 |
+
purpose:
|
| 6 |
+
required: false
|
| 7 |
+
default: ''
|
| 8 |
+
type: string
|
| 9 |
+
tagSet:
|
| 10 |
+
required: false
|
| 11 |
+
default: CI
|
| 12 |
+
type: string
|
| 13 |
+
ctrfFolder:
|
| 14 |
+
required: false
|
| 15 |
+
default: ctrf
|
| 16 |
+
type: string
|
| 17 |
+
GITHUB_TOKEN:
|
| 18 |
+
description: 'GitHub token for API authentication'
|
| 19 |
+
required: true
|
| 20 |
+
|
| 21 |
+
runs:
|
| 22 |
+
using: composite
|
| 23 |
+
steps:
|
| 24 |
+
- name: Capture Environment
|
| 25 |
+
if: success() || failure()
|
| 26 |
+
run: |-
|
| 27 |
+
Import-Module ./tools/ci.psm1
|
| 28 |
+
Show-Environment
|
| 29 |
+
shell: pwsh
|
| 30 |
+
|
| 31 |
+
- name: Download Build Artifacts
|
| 32 |
+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
| 33 |
+
with:
|
| 34 |
+
path: "${{ github.workspace }}"
|
| 35 |
+
|
| 36 |
+
- name: Capture Artifacts Directory
|
| 37 |
+
continue-on-error: true
|
| 38 |
+
run: |-
|
| 39 |
+
Import-Module ./build.psm1
|
| 40 |
+
Write-LogGroupStart -Title 'Artifacts Directory'
|
| 41 |
+
Get-ChildItem "${{ github.workspace }}/build/*" -Recurse
|
| 42 |
+
Write-LogGroupEnd -Title 'Artifacts Directory'
|
| 43 |
+
shell: pwsh
|
| 44 |
+
|
| 45 |
+
- uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
|
| 46 |
+
with:
|
| 47 |
+
global-json-file: ./global.json
|
| 48 |
+
|
| 49 |
+
- name: Set Package Name by Platform
|
| 50 |
+
id: set_package_name
|
| 51 |
+
shell: pwsh
|
| 52 |
+
run: |-
|
| 53 |
+
Import-Module ./.github/workflows/GHWorkflowHelper/GHWorkflowHelper.psm1
|
| 54 |
+
$platform = $env:RUNNER_OS
|
| 55 |
+
Write-Host "Runner platform: $platform"
|
| 56 |
+
if ($platform -eq 'Linux') {
|
| 57 |
+
$packageName = 'DSC-*-x86_64-linux.tar.gz'
|
| 58 |
+
} elseif ($platform -eq 'macOS') {
|
| 59 |
+
$packageName = 'DSC-*-x86_64-apple-darwin.tar.gz'
|
| 60 |
+
} else {
|
| 61 |
+
throw "Unsupported platform: $platform"
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
Set-GWVariable -Name "DSC_PACKAGE_NAME" -Value $packageName
|
| 65 |
+
|
| 66 |
+
- name: Get Latest DSC Package Version
|
| 67 |
+
shell: pwsh
|
| 68 |
+
run: |-
|
| 69 |
+
Import-Module ./.github/workflows/GHWorkflowHelper/GHWorkflowHelper.psm1
|
| 70 |
+
$headers = @{
|
| 71 |
+
Authorization = "Bearer ${{ inputs.GITHUB_TOKEN }}"
|
| 72 |
+
}
|
| 73 |
+
$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/PowerShell/Dsc/releases" -Headers $headers
|
| 74 |
+
$latestRelease = $releases | Where-Object { $v = $_.name.trim("v"); $semVer = [System.Management.Automation.SemanticVersion]::new($v); if ($semVer.Major -eq 3 -and $semVer.Minor -ge 2) { $_ } } | Select-Object -First 1
|
| 75 |
+
$latestVersion = $latestRelease.tag_name.TrimStart("v")
|
| 76 |
+
Write-Host "Latest DSC Version: $latestVersion"
|
| 77 |
+
|
| 78 |
+
$packageName = "$env:DSC_PACKAGE_NAME"
|
| 79 |
+
|
| 80 |
+
Write-Host "Package Name: $packageName"
|
| 81 |
+
|
| 82 |
+
$downloadUrl = $latestRelease.assets | Where-Object { $_.name -like "*$packageName*" } | Select-Object -First 1 | Select-Object -ExpandProperty browser_download_url
|
| 83 |
+
Write-Host "Download URL: $downloadUrl"
|
| 84 |
+
|
| 85 |
+
$tempPath = Get-GWTempPath
|
| 86 |
+
|
| 87 |
+
Invoke-RestMethod -Uri $downloadUrl -OutFile "$tempPath/DSC.tar.gz" -Verbose -Headers $headers
|
| 88 |
+
New-Item -ItemType Directory -Path "$tempPath/DSC" -Force -Verbose
|
| 89 |
+
tar xvf "$tempPath/DSC.tar.gz" -C "$tempPath/DSC"
|
| 90 |
+
$dscRoot = "$tempPath/DSC"
|
| 91 |
+
Write-Host "DSC Root: $dscRoot"
|
| 92 |
+
Set-GWVariable -Name "DSC_ROOT" -Value $dscRoot
|
| 93 |
+
|
| 94 |
+
- name: Bootstrap
|
| 95 |
+
shell: pwsh
|
| 96 |
+
run: |-
|
| 97 |
+
Import-Module ./build.psm1
|
| 98 |
+
Write-LogGroupStart -Title 'Bootstrap'
|
| 99 |
+
Import-Module ./tools/ci.psm1
|
| 100 |
+
Invoke-CIInstall -SkipUser
|
| 101 |
+
Write-LogGroupEnd -Title 'Bootstrap'
|
| 102 |
+
|
| 103 |
+
- name: Extract Files
|
| 104 |
+
uses: actions/github-script@e69ef5462fd455e02edcaf4dd7708eda96b9eda0 # v7.0.0
|
| 105 |
+
env:
|
| 106 |
+
DESTINATION_FOLDER: "${{ github.workspace }}/bins"
|
| 107 |
+
ARCHIVE_FILE_PATTERNS: "${{ github.workspace }}/build/build.zip"
|
| 108 |
+
with:
|
| 109 |
+
script: |-
|
| 110 |
+
const fs = require('fs').promises
|
| 111 |
+
const path = require('path')
|
| 112 |
+
const target = path.resolve(process.env.DESTINATION_FOLDER)
|
| 113 |
+
const patterns = process.env.ARCHIVE_FILE_PATTERNS
|
| 114 |
+
const globber = await glob.create(patterns)
|
| 115 |
+
await io.mkdirP(path.dirname(target))
|
| 116 |
+
for await (const file of globber.globGenerator()) {
|
| 117 |
+
if ((await fs.lstat(file)).isDirectory()) continue
|
| 118 |
+
await exec.exec(`7z x ${file} -o${target} -aoa`)
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
- name: Fix permissions
|
| 122 |
+
continue-on-error: true
|
| 123 |
+
run: |-
|
| 124 |
+
find "${{ github.workspace }}/bins" -type d -exec chmod +rwx {} \;
|
| 125 |
+
find "${{ github.workspace }}/bins" -type f -exec chmod +rw {} \;
|
| 126 |
+
shell: bash
|
| 127 |
+
|
| 128 |
+
- name: Capture Extracted Build ZIP
|
| 129 |
+
continue-on-error: true
|
| 130 |
+
run: |-
|
| 131 |
+
Import-Module ./build.psm1
|
| 132 |
+
Write-LogGroupStart -Title 'Extracted Build ZIP'
|
| 133 |
+
Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue
|
| 134 |
+
Write-LogGroupEnd -Title 'Extracted Build ZIP'
|
| 135 |
+
shell: pwsh
|
| 136 |
+
|
| 137 |
+
- name: Test
|
| 138 |
+
if: success()
|
| 139 |
+
run: |-
|
| 140 |
+
Import-Module ./tools/ci.psm1
|
| 141 |
+
Restore-PSOptions -PSOptionsPath '${{ github.workspace }}/build/psoptions.json'
|
| 142 |
+
$options = (Get-PSOptions)
|
| 143 |
+
$rootPath = '${{ github.workspace }}/bins'
|
| 144 |
+
$originalRootPath = Split-Path -path $options.Output
|
| 145 |
+
$path = Join-Path -path $rootPath -ChildPath (split-path -leaf -path $originalRootPath)
|
| 146 |
+
$pwshPath = Join-Path -path $path -ChildPath 'pwsh'
|
| 147 |
+
chmod a+x $pwshPath
|
| 148 |
+
$options.Output = $pwshPath
|
| 149 |
+
Set-PSOptions $options
|
| 150 |
+
Invoke-CITest -Purpose '${{ inputs.purpose }}' -TagSet '${{ inputs.tagSet }}' -TitlePrefix '${{ inputs.buildName }}' -OutputFormat NUnitXml
|
| 151 |
+
shell: pwsh
|
| 152 |
+
|
| 153 |
+
- name: Convert, Publish, and Upload Pester Test Results
|
| 154 |
+
uses: "./.github/actions/test/process-pester-results"
|
| 155 |
+
with:
|
| 156 |
+
name: "${{ inputs.purpose }}-${{ inputs.tagSet }}"
|
| 157 |
+
testResultsFolder: "${{ runner.workspace }}/testResults"
|
| 158 |
+
ctrfFolder: "${{ inputs.ctrfFolder }}"
|
PowerShell-master/.github/actions/test/process-pester-results/action.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: process-pester-test-results
|
| 2 |
+
description: 'Process Pester test results'
|
| 3 |
+
|
| 4 |
+
inputs:
|
| 5 |
+
name:
|
| 6 |
+
required: true
|
| 7 |
+
default: ''
|
| 8 |
+
type: string
|
| 9 |
+
testResultsFolder:
|
| 10 |
+
required: false
|
| 11 |
+
default: "${{ runner.workspace }}/testResults"
|
| 12 |
+
type: string
|
| 13 |
+
|
| 14 |
+
runs:
|
| 15 |
+
using: composite
|
| 16 |
+
steps:
|
| 17 |
+
- name: Log Summary
|
| 18 |
+
run: |-
|
| 19 |
+
& "$env:GITHUB_ACTION_PATH/process-pester-results.ps1" -Name '${{ inputs.name }}' -TestResultsFolder '${{ inputs.testResultsFolder }}'
|
| 20 |
+
shell: pwsh
|
| 21 |
+
|
| 22 |
+
- name: Upload testResults artifact
|
| 23 |
+
if: always()
|
| 24 |
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
| 25 |
+
with:
|
| 26 |
+
name: junit-pester-${{ inputs.name }}
|
| 27 |
+
path: ${{ runner.workspace }}/testResults
|
PowerShell-master/.github/actions/test/process-pester-results/process-pester-results.ps1
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Microsoft Corporation.
|
| 2 |
+
# Licensed under the MIT License.
|
| 3 |
+
|
| 4 |
+
param(
|
| 5 |
+
[parameter(Mandatory)]
|
| 6 |
+
[string]$Name,
|
| 7 |
+
[parameter(Mandatory)]
|
| 8 |
+
[string]$TestResultsFolder
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
Import-Module "$PSScriptRoot/../../../../build.psm1"
|
| 12 |
+
|
| 13 |
+
if (-not $env:GITHUB_STEP_SUMMARY) {
|
| 14 |
+
Write-Error "GITHUB_STEP_SUMMARY is not set. Ensure this workflow is running in a GitHub Actions environment."
|
| 15 |
+
exit 1
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
$testCaseCount = 0
|
| 19 |
+
$testErrorCount = 0
|
| 20 |
+
$testFailureCount = 0
|
| 21 |
+
$testNotRunCount = 0
|
| 22 |
+
$testInconclusiveCount = 0
|
| 23 |
+
$testIgnoredCount = 0
|
| 24 |
+
$testSkippedCount = 0
|
| 25 |
+
$testInvalidCount = 0
|
| 26 |
+
|
| 27 |
+
# Process test results and generate annotations for failures
|
| 28 |
+
Get-ChildItem -Path "${TestResultsFolder}/*.xml" -Recurse | ForEach-Object {
|
| 29 |
+
$results = [xml] (get-content $_.FullName)
|
| 30 |
+
|
| 31 |
+
$testCaseCount += [int]$results.'test-results'.total
|
| 32 |
+
$testErrorCount += [int]$results.'test-results'.errors
|
| 33 |
+
$testFailureCount += [int]$results.'test-results'.failures
|
| 34 |
+
$testNotRunCount += [int]$results.'test-results'.'not-run'
|
| 35 |
+
$testInconclusiveCount += [int]$results.'test-results'.inconclusive
|
| 36 |
+
$testIgnoredCount += [int]$results.'test-results'.ignored
|
| 37 |
+
$testSkippedCount += [int]$results.'test-results'.skipped
|
| 38 |
+
$testInvalidCount += [int]$results.'test-results'.invalid
|
| 39 |
+
|
| 40 |
+
# Generate GitHub Actions annotations for test failures
|
| 41 |
+
# Select failed test cases
|
| 42 |
+
if ("System.Xml.XmlDocumentXPathExtensions" -as [Type]) {
|
| 43 |
+
$failures = [System.Xml.XmlDocumentXPathExtensions]::SelectNodes($results.'test-results', './/test-case[@result = "Failure"]')
|
| 44 |
+
}
|
| 45 |
+
else {
|
| 46 |
+
$failures = $results.SelectNodes('.//test-case[@result = "Failure"]')
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
foreach ($testfail in $failures) {
|
| 50 |
+
$description = $testfail.description
|
| 51 |
+
$testName = $testfail.name
|
| 52 |
+
$message = $testfail.failure.message
|
| 53 |
+
$stack_trace = $testfail.failure.'stack-trace'
|
| 54 |
+
|
| 55 |
+
# Parse stack trace to get file and line info
|
| 56 |
+
$fileInfo = Get-PesterFailureFileInfo -StackTraceString $stack_trace
|
| 57 |
+
|
| 58 |
+
if ($fileInfo.File) {
|
| 59 |
+
# Convert absolute path to relative path for GitHub Actions
|
| 60 |
+
$filePath = $fileInfo.File
|
| 61 |
+
|
| 62 |
+
# GitHub Actions expects paths relative to the workspace root
|
| 63 |
+
if ($env:GITHUB_WORKSPACE) {
|
| 64 |
+
$workspacePath = $env:GITHUB_WORKSPACE
|
| 65 |
+
if ($filePath.StartsWith($workspacePath)) {
|
| 66 |
+
$filePath = $filePath.Substring($workspacePath.Length).TrimStart('/', '\')
|
| 67 |
+
# Normalize to forward slashes for consistency
|
| 68 |
+
$filePath = $filePath -replace '\\', '/'
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
# Create annotation title
|
| 73 |
+
$annotationTitle = "Test Failure: $description / $testName"
|
| 74 |
+
|
| 75 |
+
# Build the annotation message
|
| 76 |
+
$annotationMessage = $message -replace "`n", "%0A" -replace "`r"
|
| 77 |
+
|
| 78 |
+
# Build and output the workflow command
|
| 79 |
+
$workflowCommand = "::error file=$filePath"
|
| 80 |
+
if ($fileInfo.Line) {
|
| 81 |
+
$workflowCommand += ",line=$($fileInfo.Line)"
|
| 82 |
+
}
|
| 83 |
+
$workflowCommand += ",title=$annotationTitle::$annotationMessage"
|
| 84 |
+
|
| 85 |
+
Write-Host $workflowCommand
|
| 86 |
+
|
| 87 |
+
# Output a link to the test run
|
| 88 |
+
if ($env:GITHUB_SERVER_URL -and $env:GITHUB_REPOSITORY -and $env:GITHUB_RUN_ID) {
|
| 89 |
+
$logUrl = "$($env:GITHUB_SERVER_URL)/$($env:GITHUB_REPOSITORY)/actions/runs/$($env:GITHUB_RUN_ID)"
|
| 90 |
+
Write-Host "Test logs: $logUrl"
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
@"
|
| 97 |
+
|
| 98 |
+
# Summary of $Name
|
| 99 |
+
|
| 100 |
+
- Total Tests: $testCaseCount
|
| 101 |
+
- Total Errors: $testErrorCount
|
| 102 |
+
- Total Failures: $testFailureCount
|
| 103 |
+
- Total Not Run: $testNotRunCount
|
| 104 |
+
- Total Inconclusive: $testInconclusiveCount
|
| 105 |
+
- Total Ignored: $testIgnoredCount
|
| 106 |
+
- Total Skipped: $testSkippedCount
|
| 107 |
+
- Total Invalid: $testInvalidCount
|
| 108 |
+
|
| 109 |
+
"@ | Out-File -FilePath $ENV:GITHUB_STEP_SUMMARY -Append
|
| 110 |
+
|
| 111 |
+
Write-Log "Summary written to $ENV:GITHUB_STEP_SUMMARY"
|
| 112 |
+
|
| 113 |
+
Write-LogGroupStart -Title 'Test Results'
|
| 114 |
+
Get-Content $ENV:GITHUB_STEP_SUMMARY
|
| 115 |
+
Write-LogGroupEnd -Title 'Test Results'
|
| 116 |
+
|
| 117 |
+
if ($testErrorCount -gt 0 -or $testFailureCount -gt 0) {
|
| 118 |
+
Write-Error "There were $testErrorCount/$testFailureCount errors/failures in the test results."
|
| 119 |
+
exit 1
|
| 120 |
+
}
|
| 121 |
+
if ($testCaseCount -eq 0) {
|
| 122 |
+
Write-Error "No test cases were run."
|
| 123 |
+
exit 1
|
| 124 |
+
}
|
PowerShell-master/.github/actions/test/windows/action.yml
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: windows_test
|
| 2 |
+
description: 'Test PowerShell on Windows'
|
| 3 |
+
|
| 4 |
+
inputs:
|
| 5 |
+
purpose:
|
| 6 |
+
required: false
|
| 7 |
+
default: ''
|
| 8 |
+
type: string
|
| 9 |
+
tagSet:
|
| 10 |
+
required: false
|
| 11 |
+
default: CI
|
| 12 |
+
type: string
|
| 13 |
+
ctrfFolder:
|
| 14 |
+
required: false
|
| 15 |
+
default: ctrf
|
| 16 |
+
type: string
|
| 17 |
+
GITHUB_TOKEN:
|
| 18 |
+
description: 'GitHub token for API authentication'
|
| 19 |
+
required: true
|
| 20 |
+
|
| 21 |
+
runs:
|
| 22 |
+
using: composite
|
| 23 |
+
steps:
|
| 24 |
+
- name: Capture Environment
|
| 25 |
+
if: success() || failure()
|
| 26 |
+
run: |-
|
| 27 |
+
Import-Module ./tools/ci.psm1
|
| 28 |
+
Show-Environment
|
| 29 |
+
shell: pwsh
|
| 30 |
+
|
| 31 |
+
- name: Download Build Artifacts
|
| 32 |
+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
| 33 |
+
with:
|
| 34 |
+
path: "${{ github.workspace }}"
|
| 35 |
+
|
| 36 |
+
- name: Capture Artifacts Directory
|
| 37 |
+
continue-on-error: true
|
| 38 |
+
run: |-
|
| 39 |
+
Import-Module ./build.psm1
|
| 40 |
+
Write-LogGroupStart -Title 'Artifacts Directory'
|
| 41 |
+
Get-ChildItem "${{ github.workspace }}/build/*" -Recurse
|
| 42 |
+
Write-LogGroupEnd -Title 'Artifacts Directory'
|
| 43 |
+
shell: pwsh
|
| 44 |
+
|
| 45 |
+
- uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
|
| 46 |
+
with:
|
| 47 |
+
global-json-file: .\global.json
|
| 48 |
+
|
| 49 |
+
- name: Get Latest DSC Package Version
|
| 50 |
+
shell: pwsh
|
| 51 |
+
run: |-
|
| 52 |
+
Import-Module .\.github\workflows\GHWorkflowHelper\GHWorkflowHelper.psm1
|
| 53 |
+
$headers = @{
|
| 54 |
+
Authorization = "Bearer ${{ inputs.GITHUB_TOKEN }}"
|
| 55 |
+
}
|
| 56 |
+
$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/PowerShell/Dsc/releases" -Headers $headers
|
| 57 |
+
$latestRelease = $releases | Where-Object { $v = $_.name.trim("v"); $semVer = [System.Management.Automation.SemanticVersion]::new($v); if ($semVer.Major -eq 3 -and $semVer.Minor -ge 2) { $_ } } | Select-Object -First 1
|
| 58 |
+
$latestVersion = $latestRelease.tag_name.TrimStart("v")
|
| 59 |
+
Write-Host "Latest DSC Version: $latestVersion"
|
| 60 |
+
|
| 61 |
+
$downloadUrl = $latestRelease.assets | Where-Object { $_.name -like "DSC-*-x86_64-pc-windows-msvc.zip" } | Select-Object -First 1 | Select-Object -ExpandProperty browser_download_url
|
| 62 |
+
Write-Host "Download URL: $downloadUrl"
|
| 63 |
+
$tempPath = Get-GWTempPath
|
| 64 |
+
Invoke-RestMethod -Uri $downloadUrl -OutFile "$tempPath\DSC.zip" -Headers $headers
|
| 65 |
+
|
| 66 |
+
$null = New-Item -ItemType Directory -Path "$tempPath\DSC" -Force
|
| 67 |
+
Expand-Archive -Path "$tempPath\DSC.zip" -DestinationPath "$tempPath\DSC" -Force
|
| 68 |
+
$dscRoot = "$tempPath\DSC"
|
| 69 |
+
Write-Host "DSC Root: $dscRoot"
|
| 70 |
+
Set-GWVariable -Name "DSC_ROOT" -Value $dscRoot
|
| 71 |
+
|
| 72 |
+
- name: Bootstrap
|
| 73 |
+
shell: powershell
|
| 74 |
+
run: |-
|
| 75 |
+
Import-Module ./build.psm1
|
| 76 |
+
Write-LogGroupStart -Title 'Bootstrap'
|
| 77 |
+
Write-Host "Old Path:"
|
| 78 |
+
Write-Host $env:Path
|
| 79 |
+
$dotnetPath = Join-Path $env:SystemDrive 'Program Files\dotnet'
|
| 80 |
+
$paths = $env:Path -split ";" | Where-Object { -not $_.StartsWith($dotnetPath) }
|
| 81 |
+
$env:Path = $paths -join ";"
|
| 82 |
+
Write-Host "New Path:"
|
| 83 |
+
Write-Host $env:Path
|
| 84 |
+
# Bootstrap
|
| 85 |
+
Import-Module .\tools\ci.psm1
|
| 86 |
+
Invoke-CIInstall
|
| 87 |
+
Write-LogGroupEnd -Title 'Bootstrap'
|
| 88 |
+
|
| 89 |
+
- name: Test
|
| 90 |
+
if: success()
|
| 91 |
+
run: |-
|
| 92 |
+
Import-Module .\build.psm1 -force
|
| 93 |
+
Import-Module .\tools\ci.psm1
|
| 94 |
+
Restore-PSOptions -PSOptionsPath '${{ github.workspace }}\build\psoptions.json'
|
| 95 |
+
$options = (Get-PSOptions)
|
| 96 |
+
$path = split-path -path $options.Output
|
| 97 |
+
$rootPath = split-Path -path $path
|
| 98 |
+
Expand-Archive -Path '${{ github.workspace }}\build\build.zip' -DestinationPath $rootPath -Force
|
| 99 |
+
Invoke-CITest -Purpose '${{ inputs.purpose }}' -TagSet '${{ inputs.tagSet }}' -OutputFormat NUnitXml
|
| 100 |
+
shell: pwsh
|
| 101 |
+
|
| 102 |
+
- name: Convert, Publish, and Upload Pester Test Results
|
| 103 |
+
uses: "./.github/actions/test/process-pester-results"
|
| 104 |
+
with:
|
| 105 |
+
name: "${{ inputs.purpose }}-${{ inputs.tagSet }}"
|
| 106 |
+
testResultsFolder: ${{ runner.workspace }}\testResults
|
| 107 |
+
ctrfFolder: "${{ inputs.ctrfFolder }}"
|
PowerShell-master/.github/agents/SplitADOPipelines.agent.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: SplitADOPipelines
|
| 3 |
+
description: This agent will implement and restructure the repository's existing ADO pipelines into Official and NonOfficial pipelines.
|
| 4 |
+
tools: ['vscode', 'execute', 'read', 'agent', 'edit', 'search', 'todo']
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
This agent will implement and restructure the repository's existing ADO pipelines into Official and NonOfficial pipelines.
|
| 8 |
+
|
| 9 |
+
A repository will have under the ./pipelines directory a series of yaml files that define the ADO pipelines for the repository.
|
| 10 |
+
|
| 11 |
+
First confirm if the pipelines are using a toggle switch for Official and NonOfficial. This will look something like this
|
| 12 |
+
|
| 13 |
+
```yaml
|
| 14 |
+
parameters:
|
| 15 |
+
- name: templateFile
|
| 16 |
+
value: ${{ iif ( parameters.OfficialBuild, 'v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates', 'v2/OneBranch.NonOfficial.CrossPlat.yml@onebranchTemplates' ) }}
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
Followed by:
|
| 20 |
+
|
| 21 |
+
```yaml
|
| 22 |
+
extends:
|
| 23 |
+
template: ${{ variables.templateFile }}
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
This is an indicator that this work needs to be done. This toggle switch is no longer allowed and the templates need to be hard coded.
|
| 27 |
+
|
| 28 |
+
## Refactoring Steps
|
| 29 |
+
|
| 30 |
+
### Step 1: Extract Shared Templates
|
| 31 |
+
|
| 32 |
+
For each pipeline file that uses the toggle switch pattern (e.g., `PowerShell-Packages.yml`):
|
| 33 |
+
|
| 34 |
+
1. Create a `./pipelines/templates` directory if it doesn't exist
|
| 35 |
+
2. Extract the **variables section** into `./pipelines/templates/PowerShell-Packages-Variables.yml`
|
| 36 |
+
3. Extract the **stages section** into `./pipelines/templates/PowerShell-Packages-Stages.yml`
|
| 37 |
+
|
| 38 |
+
**IMPORTANT**: Only extract the `variables:` and `stages:` sections. All other sections (parameters, resources, extends, etc.) remain in the pipeline files.
|
| 39 |
+
|
| 40 |
+
### Step 2: Create Official Pipeline (In-Place Refactoring)
|
| 41 |
+
|
| 42 |
+
The original toggle-based file becomes the Official pipeline:
|
| 43 |
+
|
| 44 |
+
1. **Keep the file in its original location** (e.g., `./pipelines/PowerShell-Packages.yml` stays where it is)
|
| 45 |
+
2. Remove the toggle switch parameter (`templateFile` parameter)
|
| 46 |
+
3. Hard-code the Official template reference:
|
| 47 |
+
```yaml
|
| 48 |
+
extends:
|
| 49 |
+
template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates
|
| 50 |
+
```
|
| 51 |
+
4. Replace the `variables:` section with a template reference:
|
| 52 |
+
```yaml
|
| 53 |
+
variables:
|
| 54 |
+
- template: templates/PowerShell-Packages-Variables.yml
|
| 55 |
+
```
|
| 56 |
+
5. Replace the `stages:` section with a template reference:
|
| 57 |
+
```yaml
|
| 58 |
+
stages:
|
| 59 |
+
- template: templates/PowerShell-Packages-Stages.yml
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
### Step 3: Create NonOfficial Pipeline
|
| 63 |
+
|
| 64 |
+
1. Create `./pipelines/NonOfficial` directory if it doesn't exist
|
| 65 |
+
2. Create the NonOfficial pipeline file (e.g., `./pipelines/NonOfficial/PowerShell-Packages-NonOfficial.yml`)
|
| 66 |
+
3. Copy the structure from the refactored Official pipeline
|
| 67 |
+
4. Hard-code the NonOfficial template reference:
|
| 68 |
+
```yaml
|
| 69 |
+
extends:
|
| 70 |
+
template: v2/OneBranch.NonOfficial.CrossPlat.yml@onebranchTemplates
|
| 71 |
+
```
|
| 72 |
+
5. Reference the same shared templates:
|
| 73 |
+
```yaml
|
| 74 |
+
variables:
|
| 75 |
+
- template: ../templates/PowerShell-Packages-Variables.yml
|
| 76 |
+
|
| 77 |
+
stages:
|
| 78 |
+
- template: ../templates/PowerShell-Packages-Stages.yml
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
**Note**: The NonOfficial pipeline uses `../templates/` because it's one directory deeper than the Official pipeline.
|
| 82 |
+
|
| 83 |
+
### Step 4: Link NonOfficial Pipelines to NonOfficial Dependencies
|
| 84 |
+
|
| 85 |
+
After creating NonOfficial pipelines, ensure they consume artifacts from other **NonOfficial** pipelines, not Official ones.
|
| 86 |
+
|
| 87 |
+
1. **Check the `resources:` section** in each NonOfficial pipeline for `pipelines:` dependencies
|
| 88 |
+
2. **Identify Official pipeline references** that need to be changed to NonOfficial
|
| 89 |
+
3. **Update the `source:` field** to point to the NonOfficial version
|
| 90 |
+
|
| 91 |
+
**Example Problem:** NonOfficial pipeline pointing to Official dependency
|
| 92 |
+
```yaml
|
| 93 |
+
resources:
|
| 94 |
+
pipelines:
|
| 95 |
+
- pipeline: CoOrdinatedBuildPipeline
|
| 96 |
+
source: 'PowerShell-Coordinated Binaries-Official' # β Wrong - Official!
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
**Solution:** Update to NonOfficial dependency
|
| 100 |
+
```yaml
|
| 101 |
+
resources:
|
| 102 |
+
pipelines:
|
| 103 |
+
- pipeline: CoOrdinatedBuildPipeline
|
| 104 |
+
source: 'PowerShell-Coordinated Binaries-NonOfficial' # β
Correct - NonOfficial!
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
**IMPORTANT**: The `source:` field must match the **exact ADO pipeline definition name** as it appears in Azure DevOps, not necessarily the file name.
|
| 108 |
+
|
| 109 |
+
### Step 5: Configure Release Environment Parameters (NonAzure Only)
|
| 110 |
+
|
| 111 |
+
**This step only applies if the pipeline uses `category: NonAzure` in the release configuration.**
|
| 112 |
+
|
| 113 |
+
If you detect this pattern in the original pipeline:
|
| 114 |
+
|
| 115 |
+
```yaml
|
| 116 |
+
extends:
|
| 117 |
+
template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates # or NonOfficial
|
| 118 |
+
parameters:
|
| 119 |
+
release:
|
| 120 |
+
category: NonAzure
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
Then you must configure the `ob_release_environment` parameter when referencing the stages template.
|
| 124 |
+
|
| 125 |
+
#### Official Pipeline Configuration
|
| 126 |
+
|
| 127 |
+
In the Official pipeline (e.g., `./pipelines/PowerShell-Packages.yml`):
|
| 128 |
+
|
| 129 |
+
```yaml
|
| 130 |
+
stages:
|
| 131 |
+
- template: templates/PowerShell-Packages-Stages.yml
|
| 132 |
+
parameters:
|
| 133 |
+
ob_release_environment: Production
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
#### NonOfficial Pipeline Configuration
|
| 137 |
+
|
| 138 |
+
In the NonOfficial pipeline (e.g., `./pipelines/NonOfficial/PowerShell-Packages-NonOfficial.yml`):
|
| 139 |
+
|
| 140 |
+
```yaml
|
| 141 |
+
stages:
|
| 142 |
+
- template: ../templates/PowerShell-Packages-Stages.yml
|
| 143 |
+
parameters:
|
| 144 |
+
ob_release_environment: Test
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
#### Update Stages Template to Accept Parameter
|
| 148 |
+
|
| 149 |
+
The extracted stages template (e.g., `./pipelines/templates/PowerShell-Packages-Stages.yml`) must declare the parameter at the top:
|
| 150 |
+
|
| 151 |
+
```yaml
|
| 152 |
+
parameters:
|
| 153 |
+
- name: ob_release_environment
|
| 154 |
+
type: string
|
| 155 |
+
|
| 156 |
+
stages:
|
| 157 |
+
# ... rest of stages configuration using ${{ parameters.ob_release_environment }}
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
**IMPORTANT**:
|
| 161 |
+
- Only configure this for pipelines with `category: NonAzure`
|
| 162 |
+
- Official pipelines always use `ob_release_environment: Production`
|
| 163 |
+
- NonOfficial pipelines always use `ob_release_environment: Test`
|
| 164 |
+
- The stages template must accept this parameter and use it in the appropriate stage configurations
|
PowerShell-master/.github/chatmodes/cherry-pick-commits.chatmode.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Cherry-Pick Commits Between Branches
|
| 2 |
+
|
| 3 |
+
Cherry-pick recent commits from a source branch to a target branch without switching branches.
|
| 4 |
+
|
| 5 |
+
## Instructions for Copilot
|
| 6 |
+
|
| 7 |
+
1. **Confirm branches with the user**
|
| 8 |
+
- Ask the user to confirm the source and target branches
|
| 9 |
+
- If different branches are needed, update the configuration
|
| 10 |
+
|
| 11 |
+
2. **Identify unique commits**
|
| 12 |
+
- Run: `git log <target-branch>..<source-branch> --oneline --reverse`
|
| 13 |
+
- **IMPORTANT**: The commit count may be misleading if branches diverged from different base commits
|
| 14 |
+
- Compare the LAST few commits from each branch to identify actual missing commits:
|
| 15 |
+
- `git log <source-branch> --oneline -10`
|
| 16 |
+
- `git log <target-branch> --oneline -10`
|
| 17 |
+
- Look for commits with the same message but different SHAs (rebased commits)
|
| 18 |
+
- Show the user ONLY the truly missing commits (usually just the most recent ones)
|
| 19 |
+
|
| 20 |
+
3. **Confirm with user before proceeding**
|
| 21 |
+
- If the commit count seems unusually high (e.g., 400+), STOP and verify semantically
|
| 22 |
+
- Ask: "I found X commits to cherry-pick. Shall I proceed?"
|
| 23 |
+
- If there are many commits, warn that this may take time
|
| 24 |
+
|
| 25 |
+
4. **Execute the cherry-pick**
|
| 26 |
+
- Ensure the target branch is checked out first
|
| 27 |
+
- Run: `git cherry-pick <sha1>` for single commits
|
| 28 |
+
- Or: `git cherry-pick <sha1> <sha2> <sha3>` for multiple commits
|
| 29 |
+
- Apply commits in chronological order (oldest first)
|
| 30 |
+
|
| 31 |
+
5. **Handle any issues**
|
| 32 |
+
- If conflicts occur, pause and ask user for guidance
|
| 33 |
+
- If empty commits occur, automatically skip with `git cherry-pick --skip`
|
| 34 |
+
|
| 35 |
+
6. **Verify and report results**
|
| 36 |
+
- Run: `git log <target-branch> -<number-of-commits> --oneline`
|
| 37 |
+
- Show the user the newly applied commits
|
| 38 |
+
- Confirm the branch is now ahead by X commits
|
| 39 |
+
|
| 40 |
+
## Key Git Commands
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
# Find unique commits (may show full divergence if branches were rebased)
|
| 44 |
+
git log <target>..<source> --oneline --reverse
|
| 45 |
+
|
| 46 |
+
# Compare recent commits on each branch (more reliable for rebased branches)
|
| 47 |
+
git log <source-branch> --oneline -10
|
| 48 |
+
git log <target-branch> --oneline -10
|
| 49 |
+
|
| 50 |
+
# Cherry-pick specific commits (when target is checked out)
|
| 51 |
+
git cherry-pick <sha1>
|
| 52 |
+
git cherry-pick <sha1> <sha2> <sha3>
|
| 53 |
+
|
| 54 |
+
# Skip empty commits
|
| 55 |
+
git cherry-pick --skip
|
| 56 |
+
|
| 57 |
+
# Verify result
|
| 58 |
+
git log <target-branch> -<count> --oneline
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## Common Scenarios
|
| 62 |
+
|
| 63 |
+
- **Empty commits**: Automatically skip with `git cherry-pick --skip`
|
| 64 |
+
- **Conflicts**: Stop, show files with conflicts, ask user to resolve
|
| 65 |
+
- **Many commits**: Warn user and confirm before proceeding
|
| 66 |
+
- **Already applied**: These will result in empty commits that should be skipped
|
| 67 |
+
- **Diverged branches**: If branches diverged (rebased), `git log` may show the entire history difference
|
| 68 |
+
- The actual missing commits are usually only the most recent ones
|
| 69 |
+
- Compare commit messages from recent history on both branches
|
| 70 |
+
- Cherry-pick only commits that are semantically missing
|
| 71 |
+
|
| 72 |
+
## Workflow Style
|
| 73 |
+
|
| 74 |
+
Use an interactive, step-by-step approach:
|
| 75 |
+
- Show output from each command
|
| 76 |
+
- Ask for confirmation before major actions
|
| 77 |
+
- Provide clear status updates
|
| 78 |
+
- Handle errors gracefully with user guidance
|
PowerShell-master/.github/dependabot.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 2
|
| 2 |
+
|
| 3 |
+
updates:
|
| 4 |
+
- package-ecosystem: "github-actions"
|
| 5 |
+
directory: "/"
|
| 6 |
+
schedule:
|
| 7 |
+
interval: "daily"
|
| 8 |
+
labels:
|
| 9 |
+
- "CL-BuildPackaging"
|
| 10 |
+
|
| 11 |
+
- package-ecosystem: "github-actions"
|
| 12 |
+
directory: "/"
|
| 13 |
+
target-branch: "release/*"
|
| 14 |
+
schedule:
|
| 15 |
+
interval: "daily"
|
| 16 |
+
labels:
|
| 17 |
+
- "CL-BuildPackaging"
|
| 18 |
+
|
| 19 |
+
- package-ecosystem: "docker"
|
| 20 |
+
directory: /
|
| 21 |
+
schedule:
|
| 22 |
+
interval: daily
|
| 23 |
+
labels:
|
| 24 |
+
- "CL-BuildPackaging"
|
| 25 |
+
|
| 26 |
+
- package-ecosystem: "docker"
|
| 27 |
+
directory: "/"
|
| 28 |
+
target-branch: "release/*"
|
| 29 |
+
schedule:
|
| 30 |
+
interval: daily
|
| 31 |
+
labels:
|
| 32 |
+
- "CL-BuildPackaging"
|
PowerShell-master/.github/instructions/build-and-packaging-steps.instructions.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo:
|
| 3 |
+
- ".github/actions/**/*.yml"
|
| 4 |
+
- ".github/workflows/**/*.yml"
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# Build and Packaging Steps Pattern
|
| 8 |
+
|
| 9 |
+
## Important Rule
|
| 10 |
+
|
| 11 |
+
**Build and packaging must run in the same step OR you must save and restore PSOptions between steps.**
|
| 12 |
+
|
| 13 |
+
## Why This Matters
|
| 14 |
+
|
| 15 |
+
When `Start-PSBuild` runs, it creates PSOptions that contain build configuration details (runtime, configuration, output path, etc.). The packaging functions like `Start-PSPackage` and `Invoke-CIFinish` rely on these PSOptions to know where the build output is located and how it was built.
|
| 16 |
+
|
| 17 |
+
GitHub Actions steps run in separate PowerShell sessions. This means PSOptions from one step are not available in the next step.
|
| 18 |
+
|
| 19 |
+
## Pattern 1: Combined Build and Package (Recommended)
|
| 20 |
+
|
| 21 |
+
Run build and packaging in the same step to keep PSOptions in memory:
|
| 22 |
+
|
| 23 |
+
```yaml
|
| 24 |
+
- name: Build and Package
|
| 25 |
+
run: |-
|
| 26 |
+
Import-Module ./tools/ci.psm1
|
| 27 |
+
$releaseTag = Get-ReleaseTag
|
| 28 |
+
Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag
|
| 29 |
+
Invoke-CIFinish
|
| 30 |
+
shell: pwsh
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
**Benefits:**
|
| 34 |
+
- Simpler code
|
| 35 |
+
- No need for intermediate files
|
| 36 |
+
- PSOptions automatically available to packaging
|
| 37 |
+
|
| 38 |
+
## Pattern 2: Separate Steps with Save/Restore
|
| 39 |
+
|
| 40 |
+
If you must separate build and packaging into different steps:
|
| 41 |
+
|
| 42 |
+
```yaml
|
| 43 |
+
- name: Build PowerShell
|
| 44 |
+
run: |-
|
| 45 |
+
Import-Module ./tools/ci.psm1
|
| 46 |
+
$releaseTag = Get-ReleaseTag
|
| 47 |
+
Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag
|
| 48 |
+
Save-PSOptions -PSOptionsPath "${{ runner.workspace }}/psoptions.json"
|
| 49 |
+
shell: pwsh
|
| 50 |
+
|
| 51 |
+
- name: Create Packages
|
| 52 |
+
run: |-
|
| 53 |
+
Import-Module ./tools/ci.psm1
|
| 54 |
+
Restore-PSOptions -PSOptionsPath "${{ runner.workspace }}/psoptions.json"
|
| 55 |
+
Invoke-CIFinish
|
| 56 |
+
shell: pwsh
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
**When to use:**
|
| 60 |
+
- When you need to run other steps between build and packaging
|
| 61 |
+
- When build and packaging require different permissions or environments
|
| 62 |
+
|
| 63 |
+
## Common Mistakes
|
| 64 |
+
|
| 65 |
+
### β Incorrect: Separate steps without save/restore
|
| 66 |
+
|
| 67 |
+
```yaml
|
| 68 |
+
- name: Build PowerShell
|
| 69 |
+
run: |-
|
| 70 |
+
Start-PSBuild -Configuration 'Release'
|
| 71 |
+
shell: pwsh
|
| 72 |
+
|
| 73 |
+
- name: Create Packages
|
| 74 |
+
run: |-
|
| 75 |
+
Invoke-CIFinish # β FAILS: PSOptions not available
|
| 76 |
+
shell: pwsh
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
### β Incorrect: Using artifacts without PSOptions
|
| 80 |
+
|
| 81 |
+
```yaml
|
| 82 |
+
- name: Download Build Artifacts
|
| 83 |
+
uses: actions/download-artifact@v4
|
| 84 |
+
with:
|
| 85 |
+
name: build
|
| 86 |
+
|
| 87 |
+
- name: Create Packages
|
| 88 |
+
run: |-
|
| 89 |
+
Invoke-CIFinish # β FAILS: PSOptions not restored
|
| 90 |
+
shell: pwsh
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
## Related Functions
|
| 94 |
+
|
| 95 |
+
- `Start-PSBuild` - Builds PowerShell and sets PSOptions
|
| 96 |
+
- `Save-PSOptions` - Saves PSOptions to a JSON file
|
| 97 |
+
- `Restore-PSOptions` - Loads PSOptions from a JSON file
|
| 98 |
+
- `Get-PSOptions` - Gets current PSOptions
|
| 99 |
+
- `Set-PSOptions` - Sets PSOptions
|
| 100 |
+
- `Start-PSPackage` - Creates packages (requires PSOptions)
|
| 101 |
+
- `Invoke-CIFinish` - Calls packaging (requires PSOptions on Linux/macOS)
|
| 102 |
+
|
| 103 |
+
## Examples
|
| 104 |
+
|
| 105 |
+
### Linux Packaging Action
|
| 106 |
+
|
| 107 |
+
```yaml
|
| 108 |
+
- name: Build and Package
|
| 109 |
+
run: |-
|
| 110 |
+
Import-Module ./tools/ci.psm1
|
| 111 |
+
$releaseTag = Get-ReleaseTag
|
| 112 |
+
Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag
|
| 113 |
+
Invoke-CIFinish
|
| 114 |
+
shell: pwsh
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
### Windows Packaging Workflow
|
| 118 |
+
|
| 119 |
+
```yaml
|
| 120 |
+
- name: Build and Package
|
| 121 |
+
run: |
|
| 122 |
+
Import-Module .\tools\ci.psm1
|
| 123 |
+
Invoke-CIFinish -Runtime ${{ matrix.runtimePrefix }}-${{ matrix.architecture }} -channel ${{ matrix.channel }}
|
| 124 |
+
shell: pwsh
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
Note: `Invoke-CIFinish` for Windows includes both build and packaging in its logic when `Stage` contains 'Build'.
|
PowerShell-master/.github/instructions/build-checkout-prerequisites.instructions.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo:
|
| 3 |
+
- ".github/**/*.yml"
|
| 4 |
+
- ".github/**/*.yaml"
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# Build and Checkout Prerequisites for PowerShell CI
|
| 8 |
+
|
| 9 |
+
This document describes the checkout and build prerequisites used in PowerShell's CI workflows. It is intended for GitHub Copilot sessions working with the build system.
|
| 10 |
+
|
| 11 |
+
## Overview
|
| 12 |
+
|
| 13 |
+
The PowerShell repository uses a standardized build process across Linux, Windows, and macOS CI workflows. Understanding the checkout configuration and the `Sync-PSTags` operation is crucial for working with the build system.
|
| 14 |
+
|
| 15 |
+
## Checkout Configuration
|
| 16 |
+
|
| 17 |
+
### Fetch Depth
|
| 18 |
+
|
| 19 |
+
All CI workflows that build or test PowerShell use `fetch-depth: 1000` in the checkout step:
|
| 20 |
+
|
| 21 |
+
```yaml
|
| 22 |
+
- name: checkout
|
| 23 |
+
uses: actions/checkout@v5
|
| 24 |
+
with:
|
| 25 |
+
fetch-depth: 1000
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
**Why 1000 commits?**
|
| 29 |
+
- The build system needs access to Git history to determine version information
|
| 30 |
+
- `Sync-PSTags` requires sufficient history to fetch and work with tags
|
| 31 |
+
- 1000 commits provides a reasonable balance between clone speed and having enough history for version calculation
|
| 32 |
+
- Shallow clones (fetch-depth: 1) would break versioning logic
|
| 33 |
+
|
| 34 |
+
**Exceptions:**
|
| 35 |
+
- The `changes` job uses default fetch depth (no explicit `fetch-depth`) since it only needs to detect file changes
|
| 36 |
+
- The `analyze` job (CodeQL) uses `fetch-depth: '0'` (full history) for comprehensive security analysis
|
| 37 |
+
- Linux packaging uses `fetch-depth: 0` to ensure all tags are available for package version metadata
|
| 38 |
+
|
| 39 |
+
### Workflows Using fetch-depth: 1000
|
| 40 |
+
|
| 41 |
+
- **Linux CI** (`.github/workflows/linux-ci.yml`): All build and test jobs
|
| 42 |
+
- **Windows CI** (`.github/workflows/windows-ci.yml`): All build and test jobs
|
| 43 |
+
- **macOS CI** (`.github/workflows/macos-ci.yml`): All build and test jobs
|
| 44 |
+
|
| 45 |
+
## Sync-PSTags Operation
|
| 46 |
+
|
| 47 |
+
### What is Sync-PSTags?
|
| 48 |
+
|
| 49 |
+
`Sync-PSTags` is a PowerShell function defined in `build.psm1` that ensures Git tags from the upstream PowerShell repository are synchronized to the local clone.
|
| 50 |
+
|
| 51 |
+
### Location
|
| 52 |
+
|
| 53 |
+
- **Function Definition**: `build.psm1` (line 36-76)
|
| 54 |
+
- **Called From**:
|
| 55 |
+
- `.github/actions/build/ci/action.yml` (Bootstrap step, line 24)
|
| 56 |
+
- `tools/ci.psm1` (Invoke-CIInstall function, line 146)
|
| 57 |
+
|
| 58 |
+
### How It Works
|
| 59 |
+
|
| 60 |
+
```powershell
|
| 61 |
+
Sync-PSTags -AddRemoteIfMissing
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
The function:
|
| 65 |
+
1. Searches for a Git remote pointing to the official PowerShell repository:
|
| 66 |
+
- `https://github.com/PowerShell/PowerShell`
|
| 67 |
+
- `git@github.com:PowerShell/PowerShell`
|
| 68 |
+
|
| 69 |
+
2. If no upstream remote exists and `-AddRemoteIfMissing` is specified:
|
| 70 |
+
- Adds a remote named `upstream` pointing to `https://github.com/PowerShell/PowerShell.git`
|
| 71 |
+
|
| 72 |
+
3. Fetches all tags from the upstream remote:
|
| 73 |
+
```bash
|
| 74 |
+
git fetch --tags --quiet upstream
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
4. Sets `$script:tagsUpToDate = $true` to indicate tags are synchronized
|
| 78 |
+
|
| 79 |
+
### Why Sync-PSTags is Required
|
| 80 |
+
|
| 81 |
+
Tags are critical for:
|
| 82 |
+
- **Version Calculation**: `Get-PSVersion` uses `git describe --abbrev=0` to find the latest tag
|
| 83 |
+
- **Build Numbering**: CI builds use tag-based versioning for artifacts
|
| 84 |
+
- **Changelog Generation**: Release notes are generated based on tags
|
| 85 |
+
- **Package Metadata**: Package versions are derived from Git tags
|
| 86 |
+
|
| 87 |
+
Without synchronized tags:
|
| 88 |
+
- Version detection would fail or return incorrect versions
|
| 89 |
+
- Builds might have inconsistent version numbers
|
| 90 |
+
- The build process would error when trying to determine the version
|
| 91 |
+
|
| 92 |
+
### Bootstrap Step in CI Action
|
| 93 |
+
|
| 94 |
+
The `.github/actions/build/ci/action.yml` includes this in the Bootstrap step:
|
| 95 |
+
|
| 96 |
+
```yaml
|
| 97 |
+
- name: Bootstrap
|
| 98 |
+
if: success()
|
| 99 |
+
run: |-
|
| 100 |
+
Write-Verbose -Verbose "Running Bootstrap..."
|
| 101 |
+
Import-Module .\tools\ci.psm1
|
| 102 |
+
Invoke-CIInstall -SkipUser
|
| 103 |
+
Write-Verbose -Verbose "Start Sync-PSTags"
|
| 104 |
+
Sync-PSTags -AddRemoteIfMissing
|
| 105 |
+
Write-Verbose -Verbose "End Sync-PSTags"
|
| 106 |
+
shell: pwsh
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
**Note**: `Sync-PSTags` is called twice:
|
| 110 |
+
1. Once by `Invoke-CIInstall` (in `tools/ci.psm1`)
|
| 111 |
+
2. Explicitly again in the Bootstrap step
|
| 112 |
+
|
| 113 |
+
This redundancy ensures tags are available even if the first call encounters issues.
|
| 114 |
+
|
| 115 |
+
## Best Practices for Copilot Sessions
|
| 116 |
+
|
| 117 |
+
When working with the PowerShell CI system:
|
| 118 |
+
|
| 119 |
+
1. **Always use `fetch-depth: 1000` or greater** when checking out code for build or test operations
|
| 120 |
+
2. **Understand that `Sync-PSTags` requires network access** to fetch tags from the upstream repository
|
| 121 |
+
3. **Don't modify the fetch-depth without understanding the impact** on version calculation
|
| 122 |
+
4. **If adding new CI workflows**, follow the existing pattern:
|
| 123 |
+
- Use `fetch-depth: 1000` for build/test jobs
|
| 124 |
+
- Call `Sync-PSTags -AddRemoteIfMissing` during bootstrap
|
| 125 |
+
- Ensure the upstream remote is properly configured
|
| 126 |
+
|
| 127 |
+
5. **For local development**, developers should:
|
| 128 |
+
- Have the upstream remote configured
|
| 129 |
+
- Run `Sync-PSTags -AddRemoteIfMissing` before building
|
| 130 |
+
- Or use `Start-PSBuild` which handles this automatically
|
| 131 |
+
|
| 132 |
+
## Related Files
|
| 133 |
+
|
| 134 |
+
- `.github/actions/build/ci/action.yml` - Main CI build action
|
| 135 |
+
- `.github/workflows/linux-ci.yml` - Linux CI workflow
|
| 136 |
+
- `.github/workflows/windows-ci.yml` - Windows CI workflow
|
| 137 |
+
- `.github/workflows/macos-ci.yml` - macOS CI workflow
|
| 138 |
+
- `build.psm1` - Contains Sync-PSTags function definition
|
| 139 |
+
- `tools/ci.psm1` - CI-specific build functions that call Sync-PSTags
|
| 140 |
+
|
| 141 |
+
## Summary
|
| 142 |
+
|
| 143 |
+
The PowerShell CI system depends on:
|
| 144 |
+
1. **Adequate Git history** (fetch-depth: 1000) for version calculation
|
| 145 |
+
2. **Synchronized Git tags** via `Sync-PSTags` for accurate versioning
|
| 146 |
+
3. **Upstream remote access** to fetch official repository tags
|
| 147 |
+
|
| 148 |
+
These prerequisites ensure consistent, accurate build versioning across all CI platforms.
|
PowerShell-master/.github/instructions/build-configuration-guide.instructions.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo:
|
| 3 |
+
- "build.psm1"
|
| 4 |
+
- "tools/ci.psm1"
|
| 5 |
+
- ".github/**/*.yml"
|
| 6 |
+
- ".github/**/*.yaml"
|
| 7 |
+
- ".pipelines/**/*.yml"
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Build Configuration Guide
|
| 11 |
+
|
| 12 |
+
## Choosing the Right Configuration
|
| 13 |
+
|
| 14 |
+
### For Testing
|
| 15 |
+
|
| 16 |
+
**Use: Default (Debug)**
|
| 17 |
+
|
| 18 |
+
```yaml
|
| 19 |
+
- name: Build for Testing
|
| 20 |
+
shell: pwsh
|
| 21 |
+
run: |
|
| 22 |
+
Import-Module ./tools/ci.psm1
|
| 23 |
+
Start-PSBuild
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
**Why Debug:**
|
| 27 |
+
- Includes debugging symbols
|
| 28 |
+
- Better error messages
|
| 29 |
+
- Faster build times
|
| 30 |
+
- Suitable for xUnit and Pester tests
|
| 31 |
+
|
| 32 |
+
**Do NOT use:**
|
| 33 |
+
- `-Configuration 'Release'` (unnecessary for tests)
|
| 34 |
+
- `-ReleaseTag` (not needed for tests)
|
| 35 |
+
- `-CI` (unless you specifically need Pester module)
|
| 36 |
+
|
| 37 |
+
### For Release/Packaging
|
| 38 |
+
|
| 39 |
+
**Use: Release with version tag and public NuGet feeds**
|
| 40 |
+
|
| 41 |
+
```yaml
|
| 42 |
+
- name: Build for Release
|
| 43 |
+
shell: pwsh
|
| 44 |
+
run: |
|
| 45 |
+
Import-Module ./build.psm1
|
| 46 |
+
Import-Module ./tools/ci.psm1
|
| 47 |
+
Switch-PSNugetConfig -Source Public
|
| 48 |
+
$releaseTag = Get-ReleaseTag
|
| 49 |
+
Start-PSBuild -Configuration 'Release' -ReleaseTag $releaseTag
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
**Why Release:**
|
| 53 |
+
- Optimized binaries
|
| 54 |
+
- No debug symbols (smaller size)
|
| 55 |
+
- Production-ready
|
| 56 |
+
|
| 57 |
+
**Why Switch-PSNugetConfig -Source Public:**
|
| 58 |
+
- Switches NuGet package sources to public feeds (nuget.org and public Azure DevOps feeds)
|
| 59 |
+
- Required for CI/CD environments that don't have access to private feeds
|
| 60 |
+
- Uses publicly available packages instead of Microsoft internal feeds
|
| 61 |
+
|
| 62 |
+
### For Code Coverage
|
| 63 |
+
|
| 64 |
+
**Use: CodeCoverage configuration**
|
| 65 |
+
|
| 66 |
+
```yaml
|
| 67 |
+
- name: Build with Coverage
|
| 68 |
+
shell: pwsh
|
| 69 |
+
run: |
|
| 70 |
+
Import-Module ./tools/ci.psm1
|
| 71 |
+
Start-PSBuild -Configuration 'CodeCoverage'
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
## Platform Considerations
|
| 75 |
+
|
| 76 |
+
### All Platforms
|
| 77 |
+
|
| 78 |
+
Same commands work across Linux, Windows, and macOS:
|
| 79 |
+
|
| 80 |
+
```yaml
|
| 81 |
+
strategy:
|
| 82 |
+
matrix:
|
| 83 |
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
| 84 |
+
runs-on: ${{ matrix.os }}
|
| 85 |
+
steps:
|
| 86 |
+
- name: Build PowerShell
|
| 87 |
+
shell: pwsh
|
| 88 |
+
run: |
|
| 89 |
+
Import-Module ./tools/ci.psm1
|
| 90 |
+
Start-PSBuild
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
### Output Locations
|
| 94 |
+
|
| 95 |
+
**Linux/macOS:**
|
| 96 |
+
```
|
| 97 |
+
src/powershell-unix/bin/Debug/<netversion>/<runtime>/publish/
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
**Windows:**
|
| 101 |
+
```
|
| 102 |
+
src/powershell-win-core/bin/Debug/<netversion>/<runtime>/publish/
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
## Best Practices
|
| 106 |
+
|
| 107 |
+
1. Use default configuration for testing
|
| 108 |
+
2. Avoid redundant parameters
|
| 109 |
+
3. Match configuration to purpose
|
| 110 |
+
4. Use `-CI` only when needed
|
| 111 |
+
5. Always specify `-ReleaseTag` for release or packaging builds
|
| 112 |
+
6. Use `Switch-PSNugetConfig -Source Public` in CI/CD for release builds
|
| 113 |
+
|
| 114 |
+
## NuGet Feed Configuration
|
| 115 |
+
|
| 116 |
+
### Switch-PSNugetConfig
|
| 117 |
+
|
| 118 |
+
The `Switch-PSNugetConfig` function in `build.psm1` manages NuGet package source configuration.
|
| 119 |
+
|
| 120 |
+
**Available Sources:**
|
| 121 |
+
|
| 122 |
+
- **Public**: Uses public feeds (nuget.org and public Azure DevOps feeds)
|
| 123 |
+
- Required for: CI/CD environments, public builds, packaging
|
| 124 |
+
- Does not require authentication
|
| 125 |
+
|
| 126 |
+
- **Private**: Uses internal PowerShell team feeds
|
| 127 |
+
- Required for: Internal development with preview packages
|
| 128 |
+
- Requires authentication credentials
|
| 129 |
+
|
| 130 |
+
- **NuGetOnly**: Uses only nuget.org
|
| 131 |
+
- Required for: Minimal dependency scenarios
|
| 132 |
+
|
| 133 |
+
**Usage:**
|
| 134 |
+
|
| 135 |
+
```powershell
|
| 136 |
+
# Switch to public feeds (most common for CI/CD)
|
| 137 |
+
Switch-PSNugetConfig -Source Public
|
| 138 |
+
|
| 139 |
+
# Switch to private feeds with authentication
|
| 140 |
+
Switch-PSNugetConfig -Source Private -UserName $userName -ClearTextPAT $pat
|
| 141 |
+
|
| 142 |
+
# Switch to nuget.org only
|
| 143 |
+
Switch-PSNugetConfig -Source NuGetOnly
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
**When to Use:**
|
| 147 |
+
|
| 148 |
+
- **Always use `-Source Public`** before building in CI/CD workflows
|
| 149 |
+
- Use before any build that will create packages for distribution
|
| 150 |
+
- Use in forks or environments without access to Microsoft internal feeds
|
PowerShell-master/.github/instructions/code-review-branch-strategy.instructions.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo: "**/*"
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# Code Review Branch Strategy Guide
|
| 6 |
+
|
| 7 |
+
This guide helps GitHub Copilot provide appropriate feedback when reviewing code changes, particularly distinguishing between issues that should be fixed in the current branch versus the default branch.
|
| 8 |
+
|
| 9 |
+
## Purpose
|
| 10 |
+
|
| 11 |
+
When reviewing pull requests, especially those targeting release branches, it's important to identify whether an issue should be fixed in:
|
| 12 |
+
- **The current PR/branch** - Release-specific fixes or backports
|
| 13 |
+
- **The default branch first** - General bugs that exist in the main codebase
|
| 14 |
+
|
| 15 |
+
## Branch Types and Fix Strategy
|
| 16 |
+
|
| 17 |
+
### Release Branches (e.g., `release/v7.5`, `release/v7.4`)
|
| 18 |
+
|
| 19 |
+
**Purpose:** Contain release-specific changes and critical backports
|
| 20 |
+
|
| 21 |
+
**Should contain:**
|
| 22 |
+
- Release-specific configuration changes
|
| 23 |
+
- Critical bug fixes that are backported from the default branch
|
| 24 |
+
- Release packaging/versioning adjustments
|
| 25 |
+
|
| 26 |
+
**Should NOT contain:**
|
| 27 |
+
- New general bug fixes that haven't been fixed in the default branch
|
| 28 |
+
- Refactoring or improvements that apply to the main codebase
|
| 29 |
+
- Workarounds for issues that exist in the default branch
|
| 30 |
+
|
| 31 |
+
### Default/Main Branch (e.g., `master`, `main`)
|
| 32 |
+
|
| 33 |
+
**Purpose:** Primary development branch for all ongoing work
|
| 34 |
+
|
| 35 |
+
**Should contain:**
|
| 36 |
+
- All general bug fixes
|
| 37 |
+
- New features and improvements
|
| 38 |
+
- Refactoring and code quality improvements
|
| 39 |
+
- Fixes that will later be backported to release branches
|
| 40 |
+
|
| 41 |
+
## Identifying Issues That Belong in the Default Branch
|
| 42 |
+
|
| 43 |
+
When reviewing a PR targeting a release branch, look for these indicators that suggest the fix should be in the default branch first:
|
| 44 |
+
|
| 45 |
+
### 1. The Root Cause Exists in Default Branch
|
| 46 |
+
|
| 47 |
+
If the underlying issue exists in the default branch's code, it should be fixed there first.
|
| 48 |
+
|
| 49 |
+
**Example:**
|
| 50 |
+
```yaml
|
| 51 |
+
# PR changes this in release/v7.5:
|
| 52 |
+
- $metadata = Get-Content "$repoRoot/tools/metadata.json" -Raw | ConvertFrom-Json
|
| 53 |
+
+ $metadata = Get-Content "$(Build.SourcesDirectory)/PowerShell/tools/metadata.json" -Raw | ConvertFrom-Json
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
**Analysis:** If `$repoRoot` is undefined because the template doesn't include its dependencies in BOTH the release branch AND the default branch, the fix should address the root cause in the default branch first.
|
| 57 |
+
|
| 58 |
+
### 2. The Fix is a Workaround Rather Than a Proper Solution
|
| 59 |
+
|
| 60 |
+
If the change introduces a workaround (hardcoded paths, special cases) rather than fixing the underlying design issue, it likely belongs in the default branch as a proper fix.
|
| 61 |
+
|
| 62 |
+
**Example:**
|
| 63 |
+
- Using hardcoded paths instead of fixing variable initialization
|
| 64 |
+
- Adding special cases instead of fixing the logic
|
| 65 |
+
- Duplicating code instead of fixing shared dependencies
|
| 66 |
+
|
| 67 |
+
### 3. The Issue Affects General Functionality
|
| 68 |
+
|
| 69 |
+
If the issue affects general functionality not specific to a release, it should be fixed in the default branch.
|
| 70 |
+
|
| 71 |
+
**Example:**
|
| 72 |
+
- Template dependencies that affect all pipelines
|
| 73 |
+
- Shared utility functions
|
| 74 |
+
- Common configuration issues
|
| 75 |
+
|
| 76 |
+
## Providing Code Review Feedback
|
| 77 |
+
|
| 78 |
+
### For Issues in the Current Branch
|
| 79 |
+
|
| 80 |
+
When an issue is specific to the current branch or is a legitimate fix for the branch being targeted, **use the default code review feedback format** without any special branch-strategy commentary.
|
| 81 |
+
|
| 82 |
+
### For Issues That Belong in the Default Branch
|
| 83 |
+
|
| 84 |
+
1. **Provide the code review feedback**
|
| 85 |
+
2. **Explain why it should be fixed in the default branch**
|
| 86 |
+
3. **Provide an issue template** in markdown format
|
| 87 |
+
|
| 88 |
+
**Example:**
|
| 89 |
+
|
| 90 |
+
```markdown
|
| 91 |
+
The `channelSelection.yml` template relies on `$repoRoot` being set by `SetVersionVariables.yml`, but doesn't declare this dependency. This issue exists in both the release branch and the default branch.
|
| 92 |
+
|
| 93 |
+
**This should be fixed in the default branch first**, then backported if needed. The proper fix is to ensure template dependencies are correctly declared, rather than using hardcoded paths as a workaround.
|
| 94 |
+
|
| 95 |
+
---
|
| 96 |
+
|
| 97 |
+
**Suggested Issue for Default Branch:**
|
| 98 |
+
|
| 99 |
+
### Issue Title
|
| 100 |
+
`channelSelection.yml` template missing dependency on `SetVersionVariables.yml`
|
| 101 |
+
|
| 102 |
+
### Description
|
| 103 |
+
The `channelSelection.yml` template uses the `$repoRoot` variable but doesn't ensure it's set beforehand by including `SetVersionVariables.yml`.
|
| 104 |
+
|
| 105 |
+
**Current State:**
|
| 106 |
+
- `channelSelection.yml` expects `$repoRoot` to be available
|
| 107 |
+
- Not all pipelines that use `channelSelection.yml` include `SetVersionVariables.yml` first
|
| 108 |
+
- This creates an implicit dependency that's not enforced
|
| 109 |
+
|
| 110 |
+
**Expected State:**
|
| 111 |
+
Either:
|
| 112 |
+
1. `channelSelection.yml` should include `SetVersionVariables.yml` as a dependency, OR
|
| 113 |
+
2. `channelSelection.yml` should be refactored to not depend on `$repoRoot`, OR
|
| 114 |
+
3. Pipelines using `channelSelection.yml` should explicitly include `SetVersionVariables.yml` first
|
| 115 |
+
|
| 116 |
+
**Files Affected:**
|
| 117 |
+
- `.pipelines/templates/channelSelection.yml`
|
| 118 |
+
- `.pipelines/templates/package-create-msix.yml`
|
| 119 |
+
- `.pipelines/templates/release-SetTagAndChangelog.yml`
|
| 120 |
+
|
| 121 |
+
**Priority:** Medium
|
| 122 |
+
**Labels:** `Issue-Bug`, `Area-Build`, `Area-Pipeline`
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
## Issue Template Format
|
| 126 |
+
|
| 127 |
+
When creating an issue template for the default branch, use this structure:
|
| 128 |
+
|
| 129 |
+
```markdown
|
| 130 |
+
### Issue Title
|
| 131 |
+
[Clear, concise description of the problem]
|
| 132 |
+
|
| 133 |
+
### Description
|
| 134 |
+
[Detailed explanation of the issue]
|
| 135 |
+
|
| 136 |
+
**Current State:**
|
| 137 |
+
- [What's happening now]
|
| 138 |
+
- [Why it's problematic]
|
| 139 |
+
|
| 140 |
+
**Expected State:**
|
| 141 |
+
- [What should happen]
|
| 142 |
+
- [Proposed solution(s)]
|
| 143 |
+
|
| 144 |
+
**Files Affected:**
|
| 145 |
+
- [List of files]
|
| 146 |
+
|
| 147 |
+
**Priority:** [Low/Medium/High/Critical]
|
| 148 |
+
**Labels:** [Suggested labels like `Issue-Bug`, `Area-*`]
|
| 149 |
+
|
| 150 |
+
**Additional Context:**
|
| 151 |
+
[Any additional information, links to related issues, etc.]
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
## Common Scenarios
|
| 155 |
+
|
| 156 |
+
### Scenario 1: Template Dependency Issues
|
| 157 |
+
|
| 158 |
+
**Indicators:**
|
| 159 |
+
- Missing template includes
|
| 160 |
+
- Undefined variables from other templates
|
| 161 |
+
- Assumptions about pipeline execution order
|
| 162 |
+
|
| 163 |
+
**Action:** Suggest fixing template dependencies in the default branch.
|
| 164 |
+
|
| 165 |
+
### Scenario 2: Hardcoded Values
|
| 166 |
+
|
| 167 |
+
**Indicators:**
|
| 168 |
+
- Hardcoded paths replacing variables
|
| 169 |
+
- Environment-specific values in shared code
|
| 170 |
+
- Magic strings or numbers
|
| 171 |
+
|
| 172 |
+
**Action:** Suggest proper variable/parameter usage in the default branch.
|
| 173 |
+
|
| 174 |
+
### Scenario 3: Logic Errors
|
| 175 |
+
|
| 176 |
+
**Indicators:**
|
| 177 |
+
- Incorrect conditional logic
|
| 178 |
+
- Missing error handling
|
| 179 |
+
- Race conditions
|
| 180 |
+
|
| 181 |
+
**Action:** Suggest fixing the logic in the default branch unless it's release-specific.
|
| 182 |
+
|
| 183 |
+
### Scenario 4: Legitimate Release Branch Fixes
|
| 184 |
+
|
| 185 |
+
**Indicators:**
|
| 186 |
+
- Version-specific configuration
|
| 187 |
+
- Release packaging changes
|
| 188 |
+
- Backport of already-fixed default branch issue
|
| 189 |
+
|
| 190 |
+
**Action:** Provide normal code review feedback for the current PR.
|
| 191 |
+
|
| 192 |
+
## Best Practices
|
| 193 |
+
|
| 194 |
+
1. **Always check if the issue exists in the default branch** before suggesting a release-branch-only fix
|
| 195 |
+
2. **Prefer fixing root causes over workarounds**
|
| 196 |
+
3. **Provide clear rationale** for why a fix belongs in the default branch
|
| 197 |
+
4. **Include actionable issue templates** so users can easily create issues
|
| 198 |
+
5. **Be helpful, not blocking** - provide the feedback even if you can't enforce where it's fixed
|
| 199 |
+
|
| 200 |
+
## Examples of Good vs. Bad Approaches
|
| 201 |
+
|
| 202 |
+
### β Bad: Workaround in Release Branch Only
|
| 203 |
+
|
| 204 |
+
```yaml
|
| 205 |
+
# In release/v7.5 only
|
| 206 |
+
- pwsh: |
|
| 207 |
+
$metadata = Get-Content "$(Build.SourcesDirectory)/PowerShell/tools/metadata.json" -Raw
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
**Why bad:** Hardcodes path to work around missing `$repoRoot`, doesn't fix the default branch.
|
| 211 |
+
|
| 212 |
+
### β
Good: Fix in Default Branch, Then Backport
|
| 213 |
+
|
| 214 |
+
```yaml
|
| 215 |
+
# In default branch first
|
| 216 |
+
- template: SetVersionVariables.yml@self # Ensures $repoRoot is set
|
| 217 |
+
- template: channelSelection.yml@self # Now can use $repoRoot
|
| 218 |
+
```
|
| 219 |
+
|
| 220 |
+
**Why good:** Fixes the root cause by ensuring dependencies are declared, then backport to release if needed.
|
| 221 |
+
|
| 222 |
+
## When in Doubt
|
| 223 |
+
|
| 224 |
+
If you're unsure whether an issue should be fixed in the current branch or the default branch, ask yourself:
|
| 225 |
+
|
| 226 |
+
1. Does this issue exist in the default branch?
|
| 227 |
+
2. Is this a workaround or a proper fix?
|
| 228 |
+
3. Will other branches/releases benefit from this fix?
|
| 229 |
+
|
| 230 |
+
If the answer to any of these is "yes," suggest fixing it in the default branch first.
|
PowerShell-master/.github/instructions/instruction-file-format.instructions.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo:
|
| 3 |
+
- ".github/instructions/**/*.instructions.md"
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Instruction File Format Guide
|
| 7 |
+
|
| 8 |
+
This document describes the format and guidelines for creating custom instruction files for GitHub Copilot in the PowerShell repository.
|
| 9 |
+
|
| 10 |
+
## File Naming Convention
|
| 11 |
+
|
| 12 |
+
All instruction files must use the `.instructions.md` suffix:
|
| 13 |
+
- β
Correct: `build-checkout-prerequisites.instructions.md`
|
| 14 |
+
- β
Correct: `start-psbuild-basics.instructions.md`
|
| 15 |
+
- β Incorrect: `build-guide.md`
|
| 16 |
+
- β Incorrect: `instructions.md`
|
| 17 |
+
|
| 18 |
+
## Required Frontmatter
|
| 19 |
+
|
| 20 |
+
Every instruction file must start with YAML frontmatter containing an `applyTo` section:
|
| 21 |
+
|
| 22 |
+
```yaml
|
| 23 |
+
---
|
| 24 |
+
applyTo:
|
| 25 |
+
- "path/to/files/**/*.ext"
|
| 26 |
+
- "specific-file.ext"
|
| 27 |
+
---
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
### applyTo Patterns
|
| 31 |
+
|
| 32 |
+
Specify which files or directories these instructions apply to:
|
| 33 |
+
|
| 34 |
+
**For workflow files:**
|
| 35 |
+
```yaml
|
| 36 |
+
applyTo:
|
| 37 |
+
- ".github/**/*.yml"
|
| 38 |
+
- ".github/**/*.yaml"
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
**For build scripts:**
|
| 42 |
+
```yaml
|
| 43 |
+
applyTo:
|
| 44 |
+
- "build.psm1"
|
| 45 |
+
- "tools/ci.psm1"
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
**For multiple contexts:**
|
| 49 |
+
```yaml
|
| 50 |
+
applyTo:
|
| 51 |
+
- "build.psm1"
|
| 52 |
+
- "tools/**/*.psm1"
|
| 53 |
+
- ".github/**/*.yml"
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Content Structure
|
| 57 |
+
|
| 58 |
+
### 1. Clear Title
|
| 59 |
+
|
| 60 |
+
Use a descriptive H1 heading after the frontmatter:
|
| 61 |
+
|
| 62 |
+
```markdown
|
| 63 |
+
# Build Configuration Guide
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
### 2. Purpose or Overview
|
| 67 |
+
|
| 68 |
+
Start with a brief explanation of what the instructions cover:
|
| 69 |
+
|
| 70 |
+
```markdown
|
| 71 |
+
## Purpose
|
| 72 |
+
|
| 73 |
+
This guide explains how to configure PowerShell builds for different scenarios.
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
### 3. Actionable Content
|
| 77 |
+
|
| 78 |
+
Provide clear, actionable guidance:
|
| 79 |
+
|
| 80 |
+
**β
Good - Specific and actionable:**
|
| 81 |
+
```markdown
|
| 82 |
+
## Default Usage
|
| 83 |
+
|
| 84 |
+
Use `Start-PSBuild` with no parameters for testing:
|
| 85 |
+
|
| 86 |
+
```powershell
|
| 87 |
+
Import-Module ./tools/ci.psm1
|
| 88 |
+
Start-PSBuild
|
| 89 |
+
```
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
**β Bad - Vague and unclear:**
|
| 93 |
+
```markdown
|
| 94 |
+
## Usage
|
| 95 |
+
|
| 96 |
+
You can use Start-PSBuild to build stuff.
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
### 4. Code Examples
|
| 100 |
+
|
| 101 |
+
Include working code examples with proper syntax highlighting:
|
| 102 |
+
|
| 103 |
+
```markdown
|
| 104 |
+
```yaml
|
| 105 |
+
- name: Build PowerShell
|
| 106 |
+
shell: pwsh
|
| 107 |
+
run: |
|
| 108 |
+
Import-Module ./tools/ci.psm1
|
| 109 |
+
Start-PSBuild
|
| 110 |
+
```
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
### 5. Context and Rationale
|
| 114 |
+
|
| 115 |
+
Explain why things are done a certain way:
|
| 116 |
+
|
| 117 |
+
```markdown
|
| 118 |
+
**Why fetch-depth: 1000?**
|
| 119 |
+
- The build system needs Git history for version calculation
|
| 120 |
+
- Shallow clones would break versioning logic
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
## Best Practices
|
| 124 |
+
|
| 125 |
+
### Be Concise
|
| 126 |
+
|
| 127 |
+
- Focus on essential information
|
| 128 |
+
- Remove redundant explanations
|
| 129 |
+
- Use bullet points for lists
|
| 130 |
+
|
| 131 |
+
### Be Specific
|
| 132 |
+
|
| 133 |
+
- Provide exact commands and parameters
|
| 134 |
+
- Include file paths and line numbers when relevant
|
| 135 |
+
- Show concrete examples, not abstract concepts
|
| 136 |
+
|
| 137 |
+
### Avoid Duplication
|
| 138 |
+
|
| 139 |
+
- Don't repeat information from other instruction files
|
| 140 |
+
- Reference other files when appropriate
|
| 141 |
+
- Keep each file focused on one topic
|
| 142 |
+
|
| 143 |
+
### Use Proper Formatting
|
| 144 |
+
|
| 145 |
+
**Headers:**
|
| 146 |
+
- Use H1 (`#`) for the main title
|
| 147 |
+
- Use H2 (`##`) for major sections
|
| 148 |
+
- Use H3 (`###`) for subsections
|
| 149 |
+
|
| 150 |
+
**Code blocks:**
|
| 151 |
+
- Always specify the language: ` ```yaml `, ` ```powershell `, ` ```bash `
|
| 152 |
+
- Keep examples short and focused
|
| 153 |
+
- Test examples before including them
|
| 154 |
+
|
| 155 |
+
**Lists:**
|
| 156 |
+
- Use `-` for unordered lists
|
| 157 |
+
- Use `1.` for ordered lists
|
| 158 |
+
- Keep list items concise
|
| 159 |
+
|
| 160 |
+
## Example Structure
|
| 161 |
+
|
| 162 |
+
```markdown
|
| 163 |
+
---
|
| 164 |
+
applyTo:
|
| 165 |
+
- "relevant/files/**/*.ext"
|
| 166 |
+
---
|
| 167 |
+
|
| 168 |
+
# Title of Instructions
|
| 169 |
+
|
| 170 |
+
Brief description of what these instructions cover.
|
| 171 |
+
|
| 172 |
+
## Section 1
|
| 173 |
+
|
| 174 |
+
Content with examples.
|
| 175 |
+
|
| 176 |
+
```language
|
| 177 |
+
code example
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
## Section 2
|
| 181 |
+
|
| 182 |
+
More specific guidance.
|
| 183 |
+
|
| 184 |
+
### Subsection
|
| 185 |
+
|
| 186 |
+
Detailed information when needed.
|
| 187 |
+
|
| 188 |
+
## Best Practices
|
| 189 |
+
|
| 190 |
+
- Actionable tip 1
|
| 191 |
+
- Actionable tip 2
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
## Maintaining Instructions
|
| 195 |
+
|
| 196 |
+
### When to Create a New File
|
| 197 |
+
|
| 198 |
+
Create a new instruction file when:
|
| 199 |
+
- Covering a distinct topic not addressed elsewhere
|
| 200 |
+
- The content is substantial enough to warrant its own file
|
| 201 |
+
- The `applyTo` scope is different from existing files
|
| 202 |
+
|
| 203 |
+
### When to Update an Existing File
|
| 204 |
+
|
| 205 |
+
Update an existing file when:
|
| 206 |
+
- Information is outdated
|
| 207 |
+
- New best practices emerge
|
| 208 |
+
- Examples need correction
|
| 209 |
+
|
| 210 |
+
### When to Merge or Delete
|
| 211 |
+
|
| 212 |
+
Merge or delete files when:
|
| 213 |
+
- Content is duplicated across multiple files
|
| 214 |
+
- A file is too small to be useful standalone
|
| 215 |
+
- Information is no longer relevant
|
| 216 |
+
|
| 217 |
+
## Reference
|
| 218 |
+
|
| 219 |
+
For more details, see:
|
| 220 |
+
- [GitHub Copilot Custom Instructions Documentation](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions)
|
PowerShell-master/.github/instructions/log-grouping-guidelines.instructions.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo:
|
| 3 |
+
- "build.psm1"
|
| 4 |
+
- "tools/ci.psm1"
|
| 5 |
+
- ".github/**/*.yml"
|
| 6 |
+
- ".github/**/*.yaml"
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
# Log Grouping Guidelines for GitHub Actions
|
| 10 |
+
|
| 11 |
+
## Purpose
|
| 12 |
+
|
| 13 |
+
Guidelines for using `Write-LogGroupStart` and `Write-LogGroupEnd` to create collapsible log sections in GitHub Actions CI/CD runs.
|
| 14 |
+
|
| 15 |
+
## Key Principles
|
| 16 |
+
|
| 17 |
+
### 1. Groups Cannot Be Nested
|
| 18 |
+
|
| 19 |
+
GitHub Actions does not support nested groups. Only use one level of grouping.
|
| 20 |
+
|
| 21 |
+
**β Don't:**
|
| 22 |
+
```powershell
|
| 23 |
+
Write-LogGroupStart -Title "Outer Group"
|
| 24 |
+
Write-LogGroupStart -Title "Inner Group"
|
| 25 |
+
# ... operations ...
|
| 26 |
+
Write-LogGroupEnd -Title "Inner Group"
|
| 27 |
+
Write-LogGroupEnd -Title "Outer Group"
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
**β
Do:**
|
| 31 |
+
```powershell
|
| 32 |
+
Write-LogGroupStart -Title "Operation A"
|
| 33 |
+
# ... operations ...
|
| 34 |
+
Write-LogGroupEnd -Title "Operation A"
|
| 35 |
+
|
| 36 |
+
Write-LogGroupStart -Title "Operation B"
|
| 37 |
+
# ... operations ...
|
| 38 |
+
Write-LogGroupEnd -Title "Operation B"
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
### 2. Groups Should Be Substantial
|
| 42 |
+
|
| 43 |
+
Only create groups for operations that generate substantial output (5+ lines). Small groups add clutter without benefit.
|
| 44 |
+
|
| 45 |
+
**β Don't:**
|
| 46 |
+
```powershell
|
| 47 |
+
Write-LogGroupStart -Title "Generate Resource Files"
|
| 48 |
+
Write-Log -message "Run ResGen"
|
| 49 |
+
Start-ResGen
|
| 50 |
+
Write-LogGroupEnd -Title "Generate Resource Files"
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
**β
Do:**
|
| 54 |
+
```powershell
|
| 55 |
+
Write-Log -message "Run ResGen (generating C# bindings for resx files)"
|
| 56 |
+
Start-ResGen
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### 3. Groups Should Represent Independent Operations
|
| 60 |
+
|
| 61 |
+
Each group should be a logically independent operation that users might want to expand/collapse separately.
|
| 62 |
+
|
| 63 |
+
**β
Good examples:**
|
| 64 |
+
- Install Native Dependencies
|
| 65 |
+
- Install .NET SDK
|
| 66 |
+
- Build PowerShell
|
| 67 |
+
- Restore NuGet Packages
|
| 68 |
+
|
| 69 |
+
**β Bad examples:**
|
| 70 |
+
- Individual project restores (too granular)
|
| 71 |
+
- Small code generation steps (too small)
|
| 72 |
+
- Sub-steps of a larger operation (would require nesting)
|
| 73 |
+
|
| 74 |
+
### 4. One Group Per Iteration Is Excessive
|
| 75 |
+
|
| 76 |
+
Avoid putting log groups inside loops where each iteration creates a separate group. This would probably cause nesting.
|
| 77 |
+
|
| 78 |
+
**β Don't:**
|
| 79 |
+
```powershell
|
| 80 |
+
$projects | ForEach-Object {
|
| 81 |
+
Write-LogGroupStart -Title "Restore Project: $_"
|
| 82 |
+
dotnet restore $_
|
| 83 |
+
Write-LogGroupEnd -Title "Restore Project: $_"
|
| 84 |
+
}
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
**β
Do:**
|
| 88 |
+
```powershell
|
| 89 |
+
Write-LogGroupStart -Title "Restore All Projects"
|
| 90 |
+
$projects | ForEach-Object {
|
| 91 |
+
Write-Log -message "Restoring $_"
|
| 92 |
+
dotnet restore $_
|
| 93 |
+
}
|
| 94 |
+
Write-LogGroupEnd -Title "Restore All Projects"
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
## Usage Pattern
|
| 98 |
+
|
| 99 |
+
```powershell
|
| 100 |
+
Write-LogGroupStart -Title "Descriptive Operation Name"
|
| 101 |
+
try {
|
| 102 |
+
# ... operation code ...
|
| 103 |
+
Write-Log -message "Status updates"
|
| 104 |
+
}
|
| 105 |
+
finally {
|
| 106 |
+
# Ensure group is always closed
|
| 107 |
+
}
|
| 108 |
+
Write-LogGroupEnd -Title "Descriptive Operation Name"
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
## When to Use Log Groups
|
| 112 |
+
|
| 113 |
+
Use log groups for:
|
| 114 |
+
- Major build phases (bootstrap, restore, build, test, package)
|
| 115 |
+
- Installation operations (dependencies, SDKs, tools)
|
| 116 |
+
- Operations that produce 5+ lines of output
|
| 117 |
+
- Operations where users might want to collapse verbose output
|
| 118 |
+
|
| 119 |
+
Don't use log groups for:
|
| 120 |
+
- Single-line operations
|
| 121 |
+
- Code that's already inside another group
|
| 122 |
+
- Loop iterations with minimal output per iteration
|
| 123 |
+
- Diagnostic or debug output that should always be visible
|
| 124 |
+
|
| 125 |
+
## Examples from build.psm1
|
| 126 |
+
|
| 127 |
+
### Good Usage
|
| 128 |
+
|
| 129 |
+
```powershell
|
| 130 |
+
function Start-PSBootstrap {
|
| 131 |
+
# Multiple independent operations, each with substantial output
|
| 132 |
+
Write-LogGroupStart -Title "Install Native Dependencies"
|
| 133 |
+
# ... apt-get/yum/brew install commands ...
|
| 134 |
+
Write-LogGroupEnd -Title "Install Native Dependencies"
|
| 135 |
+
|
| 136 |
+
Write-LogGroupStart -Title "Install .NET SDK"
|
| 137 |
+
# ... dotnet installation ...
|
| 138 |
+
Write-LogGroupEnd -Title "Install .NET SDK"
|
| 139 |
+
}
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
### Avoid
|
| 143 |
+
|
| 144 |
+
```powershell
|
| 145 |
+
# Too small - just 2-3 lines
|
| 146 |
+
Write-LogGroupStart -Title "Generate Resource Files (ResGen)"
|
| 147 |
+
Write-Log -message "Run ResGen"
|
| 148 |
+
Start-ResGen
|
| 149 |
+
Write-LogGroupEnd -Title "Generate Resource Files (ResGen)"
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
## GitHub Actions Syntax
|
| 153 |
+
|
| 154 |
+
These functions emit GitHub Actions workflow commands:
|
| 155 |
+
- `Write-LogGroupStart` β `::group::Title`
|
| 156 |
+
- `Write-LogGroupEnd` β `::endgroup::`
|
| 157 |
+
|
| 158 |
+
In the GitHub Actions UI, this renders as collapsible sections with the specified title.
|
| 159 |
+
|
| 160 |
+
## Testing
|
| 161 |
+
|
| 162 |
+
Test log grouping locally:
|
| 163 |
+
```powershell
|
| 164 |
+
$env:GITHUB_ACTIONS = 'true'
|
| 165 |
+
Import-Module ./build.psm1
|
| 166 |
+
Write-LogGroupStart -Title "Test"
|
| 167 |
+
Write-Log -Message "Content"
|
| 168 |
+
Write-LogGroupEnd -Title "Test"
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
Output should show:
|
| 172 |
+
```
|
| 173 |
+
::group::Test
|
| 174 |
+
Content
|
| 175 |
+
::endgroup::
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
## References
|
| 179 |
+
|
| 180 |
+
- [GitHub Actions: Grouping log lines](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines)
|
| 181 |
+
- `build.psm1`: `Write-LogGroupStart` and `Write-LogGroupEnd` function definitions
|
PowerShell-master/.github/instructions/onebranch-condition-syntax.instructions.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo: ".pipelines/**/*.{yml,yaml}"
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# OneBranch Pipeline Condition Syntax
|
| 6 |
+
|
| 7 |
+
## Overview
|
| 8 |
+
Azure Pipelines (OneBranch) uses specific syntax for referencing variables and parameters in condition expressions. Using the wrong syntax will cause conditions to fail silently or behave unexpectedly.
|
| 9 |
+
|
| 10 |
+
## Variable Reference Patterns
|
| 11 |
+
|
| 12 |
+
### In Condition Expressions
|
| 13 |
+
|
| 14 |
+
**β
Correct Pattern:**
|
| 15 |
+
```yaml
|
| 16 |
+
condition: eq(variables['VariableName'], 'value')
|
| 17 |
+
condition: or(eq(variables['VAR1'], 'true'), eq(variables['VAR2'], 'true'))
|
| 18 |
+
condition: and(succeeded(), eq(variables['Architecture'], 'fxdependent'))
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
**β Incorrect Patterns:**
|
| 22 |
+
```yaml
|
| 23 |
+
# Don't use $(VAR) string expansion in conditions
|
| 24 |
+
condition: eq('$(VariableName)', 'value')
|
| 25 |
+
|
| 26 |
+
# Don't use direct variable references
|
| 27 |
+
condition: eq($VariableName, 'value')
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
### In Script Content (pwsh, bash, etc.)
|
| 31 |
+
|
| 32 |
+
**β
Correct Pattern:**
|
| 33 |
+
```yaml
|
| 34 |
+
- pwsh: |
|
| 35 |
+
$value = '$(VariableName)'
|
| 36 |
+
Write-Host "Value: $(VariableName)"
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
### In Input Fields
|
| 40 |
+
|
| 41 |
+
**β
Correct Pattern:**
|
| 42 |
+
```yaml
|
| 43 |
+
inputs:
|
| 44 |
+
serviceEndpoint: '$(ServiceEndpoint)'
|
| 45 |
+
sbConfigPath: '$(SBConfigPath)'
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Parameter References
|
| 49 |
+
|
| 50 |
+
### Template Parameters (Compile-Time)
|
| 51 |
+
|
| 52 |
+
**β
Correct Pattern:**
|
| 53 |
+
```yaml
|
| 54 |
+
parameters:
|
| 55 |
+
- name: OfficialBuild
|
| 56 |
+
type: boolean
|
| 57 |
+
default: false
|
| 58 |
+
|
| 59 |
+
steps:
|
| 60 |
+
- task: SomeTask@1
|
| 61 |
+
condition: eq('${{ parameters.OfficialBuild }}', 'true')
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Note: Parameters use `${{ parameters.Name }}` because they're evaluated at template compile-time.
|
| 65 |
+
|
| 66 |
+
### Runtime Variables (Execution-Time)
|
| 67 |
+
|
| 68 |
+
**β
Correct Pattern:**
|
| 69 |
+
```yaml
|
| 70 |
+
steps:
|
| 71 |
+
- pwsh: |
|
| 72 |
+
Write-Host "##vso[task.setvariable variable=MyVar]somevalue"
|
| 73 |
+
displayName: Set Variable
|
| 74 |
+
|
| 75 |
+
- task: SomeTask@1
|
| 76 |
+
condition: eq(variables['MyVar'], 'somevalue')
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Common Scenarios
|
| 80 |
+
|
| 81 |
+
### Scenario 1: Check if Variable Equals Value
|
| 82 |
+
|
| 83 |
+
```yaml
|
| 84 |
+
- task: DoSomething@1
|
| 85 |
+
condition: eq(variables['PREVIEW'], 'true')
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
### Scenario 2: Multiple Variable Conditions (OR)
|
| 89 |
+
|
| 90 |
+
```yaml
|
| 91 |
+
- task: DoSomething@1
|
| 92 |
+
condition: or(eq(variables['STABLE'], 'true'), eq(variables['LTS'], 'true'))
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
### Scenario 3: Multiple Variable Conditions (AND)
|
| 96 |
+
|
| 97 |
+
```yaml
|
| 98 |
+
- task: DoSomething@1
|
| 99 |
+
condition: and(succeeded(), eq(variables['Architecture'], 'fxdependent'))
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
### Scenario 4: Complex Conditions
|
| 103 |
+
|
| 104 |
+
```yaml
|
| 105 |
+
- task: DoSomething@1
|
| 106 |
+
condition: and(
|
| 107 |
+
succeededOrFailed(),
|
| 108 |
+
ne(variables['UseAzDevOpsFeed'], ''),
|
| 109 |
+
eq(variables['Build.SourceBranch'], 'refs/heads/master')
|
| 110 |
+
)
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
### Scenario 5: Built-in Variables
|
| 114 |
+
|
| 115 |
+
```yaml
|
| 116 |
+
- task: CodeQL3000Init@0
|
| 117 |
+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
|
| 118 |
+
|
| 119 |
+
- step: finalize
|
| 120 |
+
condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues')
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
### Scenario 6: Parameter vs Variable
|
| 124 |
+
|
| 125 |
+
```yaml
|
| 126 |
+
parameters:
|
| 127 |
+
- name: OfficialBuild
|
| 128 |
+
type: boolean
|
| 129 |
+
|
| 130 |
+
steps:
|
| 131 |
+
# Parameter condition (compile-time)
|
| 132 |
+
- task: SignFiles@1
|
| 133 |
+
condition: eq('${{ parameters.OfficialBuild }}', 'true')
|
| 134 |
+
|
| 135 |
+
# Variable condition (runtime)
|
| 136 |
+
- task: PublishArtifact@1
|
| 137 |
+
condition: eq(variables['PUBLISH_ENABLED'], 'true')
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
## Why This Matters
|
| 141 |
+
|
| 142 |
+
**String Expansion `$(VAR)` in Conditions:**
|
| 143 |
+
- When you use `'$(VAR)'` in a condition, Azure Pipelines attempts to expand it as a string
|
| 144 |
+
- If the variable is undefined or empty, it becomes an empty string `''`
|
| 145 |
+
- The condition `eq('', 'true')` will always be false
|
| 146 |
+
- This makes debugging difficult because there's no error message
|
| 147 |
+
|
| 148 |
+
**Variables Array Syntax `variables['VAR']`:**
|
| 149 |
+
- This is the proper way to reference runtime variables in conditions
|
| 150 |
+
- Azure Pipelines correctly evaluates the variable's value
|
| 151 |
+
- Undefined variables are handled properly by the condition evaluator
|
| 152 |
+
- This is the standard pattern used throughout Azure Pipelines
|
| 153 |
+
|
| 154 |
+
## Reference Examples
|
| 155 |
+
|
| 156 |
+
Working examples can be found in:
|
| 157 |
+
- `.pipelines/templates/linux.yml` - Build.SourceBranch conditions
|
| 158 |
+
- `.pipelines/templates/windows-hosted-build.yml` - Architecture conditions
|
| 159 |
+
- `.pipelines/templates/compliance/apiscan.yml` - CODEQL_ENABLED conditions
|
| 160 |
+
- `.pipelines/templates/insert-nuget-config-azfeed.yml` - Complex AND/OR conditions
|
| 161 |
+
|
| 162 |
+
## Quick Reference Table
|
| 163 |
+
|
| 164 |
+
| Context | Syntax | Example |
|
| 165 |
+
|---------|--------|---------|
|
| 166 |
+
| Condition expression | `variables['Name']` | `condition: eq(variables['PREVIEW'], 'true')` |
|
| 167 |
+
| Script content | `$(Name)` | `pwsh: Write-Host "$(PREVIEW)"` |
|
| 168 |
+
| Task input | `$(Name)` | `inputs: path: '$(Build.SourcesDirectory)'` |
|
| 169 |
+
| Template parameter | `${{ parameters.Name }}` | `condition: eq('${{ parameters.Official }}', 'true')` |
|
| 170 |
+
|
| 171 |
+
## Troubleshooting
|
| 172 |
+
|
| 173 |
+
### Condition Always False
|
| 174 |
+
If your condition is always evaluating to false:
|
| 175 |
+
1. Check if you're using `'$(VAR)'` instead of `variables['VAR']`
|
| 176 |
+
2. Verify the variable is actually set (add a debug step to print the variable)
|
| 177 |
+
3. Check the variable value is exactly what you expect (case-sensitive)
|
| 178 |
+
|
| 179 |
+
### Variable Not Found
|
| 180 |
+
If you get errors about variables not being found:
|
| 181 |
+
1. Ensure the variable is set before the condition is evaluated
|
| 182 |
+
2. Check that the variable name is spelled correctly
|
| 183 |
+
3. Verify the variable is in scope (job vs. stage vs. pipeline level)
|
| 184 |
+
|
| 185 |
+
## Best Practices
|
| 186 |
+
|
| 187 |
+
1. **Always use `variables['Name']` in conditions** - This is the correct Azure Pipelines pattern
|
| 188 |
+
2. **Use `$(Name)` for string expansion** in scripts and inputs
|
| 189 |
+
3. **Use `${{ parameters.Name }}` for template parameters** (compile-time)
|
| 190 |
+
4. **Add debug steps** to verify variable values when troubleshooting conditions
|
| 191 |
+
5. **Follow existing patterns** in the repository - grep for `condition:` to see examples
|
| 192 |
+
|
| 193 |
+
## Common Mistakes
|
| 194 |
+
|
| 195 |
+
β **Mistake 1: String expansion in condition**
|
| 196 |
+
```yaml
|
| 197 |
+
condition: eq('$(PREVIEW)', 'true') # WRONG
|
| 198 |
+
```
|
| 199 |
+
|
| 200 |
+
β
**Fix:**
|
| 201 |
+
```yaml
|
| 202 |
+
condition: eq(variables['PREVIEW'], 'true') # CORRECT
|
| 203 |
+
```
|
| 204 |
+
|
| 205 |
+
β **Mistake 2: Missing quotes around parameter**
|
| 206 |
+
```yaml
|
| 207 |
+
condition: eq(${{ parameters.Official }}, true) # WRONG
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
β
**Fix:**
|
| 211 |
+
```yaml
|
| 212 |
+
condition: eq('${{ parameters.Official }}', 'true') # CORRECT
|
| 213 |
+
```
|
| 214 |
+
|
| 215 |
+
β **Mistake 3: Mixing syntax**
|
| 216 |
+
```yaml
|
| 217 |
+
condition: or(eq('$(STABLE)', 'true'), eq(variables['LTS'], 'true')) # INCONSISTENT
|
| 218 |
+
```
|
| 219 |
+
|
| 220 |
+
β
**Fix:**
|
| 221 |
+
```yaml
|
| 222 |
+
condition: or(eq(variables['STABLE'], 'true'), eq(variables['LTS'], 'true')) # CORRECT
|
| 223 |
+
```
|
PowerShell-master/.github/instructions/onebranch-restore-phase-pattern.instructions.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo: ".pipelines/**/*.{yml,yaml}"
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# OneBranch Restore Phase Pattern
|
| 6 |
+
|
| 7 |
+
## Overview
|
| 8 |
+
When steps need to run in the OneBranch restore phase (before the main build phase), the `ob_restore_phase` environment variable must be set in the `env:` block of **each individual step**.
|
| 9 |
+
|
| 10 |
+
## Pattern
|
| 11 |
+
|
| 12 |
+
### β
Correct (Working Pattern)
|
| 13 |
+
```yaml
|
| 14 |
+
parameters:
|
| 15 |
+
- name: "ob_restore_phase"
|
| 16 |
+
type: boolean
|
| 17 |
+
default: true # or false if you don't want restore phase
|
| 18 |
+
|
| 19 |
+
steps:
|
| 20 |
+
- powershell: |
|
| 21 |
+
# script content
|
| 22 |
+
displayName: 'Step Name'
|
| 23 |
+
env:
|
| 24 |
+
ob_restore_phase: ${{ parameters.ob_restore_phase }}
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
The key is to:
|
| 28 |
+
1. Define `ob_restore_phase` as a **boolean** parameter
|
| 29 |
+
2. Set `ob_restore_phase: ${{ parameters.ob_restore_phase }}` directly in each step's `env:` block
|
| 30 |
+
3. Pass `true` to run in restore phase, `false` to run in normal build phase
|
| 31 |
+
|
| 32 |
+
### β Incorrect (Does Not Work)
|
| 33 |
+
```yaml
|
| 34 |
+
steps:
|
| 35 |
+
- powershell: |
|
| 36 |
+
# script content
|
| 37 |
+
displayName: 'Step Name'
|
| 38 |
+
${{ if eq(parameters.useRestorePhase, 'yes') }}:
|
| 39 |
+
env:
|
| 40 |
+
ob_restore_phase: true
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
Using conditionals at the same indentation level as `env:` causes only the first step to execute in restore phase.
|
| 44 |
+
|
| 45 |
+
## Parameters
|
| 46 |
+
|
| 47 |
+
Templates using this pattern should accept an `ob_restore_phase` boolean parameter:
|
| 48 |
+
|
| 49 |
+
```yaml
|
| 50 |
+
parameters:
|
| 51 |
+
- name: "ob_restore_phase"
|
| 52 |
+
type: boolean
|
| 53 |
+
default: true # Set to true to run in restore phase by default
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Reference Examples
|
| 57 |
+
|
| 58 |
+
Working examples of this pattern can be found in:
|
| 59 |
+
- `.pipelines/templates/insert-nuget-config-azfeed.yml` - Demonstrates the correct pattern
|
| 60 |
+
- `.pipelines/templates/SetVersionVariables.yml` - Updated to use this pattern
|
| 61 |
+
|
| 62 |
+
## Why This Matters
|
| 63 |
+
|
| 64 |
+
The restore phase in OneBranch pipelines runs before signing and other build operations. Steps that need to:
|
| 65 |
+
- Set environment variables for the entire build
|
| 66 |
+
- Configure authentication
|
| 67 |
+
- Prepare the repository structure
|
| 68 |
+
|
| 69 |
+
Must run in the restore phase to be available when subsequent stages execute.
|
| 70 |
+
|
| 71 |
+
## Common Use Cases
|
| 72 |
+
|
| 73 |
+
- Setting `REPOROOT` variable
|
| 74 |
+
- Configuring NuGet feeds with authentication
|
| 75 |
+
- Setting version variables
|
| 76 |
+
- Repository preparation and validation
|
| 77 |
+
|
| 78 |
+
## Troubleshooting
|
| 79 |
+
|
| 80 |
+
If only the first step in your template is running in restore phase:
|
| 81 |
+
1. Check that `env:` block exists for **each step**
|
| 82 |
+
2. Verify the conditional `${{ if ... }}:` is **inside** the `env:` block
|
| 83 |
+
3. Confirm indentation is correct (conditional is indented under `env:`)
|
PowerShell-master/.github/instructions/onebranch-signing-configuration.instructions.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo:
|
| 3 |
+
- ".pipelines/**/*.yml"
|
| 4 |
+
- ".pipelines/**/*.yaml"
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# OneBranch Signing Configuration
|
| 8 |
+
|
| 9 |
+
This guide explains how to configure OneBranch signing variables in Azure Pipeline jobs, particularly when signing is not required.
|
| 10 |
+
|
| 11 |
+
## Purpose
|
| 12 |
+
|
| 13 |
+
OneBranch pipelines include signing infrastructure by default. For build-only jobs where signing happens in a separate stage, you should disable signing setup to improve performance and avoid unnecessary overhead.
|
| 14 |
+
|
| 15 |
+
## Disable Signing for Build-Only Jobs
|
| 16 |
+
|
| 17 |
+
When a job does not perform signing (e.g., it only builds artifacts that will be signed in a later stage), disable both signing setup and code sign validation:
|
| 18 |
+
|
| 19 |
+
```yaml
|
| 20 |
+
variables:
|
| 21 |
+
- name: ob_signing_setup_enabled
|
| 22 |
+
value: false # Disable signing setup - this is a build-only stage
|
| 23 |
+
- name: ob_sdl_codeSignValidation_enabled
|
| 24 |
+
value: false # Skip signing validation in build-only stage
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
### Why Disable These Variables?
|
| 28 |
+
|
| 29 |
+
**`ob_signing_setup_enabled: false`**
|
| 30 |
+
- Prevents OneBranch from setting up the signing infrastructure
|
| 31 |
+
- Reduces job startup time
|
| 32 |
+
- Avoids unnecessary credential validation
|
| 33 |
+
- Only disable when the job will NOT sign any artifacts
|
| 34 |
+
|
| 35 |
+
**`ob_sdl_codeSignValidation_enabled: false`**
|
| 36 |
+
- Skips validation that checks if files are properly signed
|
| 37 |
+
- Appropriate for build stages where artifacts are unsigned
|
| 38 |
+
- Must be enabled in signing/release stages to validate signatures
|
| 39 |
+
|
| 40 |
+
## Common Patterns
|
| 41 |
+
|
| 42 |
+
### Build-Only Job (No Signing)
|
| 43 |
+
|
| 44 |
+
```yaml
|
| 45 |
+
jobs:
|
| 46 |
+
- job: build_artifacts
|
| 47 |
+
variables:
|
| 48 |
+
- name: ob_signing_setup_enabled
|
| 49 |
+
value: false
|
| 50 |
+
- name: ob_sdl_codeSignValidation_enabled
|
| 51 |
+
value: false
|
| 52 |
+
steps:
|
| 53 |
+
- checkout: self
|
| 54 |
+
- pwsh: |
|
| 55 |
+
# Build unsigned artifacts
|
| 56 |
+
Start-PSBuild
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### Signing Job
|
| 60 |
+
|
| 61 |
+
```yaml
|
| 62 |
+
jobs:
|
| 63 |
+
- job: sign_artifacts
|
| 64 |
+
variables:
|
| 65 |
+
- name: ob_signing_setup_enabled
|
| 66 |
+
value: true
|
| 67 |
+
- name: ob_sdl_codeSignValidation_enabled
|
| 68 |
+
value: true
|
| 69 |
+
steps:
|
| 70 |
+
- checkout: self
|
| 71 |
+
env:
|
| 72 |
+
ob_restore_phase: true # Steps before first signing operation
|
| 73 |
+
- pwsh: |
|
| 74 |
+
# Prepare artifacts for signing
|
| 75 |
+
env:
|
| 76 |
+
ob_restore_phase: true # Steps before first signing operation
|
| 77 |
+
- task: onebranch.pipeline.signing@1
|
| 78 |
+
displayName: 'Sign artifacts'
|
| 79 |
+
# Signing step runs in build phase (no ob_restore_phase)
|
| 80 |
+
- pwsh: |
|
| 81 |
+
# Post-signing validation
|
| 82 |
+
# Post-signing steps run in build phase (no ob_restore_phase)
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## Restore Phase Usage with Signing
|
| 86 |
+
|
| 87 |
+
**The restore phase (`ob_restore_phase: true`) should only be used in jobs that perform signing operations.** It separates preparation steps from the actual signing and build steps.
|
| 88 |
+
|
| 89 |
+
### When to Use Restore Phase
|
| 90 |
+
|
| 91 |
+
Use `ob_restore_phase: true` **only** in jobs where `ob_signing_setup_enabled: true`:
|
| 92 |
+
|
| 93 |
+
```yaml
|
| 94 |
+
jobs:
|
| 95 |
+
- job: sign_artifacts
|
| 96 |
+
variables:
|
| 97 |
+
- name: ob_signing_setup_enabled
|
| 98 |
+
value: true # Signing enabled
|
| 99 |
+
steps:
|
| 100 |
+
# Steps BEFORE first signing operation: use restore phase
|
| 101 |
+
- checkout: self
|
| 102 |
+
env:
|
| 103 |
+
ob_restore_phase: true
|
| 104 |
+
- template: prepare-for-signing.yml
|
| 105 |
+
parameters:
|
| 106 |
+
ob_restore_phase: true
|
| 107 |
+
|
| 108 |
+
# SIGNING STEP: runs in build phase (no ob_restore_phase)
|
| 109 |
+
- task: onebranch.pipeline.signing@1
|
| 110 |
+
displayName: 'Sign artifacts'
|
| 111 |
+
|
| 112 |
+
# Steps AFTER signing: run in build phase (no ob_restore_phase)
|
| 113 |
+
- pwsh: |
|
| 114 |
+
# Validation or packaging
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
### When NOT to Use Restore Phase
|
| 118 |
+
|
| 119 |
+
**Do not use restore phase in build-only jobs** where `ob_signing_setup_enabled: false`:
|
| 120 |
+
|
| 121 |
+
```yaml
|
| 122 |
+
jobs:
|
| 123 |
+
- job: build_artifacts
|
| 124 |
+
variables:
|
| 125 |
+
- name: ob_signing_setup_enabled
|
| 126 |
+
value: false # No signing
|
| 127 |
+
- name: ob_sdl_codeSignValidation_enabled
|
| 128 |
+
value: false
|
| 129 |
+
steps:
|
| 130 |
+
- checkout: self
|
| 131 |
+
# NO ob_restore_phase - not needed without signing
|
| 132 |
+
- pwsh: |
|
| 133 |
+
Start-PSBuild
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
**Why?** The restore phase is part of OneBranch's signing infrastructure. Using it without signing enabled adds unnecessary overhead without benefit.
|
| 137 |
+
|
| 138 |
+
## Related Variables
|
| 139 |
+
|
| 140 |
+
Other OneBranch signing-related variables:
|
| 141 |
+
|
| 142 |
+
- `ob_sdl_binskim_enabled`: Controls BinSkim security analysis (can be false in build-only, true in signing stages)
|
| 143 |
+
|
| 144 |
+
## Best Practices
|
| 145 |
+
|
| 146 |
+
1. **Separate build and signing stages**: Build artifacts in one job, sign in another
|
| 147 |
+
2. **Disable signing in build stages**: Improves performance and clarifies intent
|
| 148 |
+
3. **Only use restore phase with signing**: The restore phase should only be used in jobs where signing is enabled (`ob_signing_setup_enabled: true`)
|
| 149 |
+
4. **Restore phase before first signing step**: All steps before the first signing operation should use `ob_restore_phase: true`
|
| 150 |
+
5. **Always validate after signing**: Enable validation in signing stages to catch issues
|
| 151 |
+
6. **Document the reason**: Add comments explaining why signing is disabled or why restore phase is used
|
| 152 |
+
|
| 153 |
+
## Example: Split Build and Sign Pipeline
|
| 154 |
+
|
| 155 |
+
```yaml
|
| 156 |
+
stages:
|
| 157 |
+
- stage: Build
|
| 158 |
+
jobs:
|
| 159 |
+
- job: build_windows
|
| 160 |
+
variables:
|
| 161 |
+
- name: ob_signing_setup_enabled
|
| 162 |
+
value: false # Build-only, no signing
|
| 163 |
+
- name: ob_sdl_codeSignValidation_enabled
|
| 164 |
+
value: false # Artifacts are unsigned
|
| 165 |
+
steps:
|
| 166 |
+
- template: templates/build-unsigned.yml
|
| 167 |
+
|
| 168 |
+
- stage: Sign
|
| 169 |
+
dependsOn: Build
|
| 170 |
+
jobs:
|
| 171 |
+
- job: sign_windows
|
| 172 |
+
variables:
|
| 173 |
+
- name: ob_signing_setup_enabled
|
| 174 |
+
value: true # Enable signing infrastructure
|
| 175 |
+
- name: ob_sdl_codeSignValidation_enabled
|
| 176 |
+
value: true # Validate signatures
|
| 177 |
+
steps:
|
| 178 |
+
- template: templates/sign-artifacts.yml
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
## Troubleshooting
|
| 182 |
+
|
| 183 |
+
**Job fails with signing-related errors but signing is disabled:**
|
| 184 |
+
- Verify `ob_signing_setup_enabled: false` is set in variables
|
| 185 |
+
- Check that no template is overriding the setting
|
| 186 |
+
- Ensure `ob_sdl_codeSignValidation_enabled: false` is also set
|
| 187 |
+
|
| 188 |
+
**Signed artifacts fail validation:**
|
| 189 |
+
- Confirm `ob_sdl_codeSignValidation_enabled: true` in signing job
|
| 190 |
+
- Verify signing actually occurred
|
| 191 |
+
- Check certificate configuration
|
| 192 |
+
|
| 193 |
+
## Reference
|
| 194 |
+
|
| 195 |
+
- PowerShell signing templates: `.pipelines/templates/packaging/windows/sign.yml`
|
PowerShell-master/.github/instructions/pester-set-itresult-pattern.instructions.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo:
|
| 3 |
+
- "**/*.Tests.ps1"
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Pester Set-ItResult Pattern for Pending and Skipped Tests
|
| 7 |
+
|
| 8 |
+
## Purpose
|
| 9 |
+
|
| 10 |
+
This instruction explains when and how to use `Set-ItResult` in Pester tests to mark tests as Pending or Skipped dynamically within test execution.
|
| 11 |
+
|
| 12 |
+
## When to Use Set-ItResult
|
| 13 |
+
|
| 14 |
+
Use `Set-ItResult` when you need to conditionally mark a test as Pending or Skipped based on runtime conditions that can't be determined at test definition time.
|
| 15 |
+
|
| 16 |
+
### Pending vs Skipped
|
| 17 |
+
|
| 18 |
+
**Pending**: Use for tests that should be enabled but temporarily can't run due to:
|
| 19 |
+
- Intermittent external service failures (network, APIs)
|
| 20 |
+
- Known bugs being fixed
|
| 21 |
+
- Missing features being implemented
|
| 22 |
+
- Environmental issues that are being resolved
|
| 23 |
+
|
| 24 |
+
**Skipped**: Use for tests that aren't applicable to the current environment:
|
| 25 |
+
- Platform-specific tests running on wrong platform
|
| 26 |
+
- Tests requiring specific hardware/configuration not present
|
| 27 |
+
- Tests requiring elevated permissions when not available
|
| 28 |
+
- Feature-specific tests when feature is disabled
|
| 29 |
+
|
| 30 |
+
## Pattern
|
| 31 |
+
|
| 32 |
+
### Basic Usage
|
| 33 |
+
|
| 34 |
+
```powershell
|
| 35 |
+
It "Test description" {
|
| 36 |
+
if ($shouldBePending) {
|
| 37 |
+
Set-ItResult -Pending -Because "Explanation of why test is pending"
|
| 38 |
+
return
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
if ($shouldBeSkipped) {
|
| 42 |
+
Set-ItResult -Skipped -Because "Explanation of why test is skipped"
|
| 43 |
+
return
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
# Test code here
|
| 47 |
+
}
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### Important: Always Return After Set-ItResult
|
| 51 |
+
|
| 52 |
+
After calling `Set-ItResult`, you **must** return from the test to prevent further execution:
|
| 53 |
+
|
| 54 |
+
```powershell
|
| 55 |
+
It "Test that checks environment" {
|
| 56 |
+
if ($env:SKIP_TESTS -eq 'true') {
|
| 57 |
+
Set-ItResult -Skipped -Because "SKIP_TESTS environment variable is set"
|
| 58 |
+
return # This is required!
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
# Test assertions
|
| 62 |
+
$result | Should -Be $expected
|
| 63 |
+
}
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
**Why?** Without `return`, the test continues executing and may fail with errors unrelated to the pending/skipped condition.
|
| 67 |
+
|
| 68 |
+
## Examples from the Codebase
|
| 69 |
+
|
| 70 |
+
### Example 1: Pending for Intermittent Network Issues
|
| 71 |
+
|
| 72 |
+
```powershell
|
| 73 |
+
It "Validate Update-Help for module" {
|
| 74 |
+
if ($markAsPending) {
|
| 75 |
+
Set-ItResult -Pending -Because "Update-Help from the web has intermittent connectivity issues. See issues #2807 and #6541."
|
| 76 |
+
return
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
Update-Help -Module $moduleName -Force
|
| 80 |
+
# validation code...
|
| 81 |
+
}
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
### Example 2: Skipped for Missing Environment
|
| 85 |
+
|
| 86 |
+
```powershell
|
| 87 |
+
It "Test requires CI environment" {
|
| 88 |
+
if (-not $env:CI) {
|
| 89 |
+
Set-ItResult -Skipped -Because "Test requires CI environment to safely install Pester"
|
| 90 |
+
return
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
Install-CIPester -ErrorAction Stop
|
| 94 |
+
}
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
### Example 3: Pending for Platform-Specific Issue
|
| 98 |
+
|
| 99 |
+
```powershell
|
| 100 |
+
It "Clear-Host works correctly" {
|
| 101 |
+
if ($IsARM64) {
|
| 102 |
+
Set-ItResult -Pending -Because "ARM64 runs in non-interactively mode and Clear-Host does not work."
|
| 103 |
+
return
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
& { Clear-Host; 'hi' } | Should -BeExactly 'hi'
|
| 107 |
+
}
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
### Example 4: Skipped for Missing Feature
|
| 111 |
+
|
| 112 |
+
```powershell
|
| 113 |
+
It "Test ACR authentication" {
|
| 114 |
+
if ($env:ACRTESTS -ne 'true') {
|
| 115 |
+
Set-ItResult -Skipped -Because "The tests require the ACRTESTS environment variable to be set to 'true' for ACR authentication."
|
| 116 |
+
return
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
$psgetModuleInfo = Find-PSResource -Name $ACRTestModule -Repository $ACRRepositoryName
|
| 120 |
+
# test assertions...
|
| 121 |
+
}
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
## Alternative: Static -Skip and -Pending Parameters
|
| 125 |
+
|
| 126 |
+
For conditions that can be determined at test definition time, use the static parameters instead:
|
| 127 |
+
|
| 128 |
+
```powershell
|
| 129 |
+
# Static skip - condition known at definition time
|
| 130 |
+
It "Windows-only test" -Skip:(-not $IsWindows) {
|
| 131 |
+
# test code
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
# Static pending - always pending
|
| 135 |
+
It "Test for feature being implemented" -Pending {
|
| 136 |
+
# test code that will fail until feature is done
|
| 137 |
+
}
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
**Use Set-ItResult when**:
|
| 141 |
+
- Condition depends on runtime state
|
| 142 |
+
- Condition is determined inside a helper function
|
| 143 |
+
- Need to check multiple conditions sequentially
|
| 144 |
+
|
| 145 |
+
**Use static parameters when**:
|
| 146 |
+
- Condition is known at test definition
|
| 147 |
+
- Condition doesn't change during test run
|
| 148 |
+
- Want Pester to show the condition in test discovery
|
| 149 |
+
|
| 150 |
+
## Best Practices
|
| 151 |
+
|
| 152 |
+
1. **Always include -Because parameter** with a clear explanation
|
| 153 |
+
2. **Always return after Set-ItResult** to prevent further execution
|
| 154 |
+
3. **Reference issues or documentation** when relevant (e.g., "See issue #1234")
|
| 155 |
+
4. **Be specific in the reason** - explain what's wrong and what's needed
|
| 156 |
+
5. **Use Pending sparingly** - it indicates a problem that should be fixed
|
| 157 |
+
6. **Prefer Skipped over Pending** when test truly isn't applicable
|
| 158 |
+
|
| 159 |
+
## Common Mistakes
|
| 160 |
+
|
| 161 |
+
### β Mistake 1: Forgetting to Return
|
| 162 |
+
|
| 163 |
+
```powershell
|
| 164 |
+
It "Test" {
|
| 165 |
+
if ($condition) {
|
| 166 |
+
Set-ItResult -Pending -Because "Reason"
|
| 167 |
+
# Missing return - test code will still execute!
|
| 168 |
+
}
|
| 169 |
+
$value | Should -Be $expected # This runs and fails
|
| 170 |
+
}
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
### β Mistake 2: Vague Reason
|
| 174 |
+
|
| 175 |
+
```powershell
|
| 176 |
+
Set-ItResult -Pending -Because "Doesn't work" # Too vague
|
| 177 |
+
```
|
| 178 |
+
|
| 179 |
+
### β
Correct:
|
| 180 |
+
|
| 181 |
+
```powershell
|
| 182 |
+
It "Test" {
|
| 183 |
+
if ($condition) {
|
| 184 |
+
Set-ItResult -Pending -Because "Update-Help has intermittent network timeouts. See issue #2807."
|
| 185 |
+
return
|
| 186 |
+
}
|
| 187 |
+
$value | Should -Be $expected
|
| 188 |
+
}
|
| 189 |
+
```
|
| 190 |
+
|
| 191 |
+
## See Also
|
| 192 |
+
|
| 193 |
+
- [Pester Documentation: Set-ItResult](https://pester.dev/docs/commands/Set-ItResult)
|
| 194 |
+
- [Pester Documentation: It](https://pester.dev/docs/commands/It)
|
| 195 |
+
- Examples in the codebase:
|
| 196 |
+
- `test/powershell/Host/ConsoleHost.Tests.ps1`
|
| 197 |
+
- `test/infrastructure/ciModule.Tests.ps1`
|
| 198 |
+
- `tools/packaging/releaseTests/sbom.tests.ps1`
|
PowerShell-master/.github/instructions/pester-test-status-and-working-meaning.instructions.md
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo: "**/*.Tests.ps1"
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# Pester Test Status Meanings and Working Tests
|
| 6 |
+
|
| 7 |
+
## Purpose
|
| 8 |
+
|
| 9 |
+
This guide clarifies Pester test outcomes and what it means for a test to be "working" - which requires both **passing** AND **actually validating functionality**.
|
| 10 |
+
|
| 11 |
+
## Test Statuses in Pester
|
| 12 |
+
|
| 13 |
+
### Passed β
|
| 14 |
+
**Status Code**: `Passed`
|
| 15 |
+
**Exit Result**: Test ran successfully, all assertions passed
|
| 16 |
+
|
| 17 |
+
**What it means**:
|
| 18 |
+
- Test executed without errors
|
| 19 |
+
- All `Should` statements evaluated to true
|
| 20 |
+
- Test setup and teardown completed without issues
|
| 21 |
+
- Test is **validating** the intended functionality
|
| 22 |
+
|
| 23 |
+
**What it does NOT mean**:
|
| 24 |
+
- The feature is working (assertions could be wrong)
|
| 25 |
+
- The test is meaningful (could be testing wrong thing)
|
| 26 |
+
- The test exercises all code paths
|
| 27 |
+
|
| 28 |
+
### Failed β
|
| 29 |
+
**Status Code**: `Failed`
|
| 30 |
+
**Exit Result**: Test ran but assertions failed
|
| 31 |
+
|
| 32 |
+
**What it means**:
|
| 33 |
+
- Test executed but an assertion returned false
|
| 34 |
+
- Expected value did not match actual value
|
| 35 |
+
- Test detected a problem with the functionality
|
| 36 |
+
|
| 37 |
+
**Examples**:
|
| 38 |
+
```
|
| 39 |
+
Expected $true but got $false
|
| 40 |
+
Expected 5 items but got 3
|
| 41 |
+
Expected no error but got: Cannot find parameter
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
### Error β
|
| 45 |
+
**Status Code**: `Error`
|
| 46 |
+
**Exit Result**: Test crashed with an exception
|
| 47 |
+
|
| 48 |
+
**What it means**:
|
| 49 |
+
- Test failed to complete
|
| 50 |
+
- An exception was thrown during test execution
|
| 51 |
+
- Could be in test setup, test body, or test cleanup
|
| 52 |
+
- Often indicates environmental issue, not code functional issue
|
| 53 |
+
|
| 54 |
+
**Examples**:
|
| 55 |
+
```
|
| 56 |
+
Cannot bind argument to parameter 'Path' because it is null
|
| 57 |
+
File not found: C:\expected\config.json
|
| 58 |
+
Access denied writing to registry
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
### Pending β³
|
| 62 |
+
**Status Code**: `Pending`
|
| 63 |
+
**Exit Result**: Test ran but never completed assertions
|
| 64 |
+
|
| 65 |
+
**What it means**:
|
| 66 |
+
- Test was explicitly marked as not ready to run
|
| 67 |
+
- `Set-ItResult -Pending` was called
|
| 68 |
+
- Used to indicate: known bugs, missing features, environmental issues
|
| 69 |
+
|
| 70 |
+
**When to use Pending**:
|
| 71 |
+
- Test for feature in development
|
| 72 |
+
- Test disabled due to known bug (issue #1234)
|
| 73 |
+
- Test disabled due to intermittent failures being fixed
|
| 74 |
+
- Platform-specific issues being resolved
|
| 75 |
+
|
| 76 |
+
**β οΈ WARNING**: Pending tests are NOT validating functionality. They hide problems.
|
| 77 |
+
|
| 78 |
+
### Skipped β
|
| 79 |
+
**Status Code**: `Skipped`
|
| 80 |
+
**Exit Result**: Test did not run (detected at start)
|
| 81 |
+
|
| 82 |
+
**What it means**:
|
| 83 |
+
- Test was intentionally not executed
|
| 84 |
+
- `-Skip` parameter or `It -Skip:$condition` was used
|
| 85 |
+
- Environment doesn't support this test
|
| 86 |
+
|
| 87 |
+
**When to use Skip**:
|
| 88 |
+
- Test not applicable to current platform (Windows-only test on Linux)
|
| 89 |
+
- Test requires feature that's not available (admin privileges)
|
| 90 |
+
- Test requires specific configuration not present
|
| 91 |
+
|
| 92 |
+
**Difference from Pending**:
|
| 93 |
+
- **Skip**: "This test shouldn't run here" (known upfront)
|
| 94 |
+
- **Pending**: "This test should eventually run but can't now"
|
| 95 |
+
|
| 96 |
+
### Ignored β
|
| 97 |
+
**Status Code**: `Ignored`
|
| 98 |
+
**Exit Result**: Test marked as not applicable
|
| 99 |
+
|
| 100 |
+
**What it means**:
|
| 101 |
+
- Test has `[Ignore("reason")]` attribute
|
| 102 |
+
- Test is permanently disabled in this location
|
| 103 |
+
- Not the same as Skipped (which is conditional)
|
| 104 |
+
|
| 105 |
+
**When to use Ignore**:
|
| 106 |
+
- Test for deprecated feature
|
| 107 |
+
- Test for bug that won't be fixed
|
| 108 |
+
- Test moved to different test file
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
## What Does "Working" Actually Mean?
|
| 113 |
+
|
| 114 |
+
A test is **working** when it meets BOTH criteria:
|
| 115 |
+
|
| 116 |
+
### 1. **Test Status is PASSED** β
|
| 117 |
+
```powershell
|
| 118 |
+
It "Test name" {
|
| 119 |
+
# Test executes
|
| 120 |
+
# All assertions pass
|
| 121 |
+
# Returns Passed status
|
| 122 |
+
}
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
### 2. **Test Actually Validates Functionality**
|
| 126 |
+
```powershell
|
| 127 |
+
# β GOOD: Tests actual functionality
|
| 128 |
+
It "Get-Item returns files from directory" -Tags @('Unit') {
|
| 129 |
+
$testDir = New-Item -ItemType Directory -Force
|
| 130 |
+
New-Item -Path $testDir -Name "file.txt" -ItemType File | Out-Null
|
| 131 |
+
|
| 132 |
+
$result = Get-Item -Path "$testDir\file.txt"
|
| 133 |
+
|
| 134 |
+
$result.Name | Should -Be "file.txt"
|
| 135 |
+
$result | Should -Exist
|
| 136 |
+
|
| 137 |
+
Remove-Item $testDir -Recurse -Force
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
# β BAD: Returns Passed but doesn't validate functionality
|
| 141 |
+
It "Get-Item returns files from directory" -Tags @('Unit') {
|
| 142 |
+
$result = Get-Item -Path somepath # May not exist, may not actually test
|
| 143 |
+
$result | Should -Not -BeNullOrEmpty # Too vague
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
# β BAD: Test marked Pending - validation is hidden
|
| 147 |
+
It "Get-Item returns files from directory" -Tags @('Unit') {
|
| 148 |
+
Set-ItResult -Pending -Because "File system not working"
|
| 149 |
+
return
|
| 150 |
+
# No validation happens at all
|
| 151 |
+
}
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
---
|
| 155 |
+
|
| 156 |
+
## The Problem with Pending Tests
|
| 157 |
+
|
| 158 |
+
### Why Pending Tests Hide Problems
|
| 159 |
+
|
| 160 |
+
```powershell
|
| 161 |
+
# BAD: Test marked Pending - looks like "working" status but validation is skipped
|
| 162 |
+
It "Download help from web" {
|
| 163 |
+
Set-ItResult -Pending -Because "Web connectivity issues"
|
| 164 |
+
return
|
| 165 |
+
|
| 166 |
+
# This code never runs:
|
| 167 |
+
Update-Help -Module PackageManagement -Force -ErrorAction Stop
|
| 168 |
+
Get-Help Get-Package | Should -Not -BeNullOrEmpty
|
| 169 |
+
}
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
**Result**:
|
| 173 |
+
- β Feature is broken (Update-Help fails)
|
| 174 |
+
- β Test shows "Pending" (looks acceptable)
|
| 175 |
+
- β Problem is hidden and never fixed
|
| 176 |
+
|
| 177 |
+
### The Right Approach
|
| 178 |
+
|
| 179 |
+
**Option A: Fix the root cause**
|
| 180 |
+
```powershell
|
| 181 |
+
It "Download help from web" {
|
| 182 |
+
# Use local assets that are guaranteed to work
|
| 183 |
+
Update-Help -Module PackageManagement -SourcePath ./assets -Force -ErrorAction Stop
|
| 184 |
+
|
| 185 |
+
Get-Help Get-Package | Should -Not -BeNullOrEmpty
|
| 186 |
+
}
|
| 187 |
+
```
|
| 188 |
+
|
| 189 |
+
**Option B: Gracefully skip when unavailable**
|
| 190 |
+
```powershell
|
| 191 |
+
It "Download help from web" -Skip:$(-not $hasInternet) {
|
| 192 |
+
Update-Help -Module PackageManagement -Force -ErrorAction Stop
|
| 193 |
+
Get-Help Get-Package | Should -Not -BeNullOrEmpty
|
| 194 |
+
}
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
**Option C: Add retry logic for intermittent issues**
|
| 198 |
+
```powershell
|
| 199 |
+
It "Download help from web" {
|
| 200 |
+
$maxRetries = 3
|
| 201 |
+
$attempt = 0
|
| 202 |
+
|
| 203 |
+
while ($attempt -lt $maxRetries) {
|
| 204 |
+
try {
|
| 205 |
+
Update-Help -Module PackageManagement -Force -ErrorAction Stop
|
| 206 |
+
break
|
| 207 |
+
}
|
| 208 |
+
catch {
|
| 209 |
+
$attempt++
|
| 210 |
+
if ($attempt -ge $maxRetries) { throw }
|
| 211 |
+
Start-Sleep -Seconds 2
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
Get-Help Get-Package | Should -Not -BeNullOrEmpty
|
| 216 |
+
}
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
---
|
| 220 |
+
|
| 221 |
+
## Test Status Summary Table
|
| 222 |
+
|
| 223 |
+
| Status | Passed? | Validates? | Counts as "Working"? | Use When |
|
| 224 |
+
|--------|---------|------------|----------------------|----------|
|
| 225 |
+
| **Passed** | β | β | **YES** | Feature is working and test proves it |
|
| 226 |
+
| **Failed** | β | β | NO | Feature is broken or test has wrong expectation |
|
| 227 |
+
| **Error** | β | β | NO | Test infrastructure broken, can't validate |
|
| 228 |
+
| **Pending** | - | β | **NO** β οΈ | Temporary - test should eventually pass |
|
| 229 |
+
| **Skipped** | - | β | NO | Test not applicable to this environment |
|
| 230 |
+
| **Ignored** | - | β | NO | Test permanently disabled |
|
| 231 |
+
|
| 232 |
+
---
|
| 233 |
+
|
| 234 |
+
## Recommended Patterns
|
| 235 |
+
|
| 236 |
+
### Pattern 1: Resilient Test with Fallback
|
| 237 |
+
```powershell
|
| 238 |
+
It "Feature works with web or local source" {
|
| 239 |
+
$useLocal = $false
|
| 240 |
+
|
| 241 |
+
try {
|
| 242 |
+
Update-Help -Module Package -Force -ErrorAction Stop
|
| 243 |
+
}
|
| 244 |
+
catch {
|
| 245 |
+
$useLocal = $true
|
| 246 |
+
Update-Help -Module Package -SourcePath ./assets -Force -ErrorAction Stop
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
# Validate functionality regardless of source
|
| 250 |
+
Get-Help Get-Package | Should -Not -BeNullOrEmpty
|
| 251 |
+
}
|
| 252 |
+
```
|
| 253 |
+
|
| 254 |
+
### Pattern 2: Conditional Skip with Clear Reason
|
| 255 |
+
```powershell
|
| 256 |
+
Describe "Update-Help from Web" -Skip $(-not (Test-InternetConnectivity)) {
|
| 257 |
+
It "Downloads help successfully" {
|
| 258 |
+
Update-Help -Module PackageManagement -Force -ErrorAction Stop
|
| 259 |
+
Get-Help Get-Package | Should -Not -BeNullOrEmpty
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
```
|
| 263 |
+
|
| 264 |
+
### Pattern 3: Separate Suites by Dependency
|
| 265 |
+
```powershell
|
| 266 |
+
Describe "Help Content Tests - Web" {
|
| 267 |
+
# Tests that require internet - can be skipped if unavailable
|
| 268 |
+
It "Downloads from web" { ... }
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
Describe "Help Content Tests - Local" {
|
| 272 |
+
# Tests with local assets - should always pass
|
| 273 |
+
It "Loads from local assets" {
|
| 274 |
+
Update-Help -Module Package -SourcePath ./assets -Force
|
| 275 |
+
Get-Help Get-Package | Should -Not -BeNullOrEmpty
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
```
|
| 279 |
+
|
| 280 |
+
---
|
| 281 |
+
|
| 282 |
+
## Checklist: Is Your Test "Working"?
|
| 283 |
+
|
| 284 |
+
- [ ] Test status is **Passed** (not Pending, not Skipped, not Failed)
|
| 285 |
+
- [ ] Test actually **executes** the feature being tested
|
| 286 |
+
- [ ] Test has **specific assertions** (not just `Should -Not -BeNullOrEmpty`)
|
| 287 |
+
- [ ] Test includes **cleanup** (removes temp files, restores state)
|
| 288 |
+
- [ ] Test can run **multiple times** without side effects
|
| 289 |
+
- [ ] Test failure **indicates a real problem** (not flaky assertions)
|
| 290 |
+
- [ ] Test success **proves the feature works** (not just "didn't crash")
|
| 291 |
+
|
| 292 |
+
If any of these is false, your test may be passing but not "working" properly.
|
| 293 |
+
|
| 294 |
+
---
|
| 295 |
+
|
| 296 |
+
## See Also
|
| 297 |
+
|
| 298 |
+
- [Pester Documentation](https://pester.dev/)
|
| 299 |
+
- [Set-ItResult Documentation](https://pester.dev/docs/commands/Set-ItResult)
|