From 27030de109a807049ce040c0f862174ff410c433 Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:07:05 -0700 Subject: [PATCH 01/11] Add PSScriptAnalyzer workflow for code quality checks --- .github/{workflow => workflows}/powershell-psscriptanalyzer.yml | 1 + 1 file changed, 1 insertion(+) rename .github/{workflow => workflows}/powershell-psscriptanalyzer.yml (99%) diff --git a/.github/workflow/powershell-psscriptanalyzer.yml b/.github/workflows/powershell-psscriptanalyzer.yml similarity index 99% rename from .github/workflow/powershell-psscriptanalyzer.yml rename to .github/workflows/powershell-psscriptanalyzer.yml index 24afae9..5415e62 100644 --- a/.github/workflow/powershell-psscriptanalyzer.yml +++ b/.github/workflows/powershell-psscriptanalyzer.yml @@ -14,6 +14,7 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + workflow_dispatch: permissions: contents: read From d4127d0a098ce0f84576d3d6c6a727ae2c5706d6 Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:26:41 -0700 Subject: [PATCH 02/11] Update PSScriptAnalyzer workflow to correct script path and add test results upload step --- .github/workflows/powershell-psscriptanalyzer.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/powershell-psscriptanalyzer.yml b/.github/workflows/powershell-psscriptanalyzer.yml index 5415e62..6558c50 100644 --- a/.github/workflows/powershell-psscriptanalyzer.yml +++ b/.github/workflows/powershell-psscriptanalyzer.yml @@ -34,7 +34,7 @@ jobs: with: dotnet-version: 8.0.x - - name: Run PSScriptAnalyzer + - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f with: # Check https://github.com/microsoft/action-psscriptanalyzer for more info about the options. @@ -61,5 +61,9 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - $PSScriptRoot = (Get-Item -Path $MyInvocation.MyCommand.Path).DirectoryName - . "$PSScriptRoot/tests/setupTest.ps1" + . "${GITHUB_WORKSPACE}/tests/setupTest.ps1" + - name: Upload Test Results + uses: actions/upload-artifact@v4 + with: + name: ubuntu-Unit-Tests + path: "${GITHUB_WORKSPACE}/out/Tests" From 7dbe8f345856a1b6734af61a3e536c1430c4e083 Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:29:58 -0700 Subject: [PATCH 03/11] Enhance PSScriptAnalyzer workflow to specify Pester path and add verbose logging for test execution --- .github/workflows/powershell-psscriptanalyzer.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/powershell-psscriptanalyzer.yml b/.github/workflows/powershell-psscriptanalyzer.yml index 6558c50..42b8596 100644 --- a/.github/workflows/powershell-psscriptanalyzer.yml +++ b/.github/workflows/powershell-psscriptanalyzer.yml @@ -61,7 +61,9 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - . "${GITHUB_WORKSPACE}/tests/setupTest.ps1" + $pesterPath = "${GITHUB_WORKSPACE}/Tests" + Write-Verbose -Message "Running Pester tests...Pester path: $pesterPath" -Verbose + . "$pesterPath/setupTest.ps1" - name: Upload Test Results uses: actions/upload-artifact@v4 with: From 304171d7cce643c81433f548dc500711a39938e8 Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:34:59 -0700 Subject: [PATCH 04/11] Fix Pester path in workflow to ensure correct test execution --- .github/workflows/powershell-psscriptanalyzer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-psscriptanalyzer.yml b/.github/workflows/powershell-psscriptanalyzer.yml index 42b8596..2c9eb74 100644 --- a/.github/workflows/powershell-psscriptanalyzer.yml +++ b/.github/workflows/powershell-psscriptanalyzer.yml @@ -61,7 +61,7 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - $pesterPath = "${GITHUB_WORKSPACE}/Tests" + $pesterPath = "$($ENV:GITHUB_WORKSPACE)/tests" Write-Verbose -Message "Running Pester tests...Pester path: $pesterPath" -Verbose . "$pesterPath/setupTest.ps1" - name: Upload Test Results From 51d38d96defc19d914abe57ba23b172cb34682b4 Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:40:08 -0700 Subject: [PATCH 05/11] Upload Test results was not discovering out/Tests. Updated to a relative location. --- .github/workflows/powershell-psscriptanalyzer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-psscriptanalyzer.yml b/.github/workflows/powershell-psscriptanalyzer.yml index 2c9eb74..7c6555a 100644 --- a/.github/workflows/powershell-psscriptanalyzer.yml +++ b/.github/workflows/powershell-psscriptanalyzer.yml @@ -68,4 +68,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: ubuntu-Unit-Tests - path: "${GITHUB_WORKSPACE}/out/Tests" + path: out/Tests" From bf6cc86fcaac02c0c4e86b127da531128f251132 Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:44:39 -0700 Subject: [PATCH 06/11] Fix path for uploading test results to use GITHUB_WORKSPACE for correct artifact location --- .github/workflows/powershell-psscriptanalyzer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-psscriptanalyzer.yml b/.github/workflows/powershell-psscriptanalyzer.yml index 7c6555a..0bbb857 100644 --- a/.github/workflows/powershell-psscriptanalyzer.yml +++ b/.github/workflows/powershell-psscriptanalyzer.yml @@ -68,4 +68,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: ubuntu-Unit-Tests - path: out/Tests" + path: "${GITHUB.WORKSPACE}/out/Tests" From 38534b0e1a4acfce9787f8e7ac3e1713a668570d Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:50:58 -0700 Subject: [PATCH 07/11] Fix path for uploading test results to use correct GITHUB_WORKSPACE syntax --- .github/workflows/powershell-psscriptanalyzer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-psscriptanalyzer.yml b/.github/workflows/powershell-psscriptanalyzer.yml index 0bbb857..6e30d9f 100644 --- a/.github/workflows/powershell-psscriptanalyzer.yml +++ b/.github/workflows/powershell-psscriptanalyzer.yml @@ -68,4 +68,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: ubuntu-Unit-Tests - path: "${GITHUB.WORKSPACE}/out/Tests" + path: "${{GITHUB.WORKSPACE}}/out/Tests" From ad78929a11039b0c72615bb4b812b44592fde9ac Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:55:42 -0700 Subject: [PATCH 08/11] seperated the different tests. Unit-Testing from Script Analysis. --- .github/workflows/powershell-pester-test.yml | 40 +++++++++++++++++++ .../workflows/powershell-psscriptanalyzer.yml | 19 --------- 2 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/powershell-pester-test.yml diff --git a/.github/workflows/powershell-pester-test.yml b/.github/workflows/powershell-pester-test.yml new file mode 100644 index 0000000..ff00102 --- /dev/null +++ b/.github/workflows/powershell-pester-test.yml @@ -0,0 +1,40 @@ +name: Pester Unit Tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + permissions: + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + name: pester-unit-tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Run Pester tests + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + . "$($ENV:GITHUB_WORKSPACE)/tests/setupTest.ps1" + - name: Upload Test Results + uses: actions/upload-artifact@v4 + with: + name: ubuntu-Unit-Tests + path: "${{GITHUB.WORKSPACE}}/out/Tests" diff --git a/.github/workflows/powershell-psscriptanalyzer.yml b/.github/workflows/powershell-psscriptanalyzer.yml index 6e30d9f..490f7b0 100644 --- a/.github/workflows/powershell-psscriptanalyzer.yml +++ b/.github/workflows/powershell-psscriptanalyzer.yml @@ -50,22 +50,3 @@ jobs: uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarif - - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore - - # run powershell script /tests/setupTest.ps1 to run pester unit-testing - - name: Run Pester tests - shell: pwsh - run: | - $ErrorActionPreference = "Stop" - $pesterPath = "$($ENV:GITHUB_WORKSPACE)/tests" - Write-Verbose -Message "Running Pester tests...Pester path: $pesterPath" -Verbose - . "$pesterPath/setupTest.ps1" - - name: Upload Test Results - uses: actions/upload-artifact@v4 - with: - name: ubuntu-Unit-Tests - path: "${{GITHUB.WORKSPACE}}/out/Tests" From 36b71a11a37ba38a5026c327dd23e63f99d934e5 Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 09:58:38 -0700 Subject: [PATCH 09/11] Add issue templates for bug reports and feature requests --- .github/{ISSUES_TEMPLATE => ISSUE_TEMPLATE}/bug_report.md | 0 .github/{ISSUES_TEMPLATE => ISSUE_TEMPLATE}/feature_report.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{ISSUES_TEMPLATE => ISSUE_TEMPLATE}/bug_report.md (100%) rename .github/{ISSUES_TEMPLATE => ISSUE_TEMPLATE}/feature_report.md (100%) diff --git a/.github/ISSUES_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md similarity index 100% rename from .github/ISSUES_TEMPLATE/bug_report.md rename to .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUES_TEMPLATE/feature_report.md b/.github/ISSUE_TEMPLATE/feature_report.md similarity index 100% rename from .github/ISSUES_TEMPLATE/feature_report.md rename to .github/ISSUE_TEMPLATE/feature_report.md From 9aaf2ee5d07c88e51ab4d855f159985dbd6f56b7 Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 10:01:41 -0700 Subject: [PATCH 10/11] Move contribution guidelines to CONTRIBUTING.md for better organization --- CONTRIBUTING.md | 18 ++++++++++++++++++ README.md | 19 +------------------ 2 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b0c96da --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,18 @@ + +We welcome contributions! To get started, follow these steps: + +1. Fork the repository. +2. Create a new branch for your feature or bug fix. +3. Commit your changes and submit a pull request. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a +Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us +the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. + +When you submit a pull request, a CLA bot will automatically determine whether you need to provide +a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions +provided by the bot. You will only need to do this once across all repos using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or +contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. \ No newline at end of file diff --git a/README.md b/README.md index c116f71..766ebf1 100644 --- a/README.md +++ b/README.md @@ -176,24 +176,7 @@ This project is licensed under the [MIT License](LICENSE). If you encounter any issues or have questions, please file an issue in the [GitHub Issues](https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork/issues) section. ## Contributing - -We welcome contributions! To get started, follow these steps: - -1. Fork the repository. -2. Create a new branch for your feature or bug fix. -3. Commit your changes and submit a pull request. - -This project welcomes contributions and suggestions. Most contributions require you to agree to a -Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us -the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. - -When you submit a pull request, a CLA bot will automatically determine whether you need to provide -a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions -provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +[Contributing](CONTRIBUTING.md). ## Code of Conduct From ad8e7079d99705dc279ff25371567f2e7f76608d Mon Sep 17 00:00:00 2001 From: Eric Marquez Date: Fri, 11 Apr 2025 10:38:03 -0700 Subject: [PATCH 11/11] Update project files for improved documentation and testing setup --- Microsoft.AzureStack.Util.ConvertNetwork.csproj | 2 +- README.md | 17 ++++++++++++++++- ...icrosoft.AzureStack.Util.ConvertNetwork.psd1 | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Microsoft.AzureStack.Util.ConvertNetwork.csproj b/Microsoft.AzureStack.Util.ConvertNetwork.csproj index c351711..463451c 100644 --- a/Microsoft.AzureStack.Util.ConvertNetwork.csproj +++ b/Microsoft.AzureStack.Util.ConvertNetwork.csproj @@ -15,7 +15,7 @@ - + diff --git a/README.md b/README.md index 766ebf1..b8ef72b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Microsoft.AzureStack.Util.ConvertNetwork -[![Build Status](https://img.shields.io/github/actions/workflow/status/microsoft/Microsoft.AzureStack.Util.ConvertNetwork/powershell-psscriptanalyzer.yml?branch=main)](https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork/actions) +[![Pester Unit Tests](https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork/actions/workflows/powershell-pester-test.yml/badge.svg)](https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork/actions/workflows/powershell-pester-test.yml) +[![PSScriptAnalyzer](https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork/actions/workflows/powershell-psscriptanalyzer.yml/badge.svg)](https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork/actions/workflows/powershell-psscriptanalyzer.yml) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) ## Overview @@ -33,6 +34,20 @@ git clone https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork. Import-Module .\src\Microsoft.AzureStack.Util.ConvertNetwork.psm1 ``` +### Unit-Testing + +Requirements: + +- dotnet8 sdk + +To install dotnet 8 see https://dotnet.microsoft.com/en-us/download/dotnet/8.0 + +The build step will download the required pester NuGet package before executing the test. + +The Pester testing script expects a dotnet build to be executed before running the test. The build step will place the script into an `/out` directory then execute the test on that script. The test results will be place in `/out/Tests`. + +Upon a pull-request, the unit-test will be performed against the script. A passing unit-test will be required before any changes are approved. + ## Usage Here are some examples of how to use the module: diff --git a/src/Microsoft.AzureStack.Util.ConvertNetwork.psd1 b/src/Microsoft.AzureStack.Util.ConvertNetwork.psd1 index 7c0e756..2e94345 100644 --- a/src/Microsoft.AzureStack.Util.ConvertNetwork.psd1 +++ b/src/Microsoft.AzureStack.Util.ConvertNetwork.psd1 @@ -106,10 +106,10 @@ PrivateData = @{ # Tags = @() # A URL to the license for this module. - # LicenseUri = '' + LicenseUri = 'https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork/blob/main/LICENSE' # A URL to the main website for this project. - # ProjectUri = '' + ProjectUri = 'https://github.com/microsoft/Microsoft.AzureStack.Util.ConvertNetwork' # A URL to an icon representing this module. # IconUri = ''