Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/powershell-pester-test.yml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read
Expand All @@ -33,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.
Expand All @@ -49,16 +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"
$PSScriptRoot = (Get-Item -Path $MyInvocation.MyCommand.Path).DirectoryName
. "$PSScriptRoot/tests/setupTest.ps1"
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion Microsoft.AzureStack.Util.ConvertNetwork.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Pester" Version="$(PesterVersion)" />
</ItemGroup>
</ItemGroup>

<Target Name="PlaceFiles" AfterTargets="Build">
<Copy SourceFiles="$(MSBuildProjectDirectory)\src\Microsoft.AzureStack.Util.ConvertNetwork.psd1" DestinationFolder="$(BinariesBuildDirectory)\$(ProjectName)" />
Expand Down
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 `<repo-root>/out` directory then execute the test on that script. The test results will be place in `<repo-root>/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:
Expand Down Expand Up @@ -176,24 +191,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

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.AzureStack.Util.ConvertNetwork.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down