From 47ea21a3ec902cc8b114dd3c33b1000577c3e1e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:23:23 +1000 Subject: [PATCH 1/3] Bump actions/checkout from 3 to 4 (#282) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/analyze.yaml | 6 +++--- .github/workflows/build.yaml | 4 ++-- .github/workflows/docs.yaml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/analyze.yaml b/.github/workflows/analyze.yaml index 67928f1..b2a78b4 100644 --- a/.github/workflows/analyze.yaml +++ b/.github/workflows/analyze.yaml @@ -29,7 +29,7 @@ jobs: contents: read steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run PSRule analysis uses: microsoft/ps-rule@main @@ -46,7 +46,7 @@ jobs: security-events: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run DevSkim scanner uses: microsoft/DevSkim-Action@v1 @@ -67,7 +67,7 @@ jobs: security-events: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 619b6bc..66665e5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 @@ -105,7 +105,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 4d7ffe5..2962e12 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -22,7 +22,7 @@ jobs: contents: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 From 1e03d05d7b7fe4a1cb57ad7e37d94005b65e8b81 Mon Sep 17 00:00:00 2001 From: Bernie White Date: Tue, 24 Oct 2023 14:43:47 +1000 Subject: [PATCH 2/3] Updated repo files (#297) --- .azure-pipelines/azure-pipelines.yaml | 189 ----------------------- .azure-pipelines/jobs/test.yaml | 76 --------- .azure-pipelines/jobs/testContainer.yaml | 76 --------- .devcontainer/Dockerfile | 10 ++ .devcontainer/container-build.ps1 | 25 +++ .devcontainer/container-start.ps1 | 11 ++ .devcontainer/devcontainer.json | 46 +++++- .editorconfig | 83 ++++++++++ .vscode/extensions.json | 12 +- .vscode/tasks.json | 128 +++++++-------- GitVersion.yml | 24 +++ modules.json | 18 +++ scripts/dependencies.psm1 | 152 ++++++++++++++++++ scripts/pipeline-deps.ps1 | 4 +- 14 files changed, 437 insertions(+), 417 deletions(-) delete mode 100644 .azure-pipelines/azure-pipelines.yaml delete mode 100644 .azure-pipelines/jobs/test.yaml delete mode 100644 .azure-pipelines/jobs/testContainer.yaml create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/container-build.ps1 create mode 100644 .devcontainer/container-start.ps1 create mode 100644 .editorconfig create mode 100644 GitVersion.yml create mode 100644 modules.json create mode 100644 scripts/dependencies.psm1 diff --git a/.azure-pipelines/azure-pipelines.yaml b/.azure-pipelines/azure-pipelines.yaml deleted file mode 100644 index cfd0313..0000000 --- a/.azure-pipelines/azure-pipelines.yaml +++ /dev/null @@ -1,189 +0,0 @@ -# Azure DevOps -# CI pipeline for PSDocs.Azure - -variables: - version: '0.4.0' - buildConfiguration: 'Release' - disable.coverage.autogenerate: 'true' - imageName: 'ubuntu-22.04' - - # Use build number format, i.e. 0.4.0-B2101001 -name: $(version)-B$(date:yyMM)$(rev:rrr) - -trigger: - branches: - include: - - 'main' - - 'release/*' - tags: - include: - - 'v0.*' - -pr: - branches: - include: - - 'main' - - 'release/*' - -stages: - -# Build pipeline -- stage: Build - displayName: Build - dependsOn: [] - jobs: - - job: - pool: - vmImage: $(imageName) - displayName: 'Module' - steps: - - # Install pipeline dependencies - - powershell: ./scripts/pipeline-deps.ps1 - displayName: 'Install dependencies' - - # Build module - - powershell: Invoke-Build -Configuration $(buildConfiguration) -Build $(Build.BuildNumber) - displayName: 'Build module' - - # DotNet test results - - task: PublishTestResults@2 - displayName: 'Publish unit test results' - inputs: - testRunTitle: 'DotNet on $(imageName)' - testRunner: VSTest - testResultsFiles: 'reports/*.trx' - mergeTestResults: true - platform: $(imageName) - configuration: $(buildConfiguration) - publishRunAttachments: true - condition: succeededOrFailed() - - # PSRule results - - task: PublishTestResults@2 - displayName: 'Publish PSRule results' - inputs: - testRunTitle: 'PSRule on $(imageName)' - testRunner: NUnit - testResultsFiles: 'reports/ps-rule*.xml' - mergeTestResults: true - platform: $(imageName) - configuration: $(buildConfiguration) - publishRunAttachments: true - condition: succeededOrFailed() - - # Generate artifacts - - publish: out/modules/PSDocs.Azure - displayName: 'Publish module' - artifact: PSDocs.Azure - -# Analysis pipeline -- stage: Analysis - displayName: Analysis - dependsOn: [] - variables: - skipComponentGovernanceDetection: true - jobs: - - - job: Secret_Scan - pool: - vmImage: 'windows-2022' - displayName: Secret scan - steps: - - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 - displayName: 'Scan for secrets' - inputs: - debugMode: false - toolMajorVersion: V2 - - - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2 - displayName: 'Publish scan logs' - continueOnError: true - - - task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1 - displayName: 'Check for failures' - inputs: - CredScan: true - ToolLogsNotFoundAction: Error - -# Test pipeline -- stage: Test - dependsOn: Build - jobs: - - - template: jobs/test.yaml - parameters: - name: ubuntu_22_04_coverage - imageName: 'ubuntu-22.04' - displayName: 'PowerShell coverage' - coverage: 'true' - publishResults: 'false' - - - template: jobs/test.yaml - parameters: - name: macOS_11 - displayName: 'PowerShell 7.3 - macOS-11' - imageName: 'macOS-11' - - - template: jobs/test.yaml - parameters: - name: windows_2022_5_1 - displayName: 'PowerShell 5.1 - Windows 2022' - imageName: 'windows-2022' - pwsh: 'false' - - - template: jobs/test.yaml - parameters: - name: windows_2022 - displayName: 'PowerShell 7.2 - Windows 2022' - imageName: 'windows-2022' - - - template: jobs/testContainer.yaml - parameters: - name: ps_7_3_ubuntu_22_04 - displayName: 'PowerShell 7.3 - ubuntu-22.04' - imageName: mcr.microsoft.com/powershell - imageTag: 7.3-ubuntu-22.04 - -# Release pipeline -- stage: Release - displayName: Release - dependsOn: [ 'Test', 'Analysis' ] - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v0.')) - jobs: - - job: - displayName: Live - pool: - vmImage: $(imageName) - variables: - isPreRelease: $[contains(variables['Build.SourceBranchName'], '-B')] - steps: - - # Download module from build - - task: DownloadPipelineArtifact@2 - displayName: 'Download module' - inputs: - artifact: PSDocs.Azure - path: $(Build.SourcesDirectory)/out/modules/PSDocs.Azure - - # Install pipeline dependencies - - powershell: ./.azure-pipelines/pipeline-deps.ps1 - displayName: 'Install dependencies' - - # Install pipeline dependencies and build module - - powershell: Invoke-Build Release -ApiKey $(apiKey) - displayName: 'Publish module' - - # Update GitHub release - - task: GitHubRelease@1 - displayName: 'GitHub release' - inputs: - gitHubConnection: 'AzureDevOps-PSDocs.Azure' - repositoryName: '$(Build.Repository.Name)' - action: edit - tag: '$(Build.SourceBranchName)' - releaseNotesSource: inline - releaseNotesInline: 'See [change log](https://github.com/Azure/PSDocs.Azure/blob/main/CHANGELOG.md)' - assetUploadMode: replace - addChangeLog: false - isPreRelease: $(isPreRelease) diff --git a/.azure-pipelines/jobs/test.yaml b/.azure-pipelines/jobs/test.yaml deleted file mode 100644 index a4a2a07..0000000 --- a/.azure-pipelines/jobs/test.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# Azure DevOps -# CI job for running VM pipelines - -parameters: - name: '' - displayName: '' - buildConfiguration: 'Release' - imageName: '' - coverage: 'false' - publishResults: 'true' - pwsh: 'true' - -jobs: -- job: ${{ parameters.name }} - displayName: ${{ parameters.displayName }} - pool: - vmImage: ${{ parameters.imageName }} - variables: - COVERAGE: ${{ parameters.coverage }} - PUBLISHRESULTS: ${{ parameters.publishResults }} - skipComponentGovernanceDetection: true - steps: - - # Install pipeline dependencies - - powershell: ./scripts/pipeline-deps.ps1 - displayName: 'Install dependencies' - - # Download module - - task: DownloadPipelineArtifact@2 - displayName: 'Download module' - inputs: - artifact: PSDocs.Azure - path: $(Build.SourcesDirectory)/out/modules/PSDocs.Azure - - # Build module - - task: PowerShell@2 - inputs: - targetType: inline - script: Invoke-Build TestModule -Configuration ${{ parameters.buildConfiguration }} -Build $(Build.BuildNumber) - pwsh: ${{ eq(parameters.pwsh, 'true') }} - env: - COVERAGE: ${{ parameters.coverage }} - displayName: 'Test module' - - # Pester test results - - task: PublishTestResults@2 - displayName: 'Publish Pester results' - inputs: - testRunTitle: 'Pester on ${{ parameters.imageName }}' - testRunner: NUnit - testResultsFiles: 'reports/pester-unit.xml' - mergeTestResults: true - platform: ${{ parameters.name }} - configuration: ${{ parameters.buildConfiguration }} - publishRunAttachments: true - condition: and(succeededOrFailed(), eq(variables['PUBLISHRESULTS'], 'true')) - - # Generate Code Coverage report - - task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4 - displayName: 'Code coverage report generator' - inputs: - reports: 'reports/pester-coverage.xml' - targetdir: 'reports/coverage' - sourcedirs: 'src/PSDocs.Azure' - reporttypes: 'HtmlInline_AzurePipelines;Cobertura;SonarQube;Badges' - tag: $(Build.BuildNumber) - condition: eq(variables['COVERAGE'], 'true') - - # Publish Code Coverage report - - task: PublishCodeCoverageResults@1 - displayName: 'Publish Pester code coverage' - inputs: - codeCoverageTool: 'Cobertura' - summaryFileLocation: 'reports/coverage/Cobertura.xml' - reportDirectory: 'reports/coverage' - condition: eq(variables['COVERAGE'], 'true') diff --git a/.azure-pipelines/jobs/testContainer.yaml b/.azure-pipelines/jobs/testContainer.yaml deleted file mode 100644 index b317552..0000000 --- a/.azure-pipelines/jobs/testContainer.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# Azure DevOps -# CI job for running container pipelines - -parameters: - name: '' - displayName: '' - buildConfiguration: 'Release' - vmImage: 'ubuntu-22.04' - imageName: '' - imageTag: '' - coverage: 'false' - publishResults: 'true' - -jobs: -- job: ${{ parameters.name }} - displayName: ${{ parameters.displayName }} - pool: - vmImage: ${{ parameters.vmImage }} - container: - image: '${{ parameters.imageName }}:${{ parameters.imageTag }}' - env: - COVERAGE: ${{ parameters.coverage }} - PUBLISHRESULTS: ${{ parameters.publishResults }} - variables: - COVERAGE: ${{ parameters.coverage }} - PUBLISHRESULTS: ${{ parameters.publishResults }} - skipComponentGovernanceDetection: true - steps: - - # Install pipeline dependencies - - powershell: ./scripts/pipeline-deps.ps1 - displayName: 'Install dependencies' - - # Download module - - task: DownloadPipelineArtifact@2 - displayName: 'Download module' - inputs: - artifact: PSDocs.Azure - path: $(Build.SourcesDirectory)/out/modules/PSDocs.Azure - - # Build module - - powershell: Invoke-Build TestModule -Configuration ${{ parameters.buildConfiguration }} -Build $(Build.BuildNumber) - displayName: 'Test module' - - # Pester test results - - task: PublishTestResults@2 - displayName: 'Publish Pester results' - inputs: - testRunTitle: 'Pester on ${{ parameters.imageTag }}' - testRunner: NUnit - testResultsFiles: 'reports/pester-unit.xml' - mergeTestResults: true - platform: ${{ parameters.imageTag }} - configuration: ${{ parameters.buildConfiguration }} - publishRunAttachments: true - condition: and(succeededOrFailed(), eq(variables['PUBLISHRESULTS'], 'true')) - - # Generate Code Coverage report - - task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4 - displayName: 'Code coverage report generator' - inputs: - reports: 'reports\pester-coverage.xml' - targetdir: 'reports\coverage' - sourcedirs: 'src\PSDocs.Azure' - reporttypes: 'HtmlInline_AzurePipelines;Cobertura;SonarQube;Badges' - tag: $(Build.BuildNumber) - condition: eq(variables['COVERAGE'], 'true') - - # Publish Code Coverage report - - task: PublishCodeCoverageResults@1 - displayName: 'Publish Pester code coverage' - inputs: - codeCoverageTool: 'Cobertura' - summaryFileLocation: 'reports/coverage/Cobertura.xml' - reportDirectory: 'reports/coverage' - condition: eq(variables['COVERAGE'], 'true') diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..7856981 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,10 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Visual Studio Code image with .NET + +# NOTE: +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/main/containers/dotnet + +ARG VARIANT="7.0-bullseye-slim" +FROM mcr.microsoft.com/vscode/devcontainers/dotnet:${VARIANT} diff --git a/.devcontainer/container-build.ps1 b/.devcontainer/container-build.ps1 new file mode 100644 index 0000000..a01331b --- /dev/null +++ b/.devcontainer/container-build.ps1 @@ -0,0 +1,25 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Note: +# This is run during container creation. + +# Install Python 3 dependencies +sudo apt install python3-pip -y +sudo python3 -m pip install --upgrade pip +sudo python3 -m pip install wheel + +# Install PowerShell dependencies +$ProgressPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue; +if ($Null -eq (Get-PackageProvider -Name NuGet -ErrorAction Ignore)) { + Install-PackageProvider -Name NuGet -Force -Scope CurrentUser; +} +if ($Null -eq (Get-InstalledModule -Name PowerShellGet -MinimumVersion 2.2.1 -ErrorAction Ignore)) { + Install-Module PowerShellGet -MinimumVersion 2.2.1 -Scope CurrentUser -Force -AllowClobber; +} +if ($Null -eq (Get-InstalledModule -Name InvokeBuild -MinimumVersion 5.4.0 -ErrorAction Ignore)) { + Install-Module InvokeBuild -MinimumVersion 5.4.0 -Scope CurrentUser -Force; +} + +Import-Module ./scripts/dependencies.psm1; +Install-Dependencies -Dev; diff --git a/.devcontainer/container-start.ps1 b/.devcontainer/container-start.ps1 new file mode 100644 index 0000000..6835f14 --- /dev/null +++ b/.devcontainer/container-start.ps1 @@ -0,0 +1,11 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Note: +# This is run during container startup. + +# Install Python packages +pip install -r requirements-docs.txt + +# Restore .NET packages +dotnet restore diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1348a90..27a1783 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,8 +1,46 @@ { - "extensions": [ - "ms-azure-devops.azure-pipelines", + "name": "PSDocs for Azure Developer Codespace", + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "pwsh", + "terminal.integrated.profiles.linux": { + "pwsh": { + "path": "/opt/microsoft/powershell/7/pwsh" + } + } + }, + "extensions": [ + "ms-dotnettools.vscode-dotnet-runtime", + "ms-dotnettools.csdevkit", "ms-vscode.powershell", + "ms-azuretools.vscode-bicep", + "msazurermtools.azurerm-vscode-tools", + "GitHub.vscode-pull-request-github", + "github.vscode-github-actions", "davidanson.vscode-markdownlint", - "redhat.vscode-yaml" - ] + "eamodio.gitlens" + ] + } + }, + "features": { + "ghcr.io/devcontainers/features/github-cli": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/powershell": { + "version": "latest" + } + }, + "onCreateCommand": "/opt/microsoft/powershell/7/pwsh -f .devcontainer/container-build.ps1", + "postStartCommand": "/opt/microsoft/powershell/7/pwsh -f .devcontainer/container-start.ps1", + "build": { + "dockerfile": "Dockerfile", + "args": { + "VARIANT": "7.0-bullseye-slim" + } + }, + "remoteUser": "vscode", + "forwardPorts": [ + 8000 + ] } diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4dfc394 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,83 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# Top-most EditorConfig file +root = true + +# Default +[*] +charset = utf-8 +indent_style = space +insert_final_newline = true + +# Source code +[*.{cs,ps1,psd1,psm1}] +indent_size = 4 + +# Xml project files +[*.{csproj,resx,ps1xml}] +indent_size = 2 + +# C# files +[*.cs] + +# Code style defaults +csharp_using_directive_placement = outside_namespace:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_preferred_modifier_order.severity = suggestion +dotnet_sort_system_directives_first = true +dotnet_style_readonly_field = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion + +# License header +file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License. + +# Suggest more modern language features when available +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion + +# Pattern matching +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_switch_expression = false:none +csharp_style_prefer_pattern_matching = false:none + +# Prefer "var" everywhere +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_var_elsewhere = true:suggestion + +# Define the 'private_fields' symbol group: +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private + +# Define the 'private_static_fields' symbol group +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private +dotnet_naming_symbols.private_static_fields.required_modifiers = static + +# Define the 'underscored' naming style +dotnet_naming_style.underscored.capitalization = pascal_case +dotnet_naming_style.underscored.required_prefix = _ + +# Private instance fields must use pascal case with a leading '_' +dotnet_naming_rule.private_fields_underscored.symbols = private_fields +dotnet_naming_rule.private_fields_underscored.style = underscored +dotnet_naming_rule.private_fields_underscored.severity = error + +# Exclude private static fields from underscored style +dotnet_naming_rule.private_static_fields_none.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_none.style = underscored +dotnet_naming_rule.private_static_fields_none.severity = none diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 44ae527..ccaee2c 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,8 +1,8 @@ { - "recommendations": [ - "ms-vscode.powershell", - "ms-azure-devops.azure-pipelines", - "redhat.vscode-yaml", - "streetsidesoftware.code-spell-checker" - ] + "recommendations": [ + "ms-vscode.powershell", + "ms-azure-devops.azure-pipelines", + "redhat.vscode-yaml", + "streetsidesoftware.code-spell-checker" + ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ccb108e..5225a84 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,66 +1,66 @@ { - "version": "2.0.0", - "tasks": [ - { - "label": "Test", - "type": "shell", - "detail": "Build and test module.", - "command": "Invoke-Build Test -AssertStyle Client", - "group": { - "kind": "test", - "isDefault": true - }, - "problemMatcher": [ - "$pester" - ], - "presentation": { - "clear": true, - "panel": "dedicated" - } - }, - { - "label": "Build", - "detail": "Build module.", - "type": "shell", - "command": "Invoke-Build Build", - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [], - "presentation": { - "clear": true, - "panel": "dedicated" - } - }, - { - "label": "Clean", - "type": "shell", - "detail": "Clean output directories.", - "command": "Invoke-Build Clean", - "problemMatcher": [] - }, - { - "label": "Update template docs", - "detail": "Generate template markdown docs.", - "type": "shell", - "command": "Invoke-Build UpdateTemplateDocs", - "problemMatcher": [], - "presentation": { - "clear": true, - "panel": "dedicated" - } - }, - { - "label": "Serve docs", - "detail": "Build and run documentation site locally.", - "type": "shell", - "command": "mkdocs serve", - "problemMatcher": [], - "presentation": { - "clear": true, - "panel": "dedicated" - } - } - ] + "version": "2.0.0", + "tasks": [ + { + "label": "Test", + "type": "shell", + "detail": "Build and test module.", + "command": "Invoke-Build Test -AssertStyle Client", + "group": { + "kind": "test", + "isDefault": true + }, + "problemMatcher": [ + "$pester" + ], + "presentation": { + "clear": true, + "panel": "dedicated" + } + }, + { + "label": "Build", + "detail": "Build module.", + "type": "shell", + "command": "Invoke-Build Build", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [], + "presentation": { + "clear": true, + "panel": "dedicated" + } + }, + { + "label": "Clean", + "type": "shell", + "detail": "Clean output directories.", + "command": "Invoke-Build Clean", + "problemMatcher": [] + }, + { + "label": "Update template docs", + "detail": "Generate template markdown docs.", + "type": "shell", + "command": "Invoke-Build UpdateTemplateDocs", + "problemMatcher": [], + "presentation": { + "clear": true, + "panel": "dedicated" + } + }, + { + "label": "Serve docs", + "detail": "Build and run documentation site locally.", + "type": "shell", + "command": "mkdocs serve", + "problemMatcher": [], + "presentation": { + "clear": true, + "panel": "dedicated" + } + } + ] } diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..10253bb --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,24 @@ +# +# Configure GitVersion +# + +next-version: 0.4.0 +branches: + main: + regex: ^main$ + tag: 'B' + increment: Minor + is-mainline: true + feature: + regex: ^feature/ + source-branches: [ 'main' ] + increment: Inherit + tag: B + release: + regex: ^release/ +ignore: + sha: [] +merge-message-formats: {} +tag-prefix: v +mode: ContinuousDeployment +increment: Inherit diff --git a/modules.json b/modules.json new file mode 100644 index 0000000..72a3c8c --- /dev/null +++ b/modules.json @@ -0,0 +1,18 @@ +{ + "dependencies": { + "PSDocs": { + "version": "0.9.0" + } + }, + "devDependencies": { + "Pester": { + "version": "4.10.1" + }, + "platyPS": { + "version": "0.14.2" + }, + "PSScriptAnalyzer": { + "version": "1.21.0" + } + } +} diff --git a/scripts/dependencies.psm1 b/scripts/dependencies.psm1 new file mode 100644 index 0000000..5e230e8 --- /dev/null +++ b/scripts/dependencies.psm1 @@ -0,0 +1,152 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Note: +# Handles dependencies updates. + +function Update-Dependencies { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $False)] + [String]$Path = (Join-Path -Path $PWD -ChildPath 'modules.json'), + + [Parameter(Mandatory = $False)] + [String]$Repository = 'PSGallery' + ) + process { + $modules = Get-Content -Path $Path -Raw | ConvertFrom-Json -AsHashtable; + $dependencies = CheckVersion $modules.dependencies -Repository $Repository; + $devDependencies = CheckVersion $modules.devDependencies -Repository $Repository -Dev; + + $modules = [Ordered]@{ + dependencies = $dependencies + devDependencies = $devDependencies + } + $modules | ConvertTo-Json -Depth 10 | Set-Content -Path $Path; + + $updates = @(git status --porcelain); + if ($Null -ne $Env:WORKING_BRANCH -and $Null -ne $updates -and $updates.Length -gt 0) { + git add modules.json; + git commit -m "Update $path"; + git push --force -u origin $Env:WORKING_BRANCH; + + $existingBranch = @(gh pr list --head $Env:WORKING_BRANCH --state open --json number | ConvertFrom-Json); + if ($Null -eq $existingBranch -or $existingBranch.Length -eq 0) { + gh pr create -B 'main' -H $Env:WORKING_BRANCH -l 'dependencies' -t 'Bump PowerShell dependencies' -F 'out/updates.txt'; + } + else { + $pr = $existingBranch[0].number + gh pr edit $pr -F 'out/updates.txt'; + } + } + } +} + +function Install-Dependencies { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $False)] + [String]$Path = (Join-Path -Path $PWD -ChildPath 'modules.json'), + + [Parameter(Mandatory = $False)] + [String]$Repository = 'PSGallery', + + [Parameter(Mandatory = $False)] + [Switch]$Dev + ) + process { + $modules = Get-Content -Path $Path -Raw | ConvertFrom-Json; + InstallVersion $modules.dependencies -Repository $Repository; + if ($Dev) { + InstallVersion $modules.devDependencies -Repository $Repository -Dev; + } + } +} + +function CheckVersion { + [CmdletBinding()] + [OutputType([System.Collections.Specialized.OrderedDictionary])] + param ( + [Parameter(Mandatory = $True)] + [Hashtable]$InputObject, + + [Parameter(Mandatory = $True)] + [String]$Repository, + + [Parameter(Mandatory = $False)] + [Switch]$Dev, + + [Parameter(Mandatory = $False)] + [String]$OutputPath = 'out/' + ) + begin { + $group = 'Dependencies'; + if ($Dev) { + $group = 'DevDependencies'; + } + if (!(Test-Path -Path $OutputPath)) { + $Null = New-Item -Path $OutputPath -ItemType Directory -Force; + } + $changeNotes = Join-Path -Path $OutputPath -ChildPath 'updates.txt'; + } + process { + $dependencies = [Ordered]@{ }; + $InputObject.GetEnumerator() | Sort-Object -Property Name | ForEach-Object { + $dependencies[$_.Name] = $_.Value + } + foreach ($module in $dependencies.GetEnumerator()) { + Write-Host -Object "[$group] -- Checking $($module.Name)"; + $installParams = @{} + $installParams += $module.Value; + $installParams.MinimumVersion = $installParams.version; + $installParams.Remove('version'); + $available = @(Find-Module -Repository $Repository -Name $module.Name @installParams -ErrorAction Ignore); + foreach ($found in $available) { + if (([Version]$found.Version) -gt ([Version]$module.Value.version)) { + Write-Host -Object "[$group] -- Newer version found $($found.Version)"; + $dependencies[$module.Name].version = $found.Version; + $Null = Add-Content -Path $changeNotes -Value "Bump $($module.Name) to v$($found.Version)."; + } + else { + Write-Host -Object "[$group] -- Already up to date."; + } + } + } + return $dependencies; + } +} + +function InstallVersion { + [CmdletBinding()] + [OutputType([void])] + param ( + [Parameter(Mandatory = $True)] + [PSObject]$InputObject, + + [Parameter(Mandatory = $True)] + [String]$Repository, + + [Parameter(Mandatory = $False)] + [Switch]$Dev + ) + begin { + $group = 'Dependencies'; + if ($Dev) { + $group = 'DevDependencies'; + } + } + process { + foreach ($module in $InputObject.PSObject.Properties.GetEnumerator()) { + Write-Host -Object "[$group] -- Installing $($module.Name) v$($module.Value.version)"; + $installParams = @{ RequiredVersion = $module.Value.version }; + if ($Null -eq (Get-InstalledModule -Name $module.Name @installParams -ErrorAction Ignore)) { + Install-Module -Name $module.Name @installParams -Force -Repository $Repository; + } + } + } +} + +Export-ModuleMember -Function @( + 'Update-Dependencies' + 'Install-Dependencies' +) diff --git a/scripts/pipeline-deps.ps1 b/scripts/pipeline-deps.ps1 index 5909c25..27e57b9 100644 --- a/scripts/pipeline-deps.ps1 +++ b/scripts/pipeline-deps.ps1 @@ -13,8 +13,8 @@ if ($Null -eq (Get-PackageProvider -Name NuGet -ErrorAction Ignore)) { Install-PackageProvider -Name NuGet -Force -Scope CurrentUser; } -if ($Null -eq (Get-InstalledModule -Name PowerShellGet -MinimumVersion 2.2.1 -ErrorAction Ignore)) { - Install-Module PowerShellGet -MinimumVersion 2.2.1 -Scope CurrentUser -Force -AllowClobber; +if ($Null -eq (Get-InstalledModule -Name PowerShellGet -MinimumVersion 2.2.1 -ErrorAction Ignore -WarningAction SilentlyContinue)) { + Install-Module PowerShellGet -MinimumVersion 2.2.1 -Scope CurrentUser -Force -AllowClobber -WarningAction SilentlyContinue; } if ($Null -eq (Get-InstalledModule -Name InvokeBuild -MinimumVersion 5.4.0 -ErrorAction Ignore)) { From 6f5603ef8718d8a8721a5ced99699de7070b3b92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:52:57 +1000 Subject: [PATCH 3/3] Bump Microsoft.CodeAnalysis.NetAnalyzers from 6.0.0 to 7.0.4 (#278) Bumps [Microsoft.CodeAnalysis.NetAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 6.0.0 to 7.0.4. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/main/PostReleaseActivities.md) - [Commits](https://github.com/dotnet/roslyn-analyzers/commits) --- updated-dependencies: - dependency-name: Microsoft.CodeAnalysis.NetAnalyzers dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bernie White --- src/PSDocs.Azure/PSDocs.Azure.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PSDocs.Azure/PSDocs.Azure.csproj b/src/PSDocs.Azure/PSDocs.Azure.csproj index 9ef78b3..55463ee 100644 --- a/src/PSDocs.Azure/PSDocs.Azure.csproj +++ b/src/PSDocs.Azure/PSDocs.Azure.csproj @@ -30,7 +30,7 @@ This project uses GitHub Issues to track bugs and feature requests. See GitHub p - + all runtime; build; native; contentfiles; analyzers; buildtransitive